-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent duplicate validation of implemented interfaces (#109)
- Loading branch information
1 parent
1571912
commit 036ed67
Showing
69 changed files
with
788 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
tests/Immediate.Validations.FunctionalTests/IntegrationTests/DuplicateTypeVisitTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Immediate.Validations.Shared; | ||
using Xunit; | ||
|
||
namespace Immediate.Validations.FunctionalTests.IntegrationTests; | ||
|
||
public partial class DuplicateTypeVisitTests | ||
{ | ||
[Validate] | ||
public partial interface IBaseInterface : IValidationTarget<IBaseInterface> | ||
{ | ||
public static int VisitCount { get; set; } | ||
|
||
private static void AdditionalValidations(ValidationResult _, IBaseInterface __) | ||
{ | ||
VisitCount++; | ||
} | ||
} | ||
|
||
[Validate] | ||
public partial interface ISubInterface : IBaseInterface, IValidationTarget<ISubInterface>; | ||
|
||
[Validate] | ||
public sealed partial record ValidateRecord : IBaseInterface, ISubInterface, IValidationTarget<ValidateRecord>; | ||
|
||
[Fact] | ||
public void TypeValidatorsAreVisitedAtMostOnce() | ||
{ | ||
var record = new ValidateRecord(); | ||
|
||
_ = ValidateRecord.Validate(record); | ||
|
||
Assert.Equal(1, IBaseInterface.VisitCount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.