public void Replaced_comparable_object_is_compared_with_custom_implementation() { var comparer = new ComparerBuilder().GetComparer <SampleObject <ComparableBaseObject <EnumSmall> > >(); var fixture = FixtureBuilder.GetInstance(); var one = new SampleObject <ComparableBaseObject <EnumSmall> > { Property = fixture.Create <ComparableChildObject <EnumSmall> >() }; comparer.Compare(one, one.DeepClone()).Should().Be(0); for (var i = 0; i < Constants.SmallCount; i++) { one.Property = fixture.Create <ComparableChildObject <EnumSmall> >(); var other = new SampleObject <ComparableBaseObject <EnumSmall> > { Property = fixture.Create <ComparableChildObject <EnumSmall> >() }; var expected = one.Property.CompareTo(other.Property).Normalize(); var actual = comparer.Compare(one, other).Normalize(); actual.Should().Be(expected); } ComparableChildObject <EnumSmall> .UsedCompareTo.Should().BeTrue(); }
public void Custom_comparable_implementation_should_return_negative_when_first_argument_isnull() { var one = new SampleObject <ComparableBaseObject <EnumSmall> > { Property = FixtureBuilder.GetInstance().Create <ComparableBaseObject <EnumSmall> >() }; var other = one.DeepClone(); one.Property = null; var comparer = new ComparerBuilder().GetComparer <SampleObject <ComparableBaseObject <EnumSmall> > >(); comparer.Compare(one, other).Should().BeNegative(); }