1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Collections;
|
21
|
|
using System.IO;
|
22
|
|
using System.Reflection;
|
23
|
|
using Seasar.Framework.Container;
|
24
|
|
using Seasar.Framework.Container.Factory;
|
25
|
|
using Seasar.Extension.Unit;
|
26
|
|
using MbUnit.Framework;
|
27
|
|
using log4net;
|
28
|
|
using log4net.Config;
|
29
|
|
using log4net.Util;
|
30
|
|
|
31
|
|
namespace Seasar.Dao.Tests.Interceptors
|
32
|
|
{
|
33
|
|
[TestFixture]
|
34
|
|
public class S2DaoInterceptorTest : S2TestCase
|
35
|
|
{
|
36
|
|
private IEmployeeDao _employeeDao = null;
|
37
|
|
private ILog _log= LogManager.GetLogger(typeof(S2DaoInterceptorTest));
|
38
|
|
|
39
|
1
|
public S2DaoInterceptorTest()
|
40
|
|
{
|
41
|
1
|
FileInfo info = new FileInfo(SystemInfo.AssemblyShortName(
|
42
|
|
Assembly.GetExecutingAssembly()) + ".dll.config");
|
43
|
1
|
XmlConfigurator.Configure(LogManager.GetRepository(), info);
|
44
|
|
}
|
45
|
|
|
46
|
1
|
[Test, S2()]
|
47
|
|
public void TestSelectBeanList()
|
48
|
|
{
|
49
|
1
|
IList employees = _employeeDao.GetAllEmployees();
|
50
|
15
|
for (int i = 0; i < employees.Count; ++i) {
|
51
|
14
|
_log.Debug(employees[i].ToString());
|
52
|
|
}
|
53
|
1
|
Assert.AreEqual(true, employees.Count > 0, "1");
|
54
|
|
}
|
55
|
|
|
56
|
1
|
[Test, S2()]
|
57
|
|
public void TestSelectBean()
|
58
|
|
{
|
59
|
1
|
Employee employee = _employeeDao.GetEmployee(7788);
|
60
|
1
|
_log.Debug(employee.ToString());
|
61
|
1
|
Assert.AreEqual("SCOTT", employee.Ename, "1");
|
62
|
|
}
|
63
|
|
|
64
|
1
|
[Test, S2()]
|
65
|
|
public void TestSelectObject()
|
66
|
|
{
|
67
|
1
|
int count = _employeeDao.GetCount();
|
68
|
1
|
_log.Debug("count:" + count);
|
69
|
1
|
Assert.AreEqual(true, count > 0, "1");
|
70
|
|
}
|
71
|
|
|
72
|
1
|
[Test, S2(Tx.Rollback)]
|
73
|
|
public void TestUpdate()
|
74
|
|
{
|
75
|
1
|
Employee employee = _employeeDao.GetEmployee(7788);
|
76
|
1
|
Assert.AreEqual(1, _employeeDao.Update(employee), "1");
|
77
|
|
}
|
78
|
|
|
79
|
1
|
[Test, S2(Tx.Rollback)]
|
80
|
|
public void TestInsert()
|
81
|
|
{
|
82
|
1
|
Assert.AreEqual(1, _employeeDao.Insert(9999, "hoge"));
|
83
|
|
}
|
84
|
|
|
85
|
1
|
[Test, S2()]
|
86
|
|
public void TestSelectNullables()
|
87
|
|
{
|
88
|
1
|
Employee emp = new Employee();
|
89
|
1
|
emp.Ename = "SCOTT";
|
90
|
1
|
Assert.AreEqual(7788, _employeeDao.GetEmpnoByEmp(emp).Value);
|
91
|
1
|
Assert.IsTrue(_employeeDao.GetEmpnoByEmp(null).HasValue);
|
92
|
1
|
emp.Ename = "Kazuya";
|
93
|
1
|
Assert.IsFalse(_employeeDao.GetEmpnoByEmp(emp).HasValue);
|
94
|
|
}
|
95
|
|
|
96
|
1
|
[Test, S2()]
|
97
|
|
public void TestSelectSqlTypes()
|
98
|
|
{
|
99
|
1
|
Hoge hoge = new Hoge();
|
100
|
1
|
Hoge hoge2 = new Hoge();
|
101
|
1
|
hoge2.Val = "SCOTT";
|
102
|
1
|
hoge.Parent = hoge2;
|
103
|
1
|
Assert.AreEqual(7788, _employeeDao.GetEmpnoByHoge(hoge).Value);
|
104
|
1
|
Assert.IsFalse(_employeeDao.GetEmpnoByHoge(null).IsNull);
|
105
|
1
|
hoge2.Val = "Kazuya";
|
106
|
1
|
Assert.IsTrue(_employeeDao.GetEmpnoByHoge(hoge).IsNull);
|
107
|
1
|
hoge2.Val = null;
|
108
|
1
|
Assert.IsTrue(_employeeDao.GetEmpnoByHoge2(hoge).IsNull);
|
109
|
|
}
|
110
|
|
|
111
|
|
}
|
112
|
|
}
|
113
|
|
|