コード例 #1
0
        private void SearchByPINCodeValidation()
        {
            var userEnteredSearchByPINCodeDto = new SearchByPINCodeModel
            {
                IsSearchToBeDoneByPINCode = Convert.ToBoolean(_configuration["CoWinAPI:IsSearchToBeDoneByPINCode"]),
                PINCodes = pinCodesToSearch
            };

            if (!_searchByPINCodeValidator.IsValid(userEnteredSearchByPINCodeDto))
            {
                throw new InvalidMobileNumberException("Invalid Configuration for Searching by PINCode: \"IsSearchToBeDoneByPINCode\": " + userEnteredSearchByPINCodeDto.IsSearchToBeDoneByPINCode.ToString() + ", \"PINCodes\": [ " + string.Join(", ", pinCodesToSearch) + " ] found in your config file. If you want to search by PINCode, please set IsSearchToBeDoneByPINCode as true and provide proper valid values for PINCodes");
            }
        }
        public void IsValid_Should_ReturnFalse_When_IsSearchToBeDoneByPINCodeIsFalseAndOneDistrictIsDefault()
        {
            var userEnteredDistrict = new List <string> {
                "400001", "REPLACE_ME_WITH_YOUR_PIN_CODE_2"
            };
            var userEnteredSearchByPINCodeDto = new SearchByPINCodeModel
            {
                IsSearchToBeDoneByPINCode = true,
                PINCodes = userEnteredDistrict
            };
            var isValid = _searchByPINCodeValidator.IsValid(userEnteredSearchByPINCodeDto);

            Assert.IsFalse(isValid);
        }
        public void IsValid_Should_ReturnFalse_When_IsSearchToBeDoneByPINCodeIsFalseAndBothPINCodesAreValid()
        {
            var userEnteredDistrict = new List <string> {
                "400001", "400006"
            };

            var userEnteredSearchByPINCodeDto = new SearchByPINCodeModel
            {
                IsSearchToBeDoneByPINCode = false,
                PINCodes = userEnteredDistrict
            };
            var isValid = _searchByPINCodeValidator.IsValid(userEnteredSearchByPINCodeDto);

            Assert.IsFalse(isValid);
        }