Skip to content

Commit de0255d

Browse files
committed
FunctionTests.cs: Minor cleanup.
1 parent 56198a9 commit de0255d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/NHibernate.Test/Linq/FunctionTests.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Linq;
3-
using System.Collections.Generic;
4-
using NHibernate.Dialect;
53
using NHibernate.DomainModel;
64
using NHibernate.DomainModel.Northwind.Entities;
75
using NHibernate.Linq;
@@ -68,9 +66,13 @@ public void LikeFunctionUserDefined()
6866
{
6967
// Verify that any method named Like, in a class named SqlMethods, will be translated.
7068

69+
// ReSharper disable RedundantNameQualifier
70+
// NOTE: Deliberately use full namespace for our SqlMethods class below, to reduce
71+
// risk of accidentally referencing NHibernate.Linq.SqlMethods.
7172
var query = (from e in db.Employees
7273
where NHibernate.Test.Linq.FunctionTests.SqlMethods.Like(e.FirstName, "Ma%et")
7374
select e).ToList();
75+
// ReSharper restore RedundantNameQualifier
7476

7577
Assert.That(query.Count, Is.EqualTo(1));
7678
Assert.That(query[0].FirstName, Is.EqualTo("Margaret"));
@@ -237,7 +239,7 @@ where ol.Quantity.ToString().Contains("5")
237239
[Test]
238240
public void Coalesce()
239241
{
240-
Assert.AreEqual(2, session.Query<AnotherEntity>().Where(e => (e.Input ?? "hello") == "hello").Count());
242+
Assert.AreEqual(2, session.Query<AnotherEntity>().Count(e => (e.Input ?? "hello") == "hello"));
241243
}
242244

243245
[Test]
@@ -253,13 +255,13 @@ public void Trim()
253255
session.Save(ae3);
254256
session.Flush();
255257

256-
Assert.AreEqual(2, session.Query<AnotherEntity>().Where(e => e.Input.Trim() == "hi").Count());
257-
Assert.AreEqual(1, session.Query<AnotherEntity>().Where(e => e.Input.TrimEnd() == " hi").Count());
258+
Assert.AreEqual(2, session.Query<AnotherEntity>().Count(e => e.Input.Trim() == "hi"));
259+
Assert.AreEqual(1, session.Query<AnotherEntity>().Count(e => e.Input.TrimEnd() == " hi"));
258260

259261
// Emulated trim does not support multiple trim characters, but for many databases it should work fine anyways.
260-
Assert.AreEqual(1, session.Query<AnotherEntity>().Where(e => e.Input.Trim('h') == "e").Count());
261-
Assert.AreEqual(1, session.Query<AnotherEntity>().Where(e => e.Input.TrimStart('h') == "eh").Count());
262-
Assert.AreEqual(1, session.Query<AnotherEntity>().Where(e => e.Input.TrimEnd('h') == "he").Count());
262+
Assert.AreEqual(1, session.Query<AnotherEntity>().Count(e => e.Input.Trim('h') == "e"));
263+
Assert.AreEqual(1, session.Query<AnotherEntity>().Count(e => e.Input.TrimStart('h') == "eh"));
264+
Assert.AreEqual(1, session.Query<AnotherEntity>().Count(e => e.Input.TrimEnd('h') == "he"));
263265

264266
// Let it rollback to get rid of temporary changes.
265267
}

0 commit comments

Comments
 (0)