Skip to content

stiankroknes/SimpleObjectCompareDotNet

Repository files navigation

License: MIT GitHub issues GitHub forks GitHub stars

NuGet Downloads (official NuGet)

SimpleObjectCompareDotNet

Get Started

Install the NuGet package: SimpleObjectCompareDotNet

Install using the Package Manager in your IDE or using the command line:

dotnet add package SimpleObjectCompareDotNet

ObjectComparer

[Fact]
public void Should_handle_simple_equal()
{
    var result1 = new Simple { Test = "1" };
    var result2 = new Simple { Test = "2" };

    var result = ObjectComparer.ComparePublicMembers(result1, result2);

    result.Should().BeEquivalentTo(new CompareResult(false, nameof(Simple.Test), result1.Test, result2.Test));
}

ObjectMembersCollector

[Fact]
public void Should_handle_simple_object()
{
    var instance = new Simple { Test = "1" };

    var result = ObjectMembersCollector.Collect(instance);

    result.Should().BeEquivalentTo(new CollectedPropertyValue(typeof(Simple), typeof(string), "Test", "1"));
}

Benchmarks

ObjectComparer

ObjectMembersCollector