Skip to content

Commit 840efd7

Browse files
committed
Test case
1 parent 20a61d1 commit 840efd7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ public async Task BasePropertyFilterAsync(string queryString, int expectedRows)
8787
Assert.That(results, Has.Count.EqualTo(expectedRows));
8888
}
8989

90+
[TestCase("$filter=CustomerId le 'ANATR'",2 )]
91+
[TestCase("$filter=startswith(CustomerId, 'ANATR')", 1)]
92+
[TestCase("$filter=endswith(CustomerId, 'ANATR')", 1)]
93+
[TestCase("$filter=indexof(CustomerId, 'ANATR') eq 0", 1)]
94+
public async Task StringFilterAsync(string queryString, int expectedCount)
95+
{
96+
Assert.That(
97+
await (ApplyFilter(session.Query<Customer>(), queryString).Cast<Customer>().ToListAsync()),
98+
Has.Count.EqualTo(expectedCount));
99+
}
100+
90101
private IQueryable ApplyFilter<T>(IQueryable<T> query, string queryString)
91102
{
92103
var context = new ODataQueryContext(CreatEdmModel(), typeof(T), null) { };

src/NHibernate.Test/Linq/ODataTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ public void BasePropertyFilter(string queryString, int expectedRows)
7575
Assert.That(results, Has.Count.EqualTo(expectedRows));
7676
}
7777

78+
[TestCase("$filter=CustomerId le 'ANATR'",2 )]
79+
[TestCase("$filter=startswith(CustomerId, 'ANATR')", 1)]
80+
[TestCase("$filter=endswith(CustomerId, 'ANATR')", 1)]
81+
[TestCase("$filter=indexof(CustomerId, 'ANATR') eq 0", 1)]
82+
public void StringFilter(string queryString, int expectedCount)
83+
{
84+
Assert.That(
85+
ApplyFilter(session.Query<Customer>(), queryString).Cast<Customer>().ToList(),
86+
Has.Count.EqualTo(expectedCount));
87+
}
88+
7889
private IQueryable ApplyFilter<T>(IQueryable<T> query, string queryString)
7990
{
8091
var context = new ODataQueryContext(CreatEdmModel(), typeof(T), null) { };

0 commit comments

Comments
 (0)