Implementation:Microsoft Semantic kernel Google Embeddings TestData
| Knowledge Sources | |
|---|---|
| Domains | Google_AI, Embeddings, Unit_Testing, Test_Data |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete mock Google AI embeddings API response JSON file used in unit tests, provided by the Connectors.Google.UnitTests project.
Description
embeddings_response.json is a test fixture file containing a mock response from the Google AI (Gemini) embeddings API. At 1548 lines, the file consists of a JSON object with a top-level embeddings array, where each element contains a values array of floating-point numbers representing embedding vectors. The embedding values are typical normalized float32 numbers (e.g., 0.008624583, -0.030451821) that simulate the high-dimensional vectors returned by Google's text embedding models.
This file is used by the GoogleAIClientEmbeddingsGenerationTests test class to mock HTTP responses, enabling unit tests to validate the connector's response parsing, vector extraction, and data mapping logic without making actual API calls to Google AI services.
Usage
This file is loaded at test time by the Google AI embeddings generation unit tests. The test class declares a constant path ./TestData/embeddings_response.json and reads it via File.ReadAllText() to populate mock HTTP response content. Developers working on the Google AI connector would use or modify this file when adding new embedding-related unit tests or when the Google AI API response format changes.
Code Reference
Source Location
- Repository: Microsoft_Semantic_kernel
- File: dotnet/src/Connectors/Connectors.Google.UnitTests/TestData/embeddings_response.json
- Lines: 1-1548
Signature
{
"embeddings": [
{
"values": [
0.008624583,
-0.030451821,
-0.042496547,
-0.029230341,
0.05486475,
0.006694871,
0.004025645,
-0.007294857,
0.0057651913,
0.037203953,
0.08070716,
0.032692064,
0.0015699493,
-0.038671605,
-0.021397846,
0.040436137,
0.040364444,
0.023915485,
0.03318194,
-0.052099578
]
}
]
}
Import
// In GoogleAIClientEmbeddingsGenerationTests.cs:
private const string TestDataFilePath = "./TestData/embeddings_response.json";
// Loading the test data:
var responseContent = File.ReadAllText(TestDataFilePath);
this._messageHandlerStub.ResponseToReturn.Content = new StringContent(responseContent);
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| N/A (static file) | JSON file | N/A | This is a static test fixture; it has no runtime inputs |
Outputs
| Name | Type | Description |
|---|---|---|
| embeddings | array | Array of embedding objects, each containing a values array of float32 numbers |
| embeddings[].values | float[] | Array of floating-point embedding vector components (hundreds of dimensions) |
Usage Examples
Loading in a Unit Test
using System.IO;
using System.Net.Http;
public class GoogleAIClientEmbeddingsGenerationTests
{
private const string TestDataFilePath = "./TestData/embeddings_response.json";
public GoogleAIClientEmbeddingsGenerationTests()
{
this._messageHandlerStub.ResponseToReturn.Content =
new StringContent(File.ReadAllText(TestDataFilePath));
this._httpClient = new HttpClient(this._messageHandlerStub, false);
}
[Fact]
public async Task ShouldReturnEmbeddings()
{
// Arrange - mock response is already set from constructor
// Act - call the Google AI embeddings client
// Assert - verify parsed embedding vectors match test data
var testDataResponse = JsonSerializer.Deserialize<GoogleAIEmbeddingResponse>(
await File.ReadAllTextAsync(TestDataFilePath))!;
Assert.NotNull(testDataResponse.Embeddings);
}
}
Related Pages
- Environment:Microsoft_Semantic_kernel_DotNet_SDK_Environment
- Microsoft_Semantic_kernel_Vertex_Embeddings_TestData -- Similar mock data for Google Vertex AI embeddings (includes statistics metadata)
- Microsoft_Semantic_kernel_MistralAI_Embeddings_TestData -- Mock embeddings data for MistralAI connector tests
- Microsoft_Semantic_kernel_HuggingFace_Embeddings_TestData -- Mock embeddings data for HuggingFace connector tests