Beispiel #1
0
        public void Validate_ShouldReturn_NotValid_IfElement_IsNotValid_OnSamePageSubmission()
        {
            var formAnswers = new FormAnswers
            {
                Pages = new List <PageAnswers>
                {
                    new PageAnswers
                    {
                        Answers = new List <Answers>()
                    }
                }
            };

            _mockFormAnswersProvider.Setup(_ => _.GetFormAnswers()).Returns(formAnswers);

            var isDateAfterValidator = new IsDateAfterValidator(_mockFormAnswersProvider.Object);
            var viewModel            = new Dictionary <string, dynamic>
            {
                {
                    "test-element",
                    "01/01/2020"
                },
                {
                    "test-comparison-element",
                    "01/01/2021"
                }
            };

            // Arrange/Act
            ValidationResult result = isDateAfterValidator.Validate(datePickerelement, viewModel, SchemaWithDatePickerElement);

            // Assert
            Assert.False(result.IsValid);
        }
Beispiel #2
0
        public void Validate_ShouldReturn_Valid_IfComparisonElement_IsNullOrEmpty()
        {
            var isDateAfterValidator = new IsDateAfterValidator(_mockFormAnswersProvider.Object);

            // Act
            ValidationResult result = isDateAfterValidator.Validate(datePickerelement, null, SchemaWithElement(new Element {
                Properties = new BaseProperty()
            }));

            // Assert
            Assert.True(result.IsValid);
        }
Beispiel #3
0
        public void Validate_Returns_Valid_IfElemenType_IsNot_DateInputOrDatePicker()
        {
            var isDateAfterValidator = new IsDateAfterValidator(_mockFormAnswersProvider.Object);

            // Arrange
            var texttBoxElement = new ElementBuilder()
                                  .WithType(EElementType.Textbox)
                                  .WithIsDateBefore("test-comparison-element")
                                  .Build();

            // Act
            ValidationResult result = isDateAfterValidator.Validate(texttBoxElement, null, SchemaWithDatePickerElement);

            // Assert
            Assert.True(result.IsValid);
        }
Beispiel #4
0
        public void Validate_Returns_Valid_IfComparisonElemenType_IsNot_DateInputOrDatePicker()
        {
            var isDateAfterValidator = new IsDateAfterValidator(_mockFormAnswersProvider.Object);

            var formSchema = SchemaWithElement(
                new Textbox
            {
                Properties = new BaseProperty {
                    QuestionId = "test-comparison-element"
                }
            });

            // Act
            ValidationResult result = isDateAfterValidator.Validate(datePickerelement, null, formSchema);

            // Assert
            Assert.True(result.IsValid);
        }
Beispiel #5
0
        public void Validate_ShouldReturn_Valid_IfElement_DoesNotHaveAValue()
        {
            var formAnswers = new FormAnswers
            {
                Pages = new List <PageAnswers>
                {
                    new PageAnswers
                    {
                        Answers = new List <Answers>
                        {
                            new Answers
                            {
                                QuestionId = "test-comparison-element",
                                Response   = "01/01/2021"
                            }
                        }
                    }
                }
            };

            _mockFormAnswersProvider.Setup(_ => _.GetFormAnswers()).Returns(formAnswers);

            var isDateAfterValidator = new IsDateAfterValidator(_mockFormAnswersProvider.Object);
            var viewModel            = new Dictionary <string, dynamic>
            {
                {
                    "test-element",
                    string.Empty
                }
            };

            // Arrange/Act
            ValidationResult result = isDateAfterValidator.Validate(datePickerelement, viewModel, SchemaWithDatePickerElement);

            // Assert
            Assert.True(result.IsValid);
        }