示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }