Skip to content

Commit

Permalink
added tests on ef.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lebee committed Nov 27, 2019
1 parent cfa0faa commit fc0510f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PoweredSoft.DynamicLinq.Test/EntityFrameworkCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,21 @@ public void TestContextTypeLessHelper()
var first = result.FirstOrDefault() as Author;
Assert.AreEqual(first?.FirstName, "David");
}

[TestMethod]
public void TestLessAndGreaterThan()
{
var context = GetCoreContext(nameof(TestWhereAnd)); //EF Core
//or new BlogContext(testConnectionString); in EF
SeedForTests(context);

var query = context.Authors.Query(q => q.LessThan("FirstName", "Mario"));
var first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "David");

query = context.Authors.Query(q => q.GreaterThan("FirstName", "Mario"));
first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "Some");
}
}
}
17 changes: 17 additions & 0 deletions PoweredSoft.DynamicLinq.Test/EntityFrameworkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public static void SeedForTests(BlogContext context)
context.SaveChanges();
}



[TestMethod]
public void TestSimpleWhere()
{
Expand Down Expand Up @@ -190,5 +192,20 @@ public void TestContextTypeLessHelper()
var first = result.FirstOrDefault() as Author;
Assert.AreEqual(first?.FirstName, "David");
}

[TestMethod]
public void TestLessAndGreaterThan()
{
var context = new BlogContext(testConnectionString);
SeedForTests(context);

var query = context.Authors.Query(q => q.LessThan("FirstName", "Mario"));
var first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "David");

query = context.Authors.Query(q => q.GreaterThan("FirstName", "Mario"));
first = query.FirstOrDefault();
Assert.AreEqual(first?.FirstName, "Some");
}
}
}

0 comments on commit fc0510f

Please sign in to comment.