forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJunctionFixture.cs
76 lines (66 loc) · 2 KB
/
JunctionFixture.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 NHibernate.DomainModel;
using NHibernate.Engine;
using NHibernate.Criterion;
using NHibernate.SqlCommand;
using NHibernate.Util;
using NUnit.Framework;
namespace NHibernate.Test.ExpressionTest
{
/// <summary>
/// Test the Junction class.
/// </summary>
/// <remarks>
/// There are no need for the subclasses Conjunction and Disjunction to have their own
/// TestFixtures because all they do is override one property.
/// </remarks>
[TestFixture]
public class JunctionFixture : BaseExpressionFixture
{
private Conjunction _conjunction;
[SetUp]
public override void SetUp()
{
base.SetUp();
_conjunction = Expression.Conjunction();
_conjunction.Add(Expression.IsNull("Address"))
.Add(Expression.Between("Count", 5, 10));
}
[Test]
public void SqlString()
{
SqlString sqlString;
using (ISession session = factory.OpenSession())
{
CreateObjects(typeof(Simple), session);
sqlString = _conjunction.ToSqlString(criteria, criteriaQuery, new CollectionHelper.EmptyMapClass<string, IFilter>());
}
string expectedSql = "(sql_alias.address is null and sql_alias.count_ between ? and ?)";
CompareSqlStrings(sqlString, expectedSql, 2);
}
[Test]
public void GetTypedValues()
{
TypedValue[] typedValues;
using (ISession session = factory.OpenSession())
{
CreateObjects(typeof(Simple), session);
typedValues = _conjunction.GetTypedValues(criteria, criteriaQuery);
}
TypedValue[] expectedTV = new TypedValue[2];
expectedTV[0] = new TypedValue(NHibernateUtil.Int32, 5, EntityMode.Poco);
expectedTV[1] = new TypedValue(NHibernateUtil.Int32, 10, EntityMode.Poco);
Assert.AreEqual(2, typedValues.Length);
for (int i = 0; i < typedValues.Length; i++)
{
Assert.AreEqual(expectedTV[i].Type, typedValues[i].Type);
Assert.AreEqual(expectedTV[i].Value, typedValues[i].Value);
}
}
[Test]
public void ToStringTest()
{
Assert.AreEqual("(Address is null and Count between 5 and 10)",
_conjunction.ToString());
}
}
}