コード例 #1
0
        public void RuleFor_NonObligatedSelectedAndDcfValueNotSelected_ViewModelErrorPropertyShouldBeTrue()
        {
            var model = GenerateInvalidNonObligated();

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            model.ReportOnQuestions.First(r => r.Id == (int)ReportOnQuestionEnum.NonObligatedDcf).HasError.Should().BeTrue();
        }
コード例 #2
0
        public void RuleFor_NonObligatedSelectedAndNullDcfValueSelected_ErrorShouldOccur()
        {
            var model = GenerateInvalidNonObligated();

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            validationResult.IsValid.Should().BeFalse();
            validationResult.Errors.Count.Should().Be(1);
        }
コード例 #3
0
        public void RuleFor_GivenSelectedValueAndNonObligatedSelectedAndDcfValueIsNo_ErrorShouldNotOccur()
        {
            var model = GenerateInvalidNonObligated();

            model.DcfSelectedValue = "No";

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            validationResult.IsValid.Should().BeTrue();
        }
コード例 #4
0
        public void RuleFor_NonObligatedSelectedAndDcfValueIsYes_ErrorShouldBeValid()
        {
            var model = GenerateInvalidNonObligated();

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            validationResult.Errors.Should().Contain(v =>
                                                     v.ErrorMessage.Equals("You must tell us whether any of the non-obligated WEEE was retained by a DCF"));
            validationResult.Errors.Should().Contain(v =>
                                                     v.PropertyName.Equals("Option-4"));
        }
コード例 #5
0
        public void RuleFor_NonObligatedSelectedAndDcfValueIsYes_ErrorShouldNotOccur()
        {
            var model = GenerateInvalidNonObligated();

            model.DcfSelectedValue = "Yes";

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            validationResult.IsValid.Should().BeTrue();
            model.ReportOnQuestions.Any(r => r.HasError).Should().BeFalse();
        }
コード例 #6
0
        public void RuleFor_GivenNoSelectedItems_ErrorShouldBeValid()
        {
            var question = fixture.Build <ReportOnQuestion>()
                           .With(r => r.Id, (int)ReportOnQuestionEnum.WeeeReceived)
                           .With(r => r.Selected, false)
                           .Create();

            var model = new SelectReportOptionsViewModel()
            {
                ReportOnQuestions = new List <ReportOnQuestion>()
                {
                    question
                },
            };

            validator = new SelectReportOptionsViewModelValidator();
            var validationResult = validator.Validate(model);

            validationResult.Errors.Should().Contain(v =>
                                                     v.ErrorMessage.Equals("You must select at least one reporting option, unless you have no data to report"));
            validationResult.Errors.Should().Contain(v =>
                                                     v.PropertyName.Equals("hasSelectedOptions"));
        }