Ejemplo n.º 1
0
        public async Task PassesRegexButPostcodeIOThrowsError()
        {
            _regexPostcodeValidator.Setup(x => x.IsPostcodeValid(It.IsAny <string>())).Returns(true);
            _repository.Setup(x => x.IsPostcodeInDbAndActive(It.IsAny <string>())).Throws <Exception>();

            PostcodeValidator postcodeValidator = new PostcodeValidator(_regexPostcodeValidator.Object, _repository.Object, _iLogger.Object);

            bool result = await postcodeValidator.IsPostcodeValidAsync("NG15FS");

            Assert.IsTrue(result);
        }
Ejemplo n.º 2
0
        public async Task IsPostcodeValid(bool passesRegexValidator, bool isInDbAndActive, bool expectedResult)
        {
            _regexPostcodeValidator.Setup(x => x.IsPostcodeValid(It.IsAny <string>())).Returns(passesRegexValidator);
            _repository.Setup(x => x.IsPostcodeInDbAndActive(It.IsAny <string>())).ReturnsAsync(isInDbAndActive);

            PostcodeValidator postcodeValidator = new PostcodeValidator(_regexPostcodeValidator.Object, _repository.Object, _iLogger.Object);

            bool result = await postcodeValidator.IsPostcodeValidAsync("NG15FS");

            Assert.AreEqual(expectedResult, result);
        }