Detester 1.0.3

dotnet add package Detester --version 1.0.3
                    
NuGet\Install-Package Detester -Version 1.0.3
                    
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="Detester" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Detester" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Detester" />
                    
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 Detester --version 1.0.3
                    
#r "nuget: Detester, 1.0.3"
                    
#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 Detester@1.0.3
                    
#: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=Detester&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Detester&version=1.0.3
                    
Install as a Cake Tool

Detester is a .NET library that enables you to write deterministic tests for AI-powered applications. It provides a fluent builder API for testing AI responses, ensuring consistency and reliability in your AI integrations.

Using Azure OpenAI

using Azure.AI.OpenAI;
using Detester;
using Microsoft.Extensions.AI;
using System.ClientModel;

// Create Azure OpenAI client and wrap it as IChatClient
var azureClient = new AzureOpenAIClient(
    new Uri("https://your-resource.openai.azure.com"),
    new ApiKeyCredential("your-azure-api-key"));
var chatClient = azureClient.GetChatClient("gpt-4-deployment").AsIChatClient();

// Create a builder with the chat client
var builder = DetesterFactory.Create(chatClient);

// Or create a builder with ChatOptions (to configure tools, behavior, and settings)
var builder = DetesterFactory.Create(chatClient, new ChatOptions {/*setup*/});

// Execute a test
await builder
    .WithPrompt("Explain quantum computing in simple terms")
    .ShouldContainResponse("quantum")
    .AssertAsync();

Using Any IChatClient

Detester works with any IChatClient implementation from Microsoft.Extensions.AI:

using Detester;
using Microsoft.Extensions.AI;

// Use any IChatClient implementation (OpenAI, Azure OpenAI, Ollama, custom, etc.)
IChatClient chatClient = // your chat client implementation
var builder = DetesterFactory.Create(chatClient);

await builder
    .WithPrompt("Test prompt")
    .ShouldContainResponse("expected text")
    .AssertAsync();

Advanced Usage

Setting Model Instructions

Set custom instructions (system messages) to guide the model's behavior:

await new DetesterBuilder(chatClient)
    .WithInstruction("Answer concisely.")
    .WithPrompt("Summarize this text.")
    .ShouldContainResponse("summary")
    .ShouldContainAll("short", "summary")
    .ShouldContainAny("tl;dr", "summary", "in short")
    .ShouldNotContainResponse("error")
    .ShouldNotContain("stack trace")
    .ShouldNotContainAnyResponse("SECRET_KEY", "password")
    .ShouldMatchRegex(@"^[A-Z].+")
    .ShouldBeEqualTo("Exact match", StringComparison.OrdinalIgnoreCase) // if you want strict equality
    .AssertAsync();

Check the README file in the repo for more details: https://github.com/sa-es-ir/detester

Product Compatible and additional computed target framework versions.
.NET 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
1.0.3 98 1/20/2026
1.0.2 100 1/18/2026
1.0.1 368 11/30/2025
1.0.0-preview.4 165 11/3/2025
1.0.0-preview.3 151 10/13/2025
0.1.0-preview.2 148 10/6/2025
0.1.0-preview.1 153 10/5/2025