Skip to content

Commit a50b5da

Browse files
committed
Split subselect tests
1 parent 19f0f50 commit a50b5da

File tree

2 files changed

+78
-50
lines changed

2 files changed

+78
-50
lines changed

src/NHibernate.Test/Async/Linq/NullComparisonTests.cs

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public class NullComparisonTestsAsync : LinqTestCase
3333
[Test]
3434
public async Task NullInequalityWithNotNullAsync()
3535
{
36-
IQueryable<AnotherEntityRequired> q;
37-
38-
q = session.Query<AnotherEntityRequired>().Where(o => o.Input != null);
36+
var q = session.Query<AnotherEntityRequired>().Where(o => o.Input != null);
3937
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothSame, BothDifferent));
4038

4139
q = session.Query<AnotherEntityRequired>().Where(o => null != o.Input);
@@ -134,18 +132,6 @@ public async Task NullInequalityWithNotNullAsync()
134132
q = session.Query<AnotherEntityRequired>().Where(o => (o.Input + o.Output) != o.Output);
135133
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase, BothSame, BothDifferent));
136134

137-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count != 1);
138-
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
139-
140-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) != 0);
141-
await (ExpectAllAsync(q, Does.Contain("is null").IgnoreCase));
142-
143-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Take(10).All(r => r.Output != null) != o.NullableBool);
144-
await (ExpectAllAsync(q, Does.Not.Contain("or case").IgnoreCase));
145-
146-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Where(r => r.Id == 0).Sum(r => r.Input.Length) != 5);
147-
await (ExpectAllAsync(q, Does.Contain("or (").IgnoreCase));
148-
149135
q = session.Query<AnotherEntityRequired>().Where(o => o.Address.Street != o.Output);
150136
await (ExpectAsync(q, Does.Contain("Input is null").IgnoreCase, BothDifferent, OutputSet, BothNull));
151137

@@ -157,6 +143,27 @@ public async Task NullInequalityWithNotNullAsync()
157143

158144
q = session.Query<AnotherEntityRequired>().Where(o => o.Address.Street != null && o.Address.Street != o.NullableOutput);
159145
await (ExpectAsync(q, Does.Contain("Output is null").IgnoreCase, InputSet, BothDifferent));
146+
}
147+
148+
[Test]
149+
public async Task NullInequalityWithNotNullSubSelectAsync()
150+
{
151+
if (!Dialect.SupportsScalarSubSelects)
152+
{
153+
Assert.Ignore("Dialect does not support scalar subselects");
154+
}
155+
156+
var q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count != 1);
157+
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
158+
159+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) != 0);
160+
await (ExpectAllAsync(q, Does.Contain("is null").IgnoreCase));
161+
162+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != null) != o.NullableBool);
163+
await (ExpectAllAsync(q, Does.Not.Contain("or case").IgnoreCase));
164+
165+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Where(r => r.Id == 0).Sum(r => r.Input.Length) != 5);
166+
await (ExpectAllAsync(q, Does.Contain("or (").IgnoreCase));
160167

161168
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != null) != (o.NullableOutput.Length > 0));
162169
await (ExpectAsync(q, Does.Not.Contain("or case").IgnoreCase));
@@ -165,9 +172,7 @@ public async Task NullInequalityWithNotNullAsync()
165172
[Test]
166173
public async Task NullEqualityWithNotNullAsync()
167174
{
168-
IQueryable<AnotherEntityRequired> q;
169-
170-
q = session.Query<AnotherEntityRequired>().Where(o => o.Input == null);
175+
var q = session.Query<AnotherEntityRequired>().Where(o => o.Input == null);
171176
await (ExpectAsync(q, Does.Not.Contain("or is null").IgnoreCase, OutputSet, BothNull));
172177

173178
q = session.Query<AnotherEntityRequired>().Where(o => null == o.Input);
@@ -260,13 +265,7 @@ public async Task NullEqualityWithNotNullAsync()
260265
q = session.Query<AnotherEntityRequired>().Where(o => (o.NullableOutput + o.Output) == o.Output);
261266
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
262267

263-
q = session.Query<AnotherEntityRequired>().Where(o => (o.Input + o.Output) == o.Output);
264-
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
265-
266-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count == 1);
267-
await (ExpectAllAsync(q, Does.Not.Contain("is null").IgnoreCase));
268-
269-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) == 0);
268+
q = session.Query<AnotherEntityRequired>().Where(o => (o.Output + o.Output) == o.Output);
270269
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
271270

272271
q = session.Query<AnotherEntityRequired>().Where(o => !o.Input.Equals(o.Output));
@@ -294,6 +293,21 @@ public async Task NullEqualityWithNotNullAsync()
294293
await (ExpectAsync(q, Does.Not.Contain("Output is null").IgnoreCase, BothSame));
295294
}
296295

296+
[Test]
297+
public async Task NullEqualityWithNotNullSubSelectAsync()
298+
{
299+
if (!Dialect.SupportsScalarSubSelects)
300+
{
301+
Assert.Ignore("Dialect does not support scalar subselects");
302+
}
303+
304+
var q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count == 1);
305+
await (ExpectAllAsync(q, Does.Not.Contain("is null").IgnoreCase));
306+
307+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) == 0);
308+
await (ExpectAsync(q, Does.Not.Contain("is null").IgnoreCase));
309+
}
310+
297311

298312
[Test]
299313
public async Task NullEqualityAsync()

