Skip to content

Commit e52e7ee

Browse files
Generate async files
1 parent 54180a4 commit e52e7ee

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

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

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public async Task LikeFunctionWithEscapeCharacterAsync()
4848
await (session.FlushAsync());
4949

5050
var query = await ((from e in db.Employees
51-
where NHibernate.Linq.SqlMethods.Like(e.FirstName, employeeNameEscaped, escapeChar)
52-
select e).ToListAsync());
51+
where NHibernate.Linq.SqlMethods.Like(e.FirstName, employeeNameEscaped, escapeChar)
52+
select e).ToListAsync());
5353

5454
Assert.That(query.Count, Is.EqualTo(1));
5555
Assert.That(query[0].FirstName, Is.EqualTo(employeeName));
@@ -93,8 +93,8 @@ where NHibernate.Test.Linq.FunctionTestsAsync.SqlMethods.Like(e.FirstName, "Ma%e
9393
public async Task SubstringFunction2Async()
9494
{
9595
var query = await ((from e in db.Employees
96-
where e.FirstName.Substring(0, 2) == "An"
97-
select e).ToListAsync());
96+
where e.FirstName.Substring(0, 2) == "An"
97+
select e).ToListAsync());
9898

9999
Assert.That(query.Count, Is.EqualTo(2));
100100
}
@@ -103,8 +103,8 @@ where e.FirstName.Substring(0, 2) == "An"
103103
public async Task SubstringFunction1Async()
104104
{
105105
var query = await ((from e in db.Employees
106-
where e.FirstName.Substring(3) == "rew"
107-
select e).ToListAsync());
106+
where e.FirstName.Substring(3) == "rew"
107+
select e).ToListAsync());
108108

109109
Assert.That(query.Count, Is.EqualTo(1));
110110
Assert.That(query[0].FirstName, Is.EqualTo("Andrew"));
@@ -142,21 +142,21 @@ public async Task ReplaceFunctionAsync()
142142
var query = from e in db.Employees
143143
where e.FirstName.StartsWith("An")
144144
select new
145-
{
146-
Before = e.FirstName,
147-
// This one call the standard string.Replace, not the extension. The linq registry handles it.
148-
AfterMethod = e.FirstName.Replace("An", "Zan"),
149-
AfterExtension = ExtensionMethods.Replace(e.FirstName, "An", "Zan"),
150-
AfterNamedExtension = e.FirstName.ReplaceExtension("An", "Zan"),
151-
AfterEvaluableExtension = e.FirstName.ReplaceWithEvaluation("An", "Zan"),
152-
AfterEvaluable2Extension = e.FirstName.ReplaceWithEvaluation2("An", "Zan"),
145+
{
146+
Before = e.FirstName,
147+
// This one call the standard string.Replace, not the extension. The linq registry handles it.
148+
AfterMethod = e.FirstName.Replace("An", "Zan"),
149+
AfterExtension = ExtensionMethods.Replace(e.FirstName, "An", "Zan"),
150+
AfterNamedExtension = e.FirstName.ReplaceExtension("An", "Zan"),
151+
AfterEvaluableExtension = e.FirstName.ReplaceWithEvaluation("An", "Zan"),
152+
AfterEvaluable2Extension = e.FirstName.ReplaceWithEvaluation2("An", "Zan"),
153153
BeforeConst = suppliedName,
154-
// This one call the standard string.Replace, not the extension. The linq registry handles it.
155-
AfterMethodConst = suppliedName.Replace("An", "Zan"),
156-
AfterExtensionConst = ExtensionMethods.Replace(suppliedName, "An", "Zan"),
157-
AfterNamedExtensionConst = suppliedName.ReplaceExtension("An", "Zan"),
158-
AfterEvaluableExtensionConst = suppliedName.ReplaceWithEvaluation("An", "Zan"),
159-
AfterEvaluable2ExtensionConst = suppliedName.ReplaceWithEvaluation2("An", "Zan")
154+
// This one call the standard string.Replace, not the extension. The linq registry handles it.
155+
AfterMethodConst = suppliedName.Replace("An", "Zan"),
156+
AfterExtensionConst = ExtensionMethods.Replace(suppliedName, "An", "Zan"),
157+
AfterNamedExtensionConst = suppliedName.ReplaceExtension("An", "Zan"),
158+
AfterEvaluableExtensionConst = suppliedName.ReplaceWithEvaluation("An", "Zan"),
159+
AfterEvaluable2ExtensionConst = suppliedName.ReplaceWithEvaluation2("An", "Zan")
160160
};
161161
var results = await (query.ToListAsync());
162162
var s = await (ObjectDumper.WriteAsync(results));
@@ -183,12 +183,12 @@ where e.FirstName.StartsWith("An")
183183
// Should cause ReplaceWithEvaluation to fail
184184
suppliedName = null;
185185
var failingQuery = from e in db.Employees
186-
where e.FirstName.StartsWith("An")
187-
select new
188-
{
189-
Before = e.FirstName,
190-
AfterEvaluableExtensionConst = suppliedName.ReplaceWithEvaluation("An", "Zan")
191-
};
186+
where e.FirstName.StartsWith("An")
187+
select new
188+
{
189+
Before = e.FirstName,
190+
AfterEvaluableExtensionConst = suppliedName.ReplaceWithEvaluation("An", "Zan")
191+
};
192192
Assert.That(() => failingQuery.ToListAsync(), Throws.InstanceOf<HibernateException>().And.InnerException.InstanceOf<ArgumentNullException>());
193193
}
194194

