Minicon.Assertions 1.2.5

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

Minicon.Assertions

Eine schlanke, kostenlose und MIT-lizenzierte Fluent-Assertion-Bibliothek für .NET im vertrauten FluentAssertions-Stil (value.Should().Be(...)).

Hintergrund: FluentAssertions ist seit Version 8 kommerziell lizenzpflichtig. Minicon.Assertions bietet die wichtigsten Assertions als freie Alternative – ohne kommerzielle Einschränkungen, ohne Lizenzkosten.

NuGet License: MIT

Installation

dotnet add package Minicon.Assertions

Schnellstart

using Minicon.Assertions;

// Gleichheit
result.Should().Be(42);
name.Should().NotBe("falsch");

// Null
value.Should().NotBeNull();
optional.Should().BeNull();

// Begründung (because) – erscheint in der Fehlermeldung
order.Total.Should().Be(100, "die Summe der Positionen ergibt {0}", 100);

Funktioniert nahtlos mit xUnit, NUnit und MSTest: Fehlschläge werden automatisch als die jeweils passende Test-Framework-Exception geworfen, damit Runner und IDE den Fehler korrekt als fehlgeschlagene Assertion anzeigen. Ohne erkanntes Framework wird MiniconAssertionException geworfen.

Unterstützte Assertions

Allgemein / Objekte

obj.Should().Be(expected);
obj.Should().NotBe(other);
obj.Should().BeNull();
obj.Should().NotBeNull();
obj.Should().BeSameAs(reference);
obj.Should().BeOfType<MyType>();
obj.Should().BeAssignableTo<IMyInterface>();
obj.Should().Match(x => x.Id > 0);
obj.Should().BeOneOf(a, b, c);

Strings

text.Should().Be("exakt");
text.Should().BeEquivalentTo("EXAKT");          // Groß-/Kleinschreibung egal
text.Should().Contain("teil");
text.Should().StartWith("Hallo");
text.Should().EndWith("Welt");
text.Should().HaveLength(11);
text.Should().BeEmpty();
text.Should().NotBeNullOrWhiteSpace();

Zahlen & vergleichbare Werte (int, long, double, decimal, DateTime, TimeSpan, …)

value.Should().BeGreaterThan(3);
value.Should().BeGreaterThanOrEqualTo(5);
value.Should().BeLessThan(10);
value.Should().BeInRange(1, 100);
value.Should().BePositive();
value.Should().BeNegative();
pi.Should().BeApproximately(3.14, 0.01);        // Toleranz für Fließkomma

Nullable-Werte

int? x = 5;
x.Should().HaveValue();
x.Should().BeGreaterThan(3);

int? y = null;
y.Should().NotHaveValue();

Booleans

flag.Should().BeTrue();
flag.Should().BeFalse();

Collections

list.Should().HaveCount(3);
list.Should().BeEmpty();
list.Should().NotBeEmpty();
list.Should().Contain(item);
list.Should().Contain(x => x.IsActive);
list.Should().NotContain(item);
list.Should().ContainSingle();
list.Should().OnlyContain(x => x > 0);
list.Should().OnlyHaveUniqueItems();
list.Should().Equal(1, 2, 3);                   // gleiche Reihenfolge
list.Should().BeEquivalentTo(new[] {3, 2, 1});  // Reihenfolge egal
list.Should().ContainInOrder(1, 3);

Exceptions

Action act = () => service.Do();

act.Should().Throw<InvalidOperationException>()
   .WithMessage("genaue Meldung");

act.Should().Throw<ArgumentException>()
   .WithMessageContaining("teilstring");

act.Should().ThrowExactly<ArgumentException>(); // exakter Typ, keine Ableitung
act.Should().NotThrow();

// Komfort-Helfer
service.Invoking(s => s.Divide(1, 0))
       .Should().Throw<DivideByZeroException>();

Verkettung mit .And

result.Should().NotBeNull().And.Be("abc");

Migration von FluentAssertions

Die API ist bewusst kompatibel gehalten. In den meisten Fällen genügt es, das using auszutauschen:

- using FluentAssertions;
+ using Minicon.Assertions;

Nicht jede FluentAssertions-Methode ist (noch) abgedeckt – siehe Liste oben. Fehlt dir etwas? Pull Requests willkommen.

Build & Test

dotnet build
dotnet test
dotnet pack src/Minicon.Assertions/Minicon.Assertions.csproj -c Release

Lizenz

MIT – frei für kommerzielle und private Nutzung.

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.
  • net10.0

    • No dependencies.

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.2.5 110 6/8/2026
1.1.0 84 6/8/2026
1.0.0 84 6/8/2026