Mercurial > pub > bltoolkit
comparison UnitTests/CS/Data/ExecuteListT.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.Collections.Generic; | |
2 using BLToolkit.Reflection; | |
3 using NUnit.Framework; | |
4 | |
5 using BLToolkit.Data; | |
6 | |
7 namespace Data | |
8 { | |
9 [TestFixture] | |
10 public class ExecuteListT | |
11 { | |
12 public class SimpleObject | |
13 { | |
14 public SimpleObject() | |
15 { | |
16 } | |
17 | |
18 public SimpleObject(InitContext context) | |
19 { | |
20 if (context.Parameters != null) | |
21 { | |
22 Assert.AreEqual(2, context.Parameters.Length); | |
23 Assert.AreEqual("123", context.Parameters[0]); | |
24 Assert.AreEqual("456", context.Parameters[1]); | |
25 } | |
26 } | |
27 | |
28 private int _key; public int Key { get { return _key; } set { _key = value; } } | |
29 private string _value; public string Value { get { return _value; } set { _value = value; } } | |
30 } | |
31 | |
32 [Test] | |
33 public void Test() | |
34 { | |
35 using (DbManager db = new DbManager()) | |
36 { | |
37 List<SimpleObject> list = new List<SimpleObject>(); | |
38 | |
39 db | |
40 #if MSSQL || SQLCE | |
41 .SetCommand(@" | |
42 SELECT 0 as [Key], 'value0' as Value UNION | |
43 SELECT 1 as [Key], 'value1' as Value UNION | |
44 SELECT 2 as [Key], 'value2' as Value") | |
45 | |
46 #else // ORACLE || FIREBIRD || ACCESS | |
47 | |
48 .SetCommand(@" | |
49 SELECT 0 as ""Key"", 'value0' as ""Value"" FROM Dual UNION | |
50 SELECT 1 as ""Key"", 'value1' as ""Value"" FROM Dual UNION | |
51 SELECT 2 as ""Key"", 'value2' as ""Value"" FROM Dual") | |
52 #endif | |
53 .ExecuteList<SimpleObject>(list); | |
54 | |
55 Assert.IsTrue(list.Count > 0); | |
56 } | |
57 } | |
58 | |
59 [Test] | |
60 public void ParamsTest() | |
61 { | |
62 using (DbManager db = new DbManager()) | |
63 { | |
64 List<SimpleObject> list = db | |
65 #if MSSQL || SQLCE | |
66 .SetCommand(@" | |
67 SELECT 0 as [Key], 'value0' as Value UNION | |
68 SELECT 1 as [Key], 'value1' as Value UNION | |
69 SELECT 2 as [Key], 'value2' as Value") | |
70 | |
71 #else // ORACLE || FIREBIRD || ACCESS | |
72 | |
73 .SetCommand(@" | |
74 SELECT 0 as ""Key"", 'value0' as ""Value"" FROM Dual UNION | |
75 SELECT 1 as ""Key"", 'value1' as ""Value"" FROM Dual UNION | |
76 SELECT 2 as ""Key"", 'value2' as ""Value"" FROM Dual") | |
77 #endif | |
78 .ExecuteList<SimpleObject>("123", "456"); | |
79 | |
80 Assert.IsNotEmpty(list); | |
81 Assert.IsInstanceOf(typeof(SimpleObject), list[0]); | |
82 } | |
83 } | |
84 } | |
85 } |