ObjectAssertions.Abstractions 0.0.0-preview2

This is a prerelease version of ObjectAssertions.Abstractions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package ObjectAssertions.Abstractions --version 0.0.0-preview2                
NuGet\Install-Package ObjectAssertions.Abstractions -Version 0.0.0-preview2                
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="ObjectAssertions.Abstractions" Version="0.0.0-preview2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObjectAssertions.Abstractions --version 0.0.0-preview2                
#r "nuget: ObjectAssertions.Abstractions, 0.0.0-preview2"                
#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.
// Install ObjectAssertions.Abstractions as a Cake Addin
#addin nuget:?package=ObjectAssertions.Abstractions&version=0.0.0-preview2&prerelease

// Install ObjectAssertions.Abstractions as a Cake Tool
#tool nuget:?package=ObjectAssertions.Abstractions&version=0.0.0-preview2&prerelease                

Object Assertions Library

ObjectAssertions is a C# library that provides a code generator for writing robust and future-proof test cases by enabling compile-time checks for all properties of an object.

With ObjectAssertions, developers can easily generate assertions for all properties of their classes and structs by implementing the IAssertsAllPropertiesOf interface. The library is designed to provide compile-time safety by making it impossible to forget to test any newly added properties. If a new property is added to a class, the code won't compile until a corresponding assertion is added.

Quickstart

Let's assume this is class you want to test

public class MyClass
{
    public int MyInt { get; set; }
    public string MyString { get; set; }
    public bool MyBool { get; set; }
}

Add package:

dotnet add package ObjectAssertions.Abstractions
dotnet add package ObjectAssertions.Generator

Define assertions class:


using ObjectAssertions.Abstractions;

public class MyClassAssertions : IAssertsAllPropertiesOf<MyClass>
{
}

Define test:

[Fact]
public void TestMyClass()
{
    var myClass = new MyClass { MyInt = 5, MyString = "Hello", MyBool = true };
    var assertions = new MyClassAssertions(myClass)
    {
        MyInt = i => Assert.Equal(5, i),        
        MyString = s => Assert.Equal("Hello", s),
        MyBool = b => Assert.Equal(true, b),
    };

    assertions.Assert();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.0.0 12,124 7/24/2024
0.4.0-preview6 262 12/10/2023
0.3.0-preview5 104 12/8/2023
0.2.0-preview4 125 7/11/2023
0.1.0-preview3 114 7/5/2023
0.0.0-preview2 126 4/20/2023
0.0.0-preview1 124 4/5/2023