public void TestCity_IsNull()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.City = null;
            result        = validator.Validate(instance);
            Assert.IsTrue(result.IsValid);
        }
        public void TestPostalCode_PostalCodeDoesNotHaveDash_HasFourDigitsAfter()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.PostalCode = "12345 6789";
            result = validator.Validate(instance);
            Assert.IsTrue(result.IsValid);
        }
        public void TestPostalCode_PostalCodeIsFiveDigits()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.PostalCode = "12345";
            result = validator.Validate(instance);
            Assert.IsTrue(result.IsValid);
        }
        public void TestStreet2_ExceedsMaxLength()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.Street2 = new String('c', AddressDTOValidator.ADDRESS_MAX_LENGTH + 1);
            result           = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(string.Format(AddressDTOValidator.ADDRESS_2_ERROR_MESSAGE, name, AddressDTOValidator.ADDRESS_MAX_LENGTH), result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(AddressErrorPath));
        }
        public void TestPostalCode_DoesNotHaveRequiredNumberOfDigits()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.PostalCode = new String('1', AddressDTOValidator.POSTAL_CODE_LENGTH - 1);
            result = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(String.Format(AddressDTOValidator.POSTAL_CODE_ERROR_MESSAGE, name, AddressDTOValidator.POSTAL_CODE_LENGTH), result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(AddressErrorPath));
        }
        public void TestCountry_IsNotUnitedStates()
        {
            var name      = "address name";
            var validator = new AddressDTOValidator((a) => name);
            var instance  = GetValidUSAddress();
            var result    = validator.Validate(instance);

            Assert.IsTrue(result.IsValid);

            instance.Country = "hello world";
            result           = validator.Validate(instance);
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, result.Errors.Count);
            Assert.AreEqual(string.Format(AddressDTOValidator.COUNTRY_ERROR_MESSAGE, name, LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME), result.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(result.Errors.First().CustomState, typeof(AddressErrorPath));
        }