public void RequiredIf_Property_Should_Be_Invalid_If_Condition_Not_Met() { var model = new RequiredIfNotEmptyAttributeTestModel { DependencyProp = "Some Other String", TestProp = null }; var isValid = Validator.TryValidateObject(model, new ValidationContext(model), new List <ValidationResult>(), true); isValid.Should().BeFalse(); }
public void RequiredIf_Property_Should_Be_Valid_If_Not_Required() { var model = new RequiredIfNotEmptyAttributeTestModel { DependencyProp = string.Empty, TestProp = null }; var isValid = Validator.TryValidateObject(model, new ValidationContext(model), new List <ValidationResult>(), true); isValid.Should().BeTrue(); model.TestProp = "some string"; isValid = Validator.TryValidateObject(model, new ValidationContext(model), new List <ValidationResult>(), true); isValid.Should().BeTrue(); }