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); }
public void Validate_GivenValidModel_ValidIsTrue() { //Arrange PolicyCreateModel model = CreateModel(); PolicyCreateModelValidator validator = CreateValidator(); //Act ValidationResult result = validator.Validate(model); //Assert result .IsValid .Should() .BeTrue(); }
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(); }
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(); }
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); }