lundi 13 mai 2019

Fluent Assertions Should().BeEquivalentTo with only private field

Try to compare objects with single private field

Object like this:

public struct A
{
    private readonly byte[] bytes;

    public A(byte[] bytes)
    {
        this.bytes = bytes;
    }
}

Compare this way:

var a = new A(new byte[] { 1, 2, 3 });
var b = new A(new byte[] { 1, 2, 3 });
a.Should().BeEquivalentTo(b);

Result:

Message: Expected a to be 

A
{
}, but found 

A
{
}.

Сan I get a positive comparison without override Equals?

Aucun commentaire:

Enregistrer un commentaire