public void InvalidObjectFailsValidation() { var dto = BuildDto(false); var result = ExtendedValidator.Validate(dto); Assert.IsNotNull(result); Assert.That(result, Has.Length.EqualTo(3)); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("AString")); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("Inner.Field")); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("InnerList[0].Field")); }
public void InvalidObjectFailsMaxLengthInnerDto2() { var dto = BuildDto(true); dto.Inner.Field = "hello"; dto.Inner.Field2 = "123456789012345"; // Try to fire MaxLengthAttribute.. var result = ExtendedValidator.Validate(dto); Assert.IsNotNull(result); Assert.That(result, Has.Length.EqualTo(1)); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("Inner.Field2")); }
public void InvalidObjectFailsRequiredOnlyValidation2() { var dto = BuildDto(false); dto.AString = "abc"; // Try to fire MinLengthAttribute.. var result = ExtendedValidator.Validate(dto, false); Assert.IsNotNull(result); Assert.That(result, Has.Length.EqualTo(2)); //Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("AString")); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("Inner.Field")); Assert.That(result, Has.Exactly(1).Property("MemberNames").Contains("InnerList[0].Field")); }