1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System.Collections;
|
20
|
|
using System.Data;
|
21
|
|
using System.Data.SqlTypes;
|
22
|
|
using MbUnit.Framework;
|
23
|
|
using Seasar.Extension.Unit;
|
24
|
|
|
25
|
|
namespace Seasar.Tests.Extension.Unit
|
26
|
|
{
|
27
|
|
[TestFixture]
|
28
|
|
public class S2AssertTest : S2TestCase
|
29
|
|
{
|
30
|
1
|
[Test]
|
31
|
|
public void TestAreDictionaryEqual()
|
32
|
|
{
|
33
|
1
|
DataSet expected = new DataSet();
|
34
|
1
|
DataTable table = expected.Tables.Add("emp");
|
35
|
1
|
table.Columns.Add("empno", typeof(long));
|
36
|
1
|
DataRow row = table.NewRow();
|
37
|
1
|
row["empno"] = 7788;
|
38
|
1
|
table.Rows.Add(row);
|
39
|
1
|
IDictionary dictionary = new Hashtable();
|
40
|
1
|
dictionary.Add("EMPNO", 7788);
|
41
|
1
|
S2Assert.AreEqual(expected, dictionary, "1");
|
42
|
|
}
|
43
|
|
|
44
|
1
|
[Test]
|
45
|
|
public void TestAreDictionaryListEqual()
|
46
|
|
{
|
47
|
1
|
DataSet expected = new DataSet();
|
48
|
1
|
DataTable table = expected.Tables.Add("emp");
|
49
|
1
|
table.Columns.Add("empno", typeof(long));
|
50
|
1
|
DataRow row = table.NewRow();
|
51
|
1
|
row["empno"] = 7788;
|
52
|
1
|
table.Rows.Add(row);
|
53
|
1
|
IDictionary dictionary = new Hashtable();
|
54
|
1
|
dictionary.Add("EMPNO", 7788);
|
55
|
1
|
IList list = new ArrayList();
|
56
|
1
|
list.Add(dictionary);
|
57
|
1
|
S2Assert.AreEqual(expected, list, "1");
|
58
|
|
}
|
59
|
|
|
60
|
1
|
[Test]
|
61
|
|
public void TestAreBeanEqual()
|
62
|
|
{
|
63
|
1
|
DataSet expected = new DataSet();
|
64
|
1
|
DataTable table = expected.Tables.Add("emp");
|
65
|
1
|
table.Columns.Add("aaa", typeof(string));
|
66
|
1
|
table.Columns.Add("bbb", typeof(decimal));
|
67
|
1
|
DataRow row = table.NewRow();
|
68
|
1
|
row["aaa"] = "111";
|
69
|
1
|
row["bbb"] = decimal.MaxValue;
|
70
|
1
|
table.Rows.Add(row);
|
71
|
1
|
Hoge bean = new Hoge();
|
72
|
1
|
bean.Aaa = "111";
|
73
|
1
|
bean.Bbb = decimal.MaxValue;
|
74
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
75
|
|
}
|
76
|
|
|
77
|
1
|
[Test]
|
78
|
|
public void TestAreBeanEqual3()
|
79
|
|
{
|
80
|
1
|
DataSet expected = new DataSet();
|
81
|
1
|
DataTable table = expected.Tables.Add("emp");
|
82
|
1
|
table.Columns.Add("aaa", typeof(string));
|
83
|
1
|
table.Columns.Add("bbb", typeof(int));
|
84
|
1
|
DataRow row = table.NewRow();
|
85
|
1
|
row["aaa"] = "111";
|
86
|
1
|
row["bbb"] = int.MaxValue;
|
87
|
1
|
table.Rows.Add(row);
|
88
|
1
|
Hoge bean = new Hoge();
|
89
|
1
|
bean.Aaa = "111";
|
90
|
1
|
bean.Bbb = int.MaxValue;
|
91
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
92
|
|
}
|
93
|
|
|
94
|
1
|
[Test]
|
95
|
|
public void TestAreBeanListEqual()
|
96
|
|
{
|
97
|
1
|
DataSet expected = new DataSet();
|
98
|
1
|
DataTable table = expected.Tables.Add("emp");
|
99
|
1
|
table.Columns.Add("aaa", typeof(string));
|
100
|
1
|
table.Columns.Add("bbb", typeof(decimal));
|
101
|
1
|
DataRow row = table.NewRow();
|
102
|
1
|
row["aaa"] = "111";
|
103
|
1
|
row["bbb"] = decimal.MaxValue;
|
104
|
1
|
table.Rows.Add(row);
|
105
|
1
|
Hoge bean = new Hoge();
|
106
|
1
|
bean.Aaa = "111";
|
107
|
1
|
bean.Bbb = decimal.MaxValue;
|
108
|
1
|
IList list = new ArrayList();
|
109
|
1
|
list.Add(bean);
|
110
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
111
|
|
}
|
112
|
|
|
113
|
1
|
[Test]
|
114
|
|
public void TestAreBeanEqual2()
|
115
|
|
{
|
116
|
1
|
DataSet expected = new DataSet();
|
117
|
1
|
DataTable table = expected.Tables.Add("emp");
|
118
|
1
|
table.Columns.Add("a_aa", typeof(string));
|
119
|
1
|
table.Columns.Add("b_bb", typeof(decimal));
|
120
|
1
|
DataRow row = table.NewRow();
|
121
|
1
|
row["a_aa"] = "111";
|
122
|
1
|
row["b_bb"] = decimal.MaxValue;
|
123
|
1
|
table.Rows.Add(row);
|
124
|
1
|
Hoge bean = new Hoge();
|
125
|
1
|
bean.Aaa = "111";
|
126
|
1
|
bean.Bbb = decimal.MaxValue;
|
127
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
128
|
|
}
|
129
|
|
|
130
|
1
|
[Test]
|
131
|
|
public void TestAreEqualForNull()
|
132
|
|
{
|
133
|
1
|
object hoge = null;
|
134
|
1
|
S2Assert.AreEqual(null, hoge, "1");
|
135
|
|
}
|
136
|
|
|
137
|
1
|
[Test]
|
138
|
|
public void TestAreBeanEqualSqlType()
|
139
|
|
{
|
140
|
|
|
141
|
1
|
DataSet expected = new DataSet();
|
142
|
1
|
DataTable table = expected.Tables.Add("emp");
|
143
|
1
|
table.Columns.Add("aaa", typeof(SqlString));
|
144
|
1
|
table.Columns.Add("bbb", typeof(SqlDecimal));
|
145
|
1
|
DataRow row = table.NewRow();
|
146
|
1
|
row["aaa"] = "111";
|
147
|
1
|
row["bbb"] = decimal.MaxValue;
|
148
|
1
|
table.Rows.Add(row);
|
149
|
1
|
HogeSqlType bean = new HogeSqlType();
|
150
|
1
|
bean.Aaa = "111";
|
151
|
1
|
bean.Bbb = decimal.MaxValue;
|
152
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
153
|
|
}
|
154
|
|
|
155
|
1
|
[Test]
|
156
|
|
public void TestAreBeanEqualSqlType2()
|
157
|
|
{
|
158
|
1
|
DataSet expected = new DataSet();
|
159
|
1
|
DataTable table = expected.Tables.Add("emp");
|
160
|
1
|
table.Columns.Add("aaa", typeof(string));
|
161
|
1
|
table.Columns.Add("bbb", typeof(decimal));
|
162
|
1
|
DataRow row = table.NewRow();
|
163
|
1
|
row["aaa"] = "111";
|
164
|
1
|
row["bbb"] = decimal.MaxValue;
|
165
|
1
|
table.Rows.Add(row);
|
166
|
1
|
HogeSqlType bean = new HogeSqlType();
|
167
|
1
|
bean.Aaa = "111";
|
168
|
1
|
bean.Bbb = decimal.MaxValue;
|
169
|
1
|
S2Assert.AreEqual(expected, bean, "1");
|
170
|
|
}
|
171
|
|
|
172
|
|
internal class Hoge
|
173
|
|
{
|
174
|
|
private string aaa;
|
175
|
|
|
176
|
|
public string Aaa
|
177
|
|
{
|
178
|
4
|
get { return aaa; }
|
179
|
4
|
set { aaa = value; }
|
180
|
|
}
|
181
|
|
|
182
|
|
private decimal bbb;
|
183
|
|
|
184
|
|
public decimal Bbb
|
185
|
|
{
|
186
|
4
|
get { return bbb; }
|
187
|
4
|
set { bbb = value; }
|
188
|
|
}
|
189
|
|
}
|
190
|
|
|
191
|
|
internal class HogeSqlType
|
192
|
|
{
|
193
|
|
private SqlString aaa;
|
194
|
|
|
195
|
|
public SqlString Aaa
|
196
|
|
{
|
197
|
2
|
get { return aaa; }
|
198
|
2
|
set { aaa = value; }
|
199
|
|
}
|
200
|
|
|
201
|
|
private SqlDecimal bbb;
|
202
|
|
|
203
|
|
public SqlDecimal Bbb
|
204
|
|
{
|
205
|
2
|
get { return bbb; }
|
206
|
2
|
set { bbb = value; }
|
207
|
|
}
|
208
|
|
}
|
209
|
|
}
|
210
|
|
}
|
211
|
|
|