public void UKPNThatIsNotNumericOr8DigitsInLengthIsInvalid(string ukpn)
        {
            _viewModel.ProviderId = ukpn;

            var result = _validator.Validate(_viewModel, ruleSet: _validatorRuleset);

            result.IsValid.Should().BeFalse();
        }
Esempio n. 2
0
        private void RevalidateModel(OrchestratorResponse <SelectProviderViewModel> defaultViewModel)
        {
            var validator = new SelectProviderViewModelValidator();
            var results   = validator.Validate(defaultViewModel.Data, ruleSet: "SearchResult");

            results.AddToModelState(ModelState, null);
        }
        public void AndTheProviderIdIsAboveLongMaxValue_ThenReturnsInvalid(
            SelectProviderViewModel viewModel,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = Double.MaxValue.ToString();
            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
        }
        public void AndTheProviderIdIsNonNumeric_ThenReturnsInvalid(
            SelectProviderViewModel viewModel,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = "abcdefghijklmnopqrstuvwxyz*!£$%^&*()_+¬`=-][#';/.,}{~@:?><";
            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
        }
        public void AndTheProviderIdIsNull_ThenReturnsInvalid(
            SelectProviderViewModel viewModel,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = null;
            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
        }
        public void AndTheProviderIdIsLessThanOne_ThenReturnsInvalid(
            SelectProviderViewModel viewModel,
            long providerId,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = $"-{Convert.ToString(providerId)}";
            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
        }
        public void AndTheProviderIdIsGreaterThanOne_ThenReturnsValid(
            SelectProviderViewModel viewModel,
            long providerId,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = Convert.ToString(providerId);

            var result = validator.Validate(viewModel);

            Assert.True(result.IsValid);
        }
        public void AndTheEmployerLegalEntityPublicHashedIdIsEmpty_ThenReturnsInvalid(
            SelectProviderViewModel viewModel,
            long providerId,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = providerId.ToString();
            viewModel.AccountLegalEntityHashedId = string.Empty;

            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
        }
        public void AndViewModelIsValid_ThenReturnsValid(
            SelectProviderViewModel viewModel,
            long providerId,
            string someString,
            SelectProviderViewModelValidator validator)
        {
            viewModel.ProviderId = providerId.ToString();
            viewModel.AccountLegalEntityHashedId = someString;

            var result = validator.Validate(viewModel);

            Assert.True(result.IsValid);
        }
        public void AndProviderIdIsInvalid_ThenCorrectValidationMessageShown(
            SelectProviderViewModel viewModel,
            string invalidId,
            SelectProviderViewModelValidator validator)
        {
            var expectedMessage = "Check UK Provider Reference Number";

            viewModel.ProviderId = invalidId;

            var result = validator.Validate(viewModel);

            Assert.False(result.IsValid);
            Assert.True(result.Errors.Any(x => x.ErrorMessage == expectedMessage));
        }