-
-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
cfdc549
commit 6f0486c
Showing
19 changed files
with
230 additions
and
19 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
12 changes: 12 additions & 0 deletions
12
...mory.Tests/__snapshots__/QueryableFilterCombinatorTests.Create_Empty_Expression_true.snap
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,12 @@ | ||
{ | ||
"data": { | ||
"root": [ | ||
{ | ||
"bar": true | ||
}, | ||
{ | ||
"bar": false | ||
} | ||
] | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/HotChocolate/Data/test/Data.Filters.InMemory.Tests/asd.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,54 @@ | ||
using System.Threading.Tasks; | ||
using HotChocolate.Execution; | ||
using Snapshooter; | ||
using Snapshooter.Xunit; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Data.Filters; | ||
|
||
public class QueryableFilterCombinatorTests | ||
{ | ||
private static readonly Foo[] _fooEntities = { new() { Bar = true }, new() { Bar = false } }; | ||
|
||
private readonly SchemaCache _cache = new(); | ||
|
||
[Fact] | ||
public async Task Create_Empty_Expression() | ||
{ | ||
// arrange | ||
var tester = _cache.CreateSchema<Foo, FooFilterInput>(_fooEntities); | ||
|
||
// act | ||
// assert | ||
var res1 = await tester.ExecuteAsync( | ||
QueryRequestBuilder.New() | ||
.SetQuery("{ root(where: { }){ bar }}") | ||
.Create()); | ||
|
||
res1.ToJson().MatchSnapshot(new SnapshotNameExtension("true")); | ||
} | ||
|
||
public class Foo | ||
{ | ||
public int Id { get; set; } | ||
|
||
public bool Bar { get; set; } | ||
} | ||
|
||
public class FooNullable | ||
{ | ||
public int Id { get; set; } | ||
|
||
public bool? Bar { get; set; } | ||
} | ||
|
||
public class FooFilterInput | ||
: FilterInputType<Foo> | ||
{ | ||
} | ||
|
||
public class FooNullableFilterInput | ||
: FilterInputType<FooNullable> | ||
{ | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
src/HotChocolate/MongoDb/test/Data.MongoDb.Filters.Tests/MongoDbFilterCombinatorTests.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,50 @@ | ||
using HotChocolate.Data.Filters; | ||
using HotChocolate.Execution; | ||
using MongoDB.Bson.Serialization.Attributes; | ||
using Squadron; | ||
using Xunit; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace HotChocolate.Data.MongoDb.Filters; | ||
|
||
public class MongoDbFilterCombinatorTests | ||
: SchemaCache | ||
, IClassFixture<MongoResource> | ||
{ | ||
private static readonly Foo[] _fooEntities = { new() { Bar = true }, new() { Bar = false } }; | ||
|
||
public MongoDbFilterCombinatorTests(MongoResource resource) | ||
{ | ||
Init(resource); | ||
} | ||
|
||
[Fact] | ||
public async Task Create_Empty_Expression() | ||
{ | ||
// arrange | ||
var tester = CreateSchema<Foo, FooFilterInput>(_fooEntities); | ||
|
||
// act | ||
// assert | ||
var res1 = await tester.ExecuteAsync( | ||
QueryRequestBuilder.New() | ||
.SetQuery("{ root(where: { }){ bar }}") | ||
.Create()); | ||
|
||
res1.MatchDocumentSnapshot("res1"); | ||
} | ||
|
||
public class Foo | ||
{ | ||
[BsonId] | ||
public Guid Id { get; set; } = Guid.NewGuid(); | ||
|
||
public bool Bar { get; set; } | ||
} | ||
|
||
public class FooFilterInput | ||
: FilterInputType<Foo> | ||
{ | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ilters.Tests/__snapshots__/MongoDbFilterCombinatorTests.Create_Empty_Expression_res1.snap
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,12 @@ | ||
{ | ||
"data": { | ||
"root": [ | ||
{ | ||
"bar": true | ||
}, | ||
{ | ||
"bar": false | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
....Tests/__snapshots__/MongoDbFilterCombinatorTests.Create_Empty_Expression_res1_query.snap
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 @@ | ||
find({ }) |
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
47 changes: 47 additions & 0 deletions
47
...hocolate/Neo4J/test/HotChocolate.Data.Neo4J.Filtering.Tests/Neo4JFilterCombinatorTests.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 System.Threading.Tasks; | ||
using HotChocolate.Data.Filters; | ||
using HotChocolate.Data.Neo4J.Sorting; | ||
using HotChocolate.Execution; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Data.Neo4J.Filtering; | ||
|
||
public class Neo4JFilterCombinatorTests | ||
: IClassFixture<Neo4JFixture> | ||
{ | ||
private readonly Neo4JFixture _fixture; | ||
|
||
public Neo4JFilterCombinatorTests(Neo4JFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
} | ||
|
||
private const string _fooEntitiesCypher = | ||
@"CREATE (:FooBool {Bar: true}), (:FooBool {Bar: false})"; | ||
|
||
[Fact] | ||
public async Task Create_Empty_Expression() | ||
{ | ||
// arrange | ||
var tester = | ||
await _fixture.GetOrCreateSchema<FooBool, FooBoolFilterType>(_fooEntitiesCypher); | ||
|
||
// act | ||
// assert | ||
IExecutionResult res1 = await tester.ExecuteAsync( | ||
QueryRequestBuilder.New() | ||
.SetQuery("{ root(where: { }){ bar }}") | ||
.Create()); | ||
|
||
res1.MatchDocumentSnapshot("ASC"); | ||
} | ||
|
||
public class FooBool | ||
{ | ||
public bool Bar { get; set; } | ||
} | ||
|
||
public class FooBoolFilterType : FilterInputType<FooBool> | ||
{ | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...Filtering.Tests/__snapshots__/Neo4JFilterCombinatorTests.Create_Empty_Expression_ASC.snap
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,12 @@ | ||
{ | ||
"data": { | ||
"root": [ | ||
{ | ||
"bar": true | ||
}, | ||
{ | ||
"bar": false | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ing.Tests/__snapshots__/Neo4JFilterCombinatorTests.Create_Empty_Expression_ASC_query.snap
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 @@ | ||
MATCH (fooBool:FooBool) RETURN fooBool {.Bar} |