単純なクラスの2つのインスタンスを使用するCreateProxy()
機能の使用方法を理解しようとしています。Likeness<T>()
public class Band
{
public string Strings { get; set; }
public string Brass { get; set; }
}
次のテストでは、2つの文字列プロパティの値を持つインスタンスにaを使用Fixture
しCreate<T>
ますBand
。
[Fact]
public void Equality_Behaves_As_Expected()
{
// arrange
var fixture = new Fixture();
fixture.Customize(new AutoMoqCustomization());
var original = fixture.Create<Band>();
// Brass something like --> "Brass65756b89-d9f3-42f8-88fc-ab6de5ae65cd"
// Strings something like --> "Strings7439fa1b-014d-4544-8428-baea66858940"
// act
var dupe = new Band {Brass = original.Brass,
Strings = original.Strings};
// Brass same as original's like --> "Brass65756b89-d9f3-42f8-88fc-ab6de5ae65cd"
// Strings same as original's like --> "Strings7439fa1b-014d-4544-8428-baea66858940"
私はさまざまなアサーションを試しましたが、問題の核心は、CreateProxy
メソッドがのプロパティを設定していないことであるようです。そのため、同じプロパティ値を持つのBand
2つのインスタンスを比較しようとしても、メソッドのインスタンスは常にnull値があります。Band
CreateProxy
// assert
var likeness = dupe.AsSource().OfLikeness<Band>()
.Without(x => x.Brass).CreateProxy();
// Brass & String properties are null using dupe as source of likeness (!)
//var likeness = original.AsSource().OfLikeness<Band>()
// .Without(x => x.Brass).CreateProxy();
// Brass & String properties are null using original as source of likeness (!)
//Assert.True(likeness.Equals(original)); // Fails
//Assert.True(original.Equals(likeness)); // Fails
// below are using FluentAssertions assembly
//likeness.Should().Be(original); // Fails (null properties)
//original.Should().Be(likeness); // Fails (null properties)
//likeness.ShouldBeEquivalentTo(original); // Fails (null properties)
//original.ShouldBeEquivalentTo(likeness); // Fails (null properties)
}
私は何か間違ったことをしなければなりませんが、PloehブログとSOで見つけることができるすべてを読みました、そして私がしていることと比較するのに十分に単純な例を見つけることができません。何か案は?