If you assign the values on the proxied instance (after calling the CreateProxy
method) the test passes:
[Fact]
public void Equality_Behaves_As_Expected()
{
// AutoMoqCustomization is not necessary.
var original = new Fixture().Create<Band>();
var likeness = original
.AsSource()
.OfLikeness<Band>()
.Without(x => x.Brass)
.CreateProxy();
likeness.Brass = "foo"; // Ignored.
likeness.Strings = original.Strings;
Assert.True(likeness.Equals(original));
likeness.Should().Be(original);
likeness.ShouldBeEquivalentTo(original);
}
Keep in mind that Likeness
creates a proxy on the target type and only that type's instance overrides Equals
.
Since the source type remains intact, the following assertions will not succeed:
Assert.True(original.Equals(likeness));
original.Should().Be(likeness);
original.ShouldBeEquivalentTo(likeness);
Update
From version 3.0.4 and above the values are automatically copied to the proxy instance (which means, likeness.Strings = original.Strings;
is going to happen automatically).