forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinqTestCase.cs
executable file
·76 lines (68 loc) · 1.87 KB
/
LinqTestCase.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using NHibernate.DomainModel.Northwind.Entities;
using NUnit.Framework;
namespace NHibernate.Test.Linq
{
public class LinqTestCase : ReadonlyTestCase
{
private Northwind _northwind;
private ISession _session;
protected override string[] Mappings
{
get
{
return new[]
{
"Northwind.Mappings.Customer.hbm.xml",
"Northwind.Mappings.Employee.hbm.xml",
"Northwind.Mappings.Order.hbm.xml",
"Northwind.Mappings.OrderLine.hbm.xml",
"Northwind.Mappings.Product.hbm.xml",
"Northwind.Mappings.ProductCategory.hbm.xml",
"Northwind.Mappings.Region.hbm.xml",
"Northwind.Mappings.Shipper.hbm.xml",
"Northwind.Mappings.Supplier.hbm.xml",
"Northwind.Mappings.Territory.hbm.xml",
"Northwind.Mappings.AnotherEntity.hbm.xml",
"Northwind.Mappings.AnotherEntityRequired.hbm.xml",
"Northwind.Mappings.Role.hbm.xml",
"Northwind.Mappings.User.hbm.xml",
"Northwind.Mappings.TimeSheet.hbm.xml",
"Northwind.Mappings.Animal.hbm.xml",
"Northwind.Mappings.Patient.hbm.xml",
"Northwind.Mappings.DynamicUser.hbm.xml",
"Northwind.Mappings.NumericEntity.hbm.xml",
"Northwind.Mappings.CompositeOrder.hbm.xml"
};
}
}
protected Northwind db
{
get { return _northwind; }
}
protected ISession session
{
get { return _session; }
}
protected override void OnSetUp()
{
base.OnSetUp();
_session = OpenSession();
_northwind = new Northwind(_session);
}
protected override void OnTearDown()
{
if (_session.IsOpen)
{
_session.Close();
}
}
public static void AssertByIds<TEntity, TId>(IEnumerable<TEntity> entities, TId[] expectedIds, Converter<TEntity, TId> entityIdGetter)
{
Assert.That(entities.Select(x => entityIdGetter(x)), Is.EquivalentTo(expectedIds));
}
}
}