Skip to content

Commit 2d25238

Browse files
committed
add Where_string_notEqual test
1 parent b4a5f61 commit 2d25238

File tree

8 files changed

+74
-0
lines changed

8 files changed

+74
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class StringEntity
2+
{
3+
public Guid Id { get; set; } = Guid.NewGuid();
4+
public string? Property { get; set; }
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class StringEntityGraphType :
2+
EfObjectGraphType<IntegrationDbContext, StringEntity>
3+
{
4+
public StringEntityGraphType(IEfGraphQLService<IntegrationDbContext> graphQlService) :
5+
base(graphQlService) =>
6+
AutoMap();
7+
}

src/Tests/IntegrationTests/IntegrationTests.SchemaPrint.verified.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
childEntities(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Child!]!
1212
dateEntities(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [DateEntity!]!
1313
enumEntities(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [EnumEntity!]!
14+
stringEntities(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [StringEntity!]!
1415
timeEntities(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [TimeEntity!]!
1516
parentEntitiesConnection(
1617
"Only return edges after the specified cursor."
@@ -313,6 +314,11 @@ enum DayOfWeek {
313314
SATURDAY
314315
}
315316

317+
type StringEntity {
318+
id: ID!
319+
property: String
320+
}
321+
316322
type TimeEntity {
317323
id: ID!
318324
property: TimeOnly
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
target:
3+
{
4+
"data": {
5+
"stringEntities": [
6+
{
7+
"id": "Guid_1"
8+
},
9+
{
10+
"id": "Guid_2"
11+
}
12+
]
13+
}
14+
},
15+
sql: {
16+
Text:
17+
select s.Id,
18+
s.Property
19+
from StringEntities as s
20+
where s.Property <> N'notValue'
21+
or s.Property is null
22+
}
23+
}

src/Tests/IntegrationTests/IntegrationTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,33 @@ public async Task Where_enum_notEqual()
215215
await RunQuery(database, query, null, null, false, [entity1, entity2]);
216216
}
217217

218+
[Fact]
219+
public async Task Where_string_notEqual()
220+
{
221+
var query =
222+
"""
223+
{
224+
stringEntities (where: {path: "Property", comparison: notEqual, value: "notValue"})
225+
{
226+
id
227+
}
228+
}
229+
""";
230+
231+
var entity1 = new StringEntity();
232+
var entity2 = new StringEntity
233+
{
234+
Property = "Value"
235+
};
236+
var entity3 = new StringEntity
237+
{
238+
Property = "notValue"
239+
};
240+
241+
await using var database = await sqlInstance.Build();
242+
await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]);
243+
}
244+
218245
[Fact]
219246
public async Task Where_enum_in()
220247
{

src/Tests/IntegrationTests/MyDataContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class IntegrationDbContext(DbContextOptions options) :
44
public DbSet<ParentEntity> ParentEntities { get; set; } = null!;
55
public DbSet<DateEntity> DateEntities { get; set; } = null!;
66
public DbSet<EnumEntity> EnumEntities { get; set; } = null!;
7+
public DbSet<StringEntity> StringEntities { get; set; } = null!;
78
public DbSet<TimeEntity> TimeEntities { get; set; } = null!;
89
public DbSet<FilterParentEntity> FilterParentEntities { get; set; } = null!;
910
public DbSet<FilterChildEntity> FilterChildEntities { get; set; } = null!;

src/Tests/IntegrationTests/Query.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public Query(IEfGraphQLService<IntegrationDbContext> efGraphQlService)
6060
name: "enumEntities",
6161
resolve: _ => _.DbContext.EnumEntities);
6262

63+
AddQueryField(
64+
name: "stringEntities",
65+
resolve: _ => _.DbContext.StringEntities);
66+
6367
AddQueryField(
6468
name: "timeEntities",
6569
resolve: _ => _.DbContext.TimeEntities);

src/Tests/IntegrationTests/Schema.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public Schema(IServiceProvider resolver) :
1414
RegisterTypeMapping(typeof(ParentEntity), typeof(ParentGraphType));
1515
RegisterTypeMapping(typeof(DateEntity), typeof(DateEntityGraphType));
1616
RegisterTypeMapping(typeof(EnumEntity), typeof(EnumEntityGraphType));
17+
RegisterTypeMapping(typeof(StringEntity), typeof(StringEntityGraphType));
1718
RegisterTypeMapping(typeof(TimeEntity), typeof(TimeEntityGraphType));
1819
RegisterTypeMapping(typeof(TimeEntity), typeof(TimeEntityGraphType));
1920
RegisterTypeMapping(typeof(Level1Entity), typeof(Level1GraphType));

0 commit comments

Comments
 (0)