-
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.
- Loading branch information
Struan Judd
committed
Feb 2, 2024
1 parent
1317a69
commit 81ead8b
Showing
15 changed files
with
153 additions
and
195 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
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
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,11 @@ | ||
using GqlPlus.Verifier.Ast.Schema; | ||
|
||
namespace GqlPlus.Verifier.Merging; | ||
|
||
internal abstract class TypedMerger<TBase, TType, TParent> | ||
: AliasedAllMerger<TBase, TType> | ||
where TBase : AstAliased | ||
where TType : AstType<TParent>, TBase | ||
where TParent : IEquatable<TParent> | ||
{ | ||
} |
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
14 changes: 14 additions & 0 deletions
14
test/GqlPlus.Verifier.ClassTests/Merging/MergeScalarAstEnumsTests.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,14 @@ | ||
using GqlPlus.Verifier.Ast; | ||
using GqlPlus.Verifier.Ast.Schema; | ||
|
||
namespace GqlPlus.Verifier.Merging; | ||
|
||
public class MergeScalarAstEnumsTests | ||
: TestScalarAsts<ScalarMemberAst, string> | ||
{ | ||
protected override ScalarMemberAst[] MakeItems(string input) | ||
=> input.ScalarMembers(); | ||
|
||
protected override AstScalar<ScalarMemberAst> MakeTyped(string name, string description = "") | ||
=> new(AstNulls.At, name, description, ScalarKind.Enum); | ||
} |
52 changes: 4 additions & 48 deletions
52
test/GqlPlus.Verifier.ClassTests/Merging/MergeScalarAstNumbersTests.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 |
---|---|---|
@@ -1,58 +1,14 @@ | ||
using GqlPlus.Verifier.Ast; | ||
using GqlPlus.Verifier.Ast.Schema; | ||
using NSubstitute; | ||
|
||
namespace GqlPlus.Verifier.Merging; | ||
|
||
public class MergeScalarAstNumbersTests | ||
: TestDescriptions<AstScalar<ScalarRangeAst>> | ||
: TestScalarAsts<ScalarRangeAst, ScalarRangeInput> | ||
{ | ||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsSameKinds_ReturnsTrue(string name) | ||
{ | ||
var items = new[] { MakeDescribed(name), MakeDescribed(name) }; | ||
protected override ScalarRangeAst[] MakeItems(ScalarRangeInput input) | ||
=> input.ScalarRange(); | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeTrue(); | ||
} | ||
|
||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsDifferentKinds_ReturnsFalse(string name) | ||
{ | ||
var items = new[] { MakeDescribed(name) with { Kind = ScalarKind.String }, MakeDescribed(name) }; | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeFalse(); | ||
} | ||
|
||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsRangesCantMerge_ReturnsFalse(string name, ScalarRangeInput range) | ||
{ | ||
var items = new[] { | ||
MakeDescribed(name) with { Items = range.ScalarRange() }, | ||
MakeDescribed(name) with { Items = range.ScalarRange() }, | ||
}; | ||
_ranges.CanMerge([]).ReturnsForAnyArgs(false); | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeFalse(); | ||
} | ||
|
||
private readonly IMerge<ScalarRangeAst> _ranges; | ||
private readonly MergeScalars<ScalarRangeAst> _merger; | ||
|
||
public MergeScalarAstNumbersTests() | ||
{ | ||
_ranges = Merger<ScalarRangeAst>(); | ||
|
||
_merger = new(_ranges); | ||
} | ||
|
||
internal override GroupsMerger<AstScalar<ScalarRangeAst>> MergerGroups => _merger; | ||
|
||
protected override AstScalar<ScalarRangeAst> MakeDescribed(string name, string description = "") | ||
protected override AstScalar<ScalarRangeAst> MakeTyped(string name, string description = "") | ||
=> new(AstNulls.At, name, description, ScalarKind.Number); | ||
} |
52 changes: 4 additions & 48 deletions
52
test/GqlPlus.Verifier.ClassTests/Merging/MergeScalarAstStringsTests.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 |
---|---|---|
@@ -1,58 +1,14 @@ | ||
using GqlPlus.Verifier.Ast; | ||
using GqlPlus.Verifier.Ast.Schema; | ||
using NSubstitute; | ||
|
||
namespace GqlPlus.Verifier.Merging; | ||
|
||
public class MergeScalarAstStringsTests | ||
: TestDescriptions<AstScalar<ScalarRegexAst>> | ||
: TestScalarAsts<ScalarRegexAst, string> | ||
{ | ||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsSameKinds_ReturnsTrue(string name) | ||
{ | ||
var items = new[] { MakeDescribed(name), MakeDescribed(name) }; | ||
protected override ScalarRegexAst[] MakeItems(string input) | ||
=> input.ScalarRegexes(); | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeTrue(); | ||
} | ||
|
||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsDifferentKinds_ReturnsFalse(string name) | ||
{ | ||
var items = new[] { MakeDescribed(name) with { Kind = ScalarKind.Number }, MakeDescribed(name) }; | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeFalse(); | ||
} | ||
|
||
[Theory, RepeatData(Repeats)] | ||
public void CanMerge_TwoItemsRegexesCantMerge_ReturnsFalse(string name, string regex) | ||
{ | ||
var items = new[] { | ||
MakeDescribed(name) with { Items = regex.ScalarRegexes() }, | ||
MakeDescribed(name) with { Items = regex.ScalarRegexes() }, | ||
}; | ||
_regexes.CanMerge([]).ReturnsForAnyArgs(false); | ||
|
||
var result = _merger.CanMerge(items); | ||
|
||
result.Should().BeFalse(); | ||
} | ||
|
||
private readonly IMerge<ScalarRegexAst> _regexes; | ||
private readonly MergeScalars<ScalarRegexAst> _merger; | ||
|
||
public MergeScalarAstStringsTests() | ||
{ | ||
_regexes = Merger<ScalarRegexAst>(); | ||
|
||
_merger = new(_regexes); | ||
} | ||
|
||
internal override GroupsMerger<AstScalar<ScalarRegexAst>> MergerGroups => _merger; | ||
|
||
protected override AstScalar<ScalarRegexAst> MakeDescribed(string name, string description = "") | ||
protected override AstScalar<ScalarRegexAst> MakeTyped(string name, string description = "") | ||
=> new(AstNulls.At, name, description, ScalarKind.String); | ||
} |
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
Oops, something went wrong.