Exemple #1
0
        public void ModelIsNull()
        {
            // Arrange
            var validator = new AreaListValidator(null, "areaType", codeService);

            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeTrue();
        }
Exemple #2
0
        public void ModelSetAndAreaDoesNotExist()
        {
            // Arrange
            codeServiceMockSetup.Setup(c => c.GetAreaByCodeAndType(It.IsAny <string>(), It.IsAny <string>())).Returns((VmOpenApiArea)null);
            var list = new List <string>()
            {
                "areaCode1", "areaCode2"
            };
            var validator = new AreaListValidator(list, "areaType", codeService);

            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeFalse();
        }
Exemple #3
0
        public void ModelIncludesNullAndAreaExists()
        {
            // Arrange
            codeServiceMockSetup.Setup(c => c.GetAreaByCodeAndType(It.IsAny <string>(), It.IsAny <string>())).Returns(new VmOpenApiArea()
            {
                Code = "code"
            });
            var list = new List <string>()
            {
                null, "areaCode"
            };
            var validator = new AreaListValidator(list, "areaType", codeService);

            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeTrue();
        }