public void OneInterface_TryValidate_Fail() { var person = new BinocularPerson { Name = "Cyclops", EyeCount = 1 }; ModelValidator.TryValidateObject(person, Results).Should().BeFalse(); Results[0].ErrorMessage.Should().Match("*EyeCount*2*"); }
public void TwoInterfaces_TryValidate_Ok() { var person = new HumanPerson { Name = "Hyacinth", EyeCount = 2, FootCount = 2 }; ModelValidator.TryValidateObject(person, Results).Should().BeTrue(); Results.Should().BeEmpty(); }
public void Concrete_TryValidate_Fail() { var person = new Person { Name = null }; ModelValidator.TryValidateObject(person, Results).Should().BeFalse(); Results.Count.Should().BePositive(); Results[0].ErrorMessage.Should().Match("*Name*required*"); }
public void Subclass_TryValidate_Fail() { var person = new BinocularPerson { Name = null, EyeCount = 2, FootCount = 2 }; ModelValidator.TryValidateObject(person, Results).Should().BeFalse(); Results.Count.Should().BePositive(); Results[0].ErrorMessage.Should().Match("*Name*required*"); }
public void TwoInterfaces_TryValidate_Fail() { var person = new HumanPerson { Name = "Clumsy Cyclops", EyeCount = 1, FootCount = 1 }; ModelValidator.TryValidateObject(person, Results).Should().BeFalse(); Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("EyeCount")); Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("FootCount")); Results.Count.Should().Be(2); }