Switchknife.Facts.Testing 0.2.0

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

Switchknife.Facts.Testing

Test doubles for Switchknife.Facts, so code that extracts facts from conversations can be tested without calling a model. No dependency beyond Switchknife.Facts and none on a test framework. Native AOT compatible.

var extractor = new ScriptedExtractor(
    """{"facts":[{"subject":{"ref":"e1","name":null,"kind":null},"predicate":"likes","value":"jazz","object":null,"text":"Anna likes jazz.","validFrom":"2026-05-01","validTo":null,"replaces":null,"evidence":["l1"],"quote":"like jazz","salience":0.8}]}""",
    new TimeoutException("the model did not answer"));

var first = await store.ExtractAsync(extractor, episode, context);   // the reply goes through the full pipeline
Assert.Equal(ExtractionStatus.Ingested, first.Status);

var second = await store.ExtractAsync(extractor, otherEpisode, context);   // the error becomes a failed episode
Assert.Equal(2, extractor.Calls);
Assert.Contains("[l1] Anna:", extractor.Requests[0].Prompt.User);
  • new ScriptedExtractor(step, step, ...): the n-th call runs the n-th step; when the steps run out, the last one keeps answering. A string is a model reply (reported as model scripted), an ExtractorResponse is returned as given (to set the extractor name, model and token counts), an Exception is thrown.
  • new ScriptedExtractor(async token => response): answers every call; wait on the token to simulate a hanging model that only a timeout or cancellation ends.
  • Calls and Requests: how many calls and each ExtractionRequest (prompt and context) in arrival order, to assert on what the pipeline sent. Recording is thread-safe.

Gold set scoring

Judge an extraction change by a number. GoldRunner.RunAsync(extractor, cases) asks the extractor about each GoldCase (a GoldItem and its ExtractionContext) through the kit's prompt, parser and validator, and GoldScorer.Score(gold, results) scores facts you already have. The match rule is the one feed-eater froze for its fact gold set: an expected fact matches when every anchor group has an alternative inside the emitted fact's subject, text, value or object (case, $ and , ignored); one emitted fact serves one expected fact; an item is recalled when half its expected facts match.

var item = new GoldItem("luna", [new GoldFact("price_change", [["luna"], ["0.10"]], "Luna costs 0.10")]);
var score = await GoldRunner.RunAsync(extractor, [new GoldCase(item, context)]);
Assert.True(score.ItemsRecalled >= 20);   // plus score.StrictPrecision, score.NegativesClean, score.KindMatched/KindTotal

An item with no facts is a negative: any fact emitted for it makes it not clean. An extractor error or an unreadable reply becomes that item's Error and counts as nothing emitted; the run goes on. Loading the gold from JSON is the caller's job (pass your own JsonTypeInfo), so the package stays AOT safe.

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
0.2.0 103 11/15/2026
0.1.0 106 10/28/2026