public void Should_Return_Not_Equal_When_Destination_Collection_Collection_Contains_Item_That_Cannot_Be_Cast_To_Likeness_Destination_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 result = value.CompareCollectionsUsingSpecificLikeness(other, (Likeness <ObjectWithAnotherIntPropertyDerived, AnotherObjectWithAnotherStringPropertiesDerived> likeness) => likeness); // 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_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); }