Cisharpai.Testing 0.3.0-alpha.8.185

This is a prerelease version of Cisharpai.Testing.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Cisharpai.Testing --version 0.3.0-alpha.8.185
                    
NuGet\Install-Package Cisharpai.Testing -Version 0.3.0-alpha.8.185
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Cisharpai.Testing" Version="0.3.0-alpha.8.185" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cisharpai.Testing" Version="0.3.0-alpha.8.185" />
                    
Directory.Packages.props
<PackageReference Include="Cisharpai.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Cisharpai.Testing --version 0.3.0-alpha.8.185
                    
#r "nuget: Cisharpai.Testing, 0.3.0-alpha.8.185"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Cisharpai.Testing@0.3.0-alpha.8.185
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Cisharpai.Testing&version=0.3.0-alpha.8.185&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Cisharpai.Testing&version=0.3.0-alpha.8.185&prerelease
                    
Install as a Cake Tool

Cisharpai.Testing

Lightweight fake clients for unit testing application code that depends on Cisharpai interfaces. No real HTTP calls are made.

Features

  • FakeChatCompletionClient — fake IChatCompletionClient with support for IStreamingChatFeature, IToolCallingFeature, IJsonOutputFeature, IGroundedChatFeature
  • FakeEmbeddingClient — fake IEmbeddingClient with support for IImageEmbeddingFeature, IMultimodalEmbeddingFeature
  • FakeResponses — static factory methods for common response objects
  • Response queues — enqueue specific responses for sequential calls
  • Default responses — fallback when the queue is empty
  • Request capture — inspect what your code sent
  • Feature opt-out — selectively disable features via flags
  • DI helpers — register fakes in IServiceCollection and get the instance back for setup/assertions

Quick Start

using Cisharpai.Testing;
using Cisharpai.Models;

var fake = new FakeChatCompletionClient();
fake.EnqueueResponse(FakeResponses.Chat("Hello from the fake!"));

// Pass 'fake' wherever IChatCompletionClient is expected
var request = new ChatCompletionRequest(
    Messages: [new LlmMessage(LlmRole.User, "Say hello")]);

var response = await fake.GetChatCompletionAsync(request);

Assert.That(response.Content, Is.EqualTo("Hello from the fake!"));
Assert.That(fake.ReceivedRequests, Has.Count.EqualTo(1));

Response Factories

FakeResponses.Chat("content")                     // simple chat response
FakeResponses.ChatError("something went wrong")   // error response
FakeResponses.ToolCall("func", argsJson)           // single tool call
FakeResponses.ToolCalls(toolCall1, toolCall2)       // multiple tool calls
FakeResponses.GroundedChat("content", citations)   // grounded chat with citations
FakeResponses.StreamingChunks("Hello", " world")   // streaming chunks
FakeResponses.Embedding([0.1f, 0.2f])              // embedding response
FakeResponses.EmbeddingError("bad input")          // embedding error

DI Registration

using Cisharpai.Testing;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
var fake = services.AddFakeChatCompletionClient();
fake.DefaultResponse = FakeResponses.Chat("default");

var provider = services.BuildServiceProvider();
var client = provider.GetRequiredService<IChatCompletionClient>();

Feature Opt-Out

Disable specific features to test code paths that check for feature availability:

var fake = new FakeChatCompletionClient(
    enabledFeatures: FakeChatFeatures.All & ~FakeChatFeatures.ToolCalling);

// Features.Get<IToolCallingFeature>() will now return null
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0-alpha.12.202 33 5/19/2026
0.3.0-alpha.11.197 49 5/15/2026
0.3.0-alpha.10.196 50 5/15/2026
0.3.0-alpha.9.186 55 5/8/2026
0.3.0-alpha.8.185 53 5/8/2026
0.3.0-alpha.7.164 41 5/6/2026
0.3.0-alpha.6.161 41 5/6/2026
0.3.0-alpha.5.159 39 5/6/2026
0.3.0-alpha.5.155 40 5/6/2026
0.3.0-alpha.4.156 44 5/6/2026
0.3.0-alpha.4.154 48 5/6/2026
0.3.0-alpha.3.150 46 4/30/2026
0.3.0-alpha.2.145 45 4/30/2026
0.2.2 91 4/30/2026
0.2.2-beta.1.147 43 4/30/2026
0.2.2-beta.1.146 41 4/30/2026
0.2.1 92 4/30/2026
0.2.1-beta.1.142 46 4/30/2026
0.2.1-beta.1.140 46 4/30/2026
0.2.1-beta.1.138 42 4/30/2026
Loading failed