@@ -260,7 +260,7 @@ where lowerName.Contains("a")
260260
public async Task TwoFunctionExpressionAsync()
261261
{
262262
var query = from e in db.Employees
263-
where e.FirstName.IndexOf("A") == e.BirthDate.Value.Month
263+
where e.FirstName.IndexOf("A") == e.BirthDate.Value.Month
264264
select e.FirstName;
265265

266266
await (ObjectDumper.WriteAsync(query));
@@ -297,9 +297,9 @@ public async Task TrimAsync()
297297
{
298298
using (session.BeginTransaction())
299299
{
300-
AnotherEntity ae1 = new AnotherEntity {Input = " hi "};
301-
AnotherEntity ae2 = new AnotherEntity {Input = "hi"};
302-
AnotherEntity ae3 = new AnotherEntity {Input = "heh"};
300+
AnotherEntity ae1 = new AnotherEntity { Input = " hi " };
301+
AnotherEntity ae2 = new AnotherEntity { Input = "hi" };
302+
AnotherEntity ae3 = new AnotherEntity { Input = "heh" };
303303
await (session.SaveAsync(ae1));
304304
await (session.SaveAsync(ae2));
305305
await (session.SaveAsync(ae3));
@@ -315,7 +315,7 @@ public async Task TrimAsync()
315315

316316
// Check when passed as array
317317
// (the single character parameter is a new overload in .netcoreapp2.0, but not net461 or .netstandard2.0).
318-
Assert.AreEqual(1, await (session.Query<AnotherEntity>().CountAsync(e => e.Input.Trim(new [] { 'h' }) == "e")));
318+
Assert.AreEqual(1, await (session.Query<AnotherEntity>().CountAsync(e => e.Input.Trim(new[] { 'h' }) == "e")));
319319
Assert.AreEqual(1, await (session.Query<AnotherEntity>().CountAsync(e => e.Input.TrimStart(new[] { 'h' }) == "eh")));
320320
Assert.AreEqual(1, await (session.Query<AnotherEntity>().CountAsync(e => e.Input.TrimEnd(new[] { 'h' }) == "he")));
321321

@@ -328,9 +328,9 @@ public async Task TrimInitialWhitespaceAsync()
328328
{
329329
using (session.BeginTransaction())
330330
{
331-
await (session.SaveAsync(new AnotherEntity {Input = " hi"}));
332-
await (session.SaveAsync(new AnotherEntity {Input = "hi"}));
333-
await (session.SaveAsync(new AnotherEntity {Input = "heh"}));
331+
await (session.SaveAsync(new AnotherEntity { Input = " hi" }));
332+
await (session.SaveAsync(new AnotherEntity { Input = "hi" }));
333+
await (session.SaveAsync(new AnotherEntity { Input = "heh" }));
334334
await (session.FlushAsync());
335335

336336
Assert.That(await (session.Query<AnotherEntity>().CountAsync(e => e.Input.TrimStart() == "hi")), Is.EqualTo(2));
@@ -373,7 +373,7 @@ public async Task WhereBoolConstantEqualAsync()
373373
var query = from item in db.Role
374374
where item.IsActive.Equals(true)
375375
select item;
376-
376+
377377
await (ObjectDumper.WriteAsync(query));
378378
}
379379

@@ -383,7 +383,7 @@ public async Task WhereBoolConditionEqualsAsync()
383383
var query = from item in db.Role
384384
where item.IsActive.Equals(item.Name != null)
385385
select item;
386-
386+
387387
await (ObjectDumper.WriteAsync(query));
388388
}
389389

@@ -393,7 +393,7 @@ public async Task WhereBoolParameterEqualAsync()
393393
var query = from item in db.Role
394394
where item.IsActive.Equals(1 == 1)
395395
select item;
396-
396+
397397
await (ObjectDumper.WriteAsync(query));
398398
}
399399

@@ -413,8 +413,8 @@ where item.IsActive.Equals(f())
413413
public async Task WhereLongEqualAsync()
414414
{
415415
var query = from item in db.PatientRecords
416-
where item.Id.Equals(-1)
417-
select item;
416+
where item.Id.Equals(-1)
417+
select item;
418418

419419
await (ObjectDumper.WriteAsync(query));
420420
}
@@ -428,7 +428,7 @@ where item.RegisteredAt.Equals(DateTime.Today)
428428

429429
await (ObjectDumper.WriteAsync(query));
430430
}
431-
431+
432432
[Test]
433433
public async Task WhereGuidEqualAsync()
434434
{
@@ -437,7 +437,7 @@ where item.Reference.Equals(Guid.Empty)
437437
select item;
438438

439439
await (ObjectDumper.WriteAsync(query));
440-
}
440+
}
441441

442442
[Test]
443443
public async Task WhereDoubleEqualAsync()
@@ -447,7 +447,7 @@ where item.BodyWeight.Equals(-1)
447447
select item;
448448

449449
await (ObjectDumper.WriteAsync(query));
450-
}
450+
}
451451

452452
[Test]
453453
public async Task WhereDecimalEqualAsync()
@@ -467,14 +467,20 @@ where item.Gender.Equals(Gender.Female)
467467
select item;
468468

469469
await (ObjectDumper.WriteAsync(query));
470+
471+
query = from item in db.PatientRecords
472+
where item.Gender.Equals(item.Gender)
473+
select item;
474+
475+
await (ObjectDumper.WriteAsync(query));
470476
}
471477

472478
[Test]
473479
public async Task WhereEquatableEqualAsync()
474480
{
475481
var query = from item in db.Shippers
476-
where ((IEquatable<Guid>) item.Reference).Equals(Guid.Empty)
477-
select item;
482+
where ((IEquatable<Guid>) item.Reference).Equals(Guid.Empty)
483+
select item;
478484

479485
await (ObjectDumper.WriteAsync(query));
480486
}

0 commit comments

Comments
 (0)