public void Validate_ZipCodeIsNotValid_ShouldReturnFalse() { List <City> validCities = GenerateSomeValidCities(); int maxZipCode = validCities.Max(c => c.ZipCode); int invalidZipCode = maxZipCode + 1; Customer customer = new CustomerBuilder().WithZipCode(invalidZipCode).Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when none of the valid cities has the zipcode of the customer."); }
public void Validate_ValidCustomer_ShouldReturnTrue() { //Arrange List <City> validCities = GenerateSomeValidCities(); City city = validCities[Random.Next(0, validCities.Count)]; Customer customer = new CustomerBuilder().WithZipCode(city.ZipCode).Build(); //Act Result result = customer.Validate(validCities); //Assert Assert.That(result.IsSuccess, Is.True); }
public void Validate_RequiredPropertyIsEmpty_ShouldReturnFailure() { List <City> validCities = GenerateSomeValidCities(); City city = validCities[Random.Next(0, validCities.Count)]; Customer customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithName(null).Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when Name is null."); customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithName("").Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when Name is an empty string."); customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithFirstName(null).Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when FirstName is null."); customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithFirstName("").Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when FirstName is an empty string."); customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithAddress(null).Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when Address is null."); customer = new CustomerBuilder().WithZipCode(city.ZipCode).WithAddress("").Build(); Assert.That(customer.Validate(validCities).IsSuccess, Is.False, "Should return failure when Address is an empty string."); }