forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryReadOnlyTests.cs
39 lines (33 loc) · 1.02 KB
/
QueryReadOnlyTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Linq;
using NHibernate.Linq;
using NUnit.Framework;
namespace NHibernate.Test.Linq
{
[TestFixture]
public class QueryReadOnlyTests : LinqTestCase
{
[Test]
public void CanSetReadOnlyOnLinqQueries()
{
var result = (from e in db.Customers
where e.CompanyName == "Bon app'"
select e).WithOptions(o => o.SetReadOnly(true)).ToList();
Assert.That(result.All(x => session.IsReadOnly(x)), Is.True);
}
[Test]
public void CanSetReadOnlyOnLinqPagingQuery()
{
var result = (from e in db.Customers
select e).Skip(1).Take(1).WithOptions(o => o.SetReadOnly(true)).ToList();
Assert.That(result.All(x => session.IsReadOnly(x)), Is.True);
}
[Test]
public void CanSetReadOnlyBeforeSkipOnLinqOrderedPageQuery()
{
var result = (from e in db.Customers
orderby e.CompanyName
select e).WithOptions(o => o.SetReadOnly(true)).Skip(5).Take(5).ToList();
Assert.That(result.All(x => session.IsReadOnly(x)), Is.True);
}
}
}