comparison UnitTests/CS/TestFixtureBase.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Collections;
3 using System.ComponentModel;
4 using System.Data;
5
6 using NUnit.Framework;
7
8 using BLToolkit.Mapping;
9
10 public class TestFixtureBase
11 {
12 public static DataTable GetDataTable()
13 {
14 var table = new DataTable();
15
16 table.Columns.Add("ID", typeof(int));
17 table.Columns.Add("Name", typeof(string));
18 table.Columns.Add("Date", typeof(DateTime));
19
20 table.Rows.Add(new object[] { 1, "John Pupkin", DateTime.Now });
21 table.Rows.Add(new object[] { 2, "Goblin", DBNull.Value });
22
23 table.AcceptChanges();
24
25 return table;
26 }
27
28 public static void CompareLists(object obj1, object obj2)
29 {
30 var list1 = obj1 is IListSource? ((IListSource)obj1).GetList(): (IList)obj1;
31 var list2 = obj2 is IListSource? ((IListSource)obj2).GetList(): (IList)obj2;
32
33 Assert.AreEqual(list1.Count, list2.Count);
34
35 for (var i = 0; i < list1.Count; i++)
36 {
37 var o1 = Map.DefaultSchema.GetDataSource(list1[i]);
38 var o2 = Map.DefaultSchema.GetDataSource(list2[i]);
39
40 for (var j = 0; j < o1.Count; j++)
41 {
42 var name = o1.GetName(j);
43
44 for (var k = 0; k < o1.Count; k++)
45 {
46 if (name == o2.GetName(k))
47 {
48 Assert.AreEqual(o1.GetValue(list1[i], j), o2.GetValue(list2[i], k));
49 break;
50 }
51 }
52 }
53 }
54 }
55 }