Exemple #1
0
        public void PropertySet_ValidationOnly_Negative_ActualNotNull()
        {
            var validatedEntity = new ValidationEntityNotNull();
            var messageCheck    = new MessageCheck("Property Set is not valid");

            messageCheck.AddPropertyLine("Not Null", "Null", "Id");
            var ex = Assert.Throws(typeof(AssertionException),
                                   () =>
                                   Assert.That(validatedEntity, Entity.Is.Valid));

            messageCheck.Check(ex);
        }
Exemple #2
0
        public void PropertySet_ValidationOnly_Negative_ChildObjects()
        {
            var validatedEntity = new ValidationWithChild
            {
                NotNullProp = new ValidationEntityNotNull {
                    Id = null
                },
                GreaterThanProp = new ValidationEntityGreaterThan {
                    Id = 4
                }
            };
            var messageCheck = new MessageCheck("Property Set is not valid");

            messageCheck.AddPropertyLine("Greater than 5", "4", "GreaterThanProp.Id");
            messageCheck.AddPropertyLine("Not Null", "Null", "NotNullProp.Id");
            var ex = Assert.Throws(typeof(AssertionException),
                                   () =>
                                   Assert.That(validatedEntity, Entity.Is.Valid));

            Console.WriteLine(ex.Message);
            messageCheck.Check(ex);
        }
Exemple #3
0
        public void PropertySet_ValidationOnly_Negative_ActualGreaterThan()
        {
            var validatedEntity = new ValidationEntityGreaterThan();
            var messageCheck    = new MessageCheck("Property Set is not valid");

            messageCheck.AddPropertyLine("Greater than 5", "0", "Id");
            var ex = Assert.Throws(typeof(AssertionException),
                                   () =>
                                   Assert.That(validatedEntity, Entity.Is.Valid));

            Console.WriteLine(ex.Message);
            messageCheck.Check(ex);
        }
Exemple #4
0
        public void PropertySet_Compare_RecursiveReference_Negative_RecursiveOnlyInExpected_Level0()
        {
            var expected = new ObjectWithRecursiveRef {
                IntValue = 1
            };

            expected.RecursiveRef = expected;
            var actual = new ObjectWithRecursiveRef {
                IntValue = 1
            };

            actual.RecursiveRef = new ObjectWithRecursiveRef {
                IntValue = 2
            };
            var messageCheck = new MessageCheck("Property Set is not equal");

            messageCheck.AddPropertyLine(typeof(ObjectWithRecursiveRef).FullName, "Null", "RecursiveRef.RecursiveRef");
            messageCheck.AddPropertyLine("1", "2", "RecursiveRef.IntValue");
            var ex = Assert.Throws(typeof(AssertionException),
                                   () =>
                                   Assert.That(actual, Entity.Is.EqualTo(expected)));

            messageCheck.Check(ex);
        }