From 747743e8c07c7d125ac79dbb72f5619a4e61b01f Mon Sep 17 00:00:00 2001 From: Lubos Hladik Date: Fri, 26 Jul 2024 15:12:30 +0200 Subject: [PATCH] Add failing test for processing ValidationResult.Success --- tests/MiniValidationPlus.UnitTests/TestTypes.cs | 8 ++++++++ tests/MiniValidationPlus.UnitTests/TryValidate.cs | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/MiniValidationPlus.UnitTests/TestTypes.cs b/tests/MiniValidationPlus.UnitTests/TestTypes.cs index 5a9b685..8a11325 100644 --- a/tests/MiniValidationPlus.UnitTests/TestTypes.cs +++ b/tests/MiniValidationPlus.UnitTests/TestTypes.cs @@ -310,3 +310,11 @@ public TestTypeWithPropertiesWithoutSetter( RequiredNullableString = requiredNullableString; } } + +class ValidatableObjectWithSuccessValidationResultTestType : IValidatableObject +{ + public IEnumerable Validate(ValidationContext validationContext) + { + yield return ValidationResult.Success; + } +} diff --git a/tests/MiniValidationPlus.UnitTests/TryValidate.cs b/tests/MiniValidationPlus.UnitTests/TryValidate.cs index a022af1..049db7e 100644 --- a/tests/MiniValidationPlus.UnitTests/TryValidate.cs +++ b/tests/MiniValidationPlus.UnitTests/TryValidate.cs @@ -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() {