コード例 #1
0
        public void Validate_GivenAParentPolicyIdAndPolicyDoesNotExist_ValidIsFalse()
        {
            //Arrange
            PolicyCreateModel model = CreateModel();

            model.ParentPolicyId = parentPolicyId;

            ISpecificationsRepository repository = CreateSpecificationsRepository(false, false);

            PolicyCreateModelValidator validator = CreateValidator(repository);

            //Act
            ValidationResult result = validator.Validate(model);

            //Assert
            result
            .IsValid
            .Should()
            .BeFalse();

            result
            .Errors
            .Count
            .Should()
            .Be(1);
        }
コード例 #2
0
        public void Validate_GivenValidModel_ValidIsTrue()
        {
            //Arrange
            PolicyCreateModel model = CreateModel();

            PolicyCreateModelValidator validator = CreateValidator();

            //Act
            ValidationResult result = validator.Validate(model);

            //Assert
            result
            .IsValid
            .Should()
            .BeTrue();
        }
コード例 #3
0
        public void Validate_GivenEmptyParentPolicyId_ValidIsTrue()
        {
            //Arrange
            PolicyCreateModel model = CreateModel();

            model.ParentPolicyId = string.Empty;

            PolicyCreateModelValidator validator = CreateValidator();

            //Act
            ValidationResult result = validator.Validate(model);

            //Assert
            result
            .IsValid
            .Should()
            .BeTrue();
        }
コード例 #4
0
        public void Validate_GivenAParentPolicyIdAndPolicyExists_ValidIsTrue()
        {
            //Arrange
            PolicyCreateModel model = CreateModel();

            model.ParentPolicyId = parentPolicyId;

            ISpecificationsRepository repository = CreateSpecificationsRepository(false, true);

            PolicyCreateModelValidator validator = CreateValidator(repository);

            //Act
            ValidationResult result = validator.Validate(model);

            //Assert
            result
            .IsValid
            .Should()
            .BeTrue();
        }
コード例 #5
0
        public void Validate_GivenEmptySpecificationId_ValidIsFalse()
        {
            //Arrange
            PolicyCreateModel model = CreateModel();

            model.SpecificationId = string.Empty;

            PolicyCreateModelValidator validator = CreateValidator();

            //Act
            ValidationResult result = validator.Validate(model);

            //Assert
            result
            .IsValid
            .Should()
            .BeFalse();

            result
            .Errors
            .Count
            .Should()
            .Be(1);
        }