コード例 #1
0
        public void AddressNotNull()
        {
            var val    = new AddressNotNullValidator();
            var errors = val.Validate(new Person {
                Address = new Address()
            });

            Assert.AreEqual(0, errors.Count);
        }
コード例 #2
0
        public void AddressNull()
        {
            var val    = new AddressNotNullValidator();
            var errors = val.Validate(new Person {
                Address = null
            });

            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Address not valid", errors[0]);
        }
コード例 #3
0
        public void ZIPValidValidatorErrorListNotEmpty()
        {
            var addNotNull  = new AddressNotNullValidator();
            var strNotEmpty = new StreetNotEmptyValidator();
            var zipVal      = new ZipValidValidator();

            var baseVal = new List <BaseValidator>()
            {
                addNotNull, strNotEmpty, zipVal,
            };

            var val    = new AddresValidator(baseVal);
            var errors = val.Validate(new Person
            {
                Address = new Address
                {
                    Street = "via Roma, 5",
                    ZIP    = "33j0"
                }
            });

            Assert.AreEqual(1, errors.Count);
        }