public void PropertySet_ChildList_ItemDifference() { var expected = new TestObjectWithChildList { Child = new List <TestObject> { new TestObject { Value = "value" } } }; var actual = new TestObjectWithChildList { Child = new List <TestObject> { new TestObject { Value = "different" } } }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine("value", "different", "Child[0].Value"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); messageCheck.Check(ex); }
public void PropertySet_ChildSet_SecondLevelDifference() { var expected = new TestObjectWithChildSet { ValidationProperty = "value", Child = new TestObjectWithChildSet { ValidationProperty = "cildvalue" } }; var actual = new TestObjectWithChildSet { ValidationProperty = "value", Child = new TestObjectWithChildSet { ValidationProperty = "cildvalue!" } }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine(expected.Child.ValidationProperty, actual.Child.ValidationProperty, "Child.ValidationProperty"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); messageCheck.Check(ex); }
public void PropertySet_ByInterface_Failure() { var object1 = new TestObjectByInterface1 { ChildList = new List <TestObjectWithChildSet> { new TestObjectWithChildSet { Child = new TestObjectWithChildSet { ValidationProperty = "valueExp" } } }, CustomValidation = "ValidationPropertyC", Object1Value = "Object1Value", Value1 = "Value1" }; var object2 = new TestObjectByInterface2 { ChildList = new List <TestObjectWithChildSet> { new TestObjectWithChildSet { Child = new TestObjectWithChildSet { ValidationProperty = "value" } } }, CustomValidation = "ValidationProperty", Object1Value = "Object2Value", Value1 = "Value1", Object2Value = "Value2" }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine("valueExp", "value", "ChildList[0].Child.ValidationProperty"); messageCheck.AddPropertyLine("ValidationPropertyCCustom", "ValidationProperty", "CustomValidation"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(object2, Entity.Is.EqualTo(object1).ByInterface(typeof(ITestObject)))); messageCheck.Check(ex); }
public void PropertySet_ValidateWithProperty_Negative() { var expected = new TestObjectCustomValidation { CustomValidation = "Validation" }; var actual = new TestObjectCustomValidation { CustomValidation = "Validation" }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine(expected.ValidationCustomValidation, actual.CustomValidation, "CustomValidation"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); messageCheck.Check(ex); }
public void PropertySet_ActualAttributes_NotNull_Failure() { var expected = new TestObjectActualValidationAttributes { IdGreaterThanZero = 5 }; var actual = new TestObjectActualValidationAttributes { IdGreaterThanZero = 5 }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine("Not Null", "Null", "IdNotNull"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); messageCheck.Check(ex); }
public void PropertySet_ChildList_ExpectingLessThanActual() { var expected = new TestObjectWithChildList { Child = new List <TestObject> { new TestObject() } }; var actual = new TestObjectWithChildList { Child = new List <TestObject> { new TestObject(), new TestObject() } }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine("1", "2", "Child.Count"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); messageCheck.Check(ex); }
public void PropertySet_ChildList_ExpectingMoreThanActual_ItemsMatch_Contains() { var expected = new EntityWithChildListContains { Child = new List <TestObject> { new TestObject(), new TestObject() } }; var actual = new EntityWithChildListContains { Child = new List <TestObject> { new TestObject() } }; var messageCheck = new MessageCheck("Property Set is not equal"); messageCheck.AddPropertyLine("Greater or equal to 2", "1", "Child.Count"); messageCheck.AddObjectLine(typeof(TestObject).ToString(), "Null", "Child[1]"); var ex = Assert.Throws(typeof(AssertionException), () => Assert.That(actual, Entity.Is.EqualTo(expected))); Console.WriteLine(ex.Message); messageCheck.Check(ex); }