public void TestValidateUpdate_InactiveCity() { 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()); city.IsActive = false; 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("CityId", results.First().Property); Assert.AreEqual(String.Format(LocationServiceAddressValidator.INACTIVE_CITY_FORMAT_ERROR_MESSAGE, city.LocationName), results.First().ErrorMessage); }
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); }
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); }