public void Validate_ShouldReturn_Valid_IfElement_IsValid_OnSamePageSubmission() { var formAnswers = new FormAnswers { Pages = new List <PageAnswers> { new PageAnswers { Answers = new List <Answers>() } } }; _mockFormAnswersProvider.Setup(_ => _.GetFormAnswers()).Returns(formAnswers); var isDateBeforeValidator = new IsDateBeforeValidator(_mockFormAnswersProvider.Object); var viewModel = new Dictionary <string, dynamic> { { "test-element", "01/01/2019" }, { "test-comparison-element", "01/01/2020" } }; // Act ValidationResult result = isDateBeforeValidator.Validate(datePickerelement, viewModel, SchemaWithDatePickerElement); // Assert Assert.True(result.IsValid); }
public void Validate_ShouldReturn_Valid_IfComparisonElement_IsNullOrEmpty() { var isDateBeforeValidator = new IsDateBeforeValidator(_mockFormAnswersProvider.Object); // Act ValidationResult result = isDateBeforeValidator.Validate(datePickerelement, null, SchemaWithElement(new Element { Properties = new BaseProperty() })); // Assert Assert.True(result.IsValid); }
public void Validate_Returns_Valid_IfElemenType_IsNot_DateInputOrDatePicker() { var isDateBeforeValidator = new IsDateBeforeValidator(_mockFormAnswersProvider.Object); // Arrange var texttBoxElement = new ElementBuilder() .WithType(EElementType.Textbox) .WithIsDateBefore("test-comparison-element") .Build(); // Act ValidationResult result = isDateBeforeValidator.Validate(texttBoxElement, null, SchemaWithDatePickerElement); // Assert Assert.True(result.IsValid); }
public void Validate_Returns_Valid_IfComparisonElemenType_IsNot_DateInputOrDatePicker() { var isDateBeforeValidator = new IsDateBeforeValidator(_mockFormAnswersProvider.Object); var formSchema = SchemaWithElement( new Textbox { Properties = new BaseProperty { QuestionId = "test-comparison-element" } }); // Act ValidationResult result = isDateBeforeValidator.Validate(datePickerelement, null, formSchema); // Assert Assert.True(result.IsValid); }
public void Validate_ShouldReturn_Valid_IfElement_DoesNotHaveAValue() { //Arrange 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 isDateBeforeValidator = new IsDateBeforeValidator(_mockFormAnswersProvider.Object); var viewModel = new Dictionary <string, dynamic> { { "test-element", string.Empty } }; // Act ValidationResult result = isDateBeforeValidator.Validate(datePickerelement, viewModel, SchemaWithDatePickerElement); // Assert Assert.True(result.IsValid); }