Exemplo n.º 1
0
        public void TestValidateUpdate_EmptyPostalCode()
        {
            var addressTypeId = AddressType.Home.Id;
            var country       = new Location
            {
                IsActive     = true,
                LocationName = "country"
            };
            var division = new Location
            {
                IsActive     = true,
                LocationName = "division"
            };
            var city = new Location
            {
                IsActive     = true,
                LocationName = "city"
            };
            string postalCode = String.Empty;
            var    entity     = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);

            var validator = new LocationServiceAddressValidator();

            Assert.AreEqual(0, validator.ValidateCreate(entity).Count());

            country.LocationName = LocationServiceAddressValidator.UNITED_STATES_COUNTRY_NAME;
            entity = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);
            var results = validator.DoValidateUpdate(entity);

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual("PostalCode", results.First().Property);
            Assert.AreEqual(LocationServiceAddressValidator.INVALID_POSTAL_CODE_MESSAGE, results.First().ErrorMessage);
        }
Exemplo n.º 2
0
        public void TestValidateCreate_InactiveDivision()
        {
            var addressTypeId = AddressType.Home.Id;
            var country       = new Location
            {
                IsActive     = true,
                LocationName = "country"
            };
            var division = new Location
            {
                IsActive     = true,
                LocationName = "division"
            };
            var city = new Location
            {
                IsActive     = true,
                LocationName = "city"
            };
            var postalCode = "12345";
            var entity     = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);

            var validator = new LocationServiceAddressValidator();

            Assert.AreEqual(0, validator.ValidateCreate(entity).Count());

            division.IsActive = false;
            entity            = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);
            var results = validator.DoValidateCreate(entity);

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual("DivisionId", results.First().Property);
            Assert.AreEqual(String.Format(LocationServiceAddressValidator.INACTIVE_DIVISION_FORMAT_ERROR_MESSAGE, division.LocationName), results.First().ErrorMessage);
        }
Exemplo n.º 3
0
        public void TestValidateUpdate_InvalidAddressTypeId()
        {
            var addressTypeId = AddressType.Home.Id;
            var country       = new Location
            {
                IsActive     = true,
                LocationName = "country"
            };
            var division = new Location
            {
                IsActive     = true,
                LocationName = "division"
            };
            var city = new Location
            {
                IsActive     = true,
                LocationName = "city"
            };
            var postalCode = "12345";
            var entity     = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);

            var validator = new LocationServiceAddressValidator();

            Assert.AreEqual(0, validator.ValidateCreate(entity).Count());

            addressTypeId = 0;
            entity        = new EcaAddressValidationEntity(addressTypeId: addressTypeId, country: country, division: division, city: city, postalCode: postalCode);
            var results = validator.DoValidateUpdate(entity);

            Assert.AreEqual(1, results.Count());
            Assert.AreEqual("AddressTypeId", results.First().Property);
            Assert.AreEqual(LocationServiceAddressValidator.INVALID_ADDRESS_TYPE_MESSAGE, results.First().ErrorMessage);
        }