src/NHibernate.Test/Linq/NullComparisonTests.cs

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ public class NullComparisonTests : LinqTestCase
2121
[Test]
2222
public void NullInequalityWithNotNull()
2323
{
24-
IQueryable<AnotherEntityRequired> q;
25-
26-
q = session.Query<AnotherEntityRequired>().Where(o => o.Input != null);
24+
var q = session.Query<AnotherEntityRequired>().Where(o => o.Input != null);
2725
Expect(q, Does.Not.Contain("is null").IgnoreCase, InputSet, BothSame, BothDifferent);
2826

2927
q = session.Query<AnotherEntityRequired>().Where(o => null != o.Input);
@@ -122,18 +120,6 @@ public void NullInequalityWithNotNull()
122120
q = session.Query<AnotherEntityRequired>().Where(o => (o.Input + o.Output) != o.Output);
123121
Expect(q, Does.Not.Contain("is null").IgnoreCase, BothSame, BothDifferent);
124122

125-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count != 1);
126-
Expect(q, Does.Not.Contain("is null").IgnoreCase);
127-
128-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) != 0);
129-
ExpectAll(q, Does.Contain("is null").IgnoreCase);
130-
131-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Take(10).All(r => r.Output != null) != o.NullableBool);
132-
ExpectAll(q, Does.Not.Contain("or case").IgnoreCase);
133-
134-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Where(r => r.Id == 0).Sum(r => r.Input.Length) != 5);
135-
ExpectAll(q, Does.Contain("or (").IgnoreCase);
136-
137123
q = session.Query<AnotherEntityRequired>().Where(o => o.Address.Street != o.Output);
138124
Expect(q, Does.Contain("Input is null").IgnoreCase, BothDifferent, OutputSet, BothNull);
139125

@@ -145,6 +131,27 @@ public void NullInequalityWithNotNull()
145131

146132
q = session.Query<AnotherEntityRequired>().Where(o => o.Address.Street != null && o.Address.Street != o.NullableOutput);
147133
Expect(q, Does.Contain("Output is null").IgnoreCase, InputSet, BothDifferent);
134+
}
135+
136+
[Test]
137+
public void NullInequalityWithNotNullSubSelect()
138+
{
139+
if (!Dialect.SupportsScalarSubSelects)
140+
{
141+
Assert.Ignore("Dialect does not support scalar subselects");
142+
}
143+
144+
var q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count != 1);
145+
Expect(q, Does.Not.Contain("is null").IgnoreCase);
146+
147+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) != 0);
148+
ExpectAll(q, Does.Contain("is null").IgnoreCase);
149+
150+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != null) != o.NullableBool);
151+
ExpectAll(q, Does.Not.Contain("or case").IgnoreCase);
152+
153+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Where(r => r.Id == 0).Sum(r => r.Input.Length) != 5);
154+
ExpectAll(q, Does.Contain("or (").IgnoreCase);
148155

149156
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.All(r => r.Output != null) != (o.NullableOutput.Length > 0));
150157
Expect(q, Does.Not.Contain("or case").IgnoreCase);
@@ -153,9 +160,7 @@ public void NullInequalityWithNotNull()
153160
[Test]
154161
public void NullEqualityWithNotNull()
155162
{
156-
IQueryable<AnotherEntityRequired> q;
157-
158-
q = session.Query<AnotherEntityRequired>().Where(o => o.Input == null);
163+
var q = session.Query<AnotherEntityRequired>().Where(o => o.Input == null);
159164
Expect(q, Does.Not.Contain("or is null").IgnoreCase, OutputSet, BothNull);
160165

161166
q = session.Query<AnotherEntityRequired>().Where(o => null == o.Input);
@@ -248,13 +253,7 @@ public void NullEqualityWithNotNull()
248253
q = session.Query<AnotherEntityRequired>().Where(o => (o.NullableOutput + o.Output) == o.Output);
249254
Expect(q, Does.Not.Contain("is null").IgnoreCase);
250255

251-
q = session.Query<AnotherEntityRequired>().Where(o => (o.Input + o.Output) == o.Output);
252-
Expect(q, Does.Not.Contain("is null").IgnoreCase);
253-
254-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count == 1);
255-
ExpectAll(q, Does.Not.Contain("is null").IgnoreCase);
256-
257-
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) == 0);
256+
q = session.Query<AnotherEntityRequired>().Where(o => (o.Output + o.Output) == o.Output);
258257
Expect(q, Does.Not.Contain("is null").IgnoreCase);
259258

260259
q = session.Query<AnotherEntityRequired>().Where(o => !o.Input.Equals(o.Output));
@@ -282,6 +281,21 @@ public void NullEqualityWithNotNull()
282281
Expect(q, Does.Not.Contain("Output is null").IgnoreCase, BothSame);
283282
}
284283

284+
[Test]
285+
public void NullEqualityWithNotNullSubSelect()
286+
{
287+
if (!Dialect.SupportsScalarSubSelects)
288+
{
289+
Assert.Ignore("Dialect does not support scalar subselects");
290+
}
291+
292+
var q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Count == 1);
293+
ExpectAll(q, Does.Not.Contain("is null").IgnoreCase);
294+
295+
q = session.Query<AnotherEntityRequired>().Where(o => o.RelatedItems.Max(r => r.Id) == 0);
296+
Expect(q, Does.Not.Contain("is null").IgnoreCase);
297+
}
298+
285299

286300
[Test]
287301
public void NullEquality()

0 commit comments

Comments
 (0)