public void Validator_passes_valid_ukprn() { var errors = new List <ValidationErrorDetail>(); _roatpOrganisationValidator.Setup(x => x.IsValidUKPRN(It.IsAny <string>())).Returns(errors); _viewModel = new AddOrganisationViaUkprnViewModel { UKPRN = "11112222" }; var validator = new AddOrganisationViaUkprnViewModelValidator(_roatpOrganisationValidator.Object, _apiClient.Object); var validationResult = validator.Validate(_viewModel); Assert.AreEqual(0, validationResult.Errors.Count); }
public void Validator_fails_invalid_ukprn() { var errors = new List <ValidationErrorDetail> { new ValidationErrorDetail { Field = "ukprn", ErrorMessage = "wrong length" } }; _roatpOrganisationValidator.Setup(x => x.IsValidUKPRN(It.IsAny <string>())).Returns(errors); _viewModel = new AddOrganisationViaUkprnViewModel { UKPRN = "111222" }; var validator = new AddOrganisationViaUkprnViewModelValidator(_roatpOrganisationValidator.Object, _apiClient.Object); var validationResult = validator.Validate(_viewModel); Assert.AreEqual(1, validationResult.Errors.Count); }