TestBase.Differ 0.2.0-preview

This is a prerelease version of TestBase.Differ.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package TestBase.Differ --version 0.2.0-preview
                    
NuGet\Install-Package TestBase.Differ -Version 0.2.0-preview
                    
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="TestBase.Differ" Version="0.2.0-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TestBase.Differ" Version="0.2.0-preview" />
                    
Directory.Packages.props
<PackageReference Include="TestBase.Differ" />
                    
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 TestBase.Differ --version 0.2.0-preview
                    
#r "nuget: TestBase.Differ, 0.2.0-preview"
                    
#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 TestBase.Differ@0.2.0-preview
                    
#: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=TestBase.Differ&version=0.2.0-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=TestBase.Differ&version=0.2.0-preview&prerelease
                    
Install as a Cake Tool

TestBase.Differ

Prerelease: An object-to-object comparison library that produces a tree of differences. Useful for unit tests, audit logs, or debugging.

API

Differ

The main entry point for comparing two objects.

var result = Differ.Diff(expected, actual, options);
if (!result) // Implicit bool conversion for result.AreEqual
{
    Console.WriteLine(result.ToString());
}

DiffOptions

Controls how comparison is performed.

  • FloatTolerance: Tolerance for floating-point comparison (default: 1e-14).
  • ExcludeMembers: Member names to exclude from comparison (supports dotted paths).
  • IncludeOnlyMembers: If non-empty, only these members are compared.
  • RequireSameType: If true, types must match exactly (default: false).
  • MaxDifferences: Maximum number of differences to report before stopping (default: 2).
  • MaxDepth: Maximum recursion depth (default: 10).
  • LeftLabel / RightLabel: Labels used in output (default: "Expected"/"Actual").
  • PublicPropertiesOnly: Only compare public readable properties.
  • WritablePropertiesOnly: Only compare writable properties.

DiffResult

Represents the result of a comparison.

  • AreEqual: Boolean property (also supports implicit conversion to bool).
  • Path: The dotted path to the difference (e.g., "User.Address.Street").
  • LeftValue / RightValue: String representations of the values that differed.
  • Children: A list of child DiffResult objects for nested differences.
  • ToString(): Produces a clean, indented summary of all differences.

DiffFormatter

Formats DiffResult with optional ANSI colour output for console display.

  • DiffFormatter.Format(result): Returns a formatted string.
  • DiffFormatter.UseColour: Static property to enable/disable ANSI colour output (default: false).
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 (1)

Showing the top 1 NuGet packages that depend on TestBase.Differ:

Package Downloads
TestBase

*TestBase* gives you a flying start with - fluent assertions that are easy to extend - sharp error messages - tools to help you test with “heavyweight” dependencies on - AspNetCore.Mvc, AspNet.Mvc or WebApi Contexts - HttpClient - Ado.Net - Streams & Logging - Mix & match with your favourite test runners & assertions. ``` UnitUnderTest.Method() .ShouldNotBeNull() .ShouldEqualByValueExceptFor(new {Id=1, Descr=expected}, ignoreList ) .Payload .ShouldMatchIgnoringCase("I expected this") .Should(someOtherPredicate); .Items .ShouldAll(predicate) .ShouldContain(item) .ShouldNotContain(predicate) .Where(predicate) .SingleOrAssertFail() item .ShouldEqualByValue() .ShouldEqualByValueExceptFor(...) .ShouldEqualByValueOnMembers() string .ShouldMatch(pattern) .ShouldNotMatch() .ShouldBeEmpty() .ShouldNotBeEmpty() .ShouldNotBeNullOrEmptyOrWhiteSpace() .ShouldEqualIgnoringCase() .ShouldContain() .ShouldBeContainedIn() .ShouldStartWith() .ShouldEndWith() ... numeric .ShouldBeBetween() .ShouldEqualWithTolerance()....GreaterThan....LessThan...GreaterOrEqualTo ... ienumerable .ShouldAll() .ShouldContain() .ShouldNotContain() .ShouldBeEmpty() .ShouldNotBeEmpty() ... stream .ShouldHaveSameStreamContentAs() .ShouldContain() value .ShouldBe() .ShouldNotBe() .ShouldBeOfType() .ShouldBeAssignableTo() ... ``` Testable Logging is in packages Extensions.Logging.ListOfString and Serilog.Sinks.ListOfString ``` // Extensions.Logging.ListOfString var log = new List<String>(); ILogger mslogger= new LoggerFactory().AddStringListLogger(log).CreateLogger("Test2"); // Serilog.Sinks.ListOfString Serilog.Logger slogger= new LoggerConfiguration().WriteTo.StringList(log).CreateLogger(); ```

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0-preview 142 3/27/2026
0.2.0-preview 70 3/27/2026
0.1.0-preview 71 3/27/2026

ChangeLog
     ---------
     0.2.0 : Compacter Diff output
     0.1.0 : Initial pre-release