Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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");
        }
Esempio n. 5
0
        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");
        }
Esempio n. 6
0
        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");
        }
Esempio n. 7
0
        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");
        }