public async Task Given_ACountryWithANullAlpha2Code_When_ValidateContractIsInvoked_Then_ErrorMessageShouldBeReturned() { MockCountriesDal.Setup(m => m.GetMatchingCountries(It.Is <CountryDto>(c => c.Alpha2Code == null))).ReturnsAsync(new CountryDto[0]); var errors = await CountryValidator.ValidateContract(new Country { Alpha2Code = null, FullName = FullName }); Assert.AreEqual(errors.First(), ErrorMessages.CountryAbbreviationMissing); }
public async Task Given_ACountryWithoutAName_When_ValidateContractIsInvoked_Then_ErrorMessageShouldBeReturned() { MockCountriesDal.Setup(m => m.GetMatchingCountries(It.Is <CountryDto>(c => c.FullName == string.Empty))).ReturnsAsync(new CountryDto[0]); var errors = await CountryValidator.ValidateContract(new Country { FullName = string.Empty, Alpha2Code = Alpha2Code }); Assert.AreEqual(errors.First(), ErrorMessages.CountryNameMissing); }
public async Task Given_ACountryWithANullAlpha2Code_When_ValidateContractIsInvoked_Then_CountriesDalGetMatchingCountriesMethodShouldBeInvokedOnce() { MockCountriesDal.Setup(m => m.GetMatchingCountries(It.Is <CountryDto>(c => c.Alpha2Code == null))).ReturnsAsync(new CountryDto[0]); await CountryValidator.ValidateContract(new Country { Alpha2Code = null, FullName = FullName }); MockCountriesDal.Verify(m => m.GetMatchingCountries(It.IsAny <CountryDto>()), Times.Once); }
public async Task Given_AValidCountry_When_ValidateContractIsInvoked_Then_CountriesDalGetMatchingCountriesMethodShouldOnlyBeInvokedOnce() { MockCountriesDal.Setup(m => m.GetMatchingCountries(It.IsAny <CountryDto>())).ReturnsAsync(new CountryDto[0]); MockCountriesDal.Setup(m => m.Create(It.IsAny <CountryDto>())).ReturnsAsync(new CountryDto()); await CountryValidator.ValidateContract(new Country { FullName = FullName, Alpha2Code = Alpha2Code }); MockCountriesDal.Verify(m => m.GetMatchingCountries(It.IsAny <CountryDto>()), Times.Once); }
public async Task Given_ACountryWithoutAUniqueName_When_ValidateContractIsInvoked_Then_ErrorMessageShouldBeReturned() { MockCountriesDal.Setup(m => m.GetMatchingCountries(It.Is <CountryDto>(c => c.FullName == FullName))).ReturnsAsync(new[] { new CountryDto { FullName = FullName } }); var errors = await CountryValidator.ValidateContract(new Country { Alpha2Code = Alpha2Code, FullName = FullName }); Assert.AreEqual(errors.First(), ErrorMessages.NonUniqueCountryName); }