Exemple #1
0
        public static void Validate_NullCommencementDate_ReturnsExpectedResult(
            DefaultDeliveryDateModel model,
            DefaultDeliveryDateValidator validator)
        {
            (bool isValid, ErrorsModel errors) = validator.Validate(model, null);

            isValid.Should().BeFalse();
            errors.Should().NotBeNull();
            errors.Errors.Should().NotBeNull();
            errors.Errors.Should().HaveCount(1);
            errors.Errors.First().Should().BeEquivalentTo(DefaultDeliveryDateValidator.CommencementDateRequired);
        }
Exemple #2
0
        public static void Validate_DateAtLimit_ReturnsExpectedResult(
            DateTime commencementDate,
            [Frozen] ValidationSettings validationSettings,
            DefaultDeliveryDateModel model,
            DefaultDeliveryDateValidator validator)
        {
            model.DeliveryDate = commencementDate.AddDays(validationSettings.MaxDeliveryDateOffsetInDays);
            (bool isValid, ErrorsModel errors) = validator.Validate(model, commencementDate);

            isValid.Should().BeTrue();
            errors.Should().NotBeNull();
            errors.Errors.Should().NotBeNull();
            errors.Errors.Should().HaveCount(0);
        }
Exemple #3
0
        public static void Validate_DateBeforeCommencementDate_ReturnsExpectedResult(
            DateTime commencementDate,
            DefaultDeliveryDateModel model,
            DefaultDeliveryDateValidator validator)
        {
            model.DeliveryDate = commencementDate.AddDays(-1);
            (bool isValid, ErrorsModel errors) = validator.Validate(model, commencementDate);

            isValid.Should().BeFalse();
            errors.Should().NotBeNull();
            errors.Errors.Should().NotBeNull();
            errors.Errors.Should().HaveCount(1);
            errors.Errors.First().Should().BeEquivalentTo(DefaultDeliveryDateValidator.OutsideWindow);
        }
Exemple #4
0
        public static void Validate_DateOutsideWindow_ReturnsExpectedResult(
            DateTime commencementDate,
            [Frozen] ValidationSettings validationSettings,
            DefaultDeliveryDateModel model,
            DefaultDeliveryDateValidator validator)
        {
            model.DeliveryDate = commencementDate.AddDays(validationSettings.MaxDeliveryDateOffsetInDays + 1);
            (bool isValid, ErrorsModel errors) = validator.Validate(model, commencementDate);

            isValid.Should().BeFalse();
            errors.Should().NotBeNull();
            errors.Errors.Should().NotBeNull();
            errors.Errors.Should().HaveCount(1);
            errors.Errors.First().Should().BeEquivalentTo(DefaultDeliveryDateValidator.OutsideWindow);
        }