Esempio n. 1
0
        public void NullBuilderMeansNoAutoRegistration()
        {
            var cf = (CheckerFactory) CheckerFactory;
            cf.Clear();
            cf.Builder = new NullCheckerBuilder();

            var p1 = new Parent {Id = 1, Name = "A"};
            var expected = new Child {Id = 1, Name = "Child", Parent = p1};
            var candidate = new Child {Id = 2, Name = "Child", Parent = p1};

            CheckFault(expected, candidate, "No checker registered for NCheck.Test.Child");
        }
Esempio n. 2
0
        public void NoIIdentifiableCheckerRegistered()
        {
            var cf = (CheckerFactory) CheckerFactory;
            cf.Clear();
            PropertyCheck.IdentityChecker = null;

            var p1 = new Parent {Id = 1, Name = "A"};
            var expected = new Child {Id = 1, Name = "Child", Parent = p1};
            var candidate = new Child {Id = 2, Name = "Child", Parent = p1};

            CheckFault(expected, candidate, "No IdentityChecker assigned, cannot perform Id check");
        }
Esempio n. 3
0
        public void ValidateCompareById()
        {
            var p1 = new Parent {Id = 1, Name = "A"};
            var expected = new Child {Id = 1, Name = "Child", Parent = p1};
            p1.Favourite = expected;

            var p2 = new Parent {Id = 1, Name = "A"};
            var candidate = new Child {Id = 1, Name = "Child", Parent = p2};
            p2.Favourite = candidate;

            Check(expected, candidate);
        }
Esempio n. 4
0
        public void ValidatePropertyMessageInChildEntity()
        {
            var expected = new Parent {Id = 1, Name = "A"};
            var c1 = new Child {Id = 1, Name = "Child", Parent = expected};
            expected.Favourite = c1;

            var candidate = new Parent {Id = 1, Name = "A"};
            var c2 = new Child {Id = 2, Name = "Child", Parent = candidate};
            candidate.Favourite = c2;

            CheckFault(expected, candidate, "Parent.Favourite.Id", 1, 2);
        }
Esempio n. 5
0
        public void ValidateMessageWhenExpectedCollectionCountIsDifferent()
        {
            var c1 = new Child();
            var expected = new Parent {Id = 1, Name = "A", Children = new List<Child>()};
            var candidate = new Parent {Id = 1, Name = "A", Children = new List<Child>()};

            candidate.Children.Add(c1);

            CheckFault(expected, candidate, "Parent.Children.Count", 0, 1);
        }
Esempio n. 6
0
        public void ValidateNullIIdentifiable()
        {
            var expected = new Child {Id = 1, Name = "Child"};
            var candidate = new Child {Id = 1, Name = "Child"};

            Check(expected, candidate);
        }
Esempio n. 7
0
        public void ValidateMessageCollectionElementIsDifferent()
        {
            var expected = new Parent {Id = 1, Name = "A", Children = new List<Child>()};
            var candidate = new Parent {Id = 1, Name = "A", Children = new List<Child>()};

            var c1 = new Child {Id = 1};
            expected.Children.Add(c1);
            var c2 = new Child {Id = 2};
            candidate.Children.Add(c2);

            CheckFault(expected, candidate, "Parent.Children[0].Id", 1, 2);
        }
Esempio n. 8
0
        public void ValidateListExplicitly()
        {
            var c1 = new Child();
            var expected = new Parent {Id = 1, Name = "A", Children = new List<Child>()};
            var candidate = new Parent {Id = 1, Name = "A", Children = new List<Child>()};

            expected.Children.Add(c1);
            candidate.Children.Add(c1);

            Check<Child>(expected.Children, candidate.Children);
        }
Esempio n. 9
0
        public void ValidateEntityWithList()
        {
            var c1 = new Child();
            var expected = new Parent {Id = 1, Name = "A", Children = new List<Child>()};
            var candidate = new Parent {Id = 1, Name = "A", Children = new List<Child>()};

            expected.Children.Add(c1);
            candidate.Children.Add(c1);

            Check(expected, candidate);
        }
Esempio n. 10
0
        public void ValidateCompareByIdWithNullIdentityChecker()
        {
            var p1 = new Parent {Id = 1, Name = "A"};
            var expected = new Child {Id = 1, Name = "Child", Parent = p1};
            p1.Favourite = expected;

            var p2 = new Parent {Id = 1, Name = "A"};
            var candidate = new Child {Id = 1, Name = "Child", Parent = p2};
            p2.Favourite = candidate;

            // NB Need to initialize the checker factory
            var x = CheckerFactory;
            PropertyCheck.IdentityChecker = null;

            CheckFault(expected, candidate, "No IdentityChecker assigned, cannot perform Id check");
        }
Esempio n. 11
0
        public void ValidateCompareByIdMessage()
        {
            var p1 = new Parent {Id = 1, Name = "A"};
            var expected = new Child {Id = 1, Name = "Child", Parent = p1};
            p1.Favourite = expected;

            var p2 = new Parent {Id = 2, Name = "A"};
            var candidate = new Child {Id = 1, Name = "Child", Parent = p2};
            p2.Favourite = candidate;

            CheckFault(expected, candidate, "Child.Parent.Id", 1, 2);
        }