Implementation:Microsoft Semantic kernel Google Search TestData
| Knowledge Sources | |
|---|---|
| Domains | Testing, Web_Search, Google_API |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Mock Google Custom Search API response JSON for the query "What is the Semantic Kernel?", used as test fixture data in the Plugins unit tests of the Semantic Kernel .NET SDK.
Description
This JSON file contains a captured Google Custom Search JSON API response for the query "What is the Semantic Kernel?". It serves as a mock response fixture for unit testing the Google search plugin integration. The response follows the Google Custom Search API schema with kind customsearch#search.
Key elements of the response:
- kind - Set to
customsearch#searchidentifying this as a Google Custom Search response - url - Template URL for the Google Custom Search API with numerous query parameter placeholders
- queries.request - Metadata about the current request including totalResults (16,200,000), searchTerms, count, startIndex, encoding, and the Custom Search Engine ID (cx)
- queries.nextPage - Pagination metadata for retrieving the next page of results (startIndex: 5)
- items - Array of search result objects (not shown in the first 30 lines, but present in the full file)
- Each item includes: title, link, displayLink, snippet, htmlSnippet, and other Google-specific fields
This fixture validates that the Google search plugin correctly handles the Google Custom Search API response format, which differs from both Bing and Brave in structure, field naming, and pagination approach.
Usage
This file is loaded during Plugins unit test execution to mock Google Custom Search API responses. It enables tests to validate Google-specific response parsing, pagination handling, and search result extraction without requiring a live Google API key or Custom Search Engine ID. Developers working on the Google search plugin use this fixture for reliable, deterministic testing.
Code Reference
Source Location
- Repository: Microsoft_Semantic_kernel
- File: dotnet/src/Plugins/Plugins.UnitTests/TestData/google_what_is_the_semantic_kernel.json
- Lines: 1-325
Signature
{
"kind": "customsearch#search",
"url": {
"type": "application/json",
"template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}..."
},
"queries": {
"request": [
{
"title": "Google Custom Search - What is the Semantic Kernel?",
"totalResults": "16200000",
"searchTerms": "What is the Semantic Kernel?",
"count": 4,
"startIndex": 1,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "1285518abfd4e4677"
}
]
}
}
Import
// Load the mock Google search response in unit tests
var json = File.ReadAllText("TestData/google_what_is_the_semantic_kernel.json");
var response = JsonSerializer.Deserialize<GoogleSearchResponse>(json);
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| searchTerms | string | yes | The search query text (e.g., "What is the Semantic Kernel?") |
| cx | string | yes | The Google Custom Search Engine ID |
| count | integer | no | Number of results to return per page (default: 4) |
| startIndex | integer | no | Index of the first result to return (default: 1) |
Outputs
| Name | Type | Description |
|---|---|---|
| kind | string | Response type identifier ("customsearch#search") |
| url | object | API template URL with parameter placeholders |
| queries.request | array | Current request metadata including totalResults, searchTerms, count, and startIndex |
| queries.nextPage | array | Next page metadata with updated startIndex for pagination |
| items | array | Array of search result objects with title, link, snippet, displayLink, and htmlSnippet |
Usage Examples
Mocking a Google Custom Search Response
// Example: Using the mock data to test the Google search plugin
var mockJson = File.ReadAllText("TestData/google_what_is_the_semantic_kernel.json");
var handler = new MockHttpMessageHandler(mockJson, HttpStatusCode.OK);
var httpClient = new HttpClient(handler);
var googlePlugin = new GoogleSearchPlugin(httpClient, "test-api-key", "test-cx-id");
var results = await googlePlugin.SearchAsync("What is the Semantic Kernel?");
Assert.NotEmpty(results);
// Verify Google-specific pagination metadata is parsed
Assert.Equal("16200000", results.TotalResults);