public void Should_Be_Able_To_Use_Comparison_Overrides_To_Force_Not_Equal() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { new ObjectWithSingleStringPropertyBuilder().WithStringValue("test").Build(), new ObjectWithSingleStringPropertyBuilder().WithStringValue("test2").Build(), }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test").Build(), new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test2").Build(), }; // exercise var result = value.CompareCollectionsUsingLikeness(other, likeness => likeness.With(x => x.StringTypeProperty).EqualsWhen((s, d) => false)); // verify Assert.That(result, Is.False); }
public void Should_Return_Equal_When_Collections_Items_Are_Equal_Using_Default_Likeness() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { new ObjectWithSingleStringPropertyBuilder().WithStringValue("test").Build(), new ObjectWithSingleStringPropertyBuilder().WithStringValue("test2").Build(), }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test").Build(), new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test2").Build(), }; // exercise var result = value.CompareCollectionsUsingLikeness(other); // verify Assert.That(result, Is.True); }
public void Should_Return_Not_Equal_When_Source_Inner_Collection_Item_Is_Null_And_Destination_Inner_Collection_Item_Is_Not_Null() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { null }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test").Build() }; // exercise var result = value.CompareCollectionsUsingLikeness(other); // verify Assert.That(result, Is.False); }
public void Should_Return_Not_Equal_When_Source_Collection_Contains_Item_That_Cannot_Be_Cast_To_Likeness_Source_Type() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test2").WithIntValue(2).Build(), }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new AnotherObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test2").WithIntValue(2).Build(), }; // exercise var action = new TestDelegate(() => value.CompareCollectionsUsingSpecificLikeness(other, (Likeness<ObjectWithAnotherStringPropertiesDerived, AnotherObjectWithAnotherIntPropertyDerived> likeness) => likeness)); // verify Assert.That(action, Throws.ArgumentException.And.Message.Contains("Source value is type of 'Jmansar.SemanticComparisonExtensions.Test.TestData.ObjectWithAnotherIntPropertyDerived', cannot cast to 'Jmansar.SemanticComparisonExtensions.Test.TestData.ObjectWithAnotherStringPropertiesDerived")); }
public void Should_Return_Not_Equal_When_Destination_Collection_Contains_BaseType_Items_And_Derived_Likeness_Is_Set() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test2").WithIntValue(2).Build(), }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new AnotherObjectWithSingleStringPropertyBuilder().WithStringValue("test2").Build(), }; // exercise var result = value.CompareCollectionsUsingSpecificLikeness(other, (Likeness<ObjectWithAnotherIntPropertyDerived, AnotherObjectWithAnotherIntPropertyDerived> likeness) => likeness); // verify Assert.That(result, Is.False); }
public void Should_Return_Not_Equal_When_Collections_Counts_Are_Different(int valueCollectionCount, int otherCollectionCount) { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[valueCollectionCount]; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[otherCollectionCount]; // exercise var result = value.CompareCollectionsUsingLikeness(other); // verify Assert.That(result, Is.False); }
public void Should_Return_Equal_When__Collections_Items_Are_Equal_Using_Likeness_For_Overriden_Types() { // fixture setup IEnumerable<ObjectWithSingleStringProperty> value = new ObjectWithSingleStringProperty[] { new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new ObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test2").WithIntValue(2).Build(), }; IEnumerable<AnotherObjectWithSingleStringProperty> other = new AnotherObjectWithSingleStringProperty[] { new AnotherObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test").WithIntValue(1).Build(), new AnotherObjectWithAnotherIntPropertyDerivedBuilder().WithStringValue("test2").WithIntValue(2).Build(), }; // exercise var result = value.CompareCollectionsUsingSpecificLikeness(other, (Likeness<ObjectWithAnotherIntPropertyDerived, AnotherObjectWithAnotherIntPropertyDerived> likeness) => likeness); // verify Assert.That(result, Is.True); }
public TypeWithInnerCollectionBuilder WithInnerCollectionItem(ObjectWithSingleStringProperty item) { _innerCollection.Add(item); return this; }