public void ShouldBeValidIfTrainingProviderSearchSpecified() { var vm = new SelectTrainingProviderEditModel { TrainingProviderSearch = "something specified", SelectionType = TrainingProviderSelectionType.TrainingProviderSearch }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeTrue(); }
public void ShouldBeValidIfUkprnSpecified() { var vm = new SelectTrainingProviderEditModel { Ukprn = "12345678", SelectionType = TrainingProviderSelectionType.Ukprn }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeTrue(); }
public void ShouldErrorIfSelectTrainingProviderNotSpecified() { var vm = new SelectTrainingProviderEditModel { IsTrainingProviderSelected = null, }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(1); result.Errors[0].PropertyName.Should().Be(nameof(SelectTrainingProviderEditModel.IsTrainingProviderSelected)); result.Errors[0].ErrorMessage.Should().Be("Please select an option to continue"); }
public void ShouldErrorIfSelectTrainingProviderNotSpecified() { var vm = new SelectTrainingProviderEditModel { IsTrainingProviderSelected = null, }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(1); result.Errors[0].PropertyName.Should().Be(nameof(SelectTrainingProviderEditModel.IsTrainingProviderSelected)); result.Errors[0].ErrorMessage.Should().Be("Select yes if you’ve found a training provider"); }
public void ShouldErrorIfTrainingProviderSearchIsNotSpecified(string inputUkprn) { var vm = new SelectTrainingProviderEditModel { TrainingProviderSearch = inputUkprn, SelectionType = TrainingProviderSelectionType.TrainingProviderSearch }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(1); result.Errors[0].PropertyName.Should().Be(nameof(SelectTrainingProviderEditModel.TrainingProviderSearch)); result.Errors[0].ErrorMessage.Should().Be("You must enter a training provider or UKPRN to continue"); }
public void ShouldErrorIfUkprnIsInvalid() { var vm = new SelectTrainingProviderEditModel { Ukprn = "invalid ukprn", SelectionType = TrainingProviderSelectionType.Ukprn }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(1); result.Errors[0].PropertyName.Should().Be(nameof(SelectTrainingProviderEditModel.Ukprn)); result.Errors[0].ErrorMessage.Should().Be("UKPRN is not recognised"); }
public void ShouldErrorIfUkprnIsNotSpecified(string inputUkprn) { var vm = new SelectTrainingProviderEditModel { Ukprn = inputUkprn, SelectionType = TrainingProviderSelectionType.Ukprn }; var validator = new SelectTrainingProviderEditModelValidator(); var result = validator.Validate(vm); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().Be(1); result.Errors[0].PropertyName.Should().Be(nameof(SelectTrainingProviderEditModel.Ukprn)); result.Errors[0].ErrorMessage.Should().Be("You must provide a UKPRN"); }