示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }