annotate UnitTests/Linq/CreateData.cs @ 5:f7d63a092920

Исправлено условие Where в тех случаях, когда репозитарий не является генериком
author cin
date Tue, 10 Mar 2015 16:02:11 +0300
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 using System;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2 using System.IO;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4 using NUnit.Framework;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 using BLToolkit.Data.DataProvider;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 using BLToolkit.Data.Linq;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9 using Data.Linq;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10 using Data.Linq.Model;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 namespace Create
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 [TestFixture]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 public class CreateData : TestBase
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 static void RunScript(string configString, string divider, string name)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 Console.WriteLine("=== " + name + " === \n");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 var text = File.ReadAllText(@"..\..\..\..\Data\Create Scripts\" + name + ".sql");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 while (true)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 var idx = text.IndexOf("SKIP " + configString + " BEGIN");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
26
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
27 if (idx >= 0)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
28 text = text.Substring(0, idx) + text.Substring(text.IndexOf("SKIP " + configString + " END", idx));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
29 else
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
30 break;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
31 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
32
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
33 var cmds = text.Replace("\r", "").Replace(divider, "\x1").Split('\x1');
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
34
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
35 Exception exception = null;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
36
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
37 using (var db = new TestDbManager(configString))
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
38 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
39 foreach (var cmd in cmds)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
40 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
41 var command = cmd.Trim();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
42
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
43 if (command.Length == 0)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
44 continue;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
45
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
46 try
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
47 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
48 Console.WriteLine(command);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
49 db.SetCommand(command).ExecuteNonQuery();
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
50 Console.WriteLine("\nOK\n");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
51 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
52 catch (Exception ex)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
53 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
54 Console.WriteLine(ex.Message);
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
55 Console.WriteLine("\nFAILED\n");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
56
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
57 if (exception == null)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
58 exception = ex;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
59 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
60 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
61
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
62 if (exception != null)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
63 throw exception;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
64
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
65 db.InsertBatch(new[]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
66 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
67 new LinqDataTypes { ID = 1, MoneyValue = 1.11m, DateTimeValue = new DateTime(2001, 1, 11, 1, 11, 21, 100), BoolValue = true, GuidValue = new Guid("ef129165-6ffe-4df9-bb6b-bb16e413c883"), SmallIntValue = 1 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
68 new LinqDataTypes { ID = 2, MoneyValue = 2.49m, DateTimeValue = new DateTime(2005, 5, 15, 5, 15, 25, 500), BoolValue = false, GuidValue = new Guid("bc663a61-7b40-4681-ac38-f9aaf55b706b"), SmallIntValue = 2 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
69 new LinqDataTypes { ID = 3, MoneyValue = 3.99m, DateTimeValue = new DateTime(2009, 9, 19, 9, 19, 29, 90), BoolValue = true, GuidValue = new Guid("d2f970c0-35ac-4987-9cd5-5badb1757436"), SmallIntValue = 3 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
70 new LinqDataTypes { ID = 4, MoneyValue = 4.50m, DateTimeValue = new DateTime(2009, 9, 20, 9, 19, 29, 90), BoolValue = false, GuidValue = new Guid("40932fdb-1543-4e4a-ac2c-ca371604fb4b"), SmallIntValue = 4 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
71 new LinqDataTypes { ID = 5, MoneyValue = 5.50m, DateTimeValue = new DateTime(2009, 9, 21, 9, 19, 29, 90), BoolValue = true, GuidValue = new Guid("febe3eca-cb5f-40b2-ad39-2979d312afca"), SmallIntValue = 5 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
72 new LinqDataTypes { ID = 6, MoneyValue = 6.55m, DateTimeValue = new DateTime(2009, 9, 22, 9, 19, 29, 90), BoolValue = false, GuidValue = new Guid("8d3c5d1d-47db-4730-9fe7-968f6228a4c0"), SmallIntValue = 6 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
73 new LinqDataTypes { ID = 7, MoneyValue = 7.00m, DateTimeValue = new DateTime(2009, 9, 23, 9, 19, 29, 90), BoolValue = true, GuidValue = new Guid("48094115-83af-46dd-a906-bff26ee21ee2"), SmallIntValue = 7 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
74 new LinqDataTypes { ID = 8, MoneyValue = 8.99m, DateTimeValue = new DateTime(2009, 9, 24, 9, 19, 29, 90), BoolValue = false, GuidValue = new Guid("c1139f1f-1335-4cd4-937e-92602f732dd3"), SmallIntValue = 8 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
75 new LinqDataTypes { ID = 9, MoneyValue = 9.63m, DateTimeValue = new DateTime(2009, 9, 25, 9, 19, 29, 90), BoolValue = true, GuidValue = new Guid("46c5c512-3d4b-4cf7-b4e7-1de080789e5d"), SmallIntValue = 9 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
76 new LinqDataTypes { ID = 10, MoneyValue = 10.77m, DateTimeValue = new DateTime(2009, 9, 26, 9, 19, 29, 90), BoolValue = false, GuidValue = new Guid("61b2bc55-147f-4b40-93ed-a4aa83602fee"), SmallIntValue = 10 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
77 new LinqDataTypes { ID = 11, MoneyValue = 11.45m, DateTimeValue = new DateTime(2009, 9, 27, 9, 19, 29, 90), BoolValue = true, GuidValue = new Guid("d3021d18-97f0-4dc0-98d0-f0c7df4a1230"), SmallIntValue = 11 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
78 new LinqDataTypes { ID = 12, MoneyValue = 11.45m, DateTimeValue = new DateTime(2012, 11, 7, 19, 19, 29, 90), BoolValue = true, GuidValue = new Guid("03021d18-97f0-4dc0-98d0-f0c7df4a1230"), SmallIntValue = 12 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
79 });
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
80
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
81 db.InsertBatch(new[]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
82 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
83 new Parent { ParentID = 1, Value1 = 1 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
84 new Parent { ParentID = 2, Value1 = null },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
85 new Parent { ParentID = 3, Value1 = 3 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
86 new Parent { ParentID = 4, Value1 = null },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
87 new Parent { ParentID = 5, Value1 = 5 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
88 new Parent { ParentID = 6, Value1 = 6 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
89 new Parent { ParentID = 7, Value1 = 1 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
90 });
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
91
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
92 db.InsertBatch(new[]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
93 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
94 new Child { ParentID = 1, ChildID = 11 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
95 new Child { ParentID = 2, ChildID = 21 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
96 new Child { ParentID = 2, ChildID = 22 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
97 new Child { ParentID = 3, ChildID = 31 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
98 new Child { ParentID = 3, ChildID = 32 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
99 new Child { ParentID = 3, ChildID = 33 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
100 new Child { ParentID = 4, ChildID = 41 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
101 new Child { ParentID = 4, ChildID = 42 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
102 new Child { ParentID = 4, ChildID = 43 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
103 new Child { ParentID = 4, ChildID = 44 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
104 new Child { ParentID = 6, ChildID = 61 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
105 new Child { ParentID = 6, ChildID = 62 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
106 new Child { ParentID = 6, ChildID = 63 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
107 new Child { ParentID = 6, ChildID = 64 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
108 new Child { ParentID = 6, ChildID = 65 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
109 new Child { ParentID = 6, ChildID = 66 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
110 new Child { ParentID = 7, ChildID = 77 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
111 });
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
112
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
113 db.InsertBatch(new[]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
114 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
115 new GrandChild { ParentID = 1, ChildID = 11, GrandChildID = 111 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
116 new GrandChild { ParentID = 2, ChildID = 21, GrandChildID = 211 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
117 new GrandChild { ParentID = 2, ChildID = 21, GrandChildID = 212 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
118 new GrandChild { ParentID = 2, ChildID = 22, GrandChildID = 221 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
119 new GrandChild { ParentID = 2, ChildID = 22, GrandChildID = 222 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
120 new GrandChild { ParentID = 3, ChildID = 31, GrandChildID = 311 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
121 new GrandChild { ParentID = 3, ChildID = 31, GrandChildID = 312 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
122 new GrandChild { ParentID = 3, ChildID = 31, GrandChildID = 313 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
123 new GrandChild { ParentID = 3, ChildID = 32, GrandChildID = 321 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
124 new GrandChild { ParentID = 3, ChildID = 32, GrandChildID = 322 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
125 new GrandChild { ParentID = 3, ChildID = 32, GrandChildID = 323 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
126 new GrandChild { ParentID = 3, ChildID = 33, GrandChildID = 331 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
127 new GrandChild { ParentID = 3, ChildID = 33, GrandChildID = 332 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
128 new GrandChild { ParentID = 3, ChildID = 33, GrandChildID = 333 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
129 new GrandChild { ParentID = 4, ChildID = 41, GrandChildID = 411 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
130 new GrandChild { ParentID = 4, ChildID = 41, GrandChildID = 412 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
131 new GrandChild { ParentID = 4, ChildID = 41, GrandChildID = 413 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
132 new GrandChild { ParentID = 4, ChildID = 41, GrandChildID = 414 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
133 new GrandChild { ParentID = 4, ChildID = 42, GrandChildID = 421 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
134 new GrandChild { ParentID = 4, ChildID = 42, GrandChildID = 422 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
135 new GrandChild { ParentID = 4, ChildID = 42, GrandChildID = 423 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
136 new GrandChild { ParentID = 4, ChildID = 42, GrandChildID = 424 },
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
137 });
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
138 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
139 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
140
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
141 [Test] public void DB2 ([IncludeDataContexts(ProviderName.DB2 )] string context) { RunScript(context, "\nGO\n", "DB2"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
142 [Test] public void Informix ([IncludeDataContexts(ProviderName.Informix )] string context) { RunScript(context, "\nGO\n", "Informix"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
143 [Test] public void Oracle ([IncludeDataContexts("Oracle" )] string context) { RunScript(context, "\n/\n", "Oracle"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
144 [Test] public void Firebird ([IncludeDataContexts(ProviderName.Firebird )] string context) { RunScript(context, "COMMIT;", "Firebird2"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
145 [Test] public void PostgreSQL([IncludeDataContexts(ProviderName.PostgreSQL)] string context) { RunScript(context, "\nGO\n", "PostgreSQL"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
146 [Test] public void MySql ([IncludeDataContexts(ProviderName.MySql )] string context) { RunScript(context, "\nGO\n", "MySql"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
147 [Test] public void Sql2000 ([IncludeDataContexts("Sql2000" )] string context) { RunScript(context, "\nGO\n", "MsSql2000"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
148 [Test] public void Sql2005 ([IncludeDataContexts("Sql2005" )] string context) { RunScript(context, "\nGO\n", "MsSql"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
149 [Test] public void Sql2008 ([IncludeDataContexts("Sql2008" )] string context) { RunScript(context, "\nGO\n", "MsSql"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
150 [Test] public void Sql2012 ([IncludeDataContexts("Sql2012" )] string context) { RunScript(context, "\nGO\n", "MsSql"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
151 [Test] public void SqlCe ([IncludeDataContexts(ProviderName.SqlCe )] string context) { RunScript(context, "\nGO\n", "SqlCe"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
152 [Test] public void SqlCeData ([IncludeDataContexts(ProviderName.SqlCe )] string context) { RunScript(context + ".Data", "\nGO\n", "SqlCe"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
153 [Test] public void SQLite ([IncludeDataContexts(ProviderName.SQLite )] string context) { RunScript(context, "\nGO\n", "SQLite"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
154 [Test] public void SQLiteData([IncludeDataContexts(ProviderName.SQLite )] string context) { RunScript(context + ".Data", "\nGO\n", "SQLite"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
155 [Test] public void Access ([IncludeDataContexts(ProviderName.Access )] string context) { RunScript(context, "\nGO\n", "Access"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
156 [Test] public void AccessData([IncludeDataContexts(ProviderName.Access )] string context) { RunScript(context + ".Data", "\nGO\n", "Access"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
157 [Test] public void Sybase ([IncludeDataContexts(ProviderName.Sybase )] string context) { RunScript(context, "\nGO\n", "Sybase"); }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
158 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
159 }