public void ModelIsNull() { // Arrange var validator = new AreaListValidator(null, "areaType", codeService); // Act validator.Validate(controller.ModelState); // Assert controller.ModelState.IsValid.Should().BeTrue(); }
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(); }
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(); }