-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Domain Member Verify class tests
- Loading branch information
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test/GqlPlus.Verifier.ClassTests/Verifying/Schema/Simple/AstDomainVerifierBase.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,32 @@ | ||
using GqlPlus.Abstractions.Schema; | ||
|
||
namespace GqlPlus.Verifying.Schema.Simple; | ||
|
||
public abstract class AstDomainVerifierBase<TMember> | ||
: VerifierBase | ||
where TMember : class, IGqlpDomainItem | ||
{ | ||
internal ForM<TMember> Members { get; } = new(); | ||
protected IMap<string> EnumValues { get; } = new Map<string>(); | ||
protected IMap<IGqlpDescribed> Types { get; } = new Map<IGqlpDescribed>(); | ||
|
||
[Fact] | ||
public void Verify_WithoutErrors() | ||
{ | ||
AstDomainVerifier<TMember> verifier = NewDomainVerifier(); | ||
|
||
EnumContext context = new(Types, Errors, EnumValues); | ||
|
||
IGqlpDomain<TMember> domain = EFor<IGqlpDomain<TMember>>(); | ||
|
||
verifier.Verify(domain, context); | ||
|
||
using AssertionScope scope = new(); | ||
|
||
Members.NotCalled(); | ||
Errors.Should().BeNullOrEmpty(); | ||
} | ||
|
||
internal virtual AstDomainVerifier<TMember> NewDomainVerifier() | ||
=> new(Members.Intf); | ||
} |
47 changes: 47 additions & 0 deletions
47
test/GqlPlus.Verifier.ClassTests/Verifying/Schema/Simple/VerifyDomainEnumTests.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,47 @@ | ||
using GqlPlus.Abstractions.Schema; | ||
using NSubstitute; | ||
|
||
namespace GqlPlus.Verifying.Schema.Simple; | ||
|
||
public class VerifyDomainEnumTests | ||
: AstDomainVerifierBase<IGqlpDomainMember> | ||
{ | ||
|
||
[Fact] | ||
public void Verify_CallsVerifierAndMergerWithoutErrors() | ||
{ | ||
AstDomainVerifier<IGqlpDomainMember> verifier = NewDomainVerifier(); | ||
|
||
EnumContext context = new(Types, Errors, EnumValues); | ||
|
||
IGqlpEnum enumType = EFor<IGqlpEnum>(); | ||
enumType.Name.Returns("domain"); | ||
IGqlpEnumItem item1 = EFor<IGqlpEnumItem>(); | ||
item1.Name.Returns("item1"); | ||
IGqlpEnumItem item2 = EFor<IGqlpEnumItem>(); | ||
item2.Name.Returns("item2"); | ||
enumType.Items.Returns([item1, item2]); | ||
Types["domain"] = enumType; | ||
|
||
EnumValues["item1"] = "domain"; | ||
EnumValues["item2"] = "domain"; | ||
|
||
IGqlpDomain<IGqlpDomainMember> domain = EFor<IGqlpDomain<IGqlpDomainMember>>(); | ||
domain.Name.Returns("domain"); | ||
IGqlpDomainMember member1 = EFor<IGqlpDomainMember>(); | ||
member1.EnumItem.Returns("item1"); | ||
IGqlpDomainMember member2 = EFor<IGqlpDomainMember>(); | ||
member2.EnumItem.Returns("item2"); | ||
domain.Items.Returns([member1, member2]); | ||
|
||
verifier.Verify(domain, context); | ||
|
||
using AssertionScope scope = new(); | ||
|
||
Members.NotCalled(); | ||
Errors.Should().BeNullOrEmpty(); | ||
} | ||
|
||
internal override AstDomainVerifier<IGqlpDomainMember> NewDomainVerifier() | ||
=> new VerifyDomainEnum(Members.Intf); | ||
} |
8 changes: 8 additions & 0 deletions
8
test/GqlPlus.Verifier.ClassTests/Verifying/Schema/Simple/VerifyDomainRangeTests.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,8 @@ | ||
using GqlPlus.Abstractions.Schema; | ||
|
||
namespace GqlPlus.Verifying.Schema.Simple; | ||
|
||
public class VerifyDomainRangeTests | ||
: AstDomainVerifierBase<IGqlpDomainRange> | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
test/GqlPlus.Verifier.ClassTests/Verifying/Schema/Simple/VerifyDomainRegexTests.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,8 @@ | ||
using GqlPlus.Abstractions.Schema; | ||
|
||
namespace GqlPlus.Verifying.Schema.Simple; | ||
|
||
public class VerifyDomainRegexTests | ||
: AstDomainVerifierBase<IGqlpDomainRegex> | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
test/GqlPlus.Verifier.ClassTests/Verifying/Schema/Simple/VerifyDomainTrueFalseTests.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,8 @@ | ||
using GqlPlus.Abstractions.Schema; | ||
|
||
namespace GqlPlus.Verifying.Schema.Simple; | ||
|
||
public class VerifyDomainTrueFalseTests | ||
: AstDomainVerifierBase<IGqlpDomainTrueFalse> | ||
{ | ||
} |