Skip to content

Commit

Permalink
Add failing test for processing ValidationResult.Success
Browse files Browse the repository at this point in the history
  • Loading branch information
luboshl committed Jul 26, 2024
1 parent f877fe7 commit 747743e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/MiniValidationPlus.UnitTests/TestTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,11 @@ public TestTypeWithPropertiesWithoutSetter(
RequiredNullableString = requiredNullableString;
}
}

class ValidatableObjectWithSuccessValidationResultTestType : IValidatableObject
{
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
yield return ValidationResult.Success;
}
}
11 changes: 11 additions & 0 deletions tests/MiniValidationPlus.UnitTests/TryValidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ public void Struct_Invalid_When_Invalid()
Assert.Single(errors);
}

[Fact]
public void Valid_When_ValidatableObject_Has_Success_ValidationResult()
{
var thingToValidate = new ValidatableObjectWithSuccessValidationResultTestType();

var result = MiniValidatorPlus.TryValidate(thingToValidate, out var errors);

Assert.True(result);
Assert.Empty(errors);
}

[Fact]
public void Invalid_When_ValidatableObject_Validate_Is_Invalid()
{
Expand Down

0 comments on commit 747743e

Please sign in to comment.