private void SearchByDistrictValidation() { var userEnteredSearchByDistrictDto = new SearchByDistrictModel { IsSearchToBeDoneByDistrict = Convert.ToBoolean(_configuration["CoWinAPI:IsSearchToBeDoneByDistrict"]), Districts = districtsToSearch }; if (!_searchByDistrictValidator.IsValid(userEnteredSearchByDistrictDto)) { throw new InvalidMobileNumberException("Invalid Configuration for Searching by District: \"IsSearchToBeDoneByDistrict\": " + userEnteredSearchByDistrictDto.IsSearchToBeDoneByDistrict.ToString() + ", \"Districts\": [ " + string.Join(", ", districtsToSearch) + " ] found in your config file. If you want to search by District, please set IsSearchToBeDoneByDistrict as true and provide proper valid values for Districts"); } }
public void IsValid_Should_ReturnFalse_When_IsSearchToBeDoneByDistrictIsFalseAndOneDistrictIsDefault() { var userEnteredDistrict = new List <string> { "395", "REPLACE_ME_WITH_YOUR_DISTRICT_CODE_2" }; var userEnteredSearchByDistrictDto = new SearchByDistrictModel { IsSearchToBeDoneByDistrict = true, Districts = userEnteredDistrict }; var isValid = _searchByDistrictValidator.IsValid(userEnteredSearchByDistrictDto); Assert.IsFalse(isValid); }
public void IsValid_Should_ReturnFalse_When_IsSearchToBeDoneByDistrictIsFalseAndBothDistrictsAreValid() { var userEnteredDistrict = new List <string> { "395", "392" }; var userEnteredSearchByDistrictDto = new SearchByDistrictModel { IsSearchToBeDoneByDistrict = false, Districts = userEnteredDistrict }; var isValid = _searchByDistrictValidator.IsValid(userEnteredSearchByDistrictDto); Assert.IsFalse(isValid); }