Datei: UnitTestGenerator/UnitTests/UnitTests.cs
Last Commit (6d63e12)
1 | // |
2 | // Copyright (c) 2002-2016 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | |
23 | using System; |
24 | using System.Linq; |
25 | using System.Reflection; |
26 | using System.Diagnostics; |
27 | using System.Collections; |
28 | using System.Collections.Generic; |
29 | using NDO; |
30 | using NDO.Mapping; |
31 | using NDO.Query; |
32 | using NUnit.Framework; |
33 | using RelationTestClasses; |
34 | using NdoUnitTests; |
35 | |
36 | namespace RelationUnitTests |
37 | { |
38 | |
39 | public class PmFactory |
40 | { |
41 | ····static PersistenceManager pm; |
42 | ····public static PersistenceManager NewPersistenceManager() |
43 | ····{ |
44 | ········if (pm == null) |
45 | ········{ |
46 | pm = new PersistenceManager( @"C:\Projekte\NDO5\UnitTestGenerator\TestGenerator\bin\UnitTests\bin\Debug\NDOMapping. xml") ; |
47 | ········} |
48 | ········else |
49 | ········{ |
50 | ············pm.UnloadCache(); |
51 | ········} |
52 | ········return pm; |
53 | ····} |
54 | } |
55 | |
56 | |
57 | [TestFixture] |
58 | public class TestAgrDir1NoTblAuto : NDOTest |
59 | { |
60 | ····AgrDir1NoTblAutoLeft ownVar; |
61 | ····AgrDir1NoTblAutoRight otherVar; |
62 | ····PersistenceManager pm; |
63 | ····[SetUp] |
64 | ····public void Setup() |
65 | ····{ |
66 | ········pm = PmFactory.NewPersistenceManager(); |
67 | ········ownVar = new AgrDir1NoTblAutoLeft(); |
68 | ········otherVar = new AgrDir1NoTblAutoRight(); |
69 | ····} |
70 | ····[TearDown] |
71 | ····public void TearDown() |
72 | ····{ |
73 | ········try |
74 | ········{ |
75 | ············pm.UnloadCache(); |
76 | ············var l = pm.Objects<AgrDir1NoTblAutoLeft>().ResultTable; |
77 | ············pm.Delete(l); |
78 | ············pm.Save(); |
79 | ············pm.UnloadCache(); |
80 | ············var m = pm.Objects<AgrDir1NoTblAutoRight>().ResultTable; |
81 | ············pm.Delete(m); |
82 | ············pm.Save(); |
83 | ············pm.UnloadCache(); |
84 | ············decimal count; |
85 | ············count = (decimal) new NDOQuery<AgrDir1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
86 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
87 | ············count = (decimal) new NDOQuery<AgrDir1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
88 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
89 | ········} |
90 | ········catch (Exception) |
91 | ········{ |
92 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
93 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
94 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
95 | ········} |
96 | ····} |
97 | ····[Test] |
98 | ····public void TestSaveReload() |
99 | ····{ |
100 | ········CreateObjects(); |
101 | ········QueryOwn(); |
102 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
104 | ····} |
105 | ····[Test] |
106 | ····public void TestSaveReloadNull() |
107 | ····{ |
108 | ········CreateObjects(); |
109 | ········QueryOwn(); |
110 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
111 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
112 | ········ownVar.RelField = null; |
113 | ········pm.Save(); |
114 | ········pm.UnloadCache(); |
115 | ········QueryOwn(); |
116 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
117 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
118 | ····} |
119 | ····[Test] |
120 | ····public void TestChangeKeyHolderLeft() |
121 | ····{ |
122 | ········CreateObjects(); |
123 | ········QueryOwn(); |
124 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
125 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
126 | ········int x = ownVar.RelField.Dummy; |
127 | ········ownVar.Dummy = 4711; |
128 | ········pm.Save(); |
129 | ········pm.UnloadCache(); |
130 | ········QueryOwn(); |
131 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
132 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
133 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
134 | ····} |
135 | ····[Test] |
136 | ····public void TestChangeKeyHolderLeftNoTouch() |
137 | ····{ |
138 | ········CreateObjects(); |
139 | ········QueryOwn(); |
140 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
141 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
142 | ········ownVar.Dummy = 4711; |
143 | ········pm.Save(); |
144 | ········pm.UnloadCache(); |
145 | ········QueryOwn(); |
146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
147 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
148 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
149 | ····} |
150 | ····[Test] |
151 | ····public void TestUpdateOrder() |
152 | ····{ |
153 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
154 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
155 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1NoTblAutoLeft)})) |
156 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1NoTblAutoRight)})), "Wrong order #1"); |
157 | ········Debug.WriteLine("AgrDir1NoTblAutoLeft"); |
158 | ····} |
159 | ····void CreateObjects() |
160 | ····{ |
161 | ········pm.MakePersistent(ownVar); |
162 | ········pm.MakePersistent(otherVar); |
163 | ········ownVar.AssignRelation(otherVar); |
164 | ········pm.Save(); |
165 | ········pm.UnloadCache(); |
166 | ····} |
167 | ····void QueryOwn() |
168 | ····{ |
169 | ········var q = new NDOQuery<AgrDir1NoTblAutoLeft>(pm); |
170 | ········ownVar = q.ExecuteSingle(); |
171 | ····} |
172 | ····void QueryOther() |
173 | ····{ |
174 | ········var q = new NDOQuery<AgrDir1NoTblAutoRight>(pm); |
175 | ········otherVar = q.ExecuteSingle(); |
176 | ····} |
177 | } |
178 | |
179 | |
180 | [TestFixture] |
181 | public class TestAgrDir1TblAuto : NDOTest |
182 | { |
183 | ····AgrDir1TblAutoLeft ownVar; |
184 | ····AgrDir1TblAutoRight otherVar; |
185 | ····PersistenceManager pm; |
186 | ····[SetUp] |
187 | ····public void Setup() |
188 | ····{ |
189 | ········pm = PmFactory.NewPersistenceManager(); |
190 | ········ownVar = new AgrDir1TblAutoLeft(); |
191 | ········otherVar = new AgrDir1TblAutoRight(); |
192 | ····} |
193 | ····[TearDown] |
194 | ····public void TearDown() |
195 | ····{ |
196 | ········try |
197 | ········{ |
198 | ············pm.UnloadCache(); |
199 | ············var l = pm.Objects<AgrDir1TblAutoLeft>().ResultTable; |
200 | ············pm.Delete(l); |
201 | ············pm.Save(); |
202 | ············pm.UnloadCache(); |
203 | ············var m = pm.Objects<AgrDir1TblAutoRight>().ResultTable; |
204 | ············pm.Delete(m); |
205 | ············pm.Save(); |
206 | ············pm.UnloadCache(); |
207 | ············decimal count; |
208 | ············count = (decimal) new NDOQuery<AgrDir1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
209 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
210 | ············count = (decimal) new NDOQuery<AgrDir1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
211 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
212 | ········} |
213 | ········catch (Exception) |
214 | ········{ |
215 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
216 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
218 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
219 | ········} |
220 | ····} |
221 | ····[Test] |
222 | ····public void TestSaveReload() |
223 | ····{ |
224 | ········CreateObjects(); |
225 | ········QueryOwn(); |
226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
227 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
228 | ····} |
229 | ····[Test] |
230 | ····public void TestSaveReloadNull() |
231 | ····{ |
232 | ········CreateObjects(); |
233 | ········QueryOwn(); |
234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
235 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
236 | ········ownVar.RelField = null; |
237 | ········pm.Save(); |
238 | ········pm.UnloadCache(); |
239 | ········QueryOwn(); |
240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
241 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
242 | ····} |
243 | ····[Test] |
244 | ····public void TestChangeKeyHolderLeft() |
245 | ····{ |
246 | ········CreateObjects(); |
247 | ········QueryOwn(); |
248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
249 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
250 | ········int x = ownVar.RelField.Dummy; |
251 | ········ownVar.Dummy = 4711; |
252 | ········pm.Save(); |
253 | ········pm.UnloadCache(); |
254 | ········QueryOwn(); |
255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
256 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
257 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
258 | ····} |
259 | ····[Test] |
260 | ····public void TestChangeKeyHolderLeftNoTouch() |
261 | ····{ |
262 | ········CreateObjects(); |
263 | ········QueryOwn(); |
264 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
265 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
266 | ········ownVar.Dummy = 4711; |
267 | ········pm.Save(); |
268 | ········pm.UnloadCache(); |
269 | ········QueryOwn(); |
270 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
271 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
272 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
273 | ····} |
274 | ····void CreateObjects() |
275 | ····{ |
276 | ········pm.MakePersistent(ownVar); |
277 | ········pm.MakePersistent(otherVar); |
278 | ········ownVar.AssignRelation(otherVar); |
279 | ········pm.Save(); |
280 | ········pm.UnloadCache(); |
281 | ····} |
282 | ····void QueryOwn() |
283 | ····{ |
284 | ········var q = new NDOQuery<AgrDir1TblAutoLeft>(pm); |
285 | ········ownVar = q.ExecuteSingle(); |
286 | ····} |
287 | ····void QueryOther() |
288 | ····{ |
289 | ········var q = new NDOQuery<AgrDir1TblAutoRight>(pm); |
290 | ········otherVar = q.ExecuteSingle(); |
291 | ····} |
292 | } |
293 | |
294 | |
295 | [TestFixture] |
296 | public class TestAgrBi11NoTblAuto : NDOTest |
297 | { |
298 | ····AgrBi11NoTblAutoLeft ownVar; |
299 | ····AgrBi11NoTblAutoRight otherVar; |
300 | ····PersistenceManager pm; |
301 | ····[SetUp] |
302 | ····public void Setup() |
303 | ····{ |
304 | ········pm = PmFactory.NewPersistenceManager(); |
305 | ········ownVar = new AgrBi11NoTblAutoLeft(); |
306 | ········otherVar = new AgrBi11NoTblAutoRight(); |
307 | ····} |
308 | ····[TearDown] |
309 | ····public void TearDown() |
310 | ····{ |
311 | ········try |
312 | ········{ |
313 | ············pm.UnloadCache(); |
314 | ············var l = pm.Objects<AgrBi11NoTblAutoLeft>().ResultTable; |
315 | ············pm.Delete(l); |
316 | ············pm.Save(); |
317 | ············pm.UnloadCache(); |
318 | ············var m = pm.Objects<AgrBi11NoTblAutoRight>().ResultTable; |
319 | ············pm.Delete(m); |
320 | ············pm.Save(); |
321 | ············pm.UnloadCache(); |
322 | ············decimal count; |
323 | ············count = (decimal) new NDOQuery<AgrBi11NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
324 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
325 | ············count = (decimal) new NDOQuery<AgrBi11NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
326 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
327 | ········} |
328 | ········catch (Exception) |
329 | ········{ |
330 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
331 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
332 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
333 | ········} |
334 | ····} |
335 | ····[Test] |
336 | ····public void TestSaveReload() |
337 | ····{ |
338 | ········CreateObjects(); |
339 | ········QueryOwn(); |
340 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
341 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
342 | ····} |
343 | ····[Test] |
344 | ····public void TestSaveReloadNull() |
345 | ····{ |
346 | ········CreateObjects(); |
347 | ········QueryOwn(); |
348 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
349 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
350 | ········ownVar.RelField = null; |
351 | ········pm.Save(); |
352 | ········pm.UnloadCache(); |
353 | ········QueryOwn(); |
354 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
355 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
356 | ····} |
357 | ····[Test] |
358 | ····public void TestChangeKeyHolderLeft() |
359 | ····{ |
360 | ········CreateObjects(); |
361 | ········QueryOwn(); |
362 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
363 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
364 | ········int x = ownVar.RelField.Dummy; |
365 | ········ownVar.Dummy = 4711; |
366 | ········pm.Save(); |
367 | ········pm.UnloadCache(); |
368 | ········QueryOwn(); |
369 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
370 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
371 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
372 | ····} |
373 | ····[Test] |
374 | ····public void TestChangeKeyHolderRight() |
375 | ····{ |
376 | ········CreateObjects(); |
377 | ········QueryOther(); |
378 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
379 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
380 | ········int x = otherVar.RelField.Dummy; |
381 | ········otherVar.Dummy = 4711; |
382 | ········pm.Save(); |
383 | ········pm.UnloadCache(); |
384 | ········QueryOther(); |
385 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
386 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
387 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
388 | ····} |
389 | ····[Test] |
390 | ····public void TestChangeKeyHolderLeftNoTouch() |
391 | ····{ |
392 | ········CreateObjects(); |
393 | ········QueryOwn(); |
394 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
395 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
396 | ········ownVar.Dummy = 4711; |
397 | ········pm.Save(); |
398 | ········pm.UnloadCache(); |
399 | ········QueryOwn(); |
400 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
401 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
402 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
403 | ····} |
404 | ····[Test] |
405 | ····public void TestChangeKeyHolderRightNoTouch() |
406 | ····{ |
407 | ········CreateObjects(); |
408 | ········QueryOther(); |
409 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
410 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
411 | ········otherVar.Dummy = 4711; |
412 | ········pm.Save(); |
413 | ········pm.UnloadCache(); |
414 | ········QueryOther(); |
415 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
416 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
417 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
418 | ····} |
419 | ····[Test] |
420 | ····public void TestRelationHash() |
421 | ····{ |
422 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblAutoLeft)); |
423 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
424 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblAutoRight)); |
425 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
426 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
427 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
428 | ····} |
429 | ····void CreateObjects() |
430 | ····{ |
431 | ········pm.MakePersistent(ownVar); |
432 | ········pm.MakePersistent(otherVar); |
433 | ········ownVar.AssignRelation(otherVar); |
434 | ········pm.Save(); |
435 | ········pm.UnloadCache(); |
436 | ····} |
437 | ····void QueryOwn() |
438 | ····{ |
439 | ········var q = new NDOQuery<AgrBi11NoTblAutoLeft>(pm); |
440 | ········ownVar = q.ExecuteSingle(); |
441 | ····} |
442 | ····void QueryOther() |
443 | ····{ |
444 | ········var q = new NDOQuery<AgrBi11NoTblAutoRight>(pm); |
445 | ········otherVar = q.ExecuteSingle(); |
446 | ····} |
447 | } |
448 | |
449 | |
450 | [TestFixture] |
451 | public class TestAgrBi11TblAuto : NDOTest |
452 | { |
453 | ····AgrBi11TblAutoLeft ownVar; |
454 | ····AgrBi11TblAutoRight otherVar; |
455 | ····PersistenceManager pm; |
456 | ····[SetUp] |
457 | ····public void Setup() |
458 | ····{ |
459 | ········pm = PmFactory.NewPersistenceManager(); |
460 | ········ownVar = new AgrBi11TblAutoLeft(); |
461 | ········otherVar = new AgrBi11TblAutoRight(); |
462 | ····} |
463 | ····[TearDown] |
464 | ····public void TearDown() |
465 | ····{ |
466 | ········try |
467 | ········{ |
468 | ············pm.UnloadCache(); |
469 | ············var l = pm.Objects<AgrBi11TblAutoLeft>().ResultTable; |
470 | ············pm.Delete(l); |
471 | ············pm.Save(); |
472 | ············pm.UnloadCache(); |
473 | ············var m = pm.Objects<AgrBi11TblAutoRight>().ResultTable; |
474 | ············pm.Delete(m); |
475 | ············pm.Save(); |
476 | ············pm.UnloadCache(); |
477 | ············decimal count; |
478 | ············count = (decimal) new NDOQuery<AgrBi11TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
479 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
480 | ············count = (decimal) new NDOQuery<AgrBi11TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
481 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
482 | ········} |
483 | ········catch (Exception) |
484 | ········{ |
485 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
486 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
487 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
488 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
489 | ········} |
490 | ····} |
491 | ····[Test] |
492 | ····public void TestSaveReload() |
493 | ····{ |
494 | ········CreateObjects(); |
495 | ········QueryOwn(); |
496 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
497 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
498 | ····} |
499 | ····[Test] |
500 | ····public void TestSaveReloadNull() |
501 | ····{ |
502 | ········CreateObjects(); |
503 | ········QueryOwn(); |
504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
505 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
506 | ········ownVar.RelField = null; |
507 | ········pm.Save(); |
508 | ········pm.UnloadCache(); |
509 | ········QueryOwn(); |
510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
511 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
512 | ····} |
513 | ····[Test] |
514 | ····public void TestChangeKeyHolderLeft() |
515 | ····{ |
516 | ········CreateObjects(); |
517 | ········QueryOwn(); |
518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
519 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
520 | ········int x = ownVar.RelField.Dummy; |
521 | ········ownVar.Dummy = 4711; |
522 | ········pm.Save(); |
523 | ········pm.UnloadCache(); |
524 | ········QueryOwn(); |
525 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
526 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
527 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
528 | ····} |
529 | ····[Test] |
530 | ····public void TestChangeKeyHolderRight() |
531 | ····{ |
532 | ········CreateObjects(); |
533 | ········QueryOther(); |
534 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
535 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
536 | ········int x = otherVar.RelField.Dummy; |
537 | ········otherVar.Dummy = 4711; |
538 | ········pm.Save(); |
539 | ········pm.UnloadCache(); |
540 | ········QueryOther(); |
541 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
542 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
543 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
544 | ····} |
545 | ····[Test] |
546 | ····public void TestChangeKeyHolderLeftNoTouch() |
547 | ····{ |
548 | ········CreateObjects(); |
549 | ········QueryOwn(); |
550 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
551 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
552 | ········ownVar.Dummy = 4711; |
553 | ········pm.Save(); |
554 | ········pm.UnloadCache(); |
555 | ········QueryOwn(); |
556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
557 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
558 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
559 | ····} |
560 | ····[Test] |
561 | ····public void TestChangeKeyHolderRightNoTouch() |
562 | ····{ |
563 | ········CreateObjects(); |
564 | ········QueryOther(); |
565 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
566 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
567 | ········otherVar.Dummy = 4711; |
568 | ········pm.Save(); |
569 | ········pm.UnloadCache(); |
570 | ········QueryOther(); |
571 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
572 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
573 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
574 | ····} |
575 | ····[Test] |
576 | ····public void TestRelationHash() |
577 | ····{ |
578 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11TblAutoLeft)); |
579 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
580 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11TblAutoRight)); |
581 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
582 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
583 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
584 | ····} |
585 | ····void CreateObjects() |
586 | ····{ |
587 | ········pm.MakePersistent(ownVar); |
588 | ········pm.MakePersistent(otherVar); |
589 | ········ownVar.AssignRelation(otherVar); |
590 | ········pm.Save(); |
591 | ········pm.UnloadCache(); |
592 | ····} |
593 | ····void QueryOwn() |
594 | ····{ |
595 | ········var q = new NDOQuery<AgrBi11TblAutoLeft>(pm); |
596 | ········ownVar = q.ExecuteSingle(); |
597 | ····} |
598 | ····void QueryOther() |
599 | ····{ |
600 | ········var q = new NDOQuery<AgrBi11TblAutoRight>(pm); |
601 | ········otherVar = q.ExecuteSingle(); |
602 | ····} |
603 | } |
604 | |
605 | |
606 | [TestFixture] |
607 | public class TestAgrDirnNoTblAuto : NDOTest |
608 | { |
609 | ····AgrDirnNoTblAutoLeft ownVar; |
610 | ····AgrDirnNoTblAutoRight otherVar; |
611 | ····PersistenceManager pm; |
612 | ····[SetUp] |
613 | ····public void Setup() |
614 | ····{ |
615 | ········pm = PmFactory.NewPersistenceManager(); |
616 | ········ownVar = new AgrDirnNoTblAutoLeft(); |
617 | ········otherVar = new AgrDirnNoTblAutoRight(); |
618 | ····} |
619 | ····[TearDown] |
620 | ····public void TearDown() |
621 | ····{ |
622 | ········try |
623 | ········{ |
624 | ············pm.UnloadCache(); |
625 | ············var l = pm.Objects<AgrDirnNoTblAutoLeft>().ResultTable; |
626 | ············pm.Delete(l); |
627 | ············pm.Save(); |
628 | ············pm.UnloadCache(); |
629 | ············var m = pm.Objects<AgrDirnNoTblAutoRight>().ResultTable; |
630 | ············pm.Delete(m); |
631 | ············pm.Save(); |
632 | ············pm.UnloadCache(); |
633 | ············decimal count; |
634 | ············count = (decimal) new NDOQuery<AgrDirnNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
636 | ············count = (decimal) new NDOQuery<AgrDirnNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
637 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
638 | ········} |
639 | ········catch (Exception) |
640 | ········{ |
641 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
642 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
644 | ········} |
645 | ····} |
646 | ····[Test] |
647 | ····public void TestSaveReload() |
648 | ····{ |
649 | ········CreateObjects(); |
650 | ········QueryOwn(); |
651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
652 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
653 | ····} |
654 | ····[Test] |
655 | ····public void TestSaveReloadNull() |
656 | ····{ |
657 | ········CreateObjects(); |
658 | ········QueryOwn(); |
659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
660 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
661 | ········ownVar.RelField = new List<AgrDirnNoTblAutoRight>(); |
662 | ········pm.Save(); |
663 | ········pm.UnloadCache(); |
664 | ········QueryOwn(); |
665 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
666 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
667 | ····} |
668 | ····[Test] |
669 | ····public void TestSaveReloadRemove() |
670 | ····{ |
671 | ········CreateObjects(); |
672 | ········QueryOwn(); |
673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
674 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
675 | ········ownVar.RemoveRelatedObject(); |
676 | ········pm.Save(); |
677 | ········pm.UnloadCache(); |
678 | ········QueryOwn(); |
679 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
680 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
681 | ····} |
682 | ····[Test] |
683 | ····public void TestUpdateOrder() |
684 | ····{ |
685 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
686 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
687 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnNoTblAutoLeft)})) |
688 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnNoTblAutoRight)})), "Wrong order #1"); |
689 | ········Debug.WriteLine("AgrDirnNoTblAutoLeft"); |
690 | ····} |
691 | ····void CreateObjects() |
692 | ····{ |
693 | ········pm.MakePersistent(ownVar); |
694 | ········pm.MakePersistent(otherVar); |
695 | ········ownVar.AssignRelation(otherVar); |
696 | ········pm.Save(); |
697 | ········pm.UnloadCache(); |
698 | ····} |
699 | ····void QueryOwn() |
700 | ····{ |
701 | ········var q = new NDOQuery<AgrDirnNoTblAutoLeft>(pm); |
702 | ········ownVar = q.ExecuteSingle(); |
703 | ····} |
704 | ····void QueryOther() |
705 | ····{ |
706 | ········var q = new NDOQuery<AgrDirnNoTblAutoRight>(pm); |
707 | ········otherVar = q.ExecuteSingle(); |
708 | ····} |
709 | } |
710 | |
711 | |
712 | [TestFixture] |
713 | public class TestAgrDirnTblAuto : NDOTest |
714 | { |
715 | ····AgrDirnTblAutoLeft ownVar; |
716 | ····AgrDirnTblAutoRight otherVar; |
717 | ····PersistenceManager pm; |
718 | ····[SetUp] |
719 | ····public void Setup() |
720 | ····{ |
721 | ········pm = PmFactory.NewPersistenceManager(); |
722 | ········ownVar = new AgrDirnTblAutoLeft(); |
723 | ········otherVar = new AgrDirnTblAutoRight(); |
724 | ····} |
725 | ····[TearDown] |
726 | ····public void TearDown() |
727 | ····{ |
728 | ········try |
729 | ········{ |
730 | ············pm.UnloadCache(); |
731 | ············var l = pm.Objects<AgrDirnTblAutoLeft>().ResultTable; |
732 | ············pm.Delete(l); |
733 | ············pm.Save(); |
734 | ············pm.UnloadCache(); |
735 | ············var m = pm.Objects<AgrDirnTblAutoRight>().ResultTable; |
736 | ············pm.Delete(m); |
737 | ············pm.Save(); |
738 | ············pm.UnloadCache(); |
739 | ············decimal count; |
740 | ············count = (decimal) new NDOQuery<AgrDirnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
741 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
742 | ············count = (decimal) new NDOQuery<AgrDirnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
743 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
744 | ········} |
745 | ········catch (Exception) |
746 | ········{ |
747 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
748 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
749 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
750 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
751 | ········} |
752 | ····} |
753 | ····[Test] |
754 | ····public void TestSaveReload() |
755 | ····{ |
756 | ········CreateObjects(); |
757 | ········QueryOwn(); |
758 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
759 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
760 | ····} |
761 | ····[Test] |
762 | ····public void TestSaveReloadNull() |
763 | ····{ |
764 | ········CreateObjects(); |
765 | ········QueryOwn(); |
766 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
767 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
768 | ········ownVar.RelField = new List<AgrDirnTblAutoRight>(); |
769 | ········pm.Save(); |
770 | ········pm.UnloadCache(); |
771 | ········QueryOwn(); |
772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
773 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
774 | ····} |
775 | ····[Test] |
776 | ····public void TestSaveReloadRemove() |
777 | ····{ |
778 | ········CreateObjects(); |
779 | ········QueryOwn(); |
780 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
781 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
782 | ········ownVar.RemoveRelatedObject(); |
783 | ········pm.Save(); |
784 | ········pm.UnloadCache(); |
785 | ········QueryOwn(); |
786 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
787 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
788 | ····} |
789 | ····void CreateObjects() |
790 | ····{ |
791 | ········pm.MakePersistent(ownVar); |
792 | ········pm.MakePersistent(otherVar); |
793 | ········ownVar.AssignRelation(otherVar); |
794 | ········pm.Save(); |
795 | ········pm.UnloadCache(); |
796 | ····} |
797 | ····void QueryOwn() |
798 | ····{ |
799 | ········var q = new NDOQuery<AgrDirnTblAutoLeft>(pm); |
800 | ········ownVar = q.ExecuteSingle(); |
801 | ····} |
802 | ····void QueryOther() |
803 | ····{ |
804 | ········var q = new NDOQuery<AgrDirnTblAutoRight>(pm); |
805 | ········otherVar = q.ExecuteSingle(); |
806 | ····} |
807 | } |
808 | |
809 | |
810 | [TestFixture] |
811 | public class TestAgrBin1NoTblAuto : NDOTest |
812 | { |
813 | ····AgrBin1NoTblAutoLeft ownVar; |
814 | ····AgrBin1NoTblAutoRight otherVar; |
815 | ····PersistenceManager pm; |
816 | ····[SetUp] |
817 | ····public void Setup() |
818 | ····{ |
819 | ········pm = PmFactory.NewPersistenceManager(); |
820 | ········ownVar = new AgrBin1NoTblAutoLeft(); |
821 | ········otherVar = new AgrBin1NoTblAutoRight(); |
822 | ····} |
823 | ····[TearDown] |
824 | ····public void TearDown() |
825 | ····{ |
826 | ········try |
827 | ········{ |
828 | ············pm.UnloadCache(); |
829 | ············var l = pm.Objects<AgrBin1NoTblAutoLeft>().ResultTable; |
830 | ············pm.Delete(l); |
831 | ············pm.Save(); |
832 | ············pm.UnloadCache(); |
833 | ············var m = pm.Objects<AgrBin1NoTblAutoRight>().ResultTable; |
834 | ············pm.Delete(m); |
835 | ············pm.Save(); |
836 | ············pm.UnloadCache(); |
837 | ············decimal count; |
838 | ············count = (decimal) new NDOQuery<AgrBin1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
839 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
840 | ············count = (decimal) new NDOQuery<AgrBin1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
841 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
842 | ········} |
843 | ········catch (Exception) |
844 | ········{ |
845 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
846 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
847 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
848 | ········} |
849 | ····} |
850 | ····[Test] |
851 | ····public void TestSaveReload() |
852 | ····{ |
853 | ········CreateObjects(); |
854 | ········QueryOwn(); |
855 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
856 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
857 | ····} |
858 | ····[Test] |
859 | ····public void TestSaveReloadNull() |
860 | ····{ |
861 | ········CreateObjects(); |
862 | ········QueryOwn(); |
863 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
864 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
865 | ········ownVar.RelField = new List<AgrBin1NoTblAutoRight>(); |
866 | ········pm.Save(); |
867 | ········pm.UnloadCache(); |
868 | ········QueryOwn(); |
869 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
870 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
871 | ····} |
872 | ····[Test] |
873 | ····public void TestSaveReloadRemove() |
874 | ····{ |
875 | ········CreateObjects(); |
876 | ········QueryOwn(); |
877 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
878 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
879 | ········ownVar.RemoveRelatedObject(); |
880 | ········pm.Save(); |
881 | ········pm.UnloadCache(); |
882 | ········QueryOwn(); |
883 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
884 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
885 | ····} |
886 | ····[Test] |
887 | ····public void TestChangeKeyHolderRight() |
888 | ····{ |
889 | ········CreateObjects(); |
890 | ········QueryOther(); |
891 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
892 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
893 | ········int x = otherVar.RelField.Dummy; |
894 | ········otherVar.Dummy = 4711; |
895 | ········pm.Save(); |
896 | ········pm.UnloadCache(); |
897 | ········QueryOther(); |
898 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
899 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
900 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
901 | ····} |
902 | ····[Test] |
903 | ····public void TestChangeKeyHolderRightNoTouch() |
904 | ····{ |
905 | ········CreateObjects(); |
906 | ········QueryOther(); |
907 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
908 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
909 | ········otherVar.Dummy = 4711; |
910 | ········pm.Save(); |
911 | ········pm.UnloadCache(); |
912 | ········QueryOther(); |
913 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
914 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
915 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
916 | ····} |
917 | ····[Test] |
918 | ····public void TestUpdateOrder() |
919 | ····{ |
920 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
921 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
922 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1NoTblAutoLeft)})) |
923 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1NoTblAutoRight)})), "Wrong order #1"); |
924 | ········Debug.WriteLine("AgrBin1NoTblAutoLeft"); |
925 | ····} |
926 | ····[Test] |
927 | ····public void TestRelationHash() |
928 | ····{ |
929 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblAutoLeft)); |
930 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
931 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblAutoRight)); |
932 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
933 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
934 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
935 | ····} |
936 | ····void CreateObjects() |
937 | ····{ |
938 | ········pm.MakePersistent(ownVar); |
939 | ········pm.MakePersistent(otherVar); |
940 | ········ownVar.AssignRelation(otherVar); |
941 | ········pm.Save(); |
942 | ········pm.UnloadCache(); |
943 | ····} |
944 | ····void QueryOwn() |
945 | ····{ |
946 | ········var q = new NDOQuery<AgrBin1NoTblAutoLeft>(pm); |
947 | ········ownVar = q.ExecuteSingle(); |
948 | ····} |
949 | ····void QueryOther() |
950 | ····{ |
951 | ········var q = new NDOQuery<AgrBin1NoTblAutoRight>(pm); |
952 | ········otherVar = q.ExecuteSingle(); |
953 | ····} |
954 | } |
955 | |
956 | |
957 | [TestFixture] |
958 | public class TestAgrBin1TblAuto : NDOTest |
959 | { |
960 | ····AgrBin1TblAutoLeft ownVar; |
961 | ····AgrBin1TblAutoRight otherVar; |
962 | ····PersistenceManager pm; |
963 | ····[SetUp] |
964 | ····public void Setup() |
965 | ····{ |
966 | ········pm = PmFactory.NewPersistenceManager(); |
967 | ········ownVar = new AgrBin1TblAutoLeft(); |
968 | ········otherVar = new AgrBin1TblAutoRight(); |
969 | ····} |
970 | ····[TearDown] |
971 | ····public void TearDown() |
972 | ····{ |
973 | ········try |
974 | ········{ |
975 | ············pm.UnloadCache(); |
976 | ············var l = pm.Objects<AgrBin1TblAutoLeft>().ResultTable; |
977 | ············pm.Delete(l); |
978 | ············pm.Save(); |
979 | ············pm.UnloadCache(); |
980 | ············var m = pm.Objects<AgrBin1TblAutoRight>().ResultTable; |
981 | ············pm.Delete(m); |
982 | ············pm.Save(); |
983 | ············pm.UnloadCache(); |
984 | ············decimal count; |
985 | ············count = (decimal) new NDOQuery<AgrBin1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
986 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
987 | ············count = (decimal) new NDOQuery<AgrBin1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
988 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
989 | ········} |
990 | ········catch (Exception) |
991 | ········{ |
992 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
993 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
994 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
995 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
996 | ········} |
997 | ····} |
998 | ····[Test] |
999 | ····public void TestSaveReload() |
1000 | ····{ |
1001 | ········CreateObjects(); |
1002 | ········QueryOwn(); |
1003 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1004 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1005 | ····} |
1006 | ····[Test] |
1007 | ····public void TestSaveReloadNull() |
1008 | ····{ |
1009 | ········CreateObjects(); |
1010 | ········QueryOwn(); |
1011 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1012 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1013 | ········ownVar.RelField = new List<AgrBin1TblAutoRight>(); |
1014 | ········pm.Save(); |
1015 | ········pm.UnloadCache(); |
1016 | ········QueryOwn(); |
1017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1018 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1019 | ····} |
1020 | ····[Test] |
1021 | ····public void TestSaveReloadRemove() |
1022 | ····{ |
1023 | ········CreateObjects(); |
1024 | ········QueryOwn(); |
1025 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1026 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1027 | ········ownVar.RemoveRelatedObject(); |
1028 | ········pm.Save(); |
1029 | ········pm.UnloadCache(); |
1030 | ········QueryOwn(); |
1031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1032 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1033 | ····} |
1034 | ····[Test] |
1035 | ····public void TestChangeKeyHolderRight() |
1036 | ····{ |
1037 | ········CreateObjects(); |
1038 | ········QueryOther(); |
1039 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1040 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1041 | ········int x = otherVar.RelField.Dummy; |
1042 | ········otherVar.Dummy = 4711; |
1043 | ········pm.Save(); |
1044 | ········pm.UnloadCache(); |
1045 | ········QueryOther(); |
1046 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1047 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1048 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1049 | ····} |
1050 | ····[Test] |
1051 | ····public void TestChangeKeyHolderRightNoTouch() |
1052 | ····{ |
1053 | ········CreateObjects(); |
1054 | ········QueryOther(); |
1055 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1056 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1057 | ········otherVar.Dummy = 4711; |
1058 | ········pm.Save(); |
1059 | ········pm.UnloadCache(); |
1060 | ········QueryOther(); |
1061 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1062 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1063 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1064 | ····} |
1065 | ····[Test] |
1066 | ····public void TestRelationHash() |
1067 | ····{ |
1068 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1TblAutoLeft)); |
1069 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1070 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1TblAutoRight)); |
1071 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1072 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1073 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1074 | ····} |
1075 | ····void CreateObjects() |
1076 | ····{ |
1077 | ········pm.MakePersistent(ownVar); |
1078 | ········pm.MakePersistent(otherVar); |
1079 | ········ownVar.AssignRelation(otherVar); |
1080 | ········pm.Save(); |
1081 | ········pm.UnloadCache(); |
1082 | ····} |
1083 | ····void QueryOwn() |
1084 | ····{ |
1085 | ········var q = new NDOQuery<AgrBin1TblAutoLeft>(pm); |
1086 | ········ownVar = q.ExecuteSingle(); |
1087 | ····} |
1088 | ····void QueryOther() |
1089 | ····{ |
1090 | ········var q = new NDOQuery<AgrBin1TblAutoRight>(pm); |
1091 | ········otherVar = q.ExecuteSingle(); |
1092 | ····} |
1093 | } |
1094 | |
1095 | |
1096 | [TestFixture] |
1097 | public class TestAgrBi1nNoTblAuto : NDOTest |
1098 | { |
1099 | ····AgrBi1nNoTblAutoLeft ownVar; |
1100 | ····AgrBi1nNoTblAutoRight otherVar; |
1101 | ····PersistenceManager pm; |
1102 | ····[SetUp] |
1103 | ····public void Setup() |
1104 | ····{ |
1105 | ········pm = PmFactory.NewPersistenceManager(); |
1106 | ········ownVar = new AgrBi1nNoTblAutoLeft(); |
1107 | ········otherVar = new AgrBi1nNoTblAutoRight(); |
1108 | ····} |
1109 | ····[TearDown] |
1110 | ····public void TearDown() |
1111 | ····{ |
1112 | ········try |
1113 | ········{ |
1114 | ············pm.UnloadCache(); |
1115 | ············var l = pm.Objects<AgrBi1nNoTblAutoLeft>().ResultTable; |
1116 | ············pm.Delete(l); |
1117 | ············pm.Save(); |
1118 | ············pm.UnloadCache(); |
1119 | ············var m = pm.Objects<AgrBi1nNoTblAutoRight>().ResultTable; |
1120 | ············pm.Delete(m); |
1121 | ············pm.Save(); |
1122 | ············pm.UnloadCache(); |
1123 | ············decimal count; |
1124 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1125 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1126 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1127 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1128 | ········} |
1129 | ········catch (Exception) |
1130 | ········{ |
1131 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1132 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1133 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1134 | ········} |
1135 | ····} |
1136 | ····[Test] |
1137 | ····public void TestSaveReload() |
1138 | ····{ |
1139 | ········CreateObjects(); |
1140 | ········QueryOwn(); |
1141 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1142 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1143 | ····} |
1144 | ····[Test] |
1145 | ····public void TestSaveReloadNull() |
1146 | ····{ |
1147 | ········CreateObjects(); |
1148 | ········QueryOwn(); |
1149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1151 | ········ownVar.RelField = null; |
1152 | ········pm.Save(); |
1153 | ········pm.UnloadCache(); |
1154 | ········QueryOwn(); |
1155 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1156 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1157 | ····} |
1158 | ····[Test] |
1159 | ····public void TestChangeKeyHolderLeft() |
1160 | ····{ |
1161 | ········CreateObjects(); |
1162 | ········QueryOwn(); |
1163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1164 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1165 | ········int x = ownVar.RelField.Dummy; |
1166 | ········ownVar.Dummy = 4711; |
1167 | ········pm.Save(); |
1168 | ········pm.UnloadCache(); |
1169 | ········QueryOwn(); |
1170 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1171 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1172 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1173 | ····} |
1174 | ····[Test] |
1175 | ····public void TestChangeKeyHolderLeftNoTouch() |
1176 | ····{ |
1177 | ········CreateObjects(); |
1178 | ········QueryOwn(); |
1179 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1181 | ········ownVar.Dummy = 4711; |
1182 | ········pm.Save(); |
1183 | ········pm.UnloadCache(); |
1184 | ········QueryOwn(); |
1185 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1186 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1187 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1188 | ····} |
1189 | ····[Test] |
1190 | ····public void TestUpdateOrder() |
1191 | ····{ |
1192 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
1193 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
1194 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nNoTblAutoLeft)})) |
1195 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nNoTblAutoRight)})), "Wrong order #1"); |
1196 | ········Debug.WriteLine("AgrBi1nNoTblAutoLeft"); |
1197 | ····} |
1198 | ····[Test] |
1199 | ····public void TestRelationHash() |
1200 | ····{ |
1201 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblAutoLeft)); |
1202 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1203 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblAutoRight)); |
1204 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1205 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1206 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1207 | ····} |
1208 | ····void CreateObjects() |
1209 | ····{ |
1210 | ········pm.MakePersistent(ownVar); |
1211 | ········pm.MakePersistent(otherVar); |
1212 | ········ownVar.AssignRelation(otherVar); |
1213 | ········pm.Save(); |
1214 | ········pm.UnloadCache(); |
1215 | ····} |
1216 | ····void QueryOwn() |
1217 | ····{ |
1218 | ········var q = new NDOQuery<AgrBi1nNoTblAutoLeft>(pm); |
1219 | ········ownVar = q.ExecuteSingle(); |
1220 | ····} |
1221 | ····void QueryOther() |
1222 | ····{ |
1223 | ········var q = new NDOQuery<AgrBi1nNoTblAutoRight>(pm); |
1224 | ········otherVar = q.ExecuteSingle(); |
1225 | ····} |
1226 | } |
1227 | |
1228 | |
1229 | [TestFixture] |
1230 | public class TestAgrBi1nTblAuto : NDOTest |
1231 | { |
1232 | ····AgrBi1nTblAutoLeft ownVar; |
1233 | ····AgrBi1nTblAutoRight otherVar; |
1234 | ····PersistenceManager pm; |
1235 | ····[SetUp] |
1236 | ····public void Setup() |
1237 | ····{ |
1238 | ········pm = PmFactory.NewPersistenceManager(); |
1239 | ········ownVar = new AgrBi1nTblAutoLeft(); |
1240 | ········otherVar = new AgrBi1nTblAutoRight(); |
1241 | ····} |
1242 | ····[TearDown] |
1243 | ····public void TearDown() |
1244 | ····{ |
1245 | ········try |
1246 | ········{ |
1247 | ············pm.UnloadCache(); |
1248 | ············var l = pm.Objects<AgrBi1nTblAutoLeft>().ResultTable; |
1249 | ············pm.Delete(l); |
1250 | ············pm.Save(); |
1251 | ············pm.UnloadCache(); |
1252 | ············var m = pm.Objects<AgrBi1nTblAutoRight>().ResultTable; |
1253 | ············pm.Delete(m); |
1254 | ············pm.Save(); |
1255 | ············pm.UnloadCache(); |
1256 | ············decimal count; |
1257 | ············count = (decimal) new NDOQuery<AgrBi1nTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1258 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1259 | ············count = (decimal) new NDOQuery<AgrBi1nTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1260 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1261 | ········} |
1262 | ········catch (Exception) |
1263 | ········{ |
1264 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1265 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1266 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1267 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1268 | ········} |
1269 | ····} |
1270 | ····[Test] |
1271 | ····public void TestSaveReload() |
1272 | ····{ |
1273 | ········CreateObjects(); |
1274 | ········QueryOwn(); |
1275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1276 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1277 | ····} |
1278 | ····[Test] |
1279 | ····public void TestSaveReloadNull() |
1280 | ····{ |
1281 | ········CreateObjects(); |
1282 | ········QueryOwn(); |
1283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1284 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1285 | ········ownVar.RelField = null; |
1286 | ········pm.Save(); |
1287 | ········pm.UnloadCache(); |
1288 | ········QueryOwn(); |
1289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1290 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1291 | ····} |
1292 | ····[Test] |
1293 | ····public void TestChangeKeyHolderLeft() |
1294 | ····{ |
1295 | ········CreateObjects(); |
1296 | ········QueryOwn(); |
1297 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1298 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1299 | ········int x = ownVar.RelField.Dummy; |
1300 | ········ownVar.Dummy = 4711; |
1301 | ········pm.Save(); |
1302 | ········pm.UnloadCache(); |
1303 | ········QueryOwn(); |
1304 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1305 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1306 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1307 | ····} |
1308 | ····[Test] |
1309 | ····public void TestChangeKeyHolderLeftNoTouch() |
1310 | ····{ |
1311 | ········CreateObjects(); |
1312 | ········QueryOwn(); |
1313 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1315 | ········ownVar.Dummy = 4711; |
1316 | ········pm.Save(); |
1317 | ········pm.UnloadCache(); |
1318 | ········QueryOwn(); |
1319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1320 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1321 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1322 | ····} |
1323 | ····[Test] |
1324 | ····public void TestRelationHash() |
1325 | ····{ |
1326 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nTblAutoLeft)); |
1327 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1328 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nTblAutoRight)); |
1329 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1330 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1331 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1332 | ····} |
1333 | ····void CreateObjects() |
1334 | ····{ |
1335 | ········pm.MakePersistent(ownVar); |
1336 | ········pm.MakePersistent(otherVar); |
1337 | ········ownVar.AssignRelation(otherVar); |
1338 | ········pm.Save(); |
1339 | ········pm.UnloadCache(); |
1340 | ····} |
1341 | ····void QueryOwn() |
1342 | ····{ |
1343 | ········var q = new NDOQuery<AgrBi1nTblAutoLeft>(pm); |
1344 | ········ownVar = q.ExecuteSingle(); |
1345 | ····} |
1346 | ····void QueryOther() |
1347 | ····{ |
1348 | ········var q = new NDOQuery<AgrBi1nTblAutoRight>(pm); |
1349 | ········otherVar = q.ExecuteSingle(); |
1350 | ····} |
1351 | } |
1352 | |
1353 | |
1354 | [TestFixture] |
1355 | public class TestAgrBinnTblAuto : NDOTest |
1356 | { |
1357 | ····AgrBinnTblAutoLeft ownVar; |
1358 | ····AgrBinnTblAutoRight otherVar; |
1359 | ····PersistenceManager pm; |
1360 | ····[SetUp] |
1361 | ····public void Setup() |
1362 | ····{ |
1363 | ········pm = PmFactory.NewPersistenceManager(); |
1364 | ········ownVar = new AgrBinnTblAutoLeft(); |
1365 | ········otherVar = new AgrBinnTblAutoRight(); |
1366 | ····} |
1367 | ····[TearDown] |
1368 | ····public void TearDown() |
1369 | ····{ |
1370 | ········try |
1371 | ········{ |
1372 | ············pm.UnloadCache(); |
1373 | ············var l = pm.Objects<AgrBinnTblAutoLeft>().ResultTable; |
1374 | ············pm.Delete(l); |
1375 | ············pm.Save(); |
1376 | ············pm.UnloadCache(); |
1377 | ············var m = pm.Objects<AgrBinnTblAutoRight>().ResultTable; |
1378 | ············pm.Delete(m); |
1379 | ············pm.Save(); |
1380 | ············pm.UnloadCache(); |
1381 | ············decimal count; |
1382 | ············count = (decimal) new NDOQuery<AgrBinnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1383 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1384 | ············count = (decimal) new NDOQuery<AgrBinnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1385 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1386 | ········} |
1387 | ········catch (Exception) |
1388 | ········{ |
1389 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1390 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1391 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1392 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1393 | ········} |
1394 | ····} |
1395 | ····[Test] |
1396 | ····public void TestSaveReload() |
1397 | ····{ |
1398 | ········CreateObjects(); |
1399 | ········QueryOwn(); |
1400 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1401 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1402 | ····} |
1403 | ····[Test] |
1404 | ····public void TestSaveReloadNull() |
1405 | ····{ |
1406 | ········CreateObjects(); |
1407 | ········QueryOwn(); |
1408 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1409 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1410 | ········ownVar.RelField = new List<AgrBinnTblAutoRight>(); |
1411 | ········pm.Save(); |
1412 | ········pm.UnloadCache(); |
1413 | ········QueryOwn(); |
1414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1415 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1416 | ····} |
1417 | ····[Test] |
1418 | ····public void TestSaveReloadRemove() |
1419 | ····{ |
1420 | ········CreateObjects(); |
1421 | ········QueryOwn(); |
1422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1424 | ········ownVar.RemoveRelatedObject(); |
1425 | ········pm.Save(); |
1426 | ········pm.UnloadCache(); |
1427 | ········QueryOwn(); |
1428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1429 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1430 | ····} |
1431 | ····[Test] |
1432 | ····public void TestRelationHash() |
1433 | ····{ |
1434 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnTblAutoLeft)); |
1435 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1436 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnTblAutoRight)); |
1437 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1438 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1439 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1440 | ····} |
1441 | ····void CreateObjects() |
1442 | ····{ |
1443 | ········pm.MakePersistent(ownVar); |
1444 | ········pm.MakePersistent(otherVar); |
1445 | ········ownVar.AssignRelation(otherVar); |
1446 | ········pm.Save(); |
1447 | ········pm.UnloadCache(); |
1448 | ····} |
1449 | ····void QueryOwn() |
1450 | ····{ |
1451 | ········var q = new NDOQuery<AgrBinnTblAutoLeft>(pm); |
1452 | ········ownVar = q.ExecuteSingle(); |
1453 | ····} |
1454 | ····void QueryOther() |
1455 | ····{ |
1456 | ········var q = new NDOQuery<AgrBinnTblAutoRight>(pm); |
1457 | ········otherVar = q.ExecuteSingle(); |
1458 | ····} |
1459 | } |
1460 | |
1461 | |
1462 | [TestFixture] |
1463 | public class TestCmpDir1NoTblAuto : NDOTest |
1464 | { |
1465 | ····CmpDir1NoTblAutoLeft ownVar; |
1466 | ····CmpDir1NoTblAutoRight otherVar; |
1467 | ····PersistenceManager pm; |
1468 | ····[SetUp] |
1469 | ····public void Setup() |
1470 | ····{ |
1471 | ········pm = PmFactory.NewPersistenceManager(); |
1472 | ········ownVar = new CmpDir1NoTblAutoLeft(); |
1473 | ········otherVar = new CmpDir1NoTblAutoRight(); |
1474 | ····} |
1475 | ····[TearDown] |
1476 | ····public void TearDown() |
1477 | ····{ |
1478 | ········try |
1479 | ········{ |
1480 | ············pm.UnloadCache(); |
1481 | ············var l = pm.Objects<CmpDir1NoTblAutoLeft>().ResultTable; |
1482 | ············pm.Delete(l); |
1483 | ············pm.Save(); |
1484 | ············pm.UnloadCache(); |
1485 | ············decimal count; |
1486 | ············count = (decimal) new NDOQuery<CmpDir1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1487 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1488 | ············count = (decimal) new NDOQuery<CmpDir1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1489 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1490 | ········} |
1491 | ········catch (Exception) |
1492 | ········{ |
1493 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1494 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1495 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1496 | ········} |
1497 | ····} |
1498 | ····[Test] |
1499 | ····public void TestSaveReload() |
1500 | ····{ |
1501 | ········CreateObjects(); |
1502 | ········QueryOwn(); |
1503 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1504 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1505 | ····} |
1506 | ····[Test] |
1507 | ····public void TestSaveReloadNull() |
1508 | ····{ |
1509 | ········CreateObjects(); |
1510 | ········QueryOwn(); |
1511 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1512 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1513 | ········ownVar.RelField = null; |
1514 | ········pm.Save(); |
1515 | ········pm.UnloadCache(); |
1516 | ········QueryOwn(); |
1517 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1518 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1519 | ····} |
1520 | ····[Test] |
1521 | ····public void TestChangeKeyHolderLeft() |
1522 | ····{ |
1523 | ········CreateObjects(); |
1524 | ········QueryOwn(); |
1525 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1526 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1527 | ········int x = ownVar.RelField.Dummy; |
1528 | ········ownVar.Dummy = 4711; |
1529 | ········pm.Save(); |
1530 | ········pm.UnloadCache(); |
1531 | ········QueryOwn(); |
1532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1533 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1534 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1535 | ····} |
1536 | ····[Test] |
1537 | ····public void TestChangeKeyHolderLeftNoTouch() |
1538 | ····{ |
1539 | ········CreateObjects(); |
1540 | ········QueryOwn(); |
1541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1542 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1543 | ········ownVar.Dummy = 4711; |
1544 | ········pm.Save(); |
1545 | ········pm.UnloadCache(); |
1546 | ········QueryOwn(); |
1547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1548 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1549 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1550 | ····} |
1551 | ····[Test] |
1552 | ····public void TestUpdateOrder() |
1553 | ····{ |
1554 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
1555 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
1556 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1NoTblAutoLeft)})) |
1557 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1NoTblAutoRight)})), "Wrong order #1"); |
1558 | ········Debug.WriteLine("CmpDir1NoTblAutoLeft"); |
1559 | ····} |
1560 | ····void CreateObjects() |
1561 | ····{ |
1562 | ········pm.MakePersistent(ownVar); |
1563 | ········ownVar.AssignRelation(otherVar); |
1564 | ········pm.Save(); |
1565 | ········pm.UnloadCache(); |
1566 | ····} |
1567 | ····void QueryOwn() |
1568 | ····{ |
1569 | ········var q = new NDOQuery<CmpDir1NoTblAutoLeft>(pm); |
1570 | ········ownVar = q.ExecuteSingle(); |
1571 | ····} |
1572 | ····void QueryOther() |
1573 | ····{ |
1574 | ········var q = new NDOQuery<CmpDir1NoTblAutoRight>(pm); |
1575 | ········otherVar = q.ExecuteSingle(); |
1576 | ····} |
1577 | } |
1578 | |
1579 | |
1580 | [TestFixture] |
1581 | public class TestCmpDir1TblAuto : NDOTest |
1582 | { |
1583 | ····CmpDir1TblAutoLeft ownVar; |
1584 | ····CmpDir1TblAutoRight otherVar; |
1585 | ····PersistenceManager pm; |
1586 | ····[SetUp] |
1587 | ····public void Setup() |
1588 | ····{ |
1589 | ········pm = PmFactory.NewPersistenceManager(); |
1590 | ········ownVar = new CmpDir1TblAutoLeft(); |
1591 | ········otherVar = new CmpDir1TblAutoRight(); |
1592 | ····} |
1593 | ····[TearDown] |
1594 | ····public void TearDown() |
1595 | ····{ |
1596 | ········try |
1597 | ········{ |
1598 | ············pm.UnloadCache(); |
1599 | ············var l = pm.Objects<CmpDir1TblAutoLeft>().ResultTable; |
1600 | ············pm.Delete(l); |
1601 | ············pm.Save(); |
1602 | ············pm.UnloadCache(); |
1603 | ············decimal count; |
1604 | ············count = (decimal) new NDOQuery<CmpDir1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1605 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1606 | ············count = (decimal) new NDOQuery<CmpDir1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1607 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1608 | ········} |
1609 | ········catch (Exception) |
1610 | ········{ |
1611 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1612 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1613 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1614 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1615 | ········} |
1616 | ····} |
1617 | ····[Test] |
1618 | ····public void TestSaveReload() |
1619 | ····{ |
1620 | ········CreateObjects(); |
1621 | ········QueryOwn(); |
1622 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1623 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1624 | ····} |
1625 | ····[Test] |
1626 | ····public void TestSaveReloadNull() |
1627 | ····{ |
1628 | ········CreateObjects(); |
1629 | ········QueryOwn(); |
1630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1631 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1632 | ········ownVar.RelField = null; |
1633 | ········pm.Save(); |
1634 | ········pm.UnloadCache(); |
1635 | ········QueryOwn(); |
1636 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1637 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1638 | ····} |
1639 | ····[Test] |
1640 | ····public void TestChangeKeyHolderLeft() |
1641 | ····{ |
1642 | ········CreateObjects(); |
1643 | ········QueryOwn(); |
1644 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1645 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1646 | ········int x = ownVar.RelField.Dummy; |
1647 | ········ownVar.Dummy = 4711; |
1648 | ········pm.Save(); |
1649 | ········pm.UnloadCache(); |
1650 | ········QueryOwn(); |
1651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1652 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1654 | ····} |
1655 | ····[Test] |
1656 | ····public void TestChangeKeyHolderLeftNoTouch() |
1657 | ····{ |
1658 | ········CreateObjects(); |
1659 | ········QueryOwn(); |
1660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1662 | ········ownVar.Dummy = 4711; |
1663 | ········pm.Save(); |
1664 | ········pm.UnloadCache(); |
1665 | ········QueryOwn(); |
1666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1667 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1669 | ····} |
1670 | ····void CreateObjects() |
1671 | ····{ |
1672 | ········pm.MakePersistent(ownVar); |
1673 | ········ownVar.AssignRelation(otherVar); |
1674 | ········pm.Save(); |
1675 | ········pm.UnloadCache(); |
1676 | ····} |
1677 | ····void QueryOwn() |
1678 | ····{ |
1679 | ········var q = new NDOQuery<CmpDir1TblAutoLeft>(pm); |
1680 | ········ownVar = q.ExecuteSingle(); |
1681 | ····} |
1682 | ····void QueryOther() |
1683 | ····{ |
1684 | ········var q = new NDOQuery<CmpDir1TblAutoRight>(pm); |
1685 | ········otherVar = q.ExecuteSingle(); |
1686 | ····} |
1687 | } |
1688 | |
1689 | |
1690 | [TestFixture] |
1691 | public class TestCmpBi11NoTblAuto : NDOTest |
1692 | { |
1693 | ····CmpBi11NoTblAutoLeft ownVar; |
1694 | ····CmpBi11NoTblAutoRight otherVar; |
1695 | ····PersistenceManager pm; |
1696 | ····[SetUp] |
1697 | ····public void Setup() |
1698 | ····{ |
1699 | ········pm = PmFactory.NewPersistenceManager(); |
1700 | ········ownVar = new CmpBi11NoTblAutoLeft(); |
1701 | ········otherVar = new CmpBi11NoTblAutoRight(); |
1702 | ····} |
1703 | ····[TearDown] |
1704 | ····public void TearDown() |
1705 | ····{ |
1706 | ········try |
1707 | ········{ |
1708 | ············pm.UnloadCache(); |
1709 | ············var l = pm.Objects<CmpBi11NoTblAutoLeft>().ResultTable; |
1710 | ············pm.Delete(l); |
1711 | ············pm.Save(); |
1712 | ············pm.UnloadCache(); |
1713 | ············decimal count; |
1714 | ············count = (decimal) new NDOQuery<CmpBi11NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1715 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1716 | ············count = (decimal) new NDOQuery<CmpBi11NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1717 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1718 | ········} |
1719 | ········catch (Exception) |
1720 | ········{ |
1721 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1722 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1723 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1724 | ········} |
1725 | ····} |
1726 | ····[Test] |
1727 | ····public void TestSaveReload() |
1728 | ····{ |
1729 | ········CreateObjects(); |
1730 | ········QueryOwn(); |
1731 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1732 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1733 | ····} |
1734 | ····[Test] |
1735 | ····public void TestSaveReloadNull() |
1736 | ····{ |
1737 | ········CreateObjects(); |
1738 | ········QueryOwn(); |
1739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1740 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1741 | ········ownVar.RelField = null; |
1742 | ········pm.Save(); |
1743 | ········pm.UnloadCache(); |
1744 | ········QueryOwn(); |
1745 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1746 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1747 | ····} |
1748 | ····[Test] |
1749 | ····public void TestChangeKeyHolderLeft() |
1750 | ····{ |
1751 | ········CreateObjects(); |
1752 | ········QueryOwn(); |
1753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1754 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1755 | ········int x = ownVar.RelField.Dummy; |
1756 | ········ownVar.Dummy = 4711; |
1757 | ········pm.Save(); |
1758 | ········pm.UnloadCache(); |
1759 | ········QueryOwn(); |
1760 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1761 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1762 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1763 | ····} |
1764 | ····[Test] |
1765 | ····public void TestChangeKeyHolderRight() |
1766 | ····{ |
1767 | ········CreateObjects(); |
1768 | ········QueryOther(); |
1769 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1770 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1771 | ········int x = otherVar.RelField.Dummy; |
1772 | ········otherVar.Dummy = 4711; |
1773 | ········pm.Save(); |
1774 | ········pm.UnloadCache(); |
1775 | ········QueryOther(); |
1776 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1777 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1778 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1779 | ····} |
1780 | ····[Test] |
1781 | ····public void TestChangeKeyHolderLeftNoTouch() |
1782 | ····{ |
1783 | ········CreateObjects(); |
1784 | ········QueryOwn(); |
1785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1787 | ········ownVar.Dummy = 4711; |
1788 | ········pm.Save(); |
1789 | ········pm.UnloadCache(); |
1790 | ········QueryOwn(); |
1791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1792 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1793 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1794 | ····} |
1795 | ····[Test] |
1796 | ····public void TestChangeKeyHolderRightNoTouch() |
1797 | ····{ |
1798 | ········CreateObjects(); |
1799 | ········QueryOther(); |
1800 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1801 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1802 | ········otherVar.Dummy = 4711; |
1803 | ········pm.Save(); |
1804 | ········pm.UnloadCache(); |
1805 | ········QueryOther(); |
1806 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1807 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1808 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1809 | ····} |
1810 | ····[Test] |
1811 | ····public void TestRelationHash() |
1812 | ····{ |
1813 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblAutoLeft)); |
1814 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1815 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblAutoRight)); |
1816 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1817 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1818 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1819 | ····} |
1820 | ····void CreateObjects() |
1821 | ····{ |
1822 | ········pm.MakePersistent(ownVar); |
1823 | ········ownVar.AssignRelation(otherVar); |
1824 | ········pm.Save(); |
1825 | ········pm.UnloadCache(); |
1826 | ····} |
1827 | ····void QueryOwn() |
1828 | ····{ |
1829 | ········var q = new NDOQuery<CmpBi11NoTblAutoLeft>(pm); |
1830 | ········ownVar = q.ExecuteSingle(); |
1831 | ····} |
1832 | ····void QueryOther() |
1833 | ····{ |
1834 | ········var q = new NDOQuery<CmpBi11NoTblAutoRight>(pm); |
1835 | ········otherVar = q.ExecuteSingle(); |
1836 | ····} |
1837 | } |
1838 | |
1839 | |
1840 | [TestFixture] |
1841 | public class TestCmpBi11TblAuto : NDOTest |
1842 | { |
1843 | ····CmpBi11TblAutoLeft ownVar; |
1844 | ····CmpBi11TblAutoRight otherVar; |
1845 | ····PersistenceManager pm; |
1846 | ····[SetUp] |
1847 | ····public void Setup() |
1848 | ····{ |
1849 | ········pm = PmFactory.NewPersistenceManager(); |
1850 | ········ownVar = new CmpBi11TblAutoLeft(); |
1851 | ········otherVar = new CmpBi11TblAutoRight(); |
1852 | ····} |
1853 | ····[TearDown] |
1854 | ····public void TearDown() |
1855 | ····{ |
1856 | ········try |
1857 | ········{ |
1858 | ············pm.UnloadCache(); |
1859 | ············var l = pm.Objects<CmpBi11TblAutoLeft>().ResultTable; |
1860 | ············pm.Delete(l); |
1861 | ············pm.Save(); |
1862 | ············pm.UnloadCache(); |
1863 | ············decimal count; |
1864 | ············count = (decimal) new NDOQuery<CmpBi11TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1866 | ············count = (decimal) new NDOQuery<CmpBi11TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1867 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1868 | ········} |
1869 | ········catch (Exception) |
1870 | ········{ |
1871 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1872 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1873 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1874 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1875 | ········} |
1876 | ····} |
1877 | ····[Test] |
1878 | ····public void TestSaveReload() |
1879 | ····{ |
1880 | ········CreateObjects(); |
1881 | ········QueryOwn(); |
1882 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1883 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1884 | ····} |
1885 | ····[Test] |
1886 | ····public void TestSaveReloadNull() |
1887 | ····{ |
1888 | ········CreateObjects(); |
1889 | ········QueryOwn(); |
1890 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1891 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1892 | ········ownVar.RelField = null; |
1893 | ········pm.Save(); |
1894 | ········pm.UnloadCache(); |
1895 | ········QueryOwn(); |
1896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1897 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1898 | ····} |
1899 | ····[Test] |
1900 | ····public void TestChangeKeyHolderLeft() |
1901 | ····{ |
1902 | ········CreateObjects(); |
1903 | ········QueryOwn(); |
1904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1905 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1906 | ········int x = ownVar.RelField.Dummy; |
1907 | ········ownVar.Dummy = 4711; |
1908 | ········pm.Save(); |
1909 | ········pm.UnloadCache(); |
1910 | ········QueryOwn(); |
1911 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1912 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1913 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1914 | ····} |
1915 | ····[Test] |
1916 | ····public void TestChangeKeyHolderRight() |
1917 | ····{ |
1918 | ········CreateObjects(); |
1919 | ········QueryOther(); |
1920 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1921 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1922 | ········int x = otherVar.RelField.Dummy; |
1923 | ········otherVar.Dummy = 4711; |
1924 | ········pm.Save(); |
1925 | ········pm.UnloadCache(); |
1926 | ········QueryOther(); |
1927 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1928 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1929 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1930 | ····} |
1931 | ····[Test] |
1932 | ····public void TestChangeKeyHolderLeftNoTouch() |
1933 | ····{ |
1934 | ········CreateObjects(); |
1935 | ········QueryOwn(); |
1936 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1937 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1938 | ········ownVar.Dummy = 4711; |
1939 | ········pm.Save(); |
1940 | ········pm.UnloadCache(); |
1941 | ········QueryOwn(); |
1942 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1943 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1945 | ····} |
1946 | ····[Test] |
1947 | ····public void TestChangeKeyHolderRightNoTouch() |
1948 | ····{ |
1949 | ········CreateObjects(); |
1950 | ········QueryOther(); |
1951 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1952 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1953 | ········otherVar.Dummy = 4711; |
1954 | ········pm.Save(); |
1955 | ········pm.UnloadCache(); |
1956 | ········QueryOther(); |
1957 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1958 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1959 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1960 | ····} |
1961 | ····[Test] |
1962 | ····public void TestRelationHash() |
1963 | ····{ |
1964 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11TblAutoLeft)); |
1965 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1966 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11TblAutoRight)); |
1967 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1968 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1969 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1970 | ····} |
1971 | ····void CreateObjects() |
1972 | ····{ |
1973 | ········pm.MakePersistent(ownVar); |
1974 | ········ownVar.AssignRelation(otherVar); |
1975 | ········pm.Save(); |
1976 | ········pm.UnloadCache(); |
1977 | ····} |
1978 | ····void QueryOwn() |
1979 | ····{ |
1980 | ········var q = new NDOQuery<CmpBi11TblAutoLeft>(pm); |
1981 | ········ownVar = q.ExecuteSingle(); |
1982 | ····} |
1983 | ····void QueryOther() |
1984 | ····{ |
1985 | ········var q = new NDOQuery<CmpBi11TblAutoRight>(pm); |
1986 | ········otherVar = q.ExecuteSingle(); |
1987 | ····} |
1988 | } |
1989 | |
1990 | |
1991 | [TestFixture] |
1992 | public class TestCmpDirnNoTblAuto : NDOTest |
1993 | { |
1994 | ····CmpDirnNoTblAutoLeft ownVar; |
1995 | ····CmpDirnNoTblAutoRight otherVar; |
1996 | ····PersistenceManager pm; |
1997 | ····[SetUp] |
1998 | ····public void Setup() |
1999 | ····{ |
2000 | ········pm = PmFactory.NewPersistenceManager(); |
2001 | ········ownVar = new CmpDirnNoTblAutoLeft(); |
2002 | ········otherVar = new CmpDirnNoTblAutoRight(); |
2003 | ····} |
2004 | ····[TearDown] |
2005 | ····public void TearDown() |
2006 | ····{ |
2007 | ········try |
2008 | ········{ |
2009 | ············pm.UnloadCache(); |
2010 | ············var l = pm.Objects<CmpDirnNoTblAutoLeft>().ResultTable; |
2011 | ············pm.Delete(l); |
2012 | ············pm.Save(); |
2013 | ············pm.UnloadCache(); |
2014 | ············decimal count; |
2015 | ············count = (decimal) new NDOQuery<CmpDirnNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2016 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2017 | ············count = (decimal) new NDOQuery<CmpDirnNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2018 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2019 | ········} |
2020 | ········catch (Exception) |
2021 | ········{ |
2022 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2023 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2024 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2025 | ········} |
2026 | ····} |
2027 | ····[Test] |
2028 | ····public void TestSaveReload() |
2029 | ····{ |
2030 | ········CreateObjects(); |
2031 | ········QueryOwn(); |
2032 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2033 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2034 | ····} |
2035 | ····[Test] |
2036 | ····public void TestSaveReloadNull() |
2037 | ····{ |
2038 | ········CreateObjects(); |
2039 | ········QueryOwn(); |
2040 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2041 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2042 | ········ownVar.RelField = new List<CmpDirnNoTblAutoRight>(); |
2043 | ········pm.Save(); |
2044 | ········pm.UnloadCache(); |
2045 | ········QueryOwn(); |
2046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2047 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2048 | ····} |
2049 | ····[Test] |
2050 | ····public void TestSaveReloadRemove() |
2051 | ····{ |
2052 | ········CreateObjects(); |
2053 | ········QueryOwn(); |
2054 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2055 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2056 | ········ownVar.RemoveRelatedObject(); |
2057 | ········pm.Save(); |
2058 | ········pm.UnloadCache(); |
2059 | ········QueryOwn(); |
2060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2061 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2062 | ····} |
2063 | ····[Test] |
2064 | ····public void TestUpdateOrder() |
2065 | ····{ |
2066 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2067 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2068 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnNoTblAutoLeft)})) |
2069 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnNoTblAutoRight)})), "Wrong order #1"); |
2070 | ········Debug.WriteLine("CmpDirnNoTblAutoLeft"); |
2071 | ····} |
2072 | ····void CreateObjects() |
2073 | ····{ |
2074 | ········pm.MakePersistent(ownVar); |
2075 | ········ownVar.AssignRelation(otherVar); |
2076 | ········pm.Save(); |
2077 | ········pm.UnloadCache(); |
2078 | ····} |
2079 | ····void QueryOwn() |
2080 | ····{ |
2081 | ········var q = new NDOQuery<CmpDirnNoTblAutoLeft>(pm); |
2082 | ········ownVar = q.ExecuteSingle(); |
2083 | ····} |
2084 | ····void QueryOther() |
2085 | ····{ |
2086 | ········var q = new NDOQuery<CmpDirnNoTblAutoRight>(pm); |
2087 | ········otherVar = q.ExecuteSingle(); |
2088 | ····} |
2089 | } |
2090 | |
2091 | |
2092 | [TestFixture] |
2093 | public class TestCmpDirnTblAuto : NDOTest |
2094 | { |
2095 | ····CmpDirnTblAutoLeft ownVar; |
2096 | ····CmpDirnTblAutoRight otherVar; |
2097 | ····PersistenceManager pm; |
2098 | ····[SetUp] |
2099 | ····public void Setup() |
2100 | ····{ |
2101 | ········pm = PmFactory.NewPersistenceManager(); |
2102 | ········ownVar = new CmpDirnTblAutoLeft(); |
2103 | ········otherVar = new CmpDirnTblAutoRight(); |
2104 | ····} |
2105 | ····[TearDown] |
2106 | ····public void TearDown() |
2107 | ····{ |
2108 | ········try |
2109 | ········{ |
2110 | ············pm.UnloadCache(); |
2111 | ············var l = pm.Objects<CmpDirnTblAutoLeft>().ResultTable; |
2112 | ············pm.Delete(l); |
2113 | ············pm.Save(); |
2114 | ············pm.UnloadCache(); |
2115 | ············decimal count; |
2116 | ············count = (decimal) new NDOQuery<CmpDirnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2117 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2118 | ············count = (decimal) new NDOQuery<CmpDirnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2119 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2120 | ········} |
2121 | ········catch (Exception) |
2122 | ········{ |
2123 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2124 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2125 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2126 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2127 | ········} |
2128 | ····} |
2129 | ····[Test] |
2130 | ····public void TestSaveReload() |
2131 | ····{ |
2132 | ········CreateObjects(); |
2133 | ········QueryOwn(); |
2134 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2135 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2136 | ····} |
2137 | ····[Test] |
2138 | ····public void TestSaveReloadNull() |
2139 | ····{ |
2140 | ········CreateObjects(); |
2141 | ········QueryOwn(); |
2142 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2143 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2144 | ········ownVar.RelField = new List<CmpDirnTblAutoRight>(); |
2145 | ········pm.Save(); |
2146 | ········pm.UnloadCache(); |
2147 | ········QueryOwn(); |
2148 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2149 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2150 | ····} |
2151 | ····[Test] |
2152 | ····public void TestSaveReloadRemove() |
2153 | ····{ |
2154 | ········CreateObjects(); |
2155 | ········QueryOwn(); |
2156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2157 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2158 | ········ownVar.RemoveRelatedObject(); |
2159 | ········pm.Save(); |
2160 | ········pm.UnloadCache(); |
2161 | ········QueryOwn(); |
2162 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2163 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2164 | ····} |
2165 | ····void CreateObjects() |
2166 | ····{ |
2167 | ········pm.MakePersistent(ownVar); |
2168 | ········ownVar.AssignRelation(otherVar); |
2169 | ········pm.Save(); |
2170 | ········pm.UnloadCache(); |
2171 | ····} |
2172 | ····void QueryOwn() |
2173 | ····{ |
2174 | ········var q = new NDOQuery<CmpDirnTblAutoLeft>(pm); |
2175 | ········ownVar = q.ExecuteSingle(); |
2176 | ····} |
2177 | ····void QueryOther() |
2178 | ····{ |
2179 | ········var q = new NDOQuery<CmpDirnTblAutoRight>(pm); |
2180 | ········otherVar = q.ExecuteSingle(); |
2181 | ····} |
2182 | } |
2183 | |
2184 | |
2185 | [TestFixture] |
2186 | public class TestCmpBin1NoTblAuto : NDOTest |
2187 | { |
2188 | ····CmpBin1NoTblAutoLeft ownVar; |
2189 | ····CmpBin1NoTblAutoRight otherVar; |
2190 | ····PersistenceManager pm; |
2191 | ····[SetUp] |
2192 | ····public void Setup() |
2193 | ····{ |
2194 | ········pm = PmFactory.NewPersistenceManager(); |
2195 | ········ownVar = new CmpBin1NoTblAutoLeft(); |
2196 | ········otherVar = new CmpBin1NoTblAutoRight(); |
2197 | ····} |
2198 | ····[TearDown] |
2199 | ····public void TearDown() |
2200 | ····{ |
2201 | ········try |
2202 | ········{ |
2203 | ············pm.UnloadCache(); |
2204 | ············var l = pm.Objects<CmpBin1NoTblAutoLeft>().ResultTable; |
2205 | ············pm.Delete(l); |
2206 | ············pm.Save(); |
2207 | ············pm.UnloadCache(); |
2208 | ············decimal count; |
2209 | ············count = (decimal) new NDOQuery<CmpBin1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2210 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2211 | ············count = (decimal) new NDOQuery<CmpBin1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2212 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2213 | ········} |
2214 | ········catch (Exception) |
2215 | ········{ |
2216 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2218 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2219 | ········} |
2220 | ····} |
2221 | ····[Test] |
2222 | ····public void TestSaveReload() |
2223 | ····{ |
2224 | ········CreateObjects(); |
2225 | ········QueryOwn(); |
2226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2227 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2228 | ····} |
2229 | ····[Test] |
2230 | ····public void TestSaveReloadNull() |
2231 | ····{ |
2232 | ········CreateObjects(); |
2233 | ········QueryOwn(); |
2234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2235 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2236 | ········ownVar.RelField = new List<CmpBin1NoTblAutoRight>(); |
2237 | ········pm.Save(); |
2238 | ········pm.UnloadCache(); |
2239 | ········QueryOwn(); |
2240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2241 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2242 | ····} |
2243 | ····[Test] |
2244 | ····public void TestSaveReloadRemove() |
2245 | ····{ |
2246 | ········CreateObjects(); |
2247 | ········QueryOwn(); |
2248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2249 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2250 | ········ownVar.RemoveRelatedObject(); |
2251 | ········pm.Save(); |
2252 | ········pm.UnloadCache(); |
2253 | ········QueryOwn(); |
2254 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2255 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2256 | ····} |
2257 | ····[Test] |
2258 | ····public void TestChangeKeyHolderRight() |
2259 | ····{ |
2260 | ········CreateObjects(); |
2261 | ········QueryOther(); |
2262 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2263 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2264 | ········int x = otherVar.RelField.Dummy; |
2265 | ········otherVar.Dummy = 4711; |
2266 | ········pm.Save(); |
2267 | ········pm.UnloadCache(); |
2268 | ········QueryOther(); |
2269 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2270 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2271 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2272 | ····} |
2273 | ····[Test] |
2274 | ····public void TestChangeKeyHolderRightNoTouch() |
2275 | ····{ |
2276 | ········CreateObjects(); |
2277 | ········QueryOther(); |
2278 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2279 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2280 | ········otherVar.Dummy = 4711; |
2281 | ········pm.Save(); |
2282 | ········pm.UnloadCache(); |
2283 | ········QueryOther(); |
2284 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2285 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2286 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2287 | ····} |
2288 | ····[Test] |
2289 | ····public void TestUpdateOrder() |
2290 | ····{ |
2291 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2292 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2293 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1NoTblAutoLeft)})) |
2294 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1NoTblAutoRight)})), "Wrong order #1"); |
2295 | ········Debug.WriteLine("CmpBin1NoTblAutoLeft"); |
2296 | ····} |
2297 | ····[Test] |
2298 | ····public void TestRelationHash() |
2299 | ····{ |
2300 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblAutoLeft)); |
2301 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2302 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblAutoRight)); |
2303 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2304 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2305 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2306 | ····} |
2307 | ····void CreateObjects() |
2308 | ····{ |
2309 | ········pm.MakePersistent(ownVar); |
2310 | ········ownVar.AssignRelation(otherVar); |
2311 | ········pm.Save(); |
2312 | ········pm.UnloadCache(); |
2313 | ····} |
2314 | ····void QueryOwn() |
2315 | ····{ |
2316 | ········var q = new NDOQuery<CmpBin1NoTblAutoLeft>(pm); |
2317 | ········ownVar = q.ExecuteSingle(); |
2318 | ····} |
2319 | ····void QueryOther() |
2320 | ····{ |
2321 | ········var q = new NDOQuery<CmpBin1NoTblAutoRight>(pm); |
2322 | ········otherVar = q.ExecuteSingle(); |
2323 | ····} |
2324 | } |
2325 | |
2326 | |
2327 | [TestFixture] |
2328 | public class TestCmpBin1TblAuto : NDOTest |
2329 | { |
2330 | ····CmpBin1TblAutoLeft ownVar; |
2331 | ····CmpBin1TblAutoRight otherVar; |
2332 | ····PersistenceManager pm; |
2333 | ····[SetUp] |
2334 | ····public void Setup() |
2335 | ····{ |
2336 | ········pm = PmFactory.NewPersistenceManager(); |
2337 | ········ownVar = new CmpBin1TblAutoLeft(); |
2338 | ········otherVar = new CmpBin1TblAutoRight(); |
2339 | ····} |
2340 | ····[TearDown] |
2341 | ····public void TearDown() |
2342 | ····{ |
2343 | ········try |
2344 | ········{ |
2345 | ············pm.UnloadCache(); |
2346 | ············var l = pm.Objects<CmpBin1TblAutoLeft>().ResultTable; |
2347 | ············pm.Delete(l); |
2348 | ············pm.Save(); |
2349 | ············pm.UnloadCache(); |
2350 | ············decimal count; |
2351 | ············count = (decimal) new NDOQuery<CmpBin1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2352 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2353 | ············count = (decimal) new NDOQuery<CmpBin1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2354 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2355 | ········} |
2356 | ········catch (Exception) |
2357 | ········{ |
2358 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2359 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2360 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2361 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2362 | ········} |
2363 | ····} |
2364 | ····[Test] |
2365 | ····public void TestSaveReload() |
2366 | ····{ |
2367 | ········CreateObjects(); |
2368 | ········QueryOwn(); |
2369 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2370 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2371 | ····} |
2372 | ····[Test] |
2373 | ····public void TestSaveReloadNull() |
2374 | ····{ |
2375 | ········CreateObjects(); |
2376 | ········QueryOwn(); |
2377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2378 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2379 | ········ownVar.RelField = new List<CmpBin1TblAutoRight>(); |
2380 | ········pm.Save(); |
2381 | ········pm.UnloadCache(); |
2382 | ········QueryOwn(); |
2383 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2384 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2385 | ····} |
2386 | ····[Test] |
2387 | ····public void TestSaveReloadRemove() |
2388 | ····{ |
2389 | ········CreateObjects(); |
2390 | ········QueryOwn(); |
2391 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2392 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2393 | ········ownVar.RemoveRelatedObject(); |
2394 | ········pm.Save(); |
2395 | ········pm.UnloadCache(); |
2396 | ········QueryOwn(); |
2397 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2398 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2399 | ····} |
2400 | ····[Test] |
2401 | ····public void TestChangeKeyHolderRight() |
2402 | ····{ |
2403 | ········CreateObjects(); |
2404 | ········QueryOther(); |
2405 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2406 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2407 | ········int x = otherVar.RelField.Dummy; |
2408 | ········otherVar.Dummy = 4711; |
2409 | ········pm.Save(); |
2410 | ········pm.UnloadCache(); |
2411 | ········QueryOther(); |
2412 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2413 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2414 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2415 | ····} |
2416 | ····[Test] |
2417 | ····public void TestChangeKeyHolderRightNoTouch() |
2418 | ····{ |
2419 | ········CreateObjects(); |
2420 | ········QueryOther(); |
2421 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2422 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2423 | ········otherVar.Dummy = 4711; |
2424 | ········pm.Save(); |
2425 | ········pm.UnloadCache(); |
2426 | ········QueryOther(); |
2427 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2428 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2429 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2430 | ····} |
2431 | ····[Test] |
2432 | ····public void TestRelationHash() |
2433 | ····{ |
2434 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1TblAutoLeft)); |
2435 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2436 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1TblAutoRight)); |
2437 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2438 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2439 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2440 | ····} |
2441 | ····void CreateObjects() |
2442 | ····{ |
2443 | ········pm.MakePersistent(ownVar); |
2444 | ········ownVar.AssignRelation(otherVar); |
2445 | ········pm.Save(); |
2446 | ········pm.UnloadCache(); |
2447 | ····} |
2448 | ····void QueryOwn() |
2449 | ····{ |
2450 | ········var q = new NDOQuery<CmpBin1TblAutoLeft>(pm); |
2451 | ········ownVar = q.ExecuteSingle(); |
2452 | ····} |
2453 | ····void QueryOther() |
2454 | ····{ |
2455 | ········var q = new NDOQuery<CmpBin1TblAutoRight>(pm); |
2456 | ········otherVar = q.ExecuteSingle(); |
2457 | ····} |
2458 | } |
2459 | |
2460 | |
2461 | [TestFixture] |
2462 | public class TestCmpBi1nNoTblAuto : NDOTest |
2463 | { |
2464 | ····CmpBi1nNoTblAutoLeft ownVar; |
2465 | ····CmpBi1nNoTblAutoRight otherVar; |
2466 | ····PersistenceManager pm; |
2467 | ····[SetUp] |
2468 | ····public void Setup() |
2469 | ····{ |
2470 | ········pm = PmFactory.NewPersistenceManager(); |
2471 | ········ownVar = new CmpBi1nNoTblAutoLeft(); |
2472 | ········otherVar = new CmpBi1nNoTblAutoRight(); |
2473 | ····} |
2474 | ····[TearDown] |
2475 | ····public void TearDown() |
2476 | ····{ |
2477 | ········try |
2478 | ········{ |
2479 | ············pm.UnloadCache(); |
2480 | ············var l = pm.Objects<CmpBi1nNoTblAutoLeft>().ResultTable; |
2481 | ············pm.Delete(l); |
2482 | ············pm.Save(); |
2483 | ············pm.UnloadCache(); |
2484 | ············decimal count; |
2485 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2486 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2487 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2488 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2489 | ········} |
2490 | ········catch (Exception) |
2491 | ········{ |
2492 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2493 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2494 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2495 | ········} |
2496 | ····} |
2497 | ····[Test] |
2498 | ····public void TestSaveReload() |
2499 | ····{ |
2500 | ········CreateObjects(); |
2501 | ········QueryOwn(); |
2502 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2503 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2504 | ····} |
2505 | ····[Test] |
2506 | ····public void TestSaveReloadNull() |
2507 | ····{ |
2508 | ········CreateObjects(); |
2509 | ········QueryOwn(); |
2510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2511 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2512 | ········ownVar.RelField = null; |
2513 | ········pm.Save(); |
2514 | ········pm.UnloadCache(); |
2515 | ········QueryOwn(); |
2516 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2517 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2518 | ····} |
2519 | ····[Test] |
2520 | ····public void TestChangeKeyHolderLeft() |
2521 | ····{ |
2522 | ········CreateObjects(); |
2523 | ········QueryOwn(); |
2524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2525 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2526 | ········int x = ownVar.RelField.Dummy; |
2527 | ········ownVar.Dummy = 4711; |
2528 | ········pm.Save(); |
2529 | ········pm.UnloadCache(); |
2530 | ········QueryOwn(); |
2531 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2532 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2533 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2534 | ····} |
2535 | ····[Test] |
2536 | ····public void TestChangeKeyHolderLeftNoTouch() |
2537 | ····{ |
2538 | ········CreateObjects(); |
2539 | ········QueryOwn(); |
2540 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2541 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2542 | ········ownVar.Dummy = 4711; |
2543 | ········pm.Save(); |
2544 | ········pm.UnloadCache(); |
2545 | ········QueryOwn(); |
2546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2547 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2548 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2549 | ····} |
2550 | ····[Test] |
2551 | ····public void TestUpdateOrder() |
2552 | ····{ |
2553 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2554 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2555 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBi1nNoTblAutoLeft)})) |
2556 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpBi1nNoTblAutoRight)})), "Wrong order #1"); |
2557 | ········Debug.WriteLine("CmpBi1nNoTblAutoLeft"); |
2558 | ····} |
2559 | ····[Test] |
2560 | ····public void TestRelationHash() |
2561 | ····{ |
2562 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblAutoLeft)); |
2563 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2564 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblAutoRight)); |
2565 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2566 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2567 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2568 | ····} |
2569 | ····void CreateObjects() |
2570 | ····{ |
2571 | ········pm.MakePersistent(ownVar); |
2572 | ········ownVar.AssignRelation(otherVar); |
2573 | ········pm.Save(); |
2574 | ········pm.UnloadCache(); |
2575 | ····} |
2576 | ····void QueryOwn() |
2577 | ····{ |
2578 | ········var q = new NDOQuery<CmpBi1nNoTblAutoLeft>(pm); |
2579 | ········ownVar = q.ExecuteSingle(); |
2580 | ····} |
2581 | ····void QueryOther() |
2582 | ····{ |
2583 | ········var q = new NDOQuery<CmpBi1nNoTblAutoRight>(pm); |
2584 | ········otherVar = q.ExecuteSingle(); |
2585 | ····} |
2586 | } |
2587 | |
2588 | |
2589 | [TestFixture] |
2590 | public class TestCmpBi1nTblAuto : NDOTest |
2591 | { |
2592 | ····CmpBi1nTblAutoLeft ownVar; |
2593 | ····CmpBi1nTblAutoRight otherVar; |
2594 | ····PersistenceManager pm; |
2595 | ····[SetUp] |
2596 | ····public void Setup() |
2597 | ····{ |
2598 | ········pm = PmFactory.NewPersistenceManager(); |
2599 | ········ownVar = new CmpBi1nTblAutoLeft(); |
2600 | ········otherVar = new CmpBi1nTblAutoRight(); |
2601 | ····} |
2602 | ····[TearDown] |
2603 | ····public void TearDown() |
2604 | ····{ |
2605 | ········try |
2606 | ········{ |
2607 | ············pm.UnloadCache(); |
2608 | ············var l = pm.Objects<CmpBi1nTblAutoLeft>().ResultTable; |
2609 | ············pm.Delete(l); |
2610 | ············pm.Save(); |
2611 | ············pm.UnloadCache(); |
2612 | ············decimal count; |
2613 | ············count = (decimal) new NDOQuery<CmpBi1nTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2614 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2615 | ············count = (decimal) new NDOQuery<CmpBi1nTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2616 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2617 | ········} |
2618 | ········catch (Exception) |
2619 | ········{ |
2620 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2621 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2622 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2623 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2624 | ········} |
2625 | ····} |
2626 | ····[Test] |
2627 | ····public void TestSaveReload() |
2628 | ····{ |
2629 | ········CreateObjects(); |
2630 | ········QueryOwn(); |
2631 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2632 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2633 | ····} |
2634 | ····[Test] |
2635 | ····public void TestSaveReloadNull() |
2636 | ····{ |
2637 | ········CreateObjects(); |
2638 | ········QueryOwn(); |
2639 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2640 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2641 | ········ownVar.RelField = null; |
2642 | ········pm.Save(); |
2643 | ········pm.UnloadCache(); |
2644 | ········QueryOwn(); |
2645 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2646 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2647 | ····} |
2648 | ····[Test] |
2649 | ····public void TestChangeKeyHolderLeft() |
2650 | ····{ |
2651 | ········CreateObjects(); |
2652 | ········QueryOwn(); |
2653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2654 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2655 | ········int x = ownVar.RelField.Dummy; |
2656 | ········ownVar.Dummy = 4711; |
2657 | ········pm.Save(); |
2658 | ········pm.UnloadCache(); |
2659 | ········QueryOwn(); |
2660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2661 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2662 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2663 | ····} |
2664 | ····[Test] |
2665 | ····public void TestChangeKeyHolderLeftNoTouch() |
2666 | ····{ |
2667 | ········CreateObjects(); |
2668 | ········QueryOwn(); |
2669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2670 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2671 | ········ownVar.Dummy = 4711; |
2672 | ········pm.Save(); |
2673 | ········pm.UnloadCache(); |
2674 | ········QueryOwn(); |
2675 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2676 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2677 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2678 | ····} |
2679 | ····[Test] |
2680 | ····public void TestRelationHash() |
2681 | ····{ |
2682 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nTblAutoLeft)); |
2683 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2684 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nTblAutoRight)); |
2685 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2686 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2687 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2688 | ····} |
2689 | ····void CreateObjects() |
2690 | ····{ |
2691 | ········pm.MakePersistent(ownVar); |
2692 | ········ownVar.AssignRelation(otherVar); |
2693 | ········pm.Save(); |
2694 | ········pm.UnloadCache(); |
2695 | ····} |
2696 | ····void QueryOwn() |
2697 | ····{ |
2698 | ········var q = new NDOQuery<CmpBi1nTblAutoLeft>(pm); |
2699 | ········ownVar = q.ExecuteSingle(); |
2700 | ····} |
2701 | ····void QueryOther() |
2702 | ····{ |
2703 | ········var q = new NDOQuery<CmpBi1nTblAutoRight>(pm); |
2704 | ········otherVar = q.ExecuteSingle(); |
2705 | ····} |
2706 | } |
2707 | |
2708 | |
2709 | [TestFixture] |
2710 | public class TestCmpBinnTblAuto : NDOTest |
2711 | { |
2712 | ····CmpBinnTblAutoLeft ownVar; |
2713 | ····CmpBinnTblAutoRight otherVar; |
2714 | ····PersistenceManager pm; |
2715 | ····[SetUp] |
2716 | ····public void Setup() |
2717 | ····{ |
2718 | ········pm = PmFactory.NewPersistenceManager(); |
2719 | ········ownVar = new CmpBinnTblAutoLeft(); |
2720 | ········otherVar = new CmpBinnTblAutoRight(); |
2721 | ····} |
2722 | ····[TearDown] |
2723 | ····public void TearDown() |
2724 | ····{ |
2725 | ········try |
2726 | ········{ |
2727 | ············pm.UnloadCache(); |
2728 | ············var l = pm.Objects<CmpBinnTblAutoLeft>().ResultTable; |
2729 | ············pm.Delete(l); |
2730 | ············pm.Save(); |
2731 | ············pm.UnloadCache(); |
2732 | ············decimal count; |
2733 | ············count = (decimal) new NDOQuery<CmpBinnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2734 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2735 | ············count = (decimal) new NDOQuery<CmpBinnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2736 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2737 | ········} |
2738 | ········catch (Exception) |
2739 | ········{ |
2740 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2741 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2742 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2743 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2744 | ········} |
2745 | ····} |
2746 | ····[Test] |
2747 | ····public void TestSaveReload() |
2748 | ····{ |
2749 | ········CreateObjects(); |
2750 | ········QueryOwn(); |
2751 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2752 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2753 | ····} |
2754 | ····[Test] |
2755 | ····public void TestSaveReloadNull() |
2756 | ····{ |
2757 | ········CreateObjects(); |
2758 | ········QueryOwn(); |
2759 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2760 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2761 | ········ownVar.RelField = new List<CmpBinnTblAutoRight>(); |
2762 | ········pm.Save(); |
2763 | ········pm.UnloadCache(); |
2764 | ········QueryOwn(); |
2765 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2766 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2767 | ····} |
2768 | ····[Test] |
2769 | ····public void TestSaveReloadRemove() |
2770 | ····{ |
2771 | ········CreateObjects(); |
2772 | ········QueryOwn(); |
2773 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2774 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2775 | ········ownVar.RemoveRelatedObject(); |
2776 | ········pm.Save(); |
2777 | ········pm.UnloadCache(); |
2778 | ········QueryOwn(); |
2779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2780 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2781 | ····} |
2782 | ····[Test] |
2783 | ····public void TestRelationHash() |
2784 | ····{ |
2785 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnTblAutoLeft)); |
2786 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2787 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnTblAutoRight)); |
2788 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2789 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2790 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2791 | ····} |
2792 | ····void CreateObjects() |
2793 | ····{ |
2794 | ········pm.MakePersistent(ownVar); |
2795 | ········ownVar.AssignRelation(otherVar); |
2796 | ········pm.Save(); |
2797 | ········pm.UnloadCache(); |
2798 | ····} |
2799 | ····void QueryOwn() |
2800 | ····{ |
2801 | ········var q = new NDOQuery<CmpBinnTblAutoLeft>(pm); |
2802 | ········ownVar = q.ExecuteSingle(); |
2803 | ····} |
2804 | ····void QueryOther() |
2805 | ····{ |
2806 | ········var q = new NDOQuery<CmpBinnTblAutoRight>(pm); |
2807 | ········otherVar = q.ExecuteSingle(); |
2808 | ····} |
2809 | } |
2810 | |
2811 | |
2812 | [TestFixture] |
2813 | public class TestAgrDir1OwnpconNoTblAuto : NDOTest |
2814 | { |
2815 | ····AgrDir1OwnpconNoTblAutoLeftBase ownVar; |
2816 | ····AgrDir1OwnpconNoTblAutoRight otherVar; |
2817 | ····PersistenceManager pm; |
2818 | ····[SetUp] |
2819 | ····public void Setup() |
2820 | ····{ |
2821 | ········pm = PmFactory.NewPersistenceManager(); |
2822 | ········ownVar = new AgrDir1OwnpconNoTblAutoLeftDerived(); |
2823 | ········otherVar = new AgrDir1OwnpconNoTblAutoRight(); |
2824 | ····} |
2825 | ····[TearDown] |
2826 | ····public void TearDown() |
2827 | ····{ |
2828 | ········try |
2829 | ········{ |
2830 | ············pm.UnloadCache(); |
2831 | ············var l = pm.Objects<AgrDir1OwnpconNoTblAutoLeftBase>().ResultTable; |
2832 | ············pm.Delete(l); |
2833 | ············pm.Save(); |
2834 | ············pm.UnloadCache(); |
2835 | ············var m = pm.Objects<AgrDir1OwnpconNoTblAutoRight>().ResultTable; |
2836 | ············pm.Delete(m); |
2837 | ············pm.Save(); |
2838 | ············pm.UnloadCache(); |
2839 | ············decimal count; |
2840 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2841 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2842 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2843 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2844 | ········} |
2845 | ········catch (Exception) |
2846 | ········{ |
2847 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2848 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2849 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2850 | ········} |
2851 | ····} |
2852 | ····[Test] |
2853 | ····public void TestSaveReload() |
2854 | ····{ |
2855 | ········CreateObjects(); |
2856 | ········QueryOwn(); |
2857 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2858 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2859 | ····} |
2860 | ····[Test] |
2861 | ····public void TestSaveReloadNull() |
2862 | ····{ |
2863 | ········CreateObjects(); |
2864 | ········QueryOwn(); |
2865 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2866 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2867 | ········ownVar.RelField = null; |
2868 | ········pm.Save(); |
2869 | ········pm.UnloadCache(); |
2870 | ········QueryOwn(); |
2871 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2872 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2873 | ····} |
2874 | ····[Test] |
2875 | ····public void TestChangeKeyHolderLeft() |
2876 | ····{ |
2877 | ········CreateObjects(); |
2878 | ········QueryOwn(); |
2879 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2880 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2881 | ········int x = ownVar.RelField.Dummy; |
2882 | ········ownVar.Dummy = 4711; |
2883 | ········pm.Save(); |
2884 | ········pm.UnloadCache(); |
2885 | ········QueryOwn(); |
2886 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2887 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2888 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2889 | ····} |
2890 | ····[Test] |
2891 | ····public void TestChangeKeyHolderLeftNoTouch() |
2892 | ····{ |
2893 | ········CreateObjects(); |
2894 | ········QueryOwn(); |
2895 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2896 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2897 | ········ownVar.Dummy = 4711; |
2898 | ········pm.Save(); |
2899 | ········pm.UnloadCache(); |
2900 | ········QueryOwn(); |
2901 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2902 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2903 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2904 | ····} |
2905 | ····[Test] |
2906 | ····public void TestUpdateOrder() |
2907 | ····{ |
2908 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2909 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2910 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoLeftBase)})) |
2911 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
2912 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoLeftDerived)})) |
2913 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
2914 | ········Debug.WriteLine("AgrDir1OwnpconNoTblAutoLeftBase"); |
2915 | ····} |
2916 | ····void CreateObjects() |
2917 | ····{ |
2918 | ········pm.MakePersistent(ownVar); |
2919 | ········pm.MakePersistent(otherVar); |
2920 | ········ownVar.AssignRelation(otherVar); |
2921 | ········pm.Save(); |
2922 | ········pm.UnloadCache(); |
2923 | ····} |
2924 | ····void QueryOwn() |
2925 | ····{ |
2926 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblAutoLeftBase>(pm); |
2927 | ········ownVar = q.ExecuteSingle(); |
2928 | ····} |
2929 | ····void QueryOther() |
2930 | ····{ |
2931 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblAutoRight>(pm); |
2932 | ········otherVar = q.ExecuteSingle(); |
2933 | ····} |
2934 | } |
2935 | |
2936 | |
2937 | [TestFixture] |
2938 | public class TestAgrDir1OwnpconTblAuto : NDOTest |
2939 | { |
2940 | ····AgrDir1OwnpconTblAutoLeftBase ownVar; |
2941 | ····AgrDir1OwnpconTblAutoRight otherVar; |
2942 | ····PersistenceManager pm; |
2943 | ····[SetUp] |
2944 | ····public void Setup() |
2945 | ····{ |
2946 | ········pm = PmFactory.NewPersistenceManager(); |
2947 | ········ownVar = new AgrDir1OwnpconTblAutoLeftDerived(); |
2948 | ········otherVar = new AgrDir1OwnpconTblAutoRight(); |
2949 | ····} |
2950 | ····[TearDown] |
2951 | ····public void TearDown() |
2952 | ····{ |
2953 | ········try |
2954 | ········{ |
2955 | ············pm.UnloadCache(); |
2956 | ············var l = pm.Objects<AgrDir1OwnpconTblAutoLeftBase>().ResultTable; |
2957 | ············pm.Delete(l); |
2958 | ············pm.Save(); |
2959 | ············pm.UnloadCache(); |
2960 | ············var m = pm.Objects<AgrDir1OwnpconTblAutoRight>().ResultTable; |
2961 | ············pm.Delete(m); |
2962 | ············pm.Save(); |
2963 | ············pm.UnloadCache(); |
2964 | ············decimal count; |
2965 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2966 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2967 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2968 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2969 | ········} |
2970 | ········catch (Exception) |
2971 | ········{ |
2972 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2973 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2974 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2975 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2976 | ········} |
2977 | ····} |
2978 | ····[Test] |
2979 | ····public void TestSaveReload() |
2980 | ····{ |
2981 | ········CreateObjects(); |
2982 | ········QueryOwn(); |
2983 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2984 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2985 | ····} |
2986 | ····[Test] |
2987 | ····public void TestSaveReloadNull() |
2988 | ····{ |
2989 | ········CreateObjects(); |
2990 | ········QueryOwn(); |
2991 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2992 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2993 | ········ownVar.RelField = null; |
2994 | ········pm.Save(); |
2995 | ········pm.UnloadCache(); |
2996 | ········QueryOwn(); |
2997 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2998 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2999 | ····} |
3000 | ····[Test] |
3001 | ····public void TestChangeKeyHolderLeft() |
3002 | ····{ |
3003 | ········CreateObjects(); |
3004 | ········QueryOwn(); |
3005 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3006 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3007 | ········int x = ownVar.RelField.Dummy; |
3008 | ········ownVar.Dummy = 4711; |
3009 | ········pm.Save(); |
3010 | ········pm.UnloadCache(); |
3011 | ········QueryOwn(); |
3012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3013 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3014 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3015 | ····} |
3016 | ····[Test] |
3017 | ····public void TestChangeKeyHolderLeftNoTouch() |
3018 | ····{ |
3019 | ········CreateObjects(); |
3020 | ········QueryOwn(); |
3021 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3022 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3023 | ········ownVar.Dummy = 4711; |
3024 | ········pm.Save(); |
3025 | ········pm.UnloadCache(); |
3026 | ········QueryOwn(); |
3027 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3028 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3029 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3030 | ····} |
3031 | ····void CreateObjects() |
3032 | ····{ |
3033 | ········pm.MakePersistent(ownVar); |
3034 | ········pm.MakePersistent(otherVar); |
3035 | ········ownVar.AssignRelation(otherVar); |
3036 | ········pm.Save(); |
3037 | ········pm.UnloadCache(); |
3038 | ····} |
3039 | ····void QueryOwn() |
3040 | ····{ |
3041 | ········var q = new NDOQuery<AgrDir1OwnpconTblAutoLeftBase>(pm); |
3042 | ········ownVar = q.ExecuteSingle(); |
3043 | ····} |
3044 | ····void QueryOther() |
3045 | ····{ |
3046 | ········var q = new NDOQuery<AgrDir1OwnpconTblAutoRight>(pm); |
3047 | ········otherVar = q.ExecuteSingle(); |
3048 | ····} |
3049 | } |
3050 | |
3051 | |
3052 | [TestFixture] |
3053 | public class TestAgrBi11OwnpconNoTblAuto : NDOTest |
3054 | { |
3055 | ····AgrBi11OwnpconNoTblAutoLeftBase ownVar; |
3056 | ····AgrBi11OwnpconNoTblAutoRight otherVar; |
3057 | ····PersistenceManager pm; |
3058 | ····[SetUp] |
3059 | ····public void Setup() |
3060 | ····{ |
3061 | ········pm = PmFactory.NewPersistenceManager(); |
3062 | ········ownVar = new AgrBi11OwnpconNoTblAutoLeftDerived(); |
3063 | ········otherVar = new AgrBi11OwnpconNoTblAutoRight(); |
3064 | ····} |
3065 | ····[TearDown] |
3066 | ····public void TearDown() |
3067 | ····{ |
3068 | ········try |
3069 | ········{ |
3070 | ············pm.UnloadCache(); |
3071 | ············var l = pm.Objects<AgrBi11OwnpconNoTblAutoLeftBase>().ResultTable; |
3072 | ············pm.Delete(l); |
3073 | ············pm.Save(); |
3074 | ············pm.UnloadCache(); |
3075 | ············var m = pm.Objects<AgrBi11OwnpconNoTblAutoRight>().ResultTable; |
3076 | ············pm.Delete(m); |
3077 | ············pm.Save(); |
3078 | ············pm.UnloadCache(); |
3079 | ············decimal count; |
3080 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3081 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3082 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3083 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3084 | ········} |
3085 | ········catch (Exception) |
3086 | ········{ |
3087 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3088 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3089 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3090 | ········} |
3091 | ····} |
3092 | ····[Test] |
3093 | ····public void TestSaveReload() |
3094 | ····{ |
3095 | ········CreateObjects(); |
3096 | ········QueryOwn(); |
3097 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3098 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3099 | ····} |
3100 | ····[Test] |
3101 | ····public void TestSaveReloadNull() |
3102 | ····{ |
3103 | ········CreateObjects(); |
3104 | ········QueryOwn(); |
3105 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3106 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3107 | ········ownVar.RelField = null; |
3108 | ········pm.Save(); |
3109 | ········pm.UnloadCache(); |
3110 | ········QueryOwn(); |
3111 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3112 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3113 | ····} |
3114 | ····[Test] |
3115 | ····public void TestChangeKeyHolderLeft() |
3116 | ····{ |
3117 | ········CreateObjects(); |
3118 | ········QueryOwn(); |
3119 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3120 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3121 | ········int x = ownVar.RelField.Dummy; |
3122 | ········ownVar.Dummy = 4711; |
3123 | ········pm.Save(); |
3124 | ········pm.UnloadCache(); |
3125 | ········QueryOwn(); |
3126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3127 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3128 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3129 | ····} |
3130 | ····[Test] |
3131 | ····public void TestChangeKeyHolderRight() |
3132 | ····{ |
3133 | ········CreateObjects(); |
3134 | ········QueryOther(); |
3135 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3136 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3137 | ········int x = otherVar.RelField.Dummy; |
3138 | ········otherVar.Dummy = 4711; |
3139 | ········pm.Save(); |
3140 | ········pm.UnloadCache(); |
3141 | ········QueryOther(); |
3142 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3143 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3144 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3145 | ····} |
3146 | ····[Test] |
3147 | ····public void TestChangeKeyHolderLeftNoTouch() |
3148 | ····{ |
3149 | ········CreateObjects(); |
3150 | ········QueryOwn(); |
3151 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3152 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3153 | ········ownVar.Dummy = 4711; |
3154 | ········pm.Save(); |
3155 | ········pm.UnloadCache(); |
3156 | ········QueryOwn(); |
3157 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3158 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3159 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3160 | ····} |
3161 | ····[Test] |
3162 | ····public void TestChangeKeyHolderRightNoTouch() |
3163 | ····{ |
3164 | ········CreateObjects(); |
3165 | ········QueryOther(); |
3166 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3167 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3168 | ········otherVar.Dummy = 4711; |
3169 | ········pm.Save(); |
3170 | ········pm.UnloadCache(); |
3171 | ········QueryOther(); |
3172 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3173 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3174 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3175 | ····} |
3176 | ····[Test] |
3177 | ····public void TestRelationHash() |
3178 | ····{ |
3179 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoLeftBase)); |
3180 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3181 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoRight)); |
3182 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3183 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3184 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3185 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoLeftDerived)); |
3186 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3187 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3188 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3189 | ····} |
3190 | ····void CreateObjects() |
3191 | ····{ |
3192 | ········pm.MakePersistent(ownVar); |
3193 | ········pm.MakePersistent(otherVar); |
3194 | ········pm.Save(); |
3195 | ········ownVar.AssignRelation(otherVar); |
3196 | ········pm.Save(); |
3197 | ········pm.UnloadCache(); |
3198 | ····} |
3199 | ····void QueryOwn() |
3200 | ····{ |
3201 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblAutoLeftBase>(pm); |
3202 | ········ownVar = q.ExecuteSingle(); |
3203 | ····} |
3204 | ····void QueryOther() |
3205 | ····{ |
3206 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblAutoRight>(pm); |
3207 | ········otherVar = q.ExecuteSingle(); |
3208 | ····} |
3209 | } |
3210 | |
3211 | |
3212 | [TestFixture] |
3213 | public class TestAgrBi11OwnpconTblAuto : NDOTest |
3214 | { |
3215 | ····AgrBi11OwnpconTblAutoLeftBase ownVar; |
3216 | ····AgrBi11OwnpconTblAutoRight otherVar; |
3217 | ····PersistenceManager pm; |
3218 | ····[SetUp] |
3219 | ····public void Setup() |
3220 | ····{ |
3221 | ········pm = PmFactory.NewPersistenceManager(); |
3222 | ········ownVar = new AgrBi11OwnpconTblAutoLeftDerived(); |
3223 | ········otherVar = new AgrBi11OwnpconTblAutoRight(); |
3224 | ····} |
3225 | ····[TearDown] |
3226 | ····public void TearDown() |
3227 | ····{ |
3228 | ········try |
3229 | ········{ |
3230 | ············pm.UnloadCache(); |
3231 | ············var l = pm.Objects<AgrBi11OwnpconTblAutoLeftBase>().ResultTable; |
3232 | ············pm.Delete(l); |
3233 | ············pm.Save(); |
3234 | ············pm.UnloadCache(); |
3235 | ············var m = pm.Objects<AgrBi11OwnpconTblAutoRight>().ResultTable; |
3236 | ············pm.Delete(m); |
3237 | ············pm.Save(); |
3238 | ············pm.UnloadCache(); |
3239 | ············decimal count; |
3240 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3241 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3242 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3243 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3244 | ········} |
3245 | ········catch (Exception) |
3246 | ········{ |
3247 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3248 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3249 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3250 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3251 | ········} |
3252 | ····} |
3253 | ····[Test] |
3254 | ····public void TestSaveReload() |
3255 | ····{ |
3256 | ········CreateObjects(); |
3257 | ········QueryOwn(); |
3258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3259 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3260 | ····} |
3261 | ····[Test] |
3262 | ····public void TestSaveReloadNull() |
3263 | ····{ |
3264 | ········CreateObjects(); |
3265 | ········QueryOwn(); |
3266 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3268 | ········ownVar.RelField = null; |
3269 | ········pm.Save(); |
3270 | ········pm.UnloadCache(); |
3271 | ········QueryOwn(); |
3272 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3273 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3274 | ····} |
3275 | ····[Test] |
3276 | ····public void TestChangeKeyHolderLeft() |
3277 | ····{ |
3278 | ········CreateObjects(); |
3279 | ········QueryOwn(); |
3280 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3281 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3282 | ········int x = ownVar.RelField.Dummy; |
3283 | ········ownVar.Dummy = 4711; |
3284 | ········pm.Save(); |
3285 | ········pm.UnloadCache(); |
3286 | ········QueryOwn(); |
3287 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3288 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3289 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3290 | ····} |
3291 | ····[Test] |
3292 | ····public void TestChangeKeyHolderRight() |
3293 | ····{ |
3294 | ········CreateObjects(); |
3295 | ········QueryOther(); |
3296 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3297 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3298 | ········int x = otherVar.RelField.Dummy; |
3299 | ········otherVar.Dummy = 4711; |
3300 | ········pm.Save(); |
3301 | ········pm.UnloadCache(); |
3302 | ········QueryOther(); |
3303 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3304 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3305 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3306 | ····} |
3307 | ····[Test] |
3308 | ····public void TestChangeKeyHolderLeftNoTouch() |
3309 | ····{ |
3310 | ········CreateObjects(); |
3311 | ········QueryOwn(); |
3312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3313 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3314 | ········ownVar.Dummy = 4711; |
3315 | ········pm.Save(); |
3316 | ········pm.UnloadCache(); |
3317 | ········QueryOwn(); |
3318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3319 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3321 | ····} |
3322 | ····[Test] |
3323 | ····public void TestChangeKeyHolderRightNoTouch() |
3324 | ····{ |
3325 | ········CreateObjects(); |
3326 | ········QueryOther(); |
3327 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3328 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3329 | ········otherVar.Dummy = 4711; |
3330 | ········pm.Save(); |
3331 | ········pm.UnloadCache(); |
3332 | ········QueryOther(); |
3333 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3334 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3335 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3336 | ····} |
3337 | ····[Test] |
3338 | ····public void TestRelationHash() |
3339 | ····{ |
3340 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoLeftBase)); |
3341 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3342 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoRight)); |
3343 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3344 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3345 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3346 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoLeftDerived)); |
3347 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3348 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3349 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3350 | ····} |
3351 | ····void CreateObjects() |
3352 | ····{ |
3353 | ········pm.MakePersistent(ownVar); |
3354 | ········pm.MakePersistent(otherVar); |
3355 | ········pm.Save(); |
3356 | ········ownVar.AssignRelation(otherVar); |
3357 | ········pm.Save(); |
3358 | ········pm.UnloadCache(); |
3359 | ····} |
3360 | ····void QueryOwn() |
3361 | ····{ |
3362 | ········var q = new NDOQuery<AgrBi11OwnpconTblAutoLeftBase>(pm); |
3363 | ········ownVar = q.ExecuteSingle(); |
3364 | ····} |
3365 | ····void QueryOther() |
3366 | ····{ |
3367 | ········var q = new NDOQuery<AgrBi11OwnpconTblAutoRight>(pm); |
3368 | ········otherVar = q.ExecuteSingle(); |
3369 | ····} |
3370 | } |
3371 | |
3372 | |
3373 | [TestFixture] |
3374 | public class TestAgrDirnOwnpconNoTblAuto : NDOTest |
3375 | { |
3376 | ····AgrDirnOwnpconNoTblAutoLeftBase ownVar; |
3377 | ····AgrDirnOwnpconNoTblAutoRight otherVar; |
3378 | ····PersistenceManager pm; |
3379 | ····[SetUp] |
3380 | ····public void Setup() |
3381 | ····{ |
3382 | ········pm = PmFactory.NewPersistenceManager(); |
3383 | ········ownVar = new AgrDirnOwnpconNoTblAutoLeftDerived(); |
3384 | ········otherVar = new AgrDirnOwnpconNoTblAutoRight(); |
3385 | ····} |
3386 | ····[TearDown] |
3387 | ····public void TearDown() |
3388 | ····{ |
3389 | ········try |
3390 | ········{ |
3391 | ············pm.UnloadCache(); |
3392 | ············var l = pm.Objects<AgrDirnOwnpconNoTblAutoLeftBase>().ResultTable; |
3393 | ············pm.Delete(l); |
3394 | ············pm.Save(); |
3395 | ············pm.UnloadCache(); |
3396 | ············var m = pm.Objects<AgrDirnOwnpconNoTblAutoRight>().ResultTable; |
3397 | ············pm.Delete(m); |
3398 | ············pm.Save(); |
3399 | ············pm.UnloadCache(); |
3400 | ············decimal count; |
3401 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3402 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3403 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3404 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3405 | ········} |
3406 | ········catch (Exception) |
3407 | ········{ |
3408 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3409 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3410 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3411 | ········} |
3412 | ····} |
3413 | ····[Test] |
3414 | ····public void TestSaveReload() |
3415 | ····{ |
3416 | ········CreateObjects(); |
3417 | ········QueryOwn(); |
3418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3419 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3420 | ····} |
3421 | ····[Test] |
3422 | ····public void TestSaveReloadNull() |
3423 | ····{ |
3424 | ········CreateObjects(); |
3425 | ········QueryOwn(); |
3426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3427 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3428 | ········ownVar.RelField = new List<AgrDirnOwnpconNoTblAutoRight>(); |
3429 | ········pm.Save(); |
3430 | ········pm.UnloadCache(); |
3431 | ········QueryOwn(); |
3432 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3433 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3434 | ····} |
3435 | ····[Test] |
3436 | ····public void TestSaveReloadRemove() |
3437 | ····{ |
3438 | ········CreateObjects(); |
3439 | ········QueryOwn(); |
3440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3441 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3442 | ········ownVar.RemoveRelatedObject(); |
3443 | ········pm.Save(); |
3444 | ········pm.UnloadCache(); |
3445 | ········QueryOwn(); |
3446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3447 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3448 | ····} |
3449 | ····[Test] |
3450 | ····public void TestUpdateOrder() |
3451 | ····{ |
3452 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
3453 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
3454 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoLeftBase)})) |
3455 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoRight)})), "Wrong order #1"); |
3456 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoLeftDerived)})) |
3457 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoRight)})), "Wrong order #2"); |
3458 | ········Debug.WriteLine("AgrDirnOwnpconNoTblAutoLeftBase"); |
3459 | ····} |
3460 | ····void CreateObjects() |
3461 | ····{ |
3462 | ········pm.MakePersistent(ownVar); |
3463 | ········pm.MakePersistent(otherVar); |
3464 | ········ownVar.AssignRelation(otherVar); |
3465 | ········pm.Save(); |
3466 | ········pm.UnloadCache(); |
3467 | ····} |
3468 | ····void QueryOwn() |
3469 | ····{ |
3470 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblAutoLeftBase>(pm); |
3471 | ········ownVar = q.ExecuteSingle(); |
3472 | ····} |
3473 | ····void QueryOther() |
3474 | ····{ |
3475 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblAutoRight>(pm); |
3476 | ········otherVar = q.ExecuteSingle(); |
3477 | ····} |
3478 | } |
3479 | |
3480 | |
3481 | [TestFixture] |
3482 | public class TestAgrDirnOwnpconTblAuto : NDOTest |
3483 | { |
3484 | ····AgrDirnOwnpconTblAutoLeftBase ownVar; |
3485 | ····AgrDirnOwnpconTblAutoRight otherVar; |
3486 | ····PersistenceManager pm; |
3487 | ····[SetUp] |
3488 | ····public void Setup() |
3489 | ····{ |
3490 | ········pm = PmFactory.NewPersistenceManager(); |
3491 | ········ownVar = new AgrDirnOwnpconTblAutoLeftDerived(); |
3492 | ········otherVar = new AgrDirnOwnpconTblAutoRight(); |
3493 | ····} |
3494 | ····[TearDown] |
3495 | ····public void TearDown() |
3496 | ····{ |
3497 | ········try |
3498 | ········{ |
3499 | ············pm.UnloadCache(); |
3500 | ············var l = pm.Objects<AgrDirnOwnpconTblAutoLeftBase>().ResultTable; |
3501 | ············pm.Delete(l); |
3502 | ············pm.Save(); |
3503 | ············pm.UnloadCache(); |
3504 | ············var m = pm.Objects<AgrDirnOwnpconTblAutoRight>().ResultTable; |
3505 | ············pm.Delete(m); |
3506 | ············pm.Save(); |
3507 | ············pm.UnloadCache(); |
3508 | ············decimal count; |
3509 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3510 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3511 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3512 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3513 | ········} |
3514 | ········catch (Exception) |
3515 | ········{ |
3516 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3517 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3518 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3519 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3520 | ········} |
3521 | ····} |
3522 | ····[Test] |
3523 | ····public void TestSaveReload() |
3524 | ····{ |
3525 | ········CreateObjects(); |
3526 | ········QueryOwn(); |
3527 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3528 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3529 | ····} |
3530 | ····[Test] |
3531 | ····public void TestSaveReloadNull() |
3532 | ····{ |
3533 | ········CreateObjects(); |
3534 | ········QueryOwn(); |
3535 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3536 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3537 | ········ownVar.RelField = new List<AgrDirnOwnpconTblAutoRight>(); |
3538 | ········pm.Save(); |
3539 | ········pm.UnloadCache(); |
3540 | ········QueryOwn(); |
3541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3542 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3543 | ····} |
3544 | ····[Test] |
3545 | ····public void TestSaveReloadRemove() |
3546 | ····{ |
3547 | ········CreateObjects(); |
3548 | ········QueryOwn(); |
3549 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3550 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3551 | ········ownVar.RemoveRelatedObject(); |
3552 | ········pm.Save(); |
3553 | ········pm.UnloadCache(); |
3554 | ········QueryOwn(); |
3555 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3556 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3557 | ····} |
3558 | ····void CreateObjects() |
3559 | ····{ |
3560 | ········pm.MakePersistent(ownVar); |
3561 | ········pm.MakePersistent(otherVar); |
3562 | ········ownVar.AssignRelation(otherVar); |
3563 | ········pm.Save(); |
3564 | ········pm.UnloadCache(); |
3565 | ····} |
3566 | ····void QueryOwn() |
3567 | ····{ |
3568 | ········var q = new NDOQuery<AgrDirnOwnpconTblAutoLeftBase>(pm); |
3569 | ········ownVar = q.ExecuteSingle(); |
3570 | ····} |
3571 | ····void QueryOther() |
3572 | ····{ |
3573 | ········var q = new NDOQuery<AgrDirnOwnpconTblAutoRight>(pm); |
3574 | ········otherVar = q.ExecuteSingle(); |
3575 | ····} |
3576 | } |
3577 | |
3578 | |
3579 | [TestFixture] |
3580 | public class TestAgrBin1OwnpconNoTblAuto : NDOTest |
3581 | { |
3582 | ····AgrBin1OwnpconNoTblAutoLeftBase ownVar; |
3583 | ····AgrBin1OwnpconNoTblAutoRight otherVar; |
3584 | ····PersistenceManager pm; |
3585 | ····[SetUp] |
3586 | ····public void Setup() |
3587 | ····{ |
3588 | ········pm = PmFactory.NewPersistenceManager(); |
3589 | ········ownVar = new AgrBin1OwnpconNoTblAutoLeftDerived(); |
3590 | ········otherVar = new AgrBin1OwnpconNoTblAutoRight(); |
3591 | ····} |
3592 | ····[TearDown] |
3593 | ····public void TearDown() |
3594 | ····{ |
3595 | ········try |
3596 | ········{ |
3597 | ············pm.UnloadCache(); |
3598 | ············var l = pm.Objects<AgrBin1OwnpconNoTblAutoLeftBase>().ResultTable; |
3599 | ············pm.Delete(l); |
3600 | ············pm.Save(); |
3601 | ············pm.UnloadCache(); |
3602 | ············var m = pm.Objects<AgrBin1OwnpconNoTblAutoRight>().ResultTable; |
3603 | ············pm.Delete(m); |
3604 | ············pm.Save(); |
3605 | ············pm.UnloadCache(); |
3606 | ············decimal count; |
3607 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3608 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3609 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3610 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3611 | ········} |
3612 | ········catch (Exception) |
3613 | ········{ |
3614 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3615 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3616 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3617 | ········} |
3618 | ····} |
3619 | ····[Test] |
3620 | ····public void TestSaveReload() |
3621 | ····{ |
3622 | ········CreateObjects(); |
3623 | ········QueryOwn(); |
3624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3625 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3626 | ····} |
3627 | ····[Test] |
3628 | ····public void TestSaveReloadNull() |
3629 | ····{ |
3630 | ········CreateObjects(); |
3631 | ········QueryOwn(); |
3632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3633 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3634 | ········ownVar.RelField = new List<AgrBin1OwnpconNoTblAutoRight>(); |
3635 | ········pm.Save(); |
3636 | ········pm.UnloadCache(); |
3637 | ········QueryOwn(); |
3638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3639 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3640 | ····} |
3641 | ····[Test] |
3642 | ····public void TestSaveReloadRemove() |
3643 | ····{ |
3644 | ········CreateObjects(); |
3645 | ········QueryOwn(); |
3646 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3647 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3648 | ········ownVar.RemoveRelatedObject(); |
3649 | ········pm.Save(); |
3650 | ········pm.UnloadCache(); |
3651 | ········QueryOwn(); |
3652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3653 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3654 | ····} |
3655 | ····[Test] |
3656 | ····public void TestChangeKeyHolderRight() |
3657 | ····{ |
3658 | ········CreateObjects(); |
3659 | ········QueryOther(); |
3660 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3661 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3662 | ········int x = otherVar.RelField.Dummy; |
3663 | ········otherVar.Dummy = 4711; |
3664 | ········pm.Save(); |
3665 | ········pm.UnloadCache(); |
3666 | ········QueryOther(); |
3667 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3668 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3669 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3670 | ····} |
3671 | ····[Test] |
3672 | ····public void TestChangeKeyHolderRightNoTouch() |
3673 | ····{ |
3674 | ········CreateObjects(); |
3675 | ········QueryOther(); |
3676 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3677 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3678 | ········otherVar.Dummy = 4711; |
3679 | ········pm.Save(); |
3680 | ········pm.UnloadCache(); |
3681 | ········QueryOther(); |
3682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3683 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3684 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3685 | ····} |
3686 | ····[Test] |
3687 | ····public void TestUpdateOrder() |
3688 | ····{ |
3689 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
3690 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
3691 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoLeftBase)})) |
3692 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
3693 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoLeftDerived)})) |
3694 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
3695 | ········Debug.WriteLine("AgrBin1OwnpconNoTblAutoLeftBase"); |
3696 | ····} |
3697 | ····[Test] |
3698 | ····public void TestRelationHash() |
3699 | ····{ |
3700 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoLeftBase)); |
3701 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3702 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoRight)); |
3703 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3704 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3705 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3706 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoLeftDerived)); |
3707 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3708 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3709 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3710 | ····} |
3711 | ····void CreateObjects() |
3712 | ····{ |
3713 | ········pm.MakePersistent(ownVar); |
3714 | ········pm.MakePersistent(otherVar); |
3715 | ········pm.Save(); |
3716 | ········ownVar.AssignRelation(otherVar); |
3717 | ········pm.Save(); |
3718 | ········pm.UnloadCache(); |
3719 | ····} |
3720 | ····void QueryOwn() |
3721 | ····{ |
3722 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblAutoLeftBase>(pm); |
3723 | ········ownVar = q.ExecuteSingle(); |
3724 | ····} |
3725 | ····void QueryOther() |
3726 | ····{ |
3727 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblAutoRight>(pm); |
3728 | ········otherVar = q.ExecuteSingle(); |
3729 | ····} |
3730 | } |
3731 | |
3732 | |
3733 | [TestFixture] |
3734 | public class TestAgrBin1OwnpconTblAuto : NDOTest |
3735 | { |
3736 | ····AgrBin1OwnpconTblAutoLeftBase ownVar; |
3737 | ····AgrBin1OwnpconTblAutoRight otherVar; |
3738 | ····PersistenceManager pm; |
3739 | ····[SetUp] |
3740 | ····public void Setup() |
3741 | ····{ |
3742 | ········pm = PmFactory.NewPersistenceManager(); |
3743 | ········ownVar = new AgrBin1OwnpconTblAutoLeftDerived(); |
3744 | ········otherVar = new AgrBin1OwnpconTblAutoRight(); |
3745 | ····} |
3746 | ····[TearDown] |
3747 | ····public void TearDown() |
3748 | ····{ |
3749 | ········try |
3750 | ········{ |
3751 | ············pm.UnloadCache(); |
3752 | ············var l = pm.Objects<AgrBin1OwnpconTblAutoLeftBase>().ResultTable; |
3753 | ············pm.Delete(l); |
3754 | ············pm.Save(); |
3755 | ············pm.UnloadCache(); |
3756 | ············var m = pm.Objects<AgrBin1OwnpconTblAutoRight>().ResultTable; |
3757 | ············pm.Delete(m); |
3758 | ············pm.Save(); |
3759 | ············pm.UnloadCache(); |
3760 | ············decimal count; |
3761 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3763 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3764 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3765 | ········} |
3766 | ········catch (Exception) |
3767 | ········{ |
3768 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3769 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3770 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3771 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3772 | ········} |
3773 | ····} |
3774 | ····[Test] |
3775 | ····public void TestSaveReload() |
3776 | ····{ |
3777 | ········CreateObjects(); |
3778 | ········QueryOwn(); |
3779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3780 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3781 | ····} |
3782 | ····[Test] |
3783 | ····public void TestSaveReloadNull() |
3784 | ····{ |
3785 | ········CreateObjects(); |
3786 | ········QueryOwn(); |
3787 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3788 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3789 | ········ownVar.RelField = new List<AgrBin1OwnpconTblAutoRight>(); |
3790 | ········pm.Save(); |
3791 | ········pm.UnloadCache(); |
3792 | ········QueryOwn(); |
3793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3794 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3795 | ····} |
3796 | ····[Test] |
3797 | ····public void TestSaveReloadRemove() |
3798 | ····{ |
3799 | ········CreateObjects(); |
3800 | ········QueryOwn(); |
3801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3802 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3803 | ········ownVar.RemoveRelatedObject(); |
3804 | ········pm.Save(); |
3805 | ········pm.UnloadCache(); |
3806 | ········QueryOwn(); |
3807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3808 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3809 | ····} |
3810 | ····[Test] |
3811 | ····public void TestChangeKeyHolderRight() |
3812 | ····{ |
3813 | ········CreateObjects(); |
3814 | ········QueryOther(); |
3815 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3816 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3817 | ········int x = otherVar.RelField.Dummy; |
3818 | ········otherVar.Dummy = 4711; |
3819 | ········pm.Save(); |
3820 | ········pm.UnloadCache(); |
3821 | ········QueryOther(); |
3822 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3823 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3824 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3825 | ····} |
3826 | ····[Test] |
3827 | ····public void TestChangeKeyHolderRightNoTouch() |
3828 | ····{ |
3829 | ········CreateObjects(); |
3830 | ········QueryOther(); |
3831 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3832 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3833 | ········otherVar.Dummy = 4711; |
3834 | ········pm.Save(); |
3835 | ········pm.UnloadCache(); |
3836 | ········QueryOther(); |
3837 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3838 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3839 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3840 | ····} |
3841 | ····[Test] |
3842 | ····public void TestRelationHash() |
3843 | ····{ |
3844 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoLeftBase)); |
3845 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3846 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoRight)); |
3847 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3848 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3849 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3850 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoLeftDerived)); |
3851 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3852 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3853 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3854 | ····} |
3855 | ····void CreateObjects() |
3856 | ····{ |
3857 | ········pm.MakePersistent(ownVar); |
3858 | ········pm.MakePersistent(otherVar); |
3859 | ········pm.Save(); |
3860 | ········ownVar.AssignRelation(otherVar); |
3861 | ········pm.Save(); |
3862 | ········pm.UnloadCache(); |
3863 | ····} |
3864 | ····void QueryOwn() |
3865 | ····{ |
3866 | ········var q = new NDOQuery<AgrBin1OwnpconTblAutoLeftBase>(pm); |
3867 | ········ownVar = q.ExecuteSingle(); |
3868 | ····} |
3869 | ····void QueryOther() |
3870 | ····{ |
3871 | ········var q = new NDOQuery<AgrBin1OwnpconTblAutoRight>(pm); |
3872 | ········otherVar = q.ExecuteSingle(); |
3873 | ····} |
3874 | } |
3875 | |
3876 | |
3877 | [TestFixture] |
3878 | public class TestAgrBi1nOwnpconTblAuto : NDOTest |
3879 | { |
3880 | ····AgrBi1nOwnpconTblAutoLeftBase ownVar; |
3881 | ····AgrBi1nOwnpconTblAutoRight otherVar; |
3882 | ····PersistenceManager pm; |
3883 | ····[SetUp] |
3884 | ····public void Setup() |
3885 | ····{ |
3886 | ········pm = PmFactory.NewPersistenceManager(); |
3887 | ········ownVar = new AgrBi1nOwnpconTblAutoLeftDerived(); |
3888 | ········otherVar = new AgrBi1nOwnpconTblAutoRight(); |
3889 | ····} |
3890 | ····[TearDown] |
3891 | ····public void TearDown() |
3892 | ····{ |
3893 | ········try |
3894 | ········{ |
3895 | ············pm.UnloadCache(); |
3896 | ············var l = pm.Objects<AgrBi1nOwnpconTblAutoLeftBase>().ResultTable; |
3897 | ············pm.Delete(l); |
3898 | ············pm.Save(); |
3899 | ············pm.UnloadCache(); |
3900 | ············var m = pm.Objects<AgrBi1nOwnpconTblAutoRight>().ResultTable; |
3901 | ············pm.Delete(m); |
3902 | ············pm.Save(); |
3903 | ············pm.UnloadCache(); |
3904 | ············decimal count; |
3905 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3906 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3907 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3908 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3909 | ········} |
3910 | ········catch (Exception) |
3911 | ········{ |
3912 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3913 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3914 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3915 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3916 | ········} |
3917 | ····} |
3918 | ····[Test] |
3919 | ····public void TestSaveReload() |
3920 | ····{ |
3921 | ········CreateObjects(); |
3922 | ········QueryOwn(); |
3923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3924 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3925 | ····} |
3926 | ····[Test] |
3927 | ····public void TestSaveReloadNull() |
3928 | ····{ |
3929 | ········CreateObjects(); |
3930 | ········QueryOwn(); |
3931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3932 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3933 | ········ownVar.RelField = null; |
3934 | ········pm.Save(); |
3935 | ········pm.UnloadCache(); |
3936 | ········QueryOwn(); |
3937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3938 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3939 | ····} |
3940 | ····[Test] |
3941 | ····public void TestChangeKeyHolderLeft() |
3942 | ····{ |
3943 | ········CreateObjects(); |
3944 | ········QueryOwn(); |
3945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3947 | ········int x = ownVar.RelField.Dummy; |
3948 | ········ownVar.Dummy = 4711; |
3949 | ········pm.Save(); |
3950 | ········pm.UnloadCache(); |
3951 | ········QueryOwn(); |
3952 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3953 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3954 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3955 | ····} |
3956 | ····[Test] |
3957 | ····public void TestChangeKeyHolderLeftNoTouch() |
3958 | ····{ |
3959 | ········CreateObjects(); |
3960 | ········QueryOwn(); |
3961 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3962 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3963 | ········ownVar.Dummy = 4711; |
3964 | ········pm.Save(); |
3965 | ········pm.UnloadCache(); |
3966 | ········QueryOwn(); |
3967 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3968 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3969 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3970 | ····} |
3971 | ····[Test] |
3972 | ····public void TestRelationHash() |
3973 | ····{ |
3974 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoLeftBase)); |
3975 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3976 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoRight)); |
3977 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3978 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3979 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3980 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoLeftDerived)); |
3981 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3982 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3983 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3984 | ····} |
3985 | ····void CreateObjects() |
3986 | ····{ |
3987 | ········pm.MakePersistent(ownVar); |
3988 | ········pm.MakePersistent(otherVar); |
3989 | ········ownVar.AssignRelation(otherVar); |
3990 | ········pm.Save(); |
3991 | ········pm.UnloadCache(); |
3992 | ····} |
3993 | ····void QueryOwn() |
3994 | ····{ |
3995 | ········var q = new NDOQuery<AgrBi1nOwnpconTblAutoLeftBase>(pm); |
3996 | ········ownVar = q.ExecuteSingle(); |
3997 | ····} |
3998 | ····void QueryOther() |
3999 | ····{ |
4000 | ········var q = new NDOQuery<AgrBi1nOwnpconTblAutoRight>(pm); |
4001 | ········otherVar = q.ExecuteSingle(); |
4002 | ····} |
4003 | } |
4004 | |
4005 | |
4006 | [TestFixture] |
4007 | public class TestAgrBinnOwnpconTblAuto : NDOTest |
4008 | { |
4009 | ····AgrBinnOwnpconTblAutoLeftBase ownVar; |
4010 | ····AgrBinnOwnpconTblAutoRight otherVar; |
4011 | ····PersistenceManager pm; |
4012 | ····[SetUp] |
4013 | ····public void Setup() |
4014 | ····{ |
4015 | ········pm = PmFactory.NewPersistenceManager(); |
4016 | ········ownVar = new AgrBinnOwnpconTblAutoLeftDerived(); |
4017 | ········otherVar = new AgrBinnOwnpconTblAutoRight(); |
4018 | ····} |
4019 | ····[TearDown] |
4020 | ····public void TearDown() |
4021 | ····{ |
4022 | ········try |
4023 | ········{ |
4024 | ············pm.UnloadCache(); |
4025 | ············var l = pm.Objects<AgrBinnOwnpconTblAutoLeftBase>().ResultTable; |
4026 | ············pm.Delete(l); |
4027 | ············pm.Save(); |
4028 | ············pm.UnloadCache(); |
4029 | ············var m = pm.Objects<AgrBinnOwnpconTblAutoRight>().ResultTable; |
4030 | ············pm.Delete(m); |
4031 | ············pm.Save(); |
4032 | ············pm.UnloadCache(); |
4033 | ············decimal count; |
4034 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4035 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4036 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4037 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4038 | ········} |
4039 | ········catch (Exception) |
4040 | ········{ |
4041 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4042 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4043 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4044 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4045 | ········} |
4046 | ····} |
4047 | ····[Test] |
4048 | ····public void TestSaveReload() |
4049 | ····{ |
4050 | ········CreateObjects(); |
4051 | ········QueryOwn(); |
4052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4053 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4054 | ····} |
4055 | ····[Test] |
4056 | ····public void TestSaveReloadNull() |
4057 | ····{ |
4058 | ········CreateObjects(); |
4059 | ········QueryOwn(); |
4060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4061 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4062 | ········ownVar.RelField = new List<AgrBinnOwnpconTblAutoRight>(); |
4063 | ········pm.Save(); |
4064 | ········pm.UnloadCache(); |
4065 | ········QueryOwn(); |
4066 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4067 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4068 | ····} |
4069 | ····[Test] |
4070 | ····public void TestSaveReloadRemove() |
4071 | ····{ |
4072 | ········CreateObjects(); |
4073 | ········QueryOwn(); |
4074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4075 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4076 | ········ownVar.RemoveRelatedObject(); |
4077 | ········pm.Save(); |
4078 | ········pm.UnloadCache(); |
4079 | ········QueryOwn(); |
4080 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4081 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4082 | ····} |
4083 | ····[Test] |
4084 | ····public void TestRelationHash() |
4085 | ····{ |
4086 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoLeftBase)); |
4087 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4088 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoRight)); |
4089 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4090 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4091 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4092 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoLeftDerived)); |
4093 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4094 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4095 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4096 | ····} |
4097 | ····void CreateObjects() |
4098 | ····{ |
4099 | ········pm.MakePersistent(ownVar); |
4100 | ········pm.MakePersistent(otherVar); |
4101 | ········ownVar.AssignRelation(otherVar); |
4102 | ········pm.Save(); |
4103 | ········pm.UnloadCache(); |
4104 | ····} |
4105 | ····void QueryOwn() |
4106 | ····{ |
4107 | ········var q = new NDOQuery<AgrBinnOwnpconTblAutoLeftBase>(pm); |
4108 | ········ownVar = q.ExecuteSingle(); |
4109 | ····} |
4110 | ····void QueryOther() |
4111 | ····{ |
4112 | ········var q = new NDOQuery<AgrBinnOwnpconTblAutoRight>(pm); |
4113 | ········otherVar = q.ExecuteSingle(); |
4114 | ····} |
4115 | } |
4116 | |
4117 | |
4118 | [TestFixture] |
4119 | public class TestCmpDir1OwnpconNoTblAuto : NDOTest |
4120 | { |
4121 | ····CmpDir1OwnpconNoTblAutoLeftBase ownVar; |
4122 | ····CmpDir1OwnpconNoTblAutoRight otherVar; |
4123 | ····PersistenceManager pm; |
4124 | ····[SetUp] |
4125 | ····public void Setup() |
4126 | ····{ |
4127 | ········pm = PmFactory.NewPersistenceManager(); |
4128 | ········ownVar = new CmpDir1OwnpconNoTblAutoLeftDerived(); |
4129 | ········otherVar = new CmpDir1OwnpconNoTblAutoRight(); |
4130 | ····} |
4131 | ····[TearDown] |
4132 | ····public void TearDown() |
4133 | ····{ |
4134 | ········try |
4135 | ········{ |
4136 | ············pm.UnloadCache(); |
4137 | ············var l = pm.Objects<CmpDir1OwnpconNoTblAutoLeftBase>().ResultTable; |
4138 | ············pm.Delete(l); |
4139 | ············pm.Save(); |
4140 | ············pm.UnloadCache(); |
4141 | ············decimal count; |
4142 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4143 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4144 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4145 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4146 | ········} |
4147 | ········catch (Exception) |
4148 | ········{ |
4149 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4150 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4151 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4152 | ········} |
4153 | ····} |
4154 | ····[Test] |
4155 | ····public void TestSaveReload() |
4156 | ····{ |
4157 | ········CreateObjects(); |
4158 | ········QueryOwn(); |
4159 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4160 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4161 | ····} |
4162 | ····[Test] |
4163 | ····public void TestSaveReloadNull() |
4164 | ····{ |
4165 | ········CreateObjects(); |
4166 | ········QueryOwn(); |
4167 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4168 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4169 | ········ownVar.RelField = null; |
4170 | ········pm.Save(); |
4171 | ········pm.UnloadCache(); |
4172 | ········QueryOwn(); |
4173 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4174 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4175 | ····} |
4176 | ····[Test] |
4177 | ····public void TestChangeKeyHolderLeft() |
4178 | ····{ |
4179 | ········CreateObjects(); |
4180 | ········QueryOwn(); |
4181 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4182 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4183 | ········int x = ownVar.RelField.Dummy; |
4184 | ········ownVar.Dummy = 4711; |
4185 | ········pm.Save(); |
4186 | ········pm.UnloadCache(); |
4187 | ········QueryOwn(); |
4188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4189 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4190 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4191 | ····} |
4192 | ····[Test] |
4193 | ····public void TestChangeKeyHolderLeftNoTouch() |
4194 | ····{ |
4195 | ········CreateObjects(); |
4196 | ········QueryOwn(); |
4197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4198 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4199 | ········ownVar.Dummy = 4711; |
4200 | ········pm.Save(); |
4201 | ········pm.UnloadCache(); |
4202 | ········QueryOwn(); |
4203 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4204 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4205 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4206 | ····} |
4207 | ····[Test] |
4208 | ····public void TestUpdateOrder() |
4209 | ····{ |
4210 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4211 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4212 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoLeftBase)})) |
4213 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
4214 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoLeftDerived)})) |
4215 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
4216 | ········Debug.WriteLine("CmpDir1OwnpconNoTblAutoLeftBase"); |
4217 | ····} |
4218 | ····void CreateObjects() |
4219 | ····{ |
4220 | ········pm.MakePersistent(ownVar); |
4221 | ········pm.Save(); |
4222 | ········ownVar.AssignRelation(otherVar); |
4223 | ········pm.Save(); |
4224 | ········pm.UnloadCache(); |
4225 | ····} |
4226 | ····void QueryOwn() |
4227 | ····{ |
4228 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblAutoLeftBase>(pm); |
4229 | ········ownVar = q.ExecuteSingle(); |
4230 | ····} |
4231 | ····void QueryOther() |
4232 | ····{ |
4233 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblAutoRight>(pm); |
4234 | ········otherVar = q.ExecuteSingle(); |
4235 | ····} |
4236 | } |
4237 | |
4238 | |
4239 | [TestFixture] |
4240 | public class TestCmpDir1OwnpconTblAuto : NDOTest |
4241 | { |
4242 | ····CmpDir1OwnpconTblAutoLeftBase ownVar; |
4243 | ····CmpDir1OwnpconTblAutoRight otherVar; |
4244 | ····PersistenceManager pm; |
4245 | ····[SetUp] |
4246 | ····public void Setup() |
4247 | ····{ |
4248 | ········pm = PmFactory.NewPersistenceManager(); |
4249 | ········ownVar = new CmpDir1OwnpconTblAutoLeftDerived(); |
4250 | ········otherVar = new CmpDir1OwnpconTblAutoRight(); |
4251 | ····} |
4252 | ····[TearDown] |
4253 | ····public void TearDown() |
4254 | ····{ |
4255 | ········try |
4256 | ········{ |
4257 | ············pm.UnloadCache(); |
4258 | ············var l = pm.Objects<CmpDir1OwnpconTblAutoLeftBase>().ResultTable; |
4259 | ············pm.Delete(l); |
4260 | ············pm.Save(); |
4261 | ············pm.UnloadCache(); |
4262 | ············decimal count; |
4263 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4264 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4265 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4266 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4267 | ········} |
4268 | ········catch (Exception) |
4269 | ········{ |
4270 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4271 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4272 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4273 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4274 | ········} |
4275 | ····} |
4276 | ····[Test] |
4277 | ····public void TestSaveReload() |
4278 | ····{ |
4279 | ········CreateObjects(); |
4280 | ········QueryOwn(); |
4281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4282 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4283 | ····} |
4284 | ····[Test] |
4285 | ····public void TestSaveReloadNull() |
4286 | ····{ |
4287 | ········CreateObjects(); |
4288 | ········QueryOwn(); |
4289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4290 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4291 | ········ownVar.RelField = null; |
4292 | ········pm.Save(); |
4293 | ········pm.UnloadCache(); |
4294 | ········QueryOwn(); |
4295 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4296 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4297 | ····} |
4298 | ····[Test] |
4299 | ····public void TestChangeKeyHolderLeft() |
4300 | ····{ |
4301 | ········CreateObjects(); |
4302 | ········QueryOwn(); |
4303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4304 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4305 | ········int x = ownVar.RelField.Dummy; |
4306 | ········ownVar.Dummy = 4711; |
4307 | ········pm.Save(); |
4308 | ········pm.UnloadCache(); |
4309 | ········QueryOwn(); |
4310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4311 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4312 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4313 | ····} |
4314 | ····[Test] |
4315 | ····public void TestChangeKeyHolderLeftNoTouch() |
4316 | ····{ |
4317 | ········CreateObjects(); |
4318 | ········QueryOwn(); |
4319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4321 | ········ownVar.Dummy = 4711; |
4322 | ········pm.Save(); |
4323 | ········pm.UnloadCache(); |
4324 | ········QueryOwn(); |
4325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4326 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4327 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4328 | ····} |
4329 | ····void CreateObjects() |
4330 | ····{ |
4331 | ········pm.MakePersistent(ownVar); |
4332 | ········ownVar.AssignRelation(otherVar); |
4333 | ········pm.Save(); |
4334 | ········pm.UnloadCache(); |
4335 | ····} |
4336 | ····void QueryOwn() |
4337 | ····{ |
4338 | ········var q = new NDOQuery<CmpDir1OwnpconTblAutoLeftBase>(pm); |
4339 | ········ownVar = q.ExecuteSingle(); |
4340 | ····} |
4341 | ····void QueryOther() |
4342 | ····{ |
4343 | ········var q = new NDOQuery<CmpDir1OwnpconTblAutoRight>(pm); |
4344 | ········otherVar = q.ExecuteSingle(); |
4345 | ····} |
4346 | } |
4347 | |
4348 | |
4349 | [TestFixture] |
4350 | public class TestCmpBi11OwnpconNoTblAuto : NDOTest |
4351 | { |
4352 | ····CmpBi11OwnpconNoTblAutoLeftBase ownVar; |
4353 | ····CmpBi11OwnpconNoTblAutoRight otherVar; |
4354 | ····PersistenceManager pm; |
4355 | ····[SetUp] |
4356 | ····public void Setup() |
4357 | ····{ |
4358 | ········pm = PmFactory.NewPersistenceManager(); |
4359 | ········ownVar = new CmpBi11OwnpconNoTblAutoLeftDerived(); |
4360 | ········otherVar = new CmpBi11OwnpconNoTblAutoRight(); |
4361 | ····} |
4362 | ····[TearDown] |
4363 | ····public void TearDown() |
4364 | ····{ |
4365 | ········try |
4366 | ········{ |
4367 | ············pm.UnloadCache(); |
4368 | ············var l = pm.Objects<CmpBi11OwnpconNoTblAutoLeftBase>().ResultTable; |
4369 | ············pm.Delete(l); |
4370 | ············pm.Save(); |
4371 | ············pm.UnloadCache(); |
4372 | ············decimal count; |
4373 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4374 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4375 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4376 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4377 | ········} |
4378 | ········catch (Exception) |
4379 | ········{ |
4380 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4382 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4383 | ········} |
4384 | ····} |
4385 | ····[Test] |
4386 | ····public void TestSaveReload() |
4387 | ····{ |
4388 | ········CreateObjects(); |
4389 | ········QueryOwn(); |
4390 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4391 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4392 | ····} |
4393 | ····[Test] |
4394 | ····public void TestSaveReloadNull() |
4395 | ····{ |
4396 | ········CreateObjects(); |
4397 | ········QueryOwn(); |
4398 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4399 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4400 | ········ownVar.RelField = null; |
4401 | ········pm.Save(); |
4402 | ········pm.UnloadCache(); |
4403 | ········QueryOwn(); |
4404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4405 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4406 | ····} |
4407 | ····[Test] |
4408 | ····public void TestChangeKeyHolderLeft() |
4409 | ····{ |
4410 | ········CreateObjects(); |
4411 | ········QueryOwn(); |
4412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4413 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4414 | ········int x = ownVar.RelField.Dummy; |
4415 | ········ownVar.Dummy = 4711; |
4416 | ········pm.Save(); |
4417 | ········pm.UnloadCache(); |
4418 | ········QueryOwn(); |
4419 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4420 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4422 | ····} |
4423 | ····[Test] |
4424 | ····public void TestChangeKeyHolderRight() |
4425 | ····{ |
4426 | ········CreateObjects(); |
4427 | ········QueryOther(); |
4428 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4429 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4430 | ········int x = otherVar.RelField.Dummy; |
4431 | ········otherVar.Dummy = 4711; |
4432 | ········pm.Save(); |
4433 | ········pm.UnloadCache(); |
4434 | ········QueryOther(); |
4435 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4436 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4437 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4438 | ····} |
4439 | ····[Test] |
4440 | ····public void TestChangeKeyHolderLeftNoTouch() |
4441 | ····{ |
4442 | ········CreateObjects(); |
4443 | ········QueryOwn(); |
4444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4445 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4446 | ········ownVar.Dummy = 4711; |
4447 | ········pm.Save(); |
4448 | ········pm.UnloadCache(); |
4449 | ········QueryOwn(); |
4450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4451 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4452 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4453 | ····} |
4454 | ····[Test] |
4455 | ····public void TestChangeKeyHolderRightNoTouch() |
4456 | ····{ |
4457 | ········CreateObjects(); |
4458 | ········QueryOther(); |
4459 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4460 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4461 | ········otherVar.Dummy = 4711; |
4462 | ········pm.Save(); |
4463 | ········pm.UnloadCache(); |
4464 | ········QueryOther(); |
4465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4468 | ····} |
4469 | ····[Test] |
4470 | ····public void TestRelationHash() |
4471 | ····{ |
4472 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoLeftBase)); |
4473 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4474 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoRight)); |
4475 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4476 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4477 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4478 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoLeftDerived)); |
4479 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4480 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4481 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4482 | ····} |
4483 | ····void CreateObjects() |
4484 | ····{ |
4485 | ········pm.MakePersistent(ownVar); |
4486 | ········pm.Save(); |
4487 | ········ownVar.AssignRelation(otherVar); |
4488 | ········pm.Save(); |
4489 | ········pm.UnloadCache(); |
4490 | ····} |
4491 | ····void QueryOwn() |
4492 | ····{ |
4493 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblAutoLeftBase>(pm); |
4494 | ········ownVar = q.ExecuteSingle(); |
4495 | ····} |
4496 | ····void QueryOther() |
4497 | ····{ |
4498 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblAutoRight>(pm); |
4499 | ········otherVar = q.ExecuteSingle(); |
4500 | ····} |
4501 | } |
4502 | |
4503 | |
4504 | [TestFixture] |
4505 | public class TestCmpBi11OwnpconTblAuto : NDOTest |
4506 | { |
4507 | ····CmpBi11OwnpconTblAutoLeftBase ownVar; |
4508 | ····CmpBi11OwnpconTblAutoRight otherVar; |
4509 | ····PersistenceManager pm; |
4510 | ····[SetUp] |
4511 | ····public void Setup() |
4512 | ····{ |
4513 | ········pm = PmFactory.NewPersistenceManager(); |
4514 | ········ownVar = new CmpBi11OwnpconTblAutoLeftDerived(); |
4515 | ········otherVar = new CmpBi11OwnpconTblAutoRight(); |
4516 | ····} |
4517 | ····[TearDown] |
4518 | ····public void TearDown() |
4519 | ····{ |
4520 | ········try |
4521 | ········{ |
4522 | ············pm.UnloadCache(); |
4523 | ············var l = pm.Objects<CmpBi11OwnpconTblAutoLeftBase>().ResultTable; |
4524 | ············pm.Delete(l); |
4525 | ············pm.Save(); |
4526 | ············pm.UnloadCache(); |
4527 | ············decimal count; |
4528 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4529 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4530 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4532 | ········} |
4533 | ········catch (Exception) |
4534 | ········{ |
4535 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4537 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4538 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4539 | ········} |
4540 | ····} |
4541 | ····[Test] |
4542 | ····public void TestSaveReload() |
4543 | ····{ |
4544 | ········CreateObjects(); |
4545 | ········QueryOwn(); |
4546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4547 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4548 | ····} |
4549 | ····[Test] |
4550 | ····public void TestSaveReloadNull() |
4551 | ····{ |
4552 | ········CreateObjects(); |
4553 | ········QueryOwn(); |
4554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4555 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4556 | ········ownVar.RelField = null; |
4557 | ········pm.Save(); |
4558 | ········pm.UnloadCache(); |
4559 | ········QueryOwn(); |
4560 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4561 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4562 | ····} |
4563 | ····[Test] |
4564 | ····public void TestChangeKeyHolderLeft() |
4565 | ····{ |
4566 | ········CreateObjects(); |
4567 | ········QueryOwn(); |
4568 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4569 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4570 | ········int x = ownVar.RelField.Dummy; |
4571 | ········ownVar.Dummy = 4711; |
4572 | ········pm.Save(); |
4573 | ········pm.UnloadCache(); |
4574 | ········QueryOwn(); |
4575 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4576 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4577 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4578 | ····} |
4579 | ····[Test] |
4580 | ····public void TestChangeKeyHolderRight() |
4581 | ····{ |
4582 | ········CreateObjects(); |
4583 | ········QueryOther(); |
4584 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4585 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4586 | ········int x = otherVar.RelField.Dummy; |
4587 | ········otherVar.Dummy = 4711; |
4588 | ········pm.Save(); |
4589 | ········pm.UnloadCache(); |
4590 | ········QueryOther(); |
4591 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4592 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4593 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4594 | ····} |
4595 | ····[Test] |
4596 | ····public void TestChangeKeyHolderLeftNoTouch() |
4597 | ····{ |
4598 | ········CreateObjects(); |
4599 | ········QueryOwn(); |
4600 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4601 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4602 | ········ownVar.Dummy = 4711; |
4603 | ········pm.Save(); |
4604 | ········pm.UnloadCache(); |
4605 | ········QueryOwn(); |
4606 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4607 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4608 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4609 | ····} |
4610 | ····[Test] |
4611 | ····public void TestChangeKeyHolderRightNoTouch() |
4612 | ····{ |
4613 | ········CreateObjects(); |
4614 | ········QueryOther(); |
4615 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4616 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4617 | ········otherVar.Dummy = 4711; |
4618 | ········pm.Save(); |
4619 | ········pm.UnloadCache(); |
4620 | ········QueryOther(); |
4621 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4622 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4623 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4624 | ····} |
4625 | ····[Test] |
4626 | ····public void TestRelationHash() |
4627 | ····{ |
4628 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoLeftBase)); |
4629 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4630 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoRight)); |
4631 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4632 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4633 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4634 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoLeftDerived)); |
4635 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4636 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4637 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4638 | ····} |
4639 | ····void CreateObjects() |
4640 | ····{ |
4641 | ········pm.MakePersistent(ownVar); |
4642 | ········ownVar.AssignRelation(otherVar); |
4643 | ········pm.Save(); |
4644 | ········pm.UnloadCache(); |
4645 | ····} |
4646 | ····void QueryOwn() |
4647 | ····{ |
4648 | ········var q = new NDOQuery<CmpBi11OwnpconTblAutoLeftBase>(pm); |
4649 | ········ownVar = q.ExecuteSingle(); |
4650 | ····} |
4651 | ····void QueryOther() |
4652 | ····{ |
4653 | ········var q = new NDOQuery<CmpBi11OwnpconTblAutoRight>(pm); |
4654 | ········otherVar = q.ExecuteSingle(); |
4655 | ····} |
4656 | } |
4657 | |
4658 | |
4659 | [TestFixture] |
4660 | public class TestCmpDirnOwnpconNoTblAuto : NDOTest |
4661 | { |
4662 | ····CmpDirnOwnpconNoTblAutoLeftBase ownVar; |
4663 | ····CmpDirnOwnpconNoTblAutoRight otherVar; |
4664 | ····PersistenceManager pm; |
4665 | ····[SetUp] |
4666 | ····public void Setup() |
4667 | ····{ |
4668 | ········pm = PmFactory.NewPersistenceManager(); |
4669 | ········ownVar = new CmpDirnOwnpconNoTblAutoLeftDerived(); |
4670 | ········otherVar = new CmpDirnOwnpconNoTblAutoRight(); |
4671 | ····} |
4672 | ····[TearDown] |
4673 | ····public void TearDown() |
4674 | ····{ |
4675 | ········try |
4676 | ········{ |
4677 | ············pm.UnloadCache(); |
4678 | ············var l = pm.Objects<CmpDirnOwnpconNoTblAutoLeftBase>().ResultTable; |
4679 | ············pm.Delete(l); |
4680 | ············pm.Save(); |
4681 | ············pm.UnloadCache(); |
4682 | ············decimal count; |
4683 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4684 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4685 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4686 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4687 | ········} |
4688 | ········catch (Exception) |
4689 | ········{ |
4690 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4691 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4692 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4693 | ········} |
4694 | ····} |
4695 | ····[Test] |
4696 | ····public void TestSaveReload() |
4697 | ····{ |
4698 | ········CreateObjects(); |
4699 | ········QueryOwn(); |
4700 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4701 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4702 | ····} |
4703 | ····[Test] |
4704 | ····public void TestSaveReloadNull() |
4705 | ····{ |
4706 | ········CreateObjects(); |
4707 | ········QueryOwn(); |
4708 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4709 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4710 | ········ownVar.RelField = new List<CmpDirnOwnpconNoTblAutoRight>(); |
4711 | ········pm.Save(); |
4712 | ········pm.UnloadCache(); |
4713 | ········QueryOwn(); |
4714 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4715 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4716 | ····} |
4717 | ····[Test] |
4718 | ····public void TestSaveReloadRemove() |
4719 | ····{ |
4720 | ········CreateObjects(); |
4721 | ········QueryOwn(); |
4722 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4723 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4724 | ········ownVar.RemoveRelatedObject(); |
4725 | ········pm.Save(); |
4726 | ········pm.UnloadCache(); |
4727 | ········QueryOwn(); |
4728 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4729 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4730 | ····} |
4731 | ····[Test] |
4732 | ····public void TestUpdateOrder() |
4733 | ····{ |
4734 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4735 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4736 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoLeftBase)})) |
4737 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoRight)})), "Wrong order #1"); |
4738 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoLeftDerived)})) |
4739 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoRight)})), "Wrong order #2"); |
4740 | ········Debug.WriteLine("CmpDirnOwnpconNoTblAutoLeftBase"); |
4741 | ····} |
4742 | ····void CreateObjects() |
4743 | ····{ |
4744 | ········pm.MakePersistent(ownVar); |
4745 | ········ownVar.AssignRelation(otherVar); |
4746 | ········pm.Save(); |
4747 | ········pm.UnloadCache(); |
4748 | ····} |
4749 | ····void QueryOwn() |
4750 | ····{ |
4751 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblAutoLeftBase>(pm); |
4752 | ········ownVar = q.ExecuteSingle(); |
4753 | ····} |
4754 | ····void QueryOther() |
4755 | ····{ |
4756 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblAutoRight>(pm); |
4757 | ········otherVar = q.ExecuteSingle(); |
4758 | ····} |
4759 | } |
4760 | |
4761 | |
4762 | [TestFixture] |
4763 | public class TestCmpDirnOwnpconTblAuto : NDOTest |
4764 | { |
4765 | ····CmpDirnOwnpconTblAutoLeftBase ownVar; |
4766 | ····CmpDirnOwnpconTblAutoRight otherVar; |
4767 | ····PersistenceManager pm; |
4768 | ····[SetUp] |
4769 | ····public void Setup() |
4770 | ····{ |
4771 | ········pm = PmFactory.NewPersistenceManager(); |
4772 | ········ownVar = new CmpDirnOwnpconTblAutoLeftDerived(); |
4773 | ········otherVar = new CmpDirnOwnpconTblAutoRight(); |
4774 | ····} |
4775 | ····[TearDown] |
4776 | ····public void TearDown() |
4777 | ····{ |
4778 | ········try |
4779 | ········{ |
4780 | ············pm.UnloadCache(); |
4781 | ············var l = pm.Objects<CmpDirnOwnpconTblAutoLeftBase>().ResultTable; |
4782 | ············pm.Delete(l); |
4783 | ············pm.Save(); |
4784 | ············pm.UnloadCache(); |
4785 | ············decimal count; |
4786 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4787 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4788 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4789 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4790 | ········} |
4791 | ········catch (Exception) |
4792 | ········{ |
4793 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4794 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4795 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4796 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4797 | ········} |
4798 | ····} |
4799 | ····[Test] |
4800 | ····public void TestSaveReload() |
4801 | ····{ |
4802 | ········CreateObjects(); |
4803 | ········QueryOwn(); |
4804 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4805 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4806 | ····} |
4807 | ····[Test] |
4808 | ····public void TestSaveReloadNull() |
4809 | ····{ |
4810 | ········CreateObjects(); |
4811 | ········QueryOwn(); |
4812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4813 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4814 | ········ownVar.RelField = new List<CmpDirnOwnpconTblAutoRight>(); |
4815 | ········pm.Save(); |
4816 | ········pm.UnloadCache(); |
4817 | ········QueryOwn(); |
4818 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4819 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4820 | ····} |
4821 | ····[Test] |
4822 | ····public void TestSaveReloadRemove() |
4823 | ····{ |
4824 | ········CreateObjects(); |
4825 | ········QueryOwn(); |
4826 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4827 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4828 | ········ownVar.RemoveRelatedObject(); |
4829 | ········pm.Save(); |
4830 | ········pm.UnloadCache(); |
4831 | ········QueryOwn(); |
4832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4833 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4834 | ····} |
4835 | ····void CreateObjects() |
4836 | ····{ |
4837 | ········pm.MakePersistent(ownVar); |
4838 | ········ownVar.AssignRelation(otherVar); |
4839 | ········pm.Save(); |
4840 | ········pm.UnloadCache(); |
4841 | ····} |
4842 | ····void QueryOwn() |
4843 | ····{ |
4844 | ········var q = new NDOQuery<CmpDirnOwnpconTblAutoLeftBase>(pm); |
4845 | ········ownVar = q.ExecuteSingle(); |
4846 | ····} |
4847 | ····void QueryOther() |
4848 | ····{ |
4849 | ········var q = new NDOQuery<CmpDirnOwnpconTblAutoRight>(pm); |
4850 | ········otherVar = q.ExecuteSingle(); |
4851 | ····} |
4852 | } |
4853 | |
4854 | |
4855 | [TestFixture] |
4856 | public class TestCmpBin1OwnpconNoTblAuto : NDOTest |
4857 | { |
4858 | ····CmpBin1OwnpconNoTblAutoLeftBase ownVar; |
4859 | ····CmpBin1OwnpconNoTblAutoRight otherVar; |
4860 | ····PersistenceManager pm; |
4861 | ····[SetUp] |
4862 | ····public void Setup() |
4863 | ····{ |
4864 | ········pm = PmFactory.NewPersistenceManager(); |
4865 | ········ownVar = new CmpBin1OwnpconNoTblAutoLeftDerived(); |
4866 | ········otherVar = new CmpBin1OwnpconNoTblAutoRight(); |
4867 | ····} |
4868 | ····[TearDown] |
4869 | ····public void TearDown() |
4870 | ····{ |
4871 | ········try |
4872 | ········{ |
4873 | ············pm.UnloadCache(); |
4874 | ············var l = pm.Objects<CmpBin1OwnpconNoTblAutoLeftBase>().ResultTable; |
4875 | ············pm.Delete(l); |
4876 | ············pm.Save(); |
4877 | ············pm.UnloadCache(); |
4878 | ············decimal count; |
4879 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4880 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4881 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4882 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4883 | ········} |
4884 | ········catch (Exception) |
4885 | ········{ |
4886 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4887 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4888 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4889 | ········} |
4890 | ····} |
4891 | ····[Test] |
4892 | ····public void TestSaveReload() |
4893 | ····{ |
4894 | ········CreateObjects(); |
4895 | ········QueryOwn(); |
4896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4897 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4898 | ····} |
4899 | ····[Test] |
4900 | ····public void TestSaveReloadNull() |
4901 | ····{ |
4902 | ········CreateObjects(); |
4903 | ········QueryOwn(); |
4904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4905 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4906 | ········ownVar.RelField = new List<CmpBin1OwnpconNoTblAutoRight>(); |
4907 | ········pm.Save(); |
4908 | ········pm.UnloadCache(); |
4909 | ········QueryOwn(); |
4910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4911 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4912 | ····} |
4913 | ····[Test] |
4914 | ····public void TestSaveReloadRemove() |
4915 | ····{ |
4916 | ········CreateObjects(); |
4917 | ········QueryOwn(); |
4918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4920 | ········ownVar.RemoveRelatedObject(); |
4921 | ········pm.Save(); |
4922 | ········pm.UnloadCache(); |
4923 | ········QueryOwn(); |
4924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4926 | ····} |
4927 | ····[Test] |
4928 | ····public void TestChangeKeyHolderRight() |
4929 | ····{ |
4930 | ········CreateObjects(); |
4931 | ········QueryOther(); |
4932 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4933 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4934 | ········int x = otherVar.RelField.Dummy; |
4935 | ········otherVar.Dummy = 4711; |
4936 | ········pm.Save(); |
4937 | ········pm.UnloadCache(); |
4938 | ········QueryOther(); |
4939 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4940 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4941 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4942 | ····} |
4943 | ····[Test] |
4944 | ····public void TestChangeKeyHolderRightNoTouch() |
4945 | ····{ |
4946 | ········CreateObjects(); |
4947 | ········QueryOther(); |
4948 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4949 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4950 | ········otherVar.Dummy = 4711; |
4951 | ········pm.Save(); |
4952 | ········pm.UnloadCache(); |
4953 | ········QueryOther(); |
4954 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4955 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4956 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4957 | ····} |
4958 | ····[Test] |
4959 | ····public void TestUpdateOrder() |
4960 | ····{ |
4961 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4962 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4963 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoLeftBase)})) |
4964 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
4965 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoLeftDerived)})) |
4966 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
4967 | ········Debug.WriteLine("CmpBin1OwnpconNoTblAutoLeftBase"); |
4968 | ····} |
4969 | ····[Test] |
4970 | ····public void TestRelationHash() |
4971 | ····{ |
4972 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoLeftBase)); |
4973 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4974 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoRight)); |
4975 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4976 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4977 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4978 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoLeftDerived)); |
4979 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4980 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4981 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4982 | ····} |
4983 | ····void CreateObjects() |
4984 | ····{ |
4985 | ········pm.MakePersistent(ownVar); |
4986 | ········ownVar.AssignRelation(otherVar); |
4987 | ········pm.Save(); |
4988 | ········pm.UnloadCache(); |
4989 | ····} |
4990 | ····void QueryOwn() |
4991 | ····{ |
4992 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblAutoLeftBase>(pm); |
4993 | ········ownVar = q.ExecuteSingle(); |
4994 | ····} |
4995 | ····void QueryOther() |
4996 | ····{ |
4997 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblAutoRight>(pm); |
4998 | ········otherVar = q.ExecuteSingle(); |
4999 | ····} |
5000 | } |
5001 | |
5002 | |
5003 | [TestFixture] |
5004 | public class TestCmpBin1OwnpconTblAuto : NDOTest |
5005 | { |
5006 | ····CmpBin1OwnpconTblAutoLeftBase ownVar; |
5007 | ····CmpBin1OwnpconTblAutoRight otherVar; |
5008 | ····PersistenceManager pm; |
5009 | ····[SetUp] |
5010 | ····public void Setup() |
5011 | ····{ |
5012 | ········pm = PmFactory.NewPersistenceManager(); |
5013 | ········ownVar = new CmpBin1OwnpconTblAutoLeftDerived(); |
5014 | ········otherVar = new CmpBin1OwnpconTblAutoRight(); |
5015 | ····} |
5016 | ····[TearDown] |
5017 | ····public void TearDown() |
5018 | ····{ |
5019 | ········try |
5020 | ········{ |
5021 | ············pm.UnloadCache(); |
5022 | ············var l = pm.Objects<CmpBin1OwnpconTblAutoLeftBase>().ResultTable; |
5023 | ············pm.Delete(l); |
5024 | ············pm.Save(); |
5025 | ············pm.UnloadCache(); |
5026 | ············decimal count; |
5027 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5028 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5029 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5030 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5031 | ········} |
5032 | ········catch (Exception) |
5033 | ········{ |
5034 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5035 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5036 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5037 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5038 | ········} |
5039 | ····} |
5040 | ····[Test] |
5041 | ····public void TestSaveReload() |
5042 | ····{ |
5043 | ········CreateObjects(); |
5044 | ········QueryOwn(); |
5045 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5046 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5047 | ····} |
5048 | ····[Test] |
5049 | ····public void TestSaveReloadNull() |
5050 | ····{ |
5051 | ········CreateObjects(); |
5052 | ········QueryOwn(); |
5053 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5054 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5055 | ········ownVar.RelField = new List<CmpBin1OwnpconTblAutoRight>(); |
5056 | ········pm.Save(); |
5057 | ········pm.UnloadCache(); |
5058 | ········QueryOwn(); |
5059 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5060 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5061 | ····} |
5062 | ····[Test] |
5063 | ····public void TestSaveReloadRemove() |
5064 | ····{ |
5065 | ········CreateObjects(); |
5066 | ········QueryOwn(); |
5067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5068 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5069 | ········ownVar.RemoveRelatedObject(); |
5070 | ········pm.Save(); |
5071 | ········pm.UnloadCache(); |
5072 | ········QueryOwn(); |
5073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5074 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5075 | ····} |
5076 | ····[Test] |
5077 | ····public void TestChangeKeyHolderRight() |
5078 | ····{ |
5079 | ········CreateObjects(); |
5080 | ········QueryOther(); |
5081 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5082 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5083 | ········int x = otherVar.RelField.Dummy; |
5084 | ········otherVar.Dummy = 4711; |
5085 | ········pm.Save(); |
5086 | ········pm.UnloadCache(); |
5087 | ········QueryOther(); |
5088 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5089 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5090 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5091 | ····} |
5092 | ····[Test] |
5093 | ····public void TestChangeKeyHolderRightNoTouch() |
5094 | ····{ |
5095 | ········CreateObjects(); |
5096 | ········QueryOther(); |
5097 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5098 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5099 | ········otherVar.Dummy = 4711; |
5100 | ········pm.Save(); |
5101 | ········pm.UnloadCache(); |
5102 | ········QueryOther(); |
5103 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5104 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5105 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5106 | ····} |
5107 | ····[Test] |
5108 | ····public void TestRelationHash() |
5109 | ····{ |
5110 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoLeftBase)); |
5111 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5112 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoRight)); |
5113 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5114 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5115 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5116 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoLeftDerived)); |
5117 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5118 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5119 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5120 | ····} |
5121 | ····void CreateObjects() |
5122 | ····{ |
5123 | ········pm.MakePersistent(ownVar); |
5124 | ········ownVar.AssignRelation(otherVar); |
5125 | ········pm.Save(); |
5126 | ········pm.UnloadCache(); |
5127 | ····} |
5128 | ····void QueryOwn() |
5129 | ····{ |
5130 | ········var q = new NDOQuery<CmpBin1OwnpconTblAutoLeftBase>(pm); |
5131 | ········ownVar = q.ExecuteSingle(); |
5132 | ····} |
5133 | ····void QueryOther() |
5134 | ····{ |
5135 | ········var q = new NDOQuery<CmpBin1OwnpconTblAutoRight>(pm); |
5136 | ········otherVar = q.ExecuteSingle(); |
5137 | ····} |
5138 | } |
5139 | |
5140 | |
5141 | [TestFixture] |
5142 | public class TestCmpBi1nOwnpconTblAuto : NDOTest |
5143 | { |
5144 | ····CmpBi1nOwnpconTblAutoLeftBase ownVar; |
5145 | ····CmpBi1nOwnpconTblAutoRight otherVar; |
5146 | ····PersistenceManager pm; |
5147 | ····[SetUp] |
5148 | ····public void Setup() |
5149 | ····{ |
5150 | ········pm = PmFactory.NewPersistenceManager(); |
5151 | ········ownVar = new CmpBi1nOwnpconTblAutoLeftDerived(); |
5152 | ········otherVar = new CmpBi1nOwnpconTblAutoRight(); |
5153 | ····} |
5154 | ····[TearDown] |
5155 | ····public void TearDown() |
5156 | ····{ |
5157 | ········try |
5158 | ········{ |
5159 | ············pm.UnloadCache(); |
5160 | ············var l = pm.Objects<CmpBi1nOwnpconTblAutoLeftBase>().ResultTable; |
5161 | ············pm.Delete(l); |
5162 | ············pm.Save(); |
5163 | ············pm.UnloadCache(); |
5164 | ············decimal count; |
5165 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5166 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5167 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5168 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5169 | ········} |
5170 | ········catch (Exception) |
5171 | ········{ |
5172 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5173 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5174 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5175 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5176 | ········} |
5177 | ····} |
5178 | ····[Test] |
5179 | ····public void TestSaveReload() |
5180 | ····{ |
5181 | ········CreateObjects(); |
5182 | ········QueryOwn(); |
5183 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5184 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5185 | ····} |
5186 | ····[Test] |
5187 | ····public void TestSaveReloadNull() |
5188 | ····{ |
5189 | ········CreateObjects(); |
5190 | ········QueryOwn(); |
5191 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5192 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5193 | ········ownVar.RelField = null; |
5194 | ········pm.Save(); |
5195 | ········pm.UnloadCache(); |
5196 | ········QueryOwn(); |
5197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5198 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5199 | ····} |
5200 | ····[Test] |
5201 | ····public void TestChangeKeyHolderLeft() |
5202 | ····{ |
5203 | ········CreateObjects(); |
5204 | ········QueryOwn(); |
5205 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5207 | ········int x = ownVar.RelField.Dummy; |
5208 | ········ownVar.Dummy = 4711; |
5209 | ········pm.Save(); |
5210 | ········pm.UnloadCache(); |
5211 | ········QueryOwn(); |
5212 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5213 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5214 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5215 | ····} |
5216 | ····[Test] |
5217 | ····public void TestChangeKeyHolderLeftNoTouch() |
5218 | ····{ |
5219 | ········CreateObjects(); |
5220 | ········QueryOwn(); |
5221 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5222 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5223 | ········ownVar.Dummy = 4711; |
5224 | ········pm.Save(); |
5225 | ········pm.UnloadCache(); |
5226 | ········QueryOwn(); |
5227 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5228 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5229 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5230 | ····} |
5231 | ····[Test] |
5232 | ····public void TestRelationHash() |
5233 | ····{ |
5234 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoLeftBase)); |
5235 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5236 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoRight)); |
5237 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5238 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5239 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5240 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoLeftDerived)); |
5241 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5242 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5243 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5244 | ····} |
5245 | ····void CreateObjects() |
5246 | ····{ |
5247 | ········pm.MakePersistent(ownVar); |
5248 | ········ownVar.AssignRelation(otherVar); |
5249 | ········pm.Save(); |
5250 | ········pm.UnloadCache(); |
5251 | ····} |
5252 | ····void QueryOwn() |
5253 | ····{ |
5254 | ········var q = new NDOQuery<CmpBi1nOwnpconTblAutoLeftBase>(pm); |
5255 | ········ownVar = q.ExecuteSingle(); |
5256 | ····} |
5257 | ····void QueryOther() |
5258 | ····{ |
5259 | ········var q = new NDOQuery<CmpBi1nOwnpconTblAutoRight>(pm); |
5260 | ········otherVar = q.ExecuteSingle(); |
5261 | ····} |
5262 | } |
5263 | |
5264 | |
5265 | [TestFixture] |
5266 | public class TestCmpBinnOwnpconTblAuto : NDOTest |
5267 | { |
5268 | ····CmpBinnOwnpconTblAutoLeftBase ownVar; |
5269 | ····CmpBinnOwnpconTblAutoRight otherVar; |
5270 | ····PersistenceManager pm; |
5271 | ····[SetUp] |
5272 | ····public void Setup() |
5273 | ····{ |
5274 | ········pm = PmFactory.NewPersistenceManager(); |
5275 | ········ownVar = new CmpBinnOwnpconTblAutoLeftDerived(); |
5276 | ········otherVar = new CmpBinnOwnpconTblAutoRight(); |
5277 | ····} |
5278 | ····[TearDown] |
5279 | ····public void TearDown() |
5280 | ····{ |
5281 | ········try |
5282 | ········{ |
5283 | ············pm.UnloadCache(); |
5284 | ············var l = pm.Objects<CmpBinnOwnpconTblAutoLeftBase>().ResultTable; |
5285 | ············pm.Delete(l); |
5286 | ············pm.Save(); |
5287 | ············pm.UnloadCache(); |
5288 | ············decimal count; |
5289 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5290 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5291 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5292 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5293 | ········} |
5294 | ········catch (Exception) |
5295 | ········{ |
5296 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5297 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5298 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5299 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5300 | ········} |
5301 | ····} |
5302 | ····[Test] |
5303 | ····public void TestSaveReload() |
5304 | ····{ |
5305 | ········CreateObjects(); |
5306 | ········QueryOwn(); |
5307 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5308 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5309 | ····} |
5310 | ····[Test] |
5311 | ····public void TestSaveReloadNull() |
5312 | ····{ |
5313 | ········CreateObjects(); |
5314 | ········QueryOwn(); |
5315 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5316 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5317 | ········ownVar.RelField = new List<CmpBinnOwnpconTblAutoRight>(); |
5318 | ········pm.Save(); |
5319 | ········pm.UnloadCache(); |
5320 | ········QueryOwn(); |
5321 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5322 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5323 | ····} |
5324 | ····[Test] |
5325 | ····public void TestSaveReloadRemove() |
5326 | ····{ |
5327 | ········CreateObjects(); |
5328 | ········QueryOwn(); |
5329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5330 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5331 | ········ownVar.RemoveRelatedObject(); |
5332 | ········pm.Save(); |
5333 | ········pm.UnloadCache(); |
5334 | ········QueryOwn(); |
5335 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5336 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5337 | ····} |
5338 | ····[Test] |
5339 | ····public void TestRelationHash() |
5340 | ····{ |
5341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoLeftBase)); |
5342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoRight)); |
5344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5347 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoLeftDerived)); |
5348 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5349 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5350 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5351 | ····} |
5352 | ····void CreateObjects() |
5353 | ····{ |
5354 | ········pm.MakePersistent(ownVar); |
5355 | ········ownVar.AssignRelation(otherVar); |
5356 | ········pm.Save(); |
5357 | ········pm.UnloadCache(); |
5358 | ····} |
5359 | ····void QueryOwn() |
5360 | ····{ |
5361 | ········var q = new NDOQuery<CmpBinnOwnpconTblAutoLeftBase>(pm); |
5362 | ········ownVar = q.ExecuteSingle(); |
5363 | ····} |
5364 | ····void QueryOther() |
5365 | ····{ |
5366 | ········var q = new NDOQuery<CmpBinnOwnpconTblAutoRight>(pm); |
5367 | ········otherVar = q.ExecuteSingle(); |
5368 | ····} |
5369 | } |
5370 | |
5371 | |
5372 | [TestFixture] |
5373 | public class TestAgrDir1OthpconNoTblAuto : NDOTest |
5374 | { |
5375 | ····AgrDir1OthpconNoTblAutoLeft ownVar; |
5376 | ····AgrDir1OthpconNoTblAutoRightBase otherVar; |
5377 | ····PersistenceManager pm; |
5378 | ····[SetUp] |
5379 | ····public void Setup() |
5380 | ····{ |
5381 | ········pm = PmFactory.NewPersistenceManager(); |
5382 | ········ownVar = new AgrDir1OthpconNoTblAutoLeft(); |
5383 | ········otherVar = new AgrDir1OthpconNoTblAutoRightDerived(); |
5384 | ····} |
5385 | ····[TearDown] |
5386 | ····public void TearDown() |
5387 | ····{ |
5388 | ········try |
5389 | ········{ |
5390 | ············pm.UnloadCache(); |
5391 | ············var l = pm.Objects<AgrDir1OthpconNoTblAutoLeft>().ResultTable; |
5392 | ············pm.Delete(l); |
5393 | ············pm.Save(); |
5394 | ············pm.UnloadCache(); |
5395 | ············var m = pm.Objects<AgrDir1OthpconNoTblAutoRightBase>().ResultTable; |
5396 | ············pm.Delete(m); |
5397 | ············pm.Save(); |
5398 | ············pm.UnloadCache(); |
5399 | ············decimal count; |
5400 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5401 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5402 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5403 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5404 | ········} |
5405 | ········catch (Exception) |
5406 | ········{ |
5407 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5408 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5409 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5410 | ········} |
5411 | ····} |
5412 | ····[Test] |
5413 | ····public void TestSaveReload() |
5414 | ····{ |
5415 | ········CreateObjects(); |
5416 | ········QueryOwn(); |
5417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5419 | ····} |
5420 | ····[Test] |
5421 | ····public void TestSaveReloadNull() |
5422 | ····{ |
5423 | ········CreateObjects(); |
5424 | ········QueryOwn(); |
5425 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5426 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5427 | ········ownVar.RelField = null; |
5428 | ········pm.Save(); |
5429 | ········pm.UnloadCache(); |
5430 | ········QueryOwn(); |
5431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5432 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5433 | ····} |
5434 | ····[Test] |
5435 | ····public void TestChangeKeyHolderLeft() |
5436 | ····{ |
5437 | ········CreateObjects(); |
5438 | ········QueryOwn(); |
5439 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5440 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5441 | ········int x = ownVar.RelField.Dummy; |
5442 | ········ownVar.Dummy = 4711; |
5443 | ········pm.Save(); |
5444 | ········pm.UnloadCache(); |
5445 | ········QueryOwn(); |
5446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5447 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5448 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5449 | ····} |
5450 | ····[Test] |
5451 | ····public void TestChangeKeyHolderLeftNoTouch() |
5452 | ····{ |
5453 | ········CreateObjects(); |
5454 | ········QueryOwn(); |
5455 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5456 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5457 | ········ownVar.Dummy = 4711; |
5458 | ········pm.Save(); |
5459 | ········pm.UnloadCache(); |
5460 | ········QueryOwn(); |
5461 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5462 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5463 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5464 | ····} |
5465 | ····[Test] |
5466 | ····public void TestUpdateOrder() |
5467 | ····{ |
5468 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
5469 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
5470 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoLeft)})) |
5471 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoRightBase)})), "Wrong order #1"); |
5472 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoLeft)})) |
5473 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
5474 | ········Debug.WriteLine("AgrDir1OthpconNoTblAutoLeft"); |
5475 | ····} |
5476 | ····void CreateObjects() |
5477 | ····{ |
5478 | ········pm.MakePersistent(ownVar); |
5479 | ········pm.Save(); |
5480 | ········pm.MakePersistent(otherVar); |
5481 | ········pm.Save(); |
5482 | ········ownVar.AssignRelation(otherVar); |
5483 | ········pm.Save(); |
5484 | ········pm.UnloadCache(); |
5485 | ····} |
5486 | ····void QueryOwn() |
5487 | ····{ |
5488 | ········var q = new NDOQuery<AgrDir1OthpconNoTblAutoLeft>(pm); |
5489 | ········ownVar = q.ExecuteSingle(); |
5490 | ····} |
5491 | ····void QueryOther() |
5492 | ····{ |
5493 | ········var q = new NDOQuery<AgrDir1OthpconNoTblAutoRightBase>(pm); |
5494 | ········otherVar = q.ExecuteSingle(); |
5495 | ····} |
5496 | } |
5497 | |
5498 | |
5499 | [TestFixture] |
5500 | public class TestAgrDir1OthpconTblAuto : NDOTest |
5501 | { |
5502 | ····AgrDir1OthpconTblAutoLeft ownVar; |
5503 | ····AgrDir1OthpconTblAutoRightBase otherVar; |
5504 | ····PersistenceManager pm; |
5505 | ····[SetUp] |
5506 | ····public void Setup() |
5507 | ····{ |
5508 | ········pm = PmFactory.NewPersistenceManager(); |
5509 | ········ownVar = new AgrDir1OthpconTblAutoLeft(); |
5510 | ········otherVar = new AgrDir1OthpconTblAutoRightDerived(); |
5511 | ····} |
5512 | ····[TearDown] |
5513 | ····public void TearDown() |
5514 | ····{ |
5515 | ········try |
5516 | ········{ |
5517 | ············pm.UnloadCache(); |
5518 | ············var l = pm.Objects<AgrDir1OthpconTblAutoLeft>().ResultTable; |
5519 | ············pm.Delete(l); |
5520 | ············pm.Save(); |
5521 | ············pm.UnloadCache(); |
5522 | ············var m = pm.Objects<AgrDir1OthpconTblAutoRightBase>().ResultTable; |
5523 | ············pm.Delete(m); |
5524 | ············pm.Save(); |
5525 | ············pm.UnloadCache(); |
5526 | ············decimal count; |
5527 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5528 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5529 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5530 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5531 | ········} |
5532 | ········catch (Exception) |
5533 | ········{ |
5534 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5535 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5537 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5538 | ········} |
5539 | ····} |
5540 | ····[Test] |
5541 | ····public void TestSaveReload() |
5542 | ····{ |
5543 | ········CreateObjects(); |
5544 | ········QueryOwn(); |
5545 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5546 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5547 | ····} |
5548 | ····[Test] |
5549 | ····public void TestSaveReloadNull() |
5550 | ····{ |
5551 | ········CreateObjects(); |
5552 | ········QueryOwn(); |
5553 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5554 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5555 | ········ownVar.RelField = null; |
5556 | ········pm.Save(); |
5557 | ········pm.UnloadCache(); |
5558 | ········QueryOwn(); |
5559 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5560 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5561 | ····} |
5562 | ····[Test] |
5563 | ····public void TestChangeKeyHolderLeft() |
5564 | ····{ |
5565 | ········CreateObjects(); |
5566 | ········QueryOwn(); |
5567 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5568 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5569 | ········int x = ownVar.RelField.Dummy; |
5570 | ········ownVar.Dummy = 4711; |
5571 | ········pm.Save(); |
5572 | ········pm.UnloadCache(); |
5573 | ········QueryOwn(); |
5574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5575 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5576 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5577 | ····} |
5578 | ····[Test] |
5579 | ····public void TestChangeKeyHolderLeftNoTouch() |
5580 | ····{ |
5581 | ········CreateObjects(); |
5582 | ········QueryOwn(); |
5583 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5584 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5585 | ········ownVar.Dummy = 4711; |
5586 | ········pm.Save(); |
5587 | ········pm.UnloadCache(); |
5588 | ········QueryOwn(); |
5589 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5590 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5591 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5592 | ····} |
5593 | ····void CreateObjects() |
5594 | ····{ |
5595 | ········pm.MakePersistent(ownVar); |
5596 | ········pm.MakePersistent(otherVar); |
5597 | ········ownVar.AssignRelation(otherVar); |
5598 | ········pm.Save(); |
5599 | ········pm.UnloadCache(); |
5600 | ····} |
5601 | ····void QueryOwn() |
5602 | ····{ |
5603 | ········var q = new NDOQuery<AgrDir1OthpconTblAutoLeft>(pm); |
5604 | ········ownVar = q.ExecuteSingle(); |
5605 | ····} |
5606 | ····void QueryOther() |
5607 | ····{ |
5608 | ········var q = new NDOQuery<AgrDir1OthpconTblAutoRightBase>(pm); |
5609 | ········otherVar = q.ExecuteSingle(); |
5610 | ····} |
5611 | } |
5612 | |
5613 | |
5614 | [TestFixture] |
5615 | public class TestAgrBi11OthpconNoTblAuto : NDOTest |
5616 | { |
5617 | ····AgrBi11OthpconNoTblAutoLeft ownVar; |
5618 | ····AgrBi11OthpconNoTblAutoRightBase otherVar; |
5619 | ····PersistenceManager pm; |
5620 | ····[SetUp] |
5621 | ····public void Setup() |
5622 | ····{ |
5623 | ········pm = PmFactory.NewPersistenceManager(); |
5624 | ········ownVar = new AgrBi11OthpconNoTblAutoLeft(); |
5625 | ········otherVar = new AgrBi11OthpconNoTblAutoRightDerived(); |
5626 | ····} |
5627 | ····[TearDown] |
5628 | ····public void TearDown() |
5629 | ····{ |
5630 | ········try |
5631 | ········{ |
5632 | ············pm.UnloadCache(); |
5633 | ············var l = pm.Objects<AgrBi11OthpconNoTblAutoLeft>().ResultTable; |
5634 | ············pm.Delete(l); |
5635 | ············pm.Save(); |
5636 | ············pm.UnloadCache(); |
5637 | ············var m = pm.Objects<AgrBi11OthpconNoTblAutoRightBase>().ResultTable; |
5638 | ············pm.Delete(m); |
5639 | ············pm.Save(); |
5640 | ············pm.UnloadCache(); |
5641 | ············decimal count; |
5642 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5643 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5644 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5645 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5646 | ········} |
5647 | ········catch (Exception) |
5648 | ········{ |
5649 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5650 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5651 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5652 | ········} |
5653 | ····} |
5654 | ····[Test] |
5655 | ····public void TestSaveReload() |
5656 | ····{ |
5657 | ········CreateObjects(); |
5658 | ········QueryOwn(); |
5659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5660 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5661 | ····} |
5662 | ····[Test] |
5663 | ····public void TestSaveReloadNull() |
5664 | ····{ |
5665 | ········CreateObjects(); |
5666 | ········QueryOwn(); |
5667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5669 | ········ownVar.RelField = null; |
5670 | ········pm.Save(); |
5671 | ········pm.UnloadCache(); |
5672 | ········QueryOwn(); |
5673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5674 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5675 | ····} |
5676 | ····[Test] |
5677 | ····public void TestChangeKeyHolderLeft() |
5678 | ····{ |
5679 | ········CreateObjects(); |
5680 | ········QueryOwn(); |
5681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5682 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5683 | ········int x = ownVar.RelField.Dummy; |
5684 | ········ownVar.Dummy = 4711; |
5685 | ········pm.Save(); |
5686 | ········pm.UnloadCache(); |
5687 | ········QueryOwn(); |
5688 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5689 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5690 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5691 | ····} |
5692 | ····[Test] |
5693 | ····public void TestChangeKeyHolderRight() |
5694 | ····{ |
5695 | ········CreateObjects(); |
5696 | ········QueryOther(); |
5697 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5698 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5699 | ········int x = otherVar.RelField.Dummy; |
5700 | ········otherVar.Dummy = 4711; |
5701 | ········pm.Save(); |
5702 | ········pm.UnloadCache(); |
5703 | ········QueryOther(); |
5704 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5705 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5706 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5707 | ····} |
5708 | ····[Test] |
5709 | ····public void TestChangeKeyHolderLeftNoTouch() |
5710 | ····{ |
5711 | ········CreateObjects(); |
5712 | ········QueryOwn(); |
5713 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5714 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5715 | ········ownVar.Dummy = 4711; |
5716 | ········pm.Save(); |
5717 | ········pm.UnloadCache(); |
5718 | ········QueryOwn(); |
5719 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5720 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5721 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5722 | ····} |
5723 | ····[Test] |
5724 | ····public void TestChangeKeyHolderRightNoTouch() |
5725 | ····{ |
5726 | ········CreateObjects(); |
5727 | ········QueryOther(); |
5728 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5729 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5730 | ········otherVar.Dummy = 4711; |
5731 | ········pm.Save(); |
5732 | ········pm.UnloadCache(); |
5733 | ········QueryOther(); |
5734 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5735 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5736 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5737 | ····} |
5738 | ····[Test] |
5739 | ····public void TestRelationHash() |
5740 | ····{ |
5741 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoLeft)); |
5742 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5743 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoRightBase)); |
5744 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5745 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5746 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5747 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoRightDerived)); |
5748 | ········Relation relderRight = clderRight.FindRelation("relField"); |
5749 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
5750 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
5751 | ····} |
5752 | ····void CreateObjects() |
5753 | ····{ |
5754 | ········pm.MakePersistent(ownVar); |
5755 | ········pm.Save(); |
5756 | ········pm.MakePersistent(otherVar); |
5757 | ········pm.Save(); |
5758 | ········ownVar.AssignRelation(otherVar); |
5759 | ········pm.Save(); |
5760 | ········pm.UnloadCache(); |
5761 | ····} |
5762 | ····void QueryOwn() |
5763 | ····{ |
5764 | ········var q = new NDOQuery<AgrBi11OthpconNoTblAutoLeft>(pm); |
5765 | ········ownVar = q.ExecuteSingle(); |
5766 | ····} |
5767 | ····void QueryOther() |
5768 | ····{ |
5769 | ········var q = new NDOQuery<AgrBi11OthpconNoTblAutoRightBase>(pm); |
5770 | ········otherVar = q.ExecuteSingle(); |
5771 | ····} |
5772 | } |
5773 | |
5774 | |
5775 | [TestFixture] |
5776 | public class TestAgrBi11OthpconTblAuto : NDOTest |
5777 | { |
5778 | ····AgrBi11OthpconTblAutoLeft ownVar; |
5779 | ····AgrBi11OthpconTblAutoRightBase otherVar; |
5780 | ····PersistenceManager pm; |
5781 | ····[SetUp] |
5782 | ····public void Setup() |
5783 | ····{ |
5784 | ········pm = PmFactory.NewPersistenceManager(); |
5785 | ········ownVar = new AgrBi11OthpconTblAutoLeft(); |
5786 | ········otherVar = new AgrBi11OthpconTblAutoRightDerived(); |
5787 | ····} |
5788 | ····[TearDown] |
5789 | ····public void TearDown() |
5790 | ····{ |
5791 | ········try |
5792 | ········{ |
5793 | ············pm.UnloadCache(); |
5794 | ············var l = pm.Objects<AgrBi11OthpconTblAutoLeft>().ResultTable; |
5795 | ············pm.Delete(l); |
5796 | ············pm.Save(); |
5797 | ············pm.UnloadCache(); |
5798 | ············var m = pm.Objects<AgrBi11OthpconTblAutoRightBase>().ResultTable; |
5799 | ············pm.Delete(m); |
5800 | ············pm.Save(); |
5801 | ············pm.UnloadCache(); |
5802 | ············decimal count; |
5803 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5804 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5805 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5806 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5807 | ········} |
5808 | ········catch (Exception) |
5809 | ········{ |
5810 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5811 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5812 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5813 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5814 | ········} |
5815 | ····} |
5816 | ····[Test] |
5817 | ····public void TestSaveReload() |
5818 | ····{ |
5819 | ········CreateObjects(); |
5820 | ········QueryOwn(); |
5821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5823 | ····} |
5824 | ····[Test] |
5825 | ····public void TestSaveReloadNull() |
5826 | ····{ |
5827 | ········CreateObjects(); |
5828 | ········QueryOwn(); |
5829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5831 | ········ownVar.RelField = null; |
5832 | ········pm.Save(); |
5833 | ········pm.UnloadCache(); |
5834 | ········QueryOwn(); |
5835 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5836 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5837 | ····} |
5838 | ····[Test] |
5839 | ····public void TestChangeKeyHolderLeft() |
5840 | ····{ |
5841 | ········CreateObjects(); |
5842 | ········QueryOwn(); |
5843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5844 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5845 | ········int x = ownVar.RelField.Dummy; |
5846 | ········ownVar.Dummy = 4711; |
5847 | ········pm.Save(); |
5848 | ········pm.UnloadCache(); |
5849 | ········QueryOwn(); |
5850 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5851 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5853 | ····} |
5854 | ····[Test] |
5855 | ····public void TestChangeKeyHolderRight() |
5856 | ····{ |
5857 | ········CreateObjects(); |
5858 | ········QueryOther(); |
5859 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5860 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5861 | ········int x = otherVar.RelField.Dummy; |
5862 | ········otherVar.Dummy = 4711; |
5863 | ········pm.Save(); |
5864 | ········pm.UnloadCache(); |
5865 | ········QueryOther(); |
5866 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5867 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5868 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5869 | ····} |
5870 | ····[Test] |
5871 | ····public void TestChangeKeyHolderLeftNoTouch() |
5872 | ····{ |
5873 | ········CreateObjects(); |
5874 | ········QueryOwn(); |
5875 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5876 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5877 | ········ownVar.Dummy = 4711; |
5878 | ········pm.Save(); |
5879 | ········pm.UnloadCache(); |
5880 | ········QueryOwn(); |
5881 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5882 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5883 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5884 | ····} |
5885 | ····[Test] |
5886 | ····public void TestChangeKeyHolderRightNoTouch() |
5887 | ····{ |
5888 | ········CreateObjects(); |
5889 | ········QueryOther(); |
5890 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5891 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5892 | ········otherVar.Dummy = 4711; |
5893 | ········pm.Save(); |
5894 | ········pm.UnloadCache(); |
5895 | ········QueryOther(); |
5896 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5897 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5898 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5899 | ····} |
5900 | ····[Test] |
5901 | ····public void TestRelationHash() |
5902 | ····{ |
5903 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoLeft)); |
5904 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5905 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoRightBase)); |
5906 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5907 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5908 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5909 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoRightDerived)); |
5910 | ········Relation relderRight = clderRight.FindRelation("relField"); |
5911 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
5912 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
5913 | ····} |
5914 | ····void CreateObjects() |
5915 | ····{ |
5916 | ········pm.MakePersistent(ownVar); |
5917 | ········pm.MakePersistent(otherVar); |
5918 | ········ownVar.AssignRelation(otherVar); |
5919 | ········pm.Save(); |
5920 | ········pm.UnloadCache(); |
5921 | ····} |
5922 | ····void QueryOwn() |
5923 | ····{ |
5924 | ········var q = new NDOQuery<AgrBi11OthpconTblAutoLeft>(pm); |
5925 | ········ownVar = q.ExecuteSingle(); |
5926 | ····} |
5927 | ····void QueryOther() |
5928 | ····{ |
5929 | ········var q = new NDOQuery<AgrBi11OthpconTblAutoRightBase>(pm); |
5930 | ········otherVar = q.ExecuteSingle(); |
5931 | ····} |
5932 | } |
5933 | |
5934 | |
5935 | [TestFixture] |
5936 | public class TestAgrDirnOthpconTblAuto : NDOTest |
5937 | { |
5938 | ····AgrDirnOthpconTblAutoLeft ownVar; |
5939 | ····AgrDirnOthpconTblAutoRightBase otherVar; |
5940 | ····PersistenceManager pm; |
5941 | ····[SetUp] |
5942 | ····public void Setup() |
5943 | ····{ |
5944 | ········pm = PmFactory.NewPersistenceManager(); |
5945 | ········ownVar = new AgrDirnOthpconTblAutoLeft(); |
5946 | ········otherVar = new AgrDirnOthpconTblAutoRightDerived(); |
5947 | ····} |
5948 | ····[TearDown] |
5949 | ····public void TearDown() |
5950 | ····{ |
5951 | ········try |
5952 | ········{ |
5953 | ············pm.UnloadCache(); |
5954 | ············var l = pm.Objects<AgrDirnOthpconTblAutoLeft>().ResultTable; |
5955 | ············pm.Delete(l); |
5956 | ············pm.Save(); |
5957 | ············pm.UnloadCache(); |
5958 | ············var m = pm.Objects<AgrDirnOthpconTblAutoRightBase>().ResultTable; |
5959 | ············pm.Delete(m); |
5960 | ············pm.Save(); |
5961 | ············pm.UnloadCache(); |
5962 | ············decimal count; |
5963 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5964 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5965 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5966 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5967 | ········} |
5968 | ········catch (Exception) |
5969 | ········{ |
5970 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5971 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5972 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5973 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5974 | ········} |
5975 | ····} |
5976 | ····[Test] |
5977 | ····public void TestSaveReload() |
5978 | ····{ |
5979 | ········CreateObjects(); |
5980 | ········QueryOwn(); |
5981 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5982 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5983 | ····} |
5984 | ····[Test] |
5985 | ····public void TestSaveReloadNull() |
5986 | ····{ |
5987 | ········CreateObjects(); |
5988 | ········QueryOwn(); |
5989 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5990 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5991 | ········ownVar.RelField = new List<AgrDirnOthpconTblAutoRightBase>(); |
5992 | ········pm.Save(); |
5993 | ········pm.UnloadCache(); |
5994 | ········QueryOwn(); |
5995 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5996 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5997 | ····} |
5998 | ····[Test] |
5999 | ····public void TestSaveReloadRemove() |
6000 | ····{ |
6001 | ········CreateObjects(); |
6002 | ········QueryOwn(); |
6003 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6004 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6005 | ········ownVar.RemoveRelatedObject(); |
6006 | ········pm.Save(); |
6007 | ········pm.UnloadCache(); |
6008 | ········QueryOwn(); |
6009 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6010 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6011 | ····} |
6012 | ····void CreateObjects() |
6013 | ····{ |
6014 | ········pm.MakePersistent(ownVar); |
6015 | ········pm.MakePersistent(otherVar); |
6016 | ········ownVar.AssignRelation(otherVar); |
6017 | ········pm.Save(); |
6018 | ········pm.UnloadCache(); |
6019 | ····} |
6020 | ····void QueryOwn() |
6021 | ····{ |
6022 | ········var q = new NDOQuery<AgrDirnOthpconTblAutoLeft>(pm); |
6023 | ········ownVar = q.ExecuteSingle(); |
6024 | ····} |
6025 | ····void QueryOther() |
6026 | ····{ |
6027 | ········var q = new NDOQuery<AgrDirnOthpconTblAutoRightBase>(pm); |
6028 | ········otherVar = q.ExecuteSingle(); |
6029 | ····} |
6030 | } |
6031 | |
6032 | |
6033 | [TestFixture] |
6034 | public class TestAgrBin1OthpconTblAuto : NDOTest |
6035 | { |
6036 | ····AgrBin1OthpconTblAutoLeft ownVar; |
6037 | ····AgrBin1OthpconTblAutoRightBase otherVar; |
6038 | ····PersistenceManager pm; |
6039 | ····[SetUp] |
6040 | ····public void Setup() |
6041 | ····{ |
6042 | ········pm = PmFactory.NewPersistenceManager(); |
6043 | ········ownVar = new AgrBin1OthpconTblAutoLeft(); |
6044 | ········otherVar = new AgrBin1OthpconTblAutoRightDerived(); |
6045 | ····} |
6046 | ····[TearDown] |
6047 | ····public void TearDown() |
6048 | ····{ |
6049 | ········try |
6050 | ········{ |
6051 | ············pm.UnloadCache(); |
6052 | ············var l = pm.Objects<AgrBin1OthpconTblAutoLeft>().ResultTable; |
6053 | ············pm.Delete(l); |
6054 | ············pm.Save(); |
6055 | ············pm.UnloadCache(); |
6056 | ············var m = pm.Objects<AgrBin1OthpconTblAutoRightBase>().ResultTable; |
6057 | ············pm.Delete(m); |
6058 | ············pm.Save(); |
6059 | ············pm.UnloadCache(); |
6060 | ············decimal count; |
6061 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6063 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6064 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6065 | ········} |
6066 | ········catch (Exception) |
6067 | ········{ |
6068 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6069 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6070 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6071 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6072 | ········} |
6073 | ····} |
6074 | ····[Test] |
6075 | ····public void TestSaveReload() |
6076 | ····{ |
6077 | ········CreateObjects(); |
6078 | ········QueryOwn(); |
6079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6080 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6081 | ····} |
6082 | ····[Test] |
6083 | ····public void TestSaveReloadNull() |
6084 | ····{ |
6085 | ········CreateObjects(); |
6086 | ········QueryOwn(); |
6087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6088 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6089 | ········ownVar.RelField = new List<AgrBin1OthpconTblAutoRightBase>(); |
6090 | ········pm.Save(); |
6091 | ········pm.UnloadCache(); |
6092 | ········QueryOwn(); |
6093 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6094 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6095 | ····} |
6096 | ····[Test] |
6097 | ····public void TestSaveReloadRemove() |
6098 | ····{ |
6099 | ········CreateObjects(); |
6100 | ········QueryOwn(); |
6101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6102 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6103 | ········ownVar.RemoveRelatedObject(); |
6104 | ········pm.Save(); |
6105 | ········pm.UnloadCache(); |
6106 | ········QueryOwn(); |
6107 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6108 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6109 | ····} |
6110 | ····[Test] |
6111 | ····public void TestChangeKeyHolderRight() |
6112 | ····{ |
6113 | ········CreateObjects(); |
6114 | ········QueryOther(); |
6115 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6116 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6117 | ········int x = otherVar.RelField.Dummy; |
6118 | ········otherVar.Dummy = 4711; |
6119 | ········pm.Save(); |
6120 | ········pm.UnloadCache(); |
6121 | ········QueryOther(); |
6122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6125 | ····} |
6126 | ····[Test] |
6127 | ····public void TestChangeKeyHolderRightNoTouch() |
6128 | ····{ |
6129 | ········CreateObjects(); |
6130 | ········QueryOther(); |
6131 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6132 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6133 | ········otherVar.Dummy = 4711; |
6134 | ········pm.Save(); |
6135 | ········pm.UnloadCache(); |
6136 | ········QueryOther(); |
6137 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6138 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6139 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6140 | ····} |
6141 | ····[Test] |
6142 | ····public void TestRelationHash() |
6143 | ····{ |
6144 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoLeft)); |
6145 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6146 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoRightBase)); |
6147 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6148 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6149 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6150 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoRightDerived)); |
6151 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6152 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6153 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6154 | ····} |
6155 | ····void CreateObjects() |
6156 | ····{ |
6157 | ········pm.MakePersistent(ownVar); |
6158 | ········pm.MakePersistent(otherVar); |
6159 | ········ownVar.AssignRelation(otherVar); |
6160 | ········pm.Save(); |
6161 | ········pm.UnloadCache(); |
6162 | ····} |
6163 | ····void QueryOwn() |
6164 | ····{ |
6165 | ········var q = new NDOQuery<AgrBin1OthpconTblAutoLeft>(pm); |
6166 | ········ownVar = q.ExecuteSingle(); |
6167 | ····} |
6168 | ····void QueryOther() |
6169 | ····{ |
6170 | ········var q = new NDOQuery<AgrBin1OthpconTblAutoRightBase>(pm); |
6171 | ········otherVar = q.ExecuteSingle(); |
6172 | ····} |
6173 | } |
6174 | |
6175 | |
6176 | [TestFixture] |
6177 | public class TestAgrBi1nOthpconNoTblAuto : NDOTest |
6178 | { |
6179 | ····AgrBi1nOthpconNoTblAutoLeft ownVar; |
6180 | ····AgrBi1nOthpconNoTblAutoRightBase otherVar; |
6181 | ····PersistenceManager pm; |
6182 | ····[SetUp] |
6183 | ····public void Setup() |
6184 | ····{ |
6185 | ········pm = PmFactory.NewPersistenceManager(); |
6186 | ········ownVar = new AgrBi1nOthpconNoTblAutoLeft(); |
6187 | ········otherVar = new AgrBi1nOthpconNoTblAutoRightDerived(); |
6188 | ····} |
6189 | ····[TearDown] |
6190 | ····public void TearDown() |
6191 | ····{ |
6192 | ········try |
6193 | ········{ |
6194 | ············pm.UnloadCache(); |
6195 | ············var l = pm.Objects<AgrBi1nOthpconNoTblAutoLeft>().ResultTable; |
6196 | ············pm.Delete(l); |
6197 | ············pm.Save(); |
6198 | ············pm.UnloadCache(); |
6199 | ············var m = pm.Objects<AgrBi1nOthpconNoTblAutoRightBase>().ResultTable; |
6200 | ············pm.Delete(m); |
6201 | ············pm.Save(); |
6202 | ············pm.UnloadCache(); |
6203 | ············decimal count; |
6204 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6205 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6206 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6207 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6208 | ········} |
6209 | ········catch (Exception) |
6210 | ········{ |
6211 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6212 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6213 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6214 | ········} |
6215 | ····} |
6216 | ····[Test] |
6217 | ····public void TestSaveReload() |
6218 | ····{ |
6219 | ········CreateObjects(); |
6220 | ········QueryOwn(); |
6221 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6222 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6223 | ····} |
6224 | ····[Test] |
6225 | ····public void TestSaveReloadNull() |
6226 | ····{ |
6227 | ········CreateObjects(); |
6228 | ········QueryOwn(); |
6229 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6230 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6231 | ········ownVar.RelField = null; |
6232 | ········pm.Save(); |
6233 | ········pm.UnloadCache(); |
6234 | ········QueryOwn(); |
6235 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6236 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6237 | ····} |
6238 | ····[Test] |
6239 | ····public void TestChangeKeyHolderLeft() |
6240 | ····{ |
6241 | ········CreateObjects(); |
6242 | ········QueryOwn(); |
6243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6244 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6245 | ········int x = ownVar.RelField.Dummy; |
6246 | ········ownVar.Dummy = 4711; |
6247 | ········pm.Save(); |
6248 | ········pm.UnloadCache(); |
6249 | ········QueryOwn(); |
6250 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6251 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6252 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6253 | ····} |
6254 | ····[Test] |
6255 | ····public void TestChangeKeyHolderLeftNoTouch() |
6256 | ····{ |
6257 | ········CreateObjects(); |
6258 | ········QueryOwn(); |
6259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6261 | ········ownVar.Dummy = 4711; |
6262 | ········pm.Save(); |
6263 | ········pm.UnloadCache(); |
6264 | ········QueryOwn(); |
6265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6266 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6268 | ····} |
6269 | ····[Test] |
6270 | ····public void TestUpdateOrder() |
6271 | ····{ |
6272 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
6273 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
6274 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoLeft)})) |
6275 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoRightBase)})), "Wrong order #1"); |
6276 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoLeft)})) |
6277 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
6278 | ········Debug.WriteLine("AgrBi1nOthpconNoTblAutoLeft"); |
6279 | ····} |
6280 | ····[Test] |
6281 | ····public void TestRelationHash() |
6282 | ····{ |
6283 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoLeft)); |
6284 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6285 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoRightBase)); |
6286 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6287 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6288 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6289 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoRightDerived)); |
6290 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6291 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6292 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6293 | ····} |
6294 | ····void CreateObjects() |
6295 | ····{ |
6296 | ········pm.MakePersistent(ownVar); |
6297 | ········pm.Save(); |
6298 | ········pm.MakePersistent(otherVar); |
6299 | ········pm.Save(); |
6300 | ········ownVar.AssignRelation(otherVar); |
6301 | ········pm.Save(); |
6302 | ········pm.UnloadCache(); |
6303 | ····} |
6304 | ····void QueryOwn() |
6305 | ····{ |
6306 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblAutoLeft>(pm); |
6307 | ········ownVar = q.ExecuteSingle(); |
6308 | ····} |
6309 | ····void QueryOther() |
6310 | ····{ |
6311 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblAutoRightBase>(pm); |
6312 | ········otherVar = q.ExecuteSingle(); |
6313 | ····} |
6314 | } |
6315 | |
6316 | |
6317 | [TestFixture] |
6318 | public class TestAgrBi1nOthpconTblAuto : NDOTest |
6319 | { |
6320 | ····AgrBi1nOthpconTblAutoLeft ownVar; |
6321 | ····AgrBi1nOthpconTblAutoRightBase otherVar; |
6322 | ····PersistenceManager pm; |
6323 | ····[SetUp] |
6324 | ····public void Setup() |
6325 | ····{ |
6326 | ········pm = PmFactory.NewPersistenceManager(); |
6327 | ········ownVar = new AgrBi1nOthpconTblAutoLeft(); |
6328 | ········otherVar = new AgrBi1nOthpconTblAutoRightDerived(); |
6329 | ····} |
6330 | ····[TearDown] |
6331 | ····public void TearDown() |
6332 | ····{ |
6333 | ········try |
6334 | ········{ |
6335 | ············pm.UnloadCache(); |
6336 | ············var l = pm.Objects<AgrBi1nOthpconTblAutoLeft>().ResultTable; |
6337 | ············pm.Delete(l); |
6338 | ············pm.Save(); |
6339 | ············pm.UnloadCache(); |
6340 | ············var m = pm.Objects<AgrBi1nOthpconTblAutoRightBase>().ResultTable; |
6341 | ············pm.Delete(m); |
6342 | ············pm.Save(); |
6343 | ············pm.UnloadCache(); |
6344 | ············decimal count; |
6345 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6346 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6347 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6348 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6349 | ········} |
6350 | ········catch (Exception) |
6351 | ········{ |
6352 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6353 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6354 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6355 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6356 | ········} |
6357 | ····} |
6358 | ····[Test] |
6359 | ····public void TestSaveReload() |
6360 | ····{ |
6361 | ········CreateObjects(); |
6362 | ········QueryOwn(); |
6363 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6364 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6365 | ····} |
6366 | ····[Test] |
6367 | ····public void TestSaveReloadNull() |
6368 | ····{ |
6369 | ········CreateObjects(); |
6370 | ········QueryOwn(); |
6371 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6372 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6373 | ········ownVar.RelField = null; |
6374 | ········pm.Save(); |
6375 | ········pm.UnloadCache(); |
6376 | ········QueryOwn(); |
6377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6378 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6379 | ····} |
6380 | ····[Test] |
6381 | ····public void TestChangeKeyHolderLeft() |
6382 | ····{ |
6383 | ········CreateObjects(); |
6384 | ········QueryOwn(); |
6385 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6386 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6387 | ········int x = ownVar.RelField.Dummy; |
6388 | ········ownVar.Dummy = 4711; |
6389 | ········pm.Save(); |
6390 | ········pm.UnloadCache(); |
6391 | ········QueryOwn(); |
6392 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6393 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6394 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6395 | ····} |
6396 | ····[Test] |
6397 | ····public void TestChangeKeyHolderLeftNoTouch() |
6398 | ····{ |
6399 | ········CreateObjects(); |
6400 | ········QueryOwn(); |
6401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6402 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6403 | ········ownVar.Dummy = 4711; |
6404 | ········pm.Save(); |
6405 | ········pm.UnloadCache(); |
6406 | ········QueryOwn(); |
6407 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6408 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6409 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6410 | ····} |
6411 | ····[Test] |
6412 | ····public void TestRelationHash() |
6413 | ····{ |
6414 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoLeft)); |
6415 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6416 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoRightBase)); |
6417 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6418 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6419 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6420 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoRightDerived)); |
6421 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6422 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6423 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6424 | ····} |
6425 | ····void CreateObjects() |
6426 | ····{ |
6427 | ········pm.MakePersistent(ownVar); |
6428 | ········pm.MakePersistent(otherVar); |
6429 | ········ownVar.AssignRelation(otherVar); |
6430 | ········pm.Save(); |
6431 | ········pm.UnloadCache(); |
6432 | ····} |
6433 | ····void QueryOwn() |
6434 | ····{ |
6435 | ········var q = new NDOQuery<AgrBi1nOthpconTblAutoLeft>(pm); |
6436 | ········ownVar = q.ExecuteSingle(); |
6437 | ····} |
6438 | ····void QueryOther() |
6439 | ····{ |
6440 | ········var q = new NDOQuery<AgrBi1nOthpconTblAutoRightBase>(pm); |
6441 | ········otherVar = q.ExecuteSingle(); |
6442 | ····} |
6443 | } |
6444 | |
6445 | |
6446 | [TestFixture] |
6447 | public class TestAgrBinnOthpconTblAuto : NDOTest |
6448 | { |
6449 | ····AgrBinnOthpconTblAutoLeft ownVar; |
6450 | ····AgrBinnOthpconTblAutoRightBase otherVar; |
6451 | ····PersistenceManager pm; |
6452 | ····[SetUp] |
6453 | ····public void Setup() |
6454 | ····{ |
6455 | ········pm = PmFactory.NewPersistenceManager(); |
6456 | ········ownVar = new AgrBinnOthpconTblAutoLeft(); |
6457 | ········otherVar = new AgrBinnOthpconTblAutoRightDerived(); |
6458 | ····} |
6459 | ····[TearDown] |
6460 | ····public void TearDown() |
6461 | ····{ |
6462 | ········try |
6463 | ········{ |
6464 | ············pm.UnloadCache(); |
6465 | ············var l = pm.Objects<AgrBinnOthpconTblAutoLeft>().ResultTable; |
6466 | ············pm.Delete(l); |
6467 | ············pm.Save(); |
6468 | ············pm.UnloadCache(); |
6469 | ············var m = pm.Objects<AgrBinnOthpconTblAutoRightBase>().ResultTable; |
6470 | ············pm.Delete(m); |
6471 | ············pm.Save(); |
6472 | ············pm.UnloadCache(); |
6473 | ············decimal count; |
6474 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6475 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6476 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6477 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6478 | ········} |
6479 | ········catch (Exception) |
6480 | ········{ |
6481 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6482 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6483 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6484 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6485 | ········} |
6486 | ····} |
6487 | ····[Test] |
6488 | ····public void TestSaveReload() |
6489 | ····{ |
6490 | ········CreateObjects(); |
6491 | ········QueryOwn(); |
6492 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6493 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6494 | ····} |
6495 | ····[Test] |
6496 | ····public void TestSaveReloadNull() |
6497 | ····{ |
6498 | ········CreateObjects(); |
6499 | ········QueryOwn(); |
6500 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6501 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6502 | ········ownVar.RelField = new List<AgrBinnOthpconTblAutoRightBase>(); |
6503 | ········pm.Save(); |
6504 | ········pm.UnloadCache(); |
6505 | ········QueryOwn(); |
6506 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6507 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6508 | ····} |
6509 | ····[Test] |
6510 | ····public void TestSaveReloadRemove() |
6511 | ····{ |
6512 | ········CreateObjects(); |
6513 | ········QueryOwn(); |
6514 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6515 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6516 | ········ownVar.RemoveRelatedObject(); |
6517 | ········pm.Save(); |
6518 | ········pm.UnloadCache(); |
6519 | ········QueryOwn(); |
6520 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6521 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6522 | ····} |
6523 | ····[Test] |
6524 | ····public void TestRelationHash() |
6525 | ····{ |
6526 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoLeft)); |
6527 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6528 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoRightBase)); |
6529 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6530 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6531 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6532 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoRightDerived)); |
6533 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6534 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6535 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6536 | ····} |
6537 | ····void CreateObjects() |
6538 | ····{ |
6539 | ········pm.MakePersistent(ownVar); |
6540 | ········pm.MakePersistent(otherVar); |
6541 | ········ownVar.AssignRelation(otherVar); |
6542 | ········pm.Save(); |
6543 | ········pm.UnloadCache(); |
6544 | ····} |
6545 | ····void QueryOwn() |
6546 | ····{ |
6547 | ········var q = new NDOQuery<AgrBinnOthpconTblAutoLeft>(pm); |
6548 | ········ownVar = q.ExecuteSingle(); |
6549 | ····} |
6550 | ····void QueryOther() |
6551 | ····{ |
6552 | ········var q = new NDOQuery<AgrBinnOthpconTblAutoRightBase>(pm); |
6553 | ········otherVar = q.ExecuteSingle(); |
6554 | ····} |
6555 | } |
6556 | |
6557 | |
6558 | [TestFixture] |
6559 | public class TestCmpDir1OthpconNoTblAuto : NDOTest |
6560 | { |
6561 | ····CmpDir1OthpconNoTblAutoLeft ownVar; |
6562 | ····CmpDir1OthpconNoTblAutoRightBase otherVar; |
6563 | ····PersistenceManager pm; |
6564 | ····[SetUp] |
6565 | ····public void Setup() |
6566 | ····{ |
6567 | ········pm = PmFactory.NewPersistenceManager(); |
6568 | ········ownVar = new CmpDir1OthpconNoTblAutoLeft(); |
6569 | ········otherVar = new CmpDir1OthpconNoTblAutoRightDerived(); |
6570 | ····} |
6571 | ····[TearDown] |
6572 | ····public void TearDown() |
6573 | ····{ |
6574 | ········try |
6575 | ········{ |
6576 | ············pm.UnloadCache(); |
6577 | ············var l = pm.Objects<CmpDir1OthpconNoTblAutoLeft>().ResultTable; |
6578 | ············pm.Delete(l); |
6579 | ············pm.Save(); |
6580 | ············pm.UnloadCache(); |
6581 | ············decimal count; |
6582 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6583 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6584 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6585 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6586 | ········} |
6587 | ········catch (Exception) |
6588 | ········{ |
6589 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6590 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6591 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6592 | ········} |
6593 | ····} |
6594 | ····[Test] |
6595 | ····public void TestSaveReload() |
6596 | ····{ |
6597 | ········bool thrown = false; |
6598 | ········try |
6599 | ········{ |
6600 | ············CreateObjects(); |
6601 | ············QueryOwn(); |
6602 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6603 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6604 | ········} |
6605 | ········catch (NDOException) |
6606 | ········{ |
6607 | ············thrown = true; |
6608 | ········} |
6609 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6610 | ····} |
6611 | ····[Test] |
6612 | ····public void TestSaveReloadNull() |
6613 | ····{ |
6614 | ········bool thrown = false; |
6615 | ········try |
6616 | ········{ |
6617 | ············CreateObjects(); |
6618 | ············QueryOwn(); |
6619 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6620 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6621 | ············ownVar.RelField = null; |
6622 | ············pm.Save(); |
6623 | ············pm.UnloadCache(); |
6624 | ············QueryOwn(); |
6625 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6626 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6627 | ········} |
6628 | ········catch (NDOException) |
6629 | ········{ |
6630 | ············thrown = true; |
6631 | ········} |
6632 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6633 | ····} |
6634 | ····void CreateObjects() |
6635 | ····{ |
6636 | ········pm.MakePersistent(ownVar); |
6637 | ········pm.Save(); |
6638 | ········ownVar.AssignRelation(otherVar); |
6639 | ········pm.Save(); |
6640 | ········pm.UnloadCache(); |
6641 | ····} |
6642 | ····void QueryOwn() |
6643 | ····{ |
6644 | ········var q = new NDOQuery<CmpDir1OthpconNoTblAutoLeft>(pm); |
6645 | ········ownVar = q.ExecuteSingle(); |
6646 | ····} |
6647 | ····void QueryOther() |
6648 | ····{ |
6649 | ········var q = new NDOQuery<CmpDir1OthpconNoTblAutoRightBase>(pm); |
6650 | ········otherVar = q.ExecuteSingle(); |
6651 | ····} |
6652 | } |
6653 | |
6654 | |
6655 | [TestFixture] |
6656 | public class TestCmpDir1OthpconTblAuto : NDOTest |
6657 | { |
6658 | ····CmpDir1OthpconTblAutoLeft ownVar; |
6659 | ····CmpDir1OthpconTblAutoRightBase otherVar; |
6660 | ····PersistenceManager pm; |
6661 | ····[SetUp] |
6662 | ····public void Setup() |
6663 | ····{ |
6664 | ········pm = PmFactory.NewPersistenceManager(); |
6665 | ········ownVar = new CmpDir1OthpconTblAutoLeft(); |
6666 | ········otherVar = new CmpDir1OthpconTblAutoRightDerived(); |
6667 | ····} |
6668 | ····[TearDown] |
6669 | ····public void TearDown() |
6670 | ····{ |
6671 | ········try |
6672 | ········{ |
6673 | ············pm.UnloadCache(); |
6674 | ············var l = pm.Objects<CmpDir1OthpconTblAutoLeft>().ResultTable; |
6675 | ············pm.Delete(l); |
6676 | ············pm.Save(); |
6677 | ············pm.UnloadCache(); |
6678 | ············decimal count; |
6679 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6680 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6681 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6682 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6683 | ········} |
6684 | ········catch (Exception) |
6685 | ········{ |
6686 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6687 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6688 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6689 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6690 | ········} |
6691 | ····} |
6692 | ····[Test] |
6693 | ····public void TestSaveReload() |
6694 | ····{ |
6695 | ········CreateObjects(); |
6696 | ········QueryOwn(); |
6697 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6698 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6699 | ····} |
6700 | ····[Test] |
6701 | ····public void TestSaveReloadNull() |
6702 | ····{ |
6703 | ········CreateObjects(); |
6704 | ········QueryOwn(); |
6705 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6706 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6707 | ········ownVar.RelField = null; |
6708 | ········pm.Save(); |
6709 | ········pm.UnloadCache(); |
6710 | ········QueryOwn(); |
6711 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6712 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6713 | ····} |
6714 | ····[Test] |
6715 | ····public void TestChangeKeyHolderLeft() |
6716 | ····{ |
6717 | ········CreateObjects(); |
6718 | ········QueryOwn(); |
6719 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6720 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6721 | ········int x = ownVar.RelField.Dummy; |
6722 | ········ownVar.Dummy = 4711; |
6723 | ········pm.Save(); |
6724 | ········pm.UnloadCache(); |
6725 | ········QueryOwn(); |
6726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6727 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6728 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6729 | ····} |
6730 | ····[Test] |
6731 | ····public void TestChangeKeyHolderLeftNoTouch() |
6732 | ····{ |
6733 | ········CreateObjects(); |
6734 | ········QueryOwn(); |
6735 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6736 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6737 | ········ownVar.Dummy = 4711; |
6738 | ········pm.Save(); |
6739 | ········pm.UnloadCache(); |
6740 | ········QueryOwn(); |
6741 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6742 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6744 | ····} |
6745 | ····void CreateObjects() |
6746 | ····{ |
6747 | ········pm.MakePersistent(ownVar); |
6748 | ········ownVar.AssignRelation(otherVar); |
6749 | ········pm.Save(); |
6750 | ········pm.UnloadCache(); |
6751 | ····} |
6752 | ····void QueryOwn() |
6753 | ····{ |
6754 | ········var q = new NDOQuery<CmpDir1OthpconTblAutoLeft>(pm); |
6755 | ········ownVar = q.ExecuteSingle(); |
6756 | ····} |
6757 | ····void QueryOther() |
6758 | ····{ |
6759 | ········var q = new NDOQuery<CmpDir1OthpconTblAutoRightBase>(pm); |
6760 | ········otherVar = q.ExecuteSingle(); |
6761 | ····} |
6762 | } |
6763 | |
6764 | |
6765 | [TestFixture] |
6766 | public class TestCmpBi11OthpconNoTblAuto : NDOTest |
6767 | { |
6768 | ····CmpBi11OthpconNoTblAutoLeft ownVar; |
6769 | ····CmpBi11OthpconNoTblAutoRightBase otherVar; |
6770 | ····PersistenceManager pm; |
6771 | ····[SetUp] |
6772 | ····public void Setup() |
6773 | ····{ |
6774 | ········pm = PmFactory.NewPersistenceManager(); |
6775 | ········ownVar = new CmpBi11OthpconNoTblAutoLeft(); |
6776 | ········otherVar = new CmpBi11OthpconNoTblAutoRightDerived(); |
6777 | ····} |
6778 | ····[TearDown] |
6779 | ····public void TearDown() |
6780 | ····{ |
6781 | ········try |
6782 | ········{ |
6783 | ············pm.UnloadCache(); |
6784 | ············var l = pm.Objects<CmpBi11OthpconNoTblAutoLeft>().ResultTable; |
6785 | ············pm.Delete(l); |
6786 | ············pm.Save(); |
6787 | ············pm.UnloadCache(); |
6788 | ············decimal count; |
6789 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6790 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6791 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6792 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6793 | ········} |
6794 | ········catch (Exception) |
6795 | ········{ |
6796 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6797 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6798 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6799 | ········} |
6800 | ····} |
6801 | ····[Test] |
6802 | ····public void TestSaveReload() |
6803 | ····{ |
6804 | ········bool thrown = false; |
6805 | ········try |
6806 | ········{ |
6807 | ············CreateObjects(); |
6808 | ············QueryOwn(); |
6809 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6810 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6811 | ········} |
6812 | ········catch (NDOException) |
6813 | ········{ |
6814 | ············thrown = true; |
6815 | ········} |
6816 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6817 | ····} |
6818 | ····[Test] |
6819 | ····public void TestSaveReloadNull() |
6820 | ····{ |
6821 | ········bool thrown = false; |
6822 | ········try |
6823 | ········{ |
6824 | ············CreateObjects(); |
6825 | ············QueryOwn(); |
6826 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6827 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6828 | ············ownVar.RelField = null; |
6829 | ············pm.Save(); |
6830 | ············pm.UnloadCache(); |
6831 | ············QueryOwn(); |
6832 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6833 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6834 | ········} |
6835 | ········catch (NDOException) |
6836 | ········{ |
6837 | ············thrown = true; |
6838 | ········} |
6839 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6840 | ····} |
6841 | ····[Test] |
6842 | ····public void TestRelationHash() |
6843 | ····{ |
6844 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoLeft)); |
6845 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6846 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoRightBase)); |
6847 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6848 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6849 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6850 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoRightDerived)); |
6851 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6852 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6853 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6854 | ····} |
6855 | ····void CreateObjects() |
6856 | ····{ |
6857 | ········pm.MakePersistent(ownVar); |
6858 | ········pm.Save(); |
6859 | ········ownVar.AssignRelation(otherVar); |
6860 | ········pm.Save(); |
6861 | ········pm.UnloadCache(); |
6862 | ····} |
6863 | ····void QueryOwn() |
6864 | ····{ |
6865 | ········var q = new NDOQuery<CmpBi11OthpconNoTblAutoLeft>(pm); |
6866 | ········ownVar = q.ExecuteSingle(); |
6867 | ····} |
6868 | ····void QueryOther() |
6869 | ····{ |
6870 | ········var q = new NDOQuery<CmpBi11OthpconNoTblAutoRightBase>(pm); |
6871 | ········otherVar = q.ExecuteSingle(); |
6872 | ····} |
6873 | } |
6874 | |
6875 | |
6876 | [TestFixture] |
6877 | public class TestCmpBi11OthpconTblAuto : NDOTest |
6878 | { |
6879 | ····CmpBi11OthpconTblAutoLeft ownVar; |
6880 | ····CmpBi11OthpconTblAutoRightBase otherVar; |
6881 | ····PersistenceManager pm; |
6882 | ····[SetUp] |
6883 | ····public void Setup() |
6884 | ····{ |
6885 | ········pm = PmFactory.NewPersistenceManager(); |
6886 | ········ownVar = new CmpBi11OthpconTblAutoLeft(); |
6887 | ········otherVar = new CmpBi11OthpconTblAutoRightDerived(); |
6888 | ····} |
6889 | ····[TearDown] |
6890 | ····public void TearDown() |
6891 | ····{ |
6892 | ········try |
6893 | ········{ |
6894 | ············pm.UnloadCache(); |
6895 | ············var l = pm.Objects<CmpBi11OthpconTblAutoLeft>().ResultTable; |
6896 | ············pm.Delete(l); |
6897 | ············pm.Save(); |
6898 | ············pm.UnloadCache(); |
6899 | ············decimal count; |
6900 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6901 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6902 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6903 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6904 | ········} |
6905 | ········catch (Exception) |
6906 | ········{ |
6907 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6909 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6910 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6911 | ········} |
6912 | ····} |
6913 | ····[Test] |
6914 | ····public void TestSaveReload() |
6915 | ····{ |
6916 | ········CreateObjects(); |
6917 | ········QueryOwn(); |
6918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6919 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6920 | ····} |
6921 | ····[Test] |
6922 | ····public void TestSaveReloadNull() |
6923 | ····{ |
6924 | ········CreateObjects(); |
6925 | ········QueryOwn(); |
6926 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6927 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6928 | ········ownVar.RelField = null; |
6929 | ········pm.Save(); |
6930 | ········pm.UnloadCache(); |
6931 | ········QueryOwn(); |
6932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6933 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6934 | ····} |
6935 | ····[Test] |
6936 | ····public void TestChangeKeyHolderLeft() |
6937 | ····{ |
6938 | ········CreateObjects(); |
6939 | ········QueryOwn(); |
6940 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6941 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6942 | ········int x = ownVar.RelField.Dummy; |
6943 | ········ownVar.Dummy = 4711; |
6944 | ········pm.Save(); |
6945 | ········pm.UnloadCache(); |
6946 | ········QueryOwn(); |
6947 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6948 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6949 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6950 | ····} |
6951 | ····[Test] |
6952 | ····public void TestChangeKeyHolderRight() |
6953 | ····{ |
6954 | ········CreateObjects(); |
6955 | ········QueryOther(); |
6956 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6957 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6958 | ········int x = otherVar.RelField.Dummy; |
6959 | ········otherVar.Dummy = 4711; |
6960 | ········pm.Save(); |
6961 | ········pm.UnloadCache(); |
6962 | ········QueryOther(); |
6963 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6964 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6965 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6966 | ····} |
6967 | ····[Test] |
6968 | ····public void TestChangeKeyHolderLeftNoTouch() |
6969 | ····{ |
6970 | ········CreateObjects(); |
6971 | ········QueryOwn(); |
6972 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6973 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6974 | ········ownVar.Dummy = 4711; |
6975 | ········pm.Save(); |
6976 | ········pm.UnloadCache(); |
6977 | ········QueryOwn(); |
6978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6979 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6980 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6981 | ····} |
6982 | ····[Test] |
6983 | ····public void TestChangeKeyHolderRightNoTouch() |
6984 | ····{ |
6985 | ········CreateObjects(); |
6986 | ········QueryOther(); |
6987 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6988 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6989 | ········otherVar.Dummy = 4711; |
6990 | ········pm.Save(); |
6991 | ········pm.UnloadCache(); |
6992 | ········QueryOther(); |
6993 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6994 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6995 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6996 | ····} |
6997 | ····[Test] |
6998 | ····public void TestRelationHash() |
6999 | ····{ |
7000 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoLeft)); |
7001 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7002 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoRightBase)); |
7003 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7004 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7005 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7006 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoRightDerived)); |
7007 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7008 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7009 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7010 | ····} |
7011 | ····void CreateObjects() |
7012 | ····{ |
7013 | ········pm.MakePersistent(ownVar); |
7014 | ········ownVar.AssignRelation(otherVar); |
7015 | ········pm.Save(); |
7016 | ········pm.UnloadCache(); |
7017 | ····} |
7018 | ····void QueryOwn() |
7019 | ····{ |
7020 | ········var q = new NDOQuery<CmpBi11OthpconTblAutoLeft>(pm); |
7021 | ········ownVar = q.ExecuteSingle(); |
7022 | ····} |
7023 | ····void QueryOther() |
7024 | ····{ |
7025 | ········var q = new NDOQuery<CmpBi11OthpconTblAutoRightBase>(pm); |
7026 | ········otherVar = q.ExecuteSingle(); |
7027 | ····} |
7028 | } |
7029 | |
7030 | |
7031 | [TestFixture] |
7032 | public class TestCmpDirnOthpconTblAuto : NDOTest |
7033 | { |
7034 | ····CmpDirnOthpconTblAutoLeft ownVar; |
7035 | ····CmpDirnOthpconTblAutoRightBase otherVar; |
7036 | ····PersistenceManager pm; |
7037 | ····[SetUp] |
7038 | ····public void Setup() |
7039 | ····{ |
7040 | ········pm = PmFactory.NewPersistenceManager(); |
7041 | ········ownVar = new CmpDirnOthpconTblAutoLeft(); |
7042 | ········otherVar = new CmpDirnOthpconTblAutoRightDerived(); |
7043 | ····} |
7044 | ····[TearDown] |
7045 | ····public void TearDown() |
7046 | ····{ |
7047 | ········try |
7048 | ········{ |
7049 | ············pm.UnloadCache(); |
7050 | ············var l = pm.Objects<CmpDirnOthpconTblAutoLeft>().ResultTable; |
7051 | ············pm.Delete(l); |
7052 | ············pm.Save(); |
7053 | ············pm.UnloadCache(); |
7054 | ············decimal count; |
7055 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7056 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7057 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7058 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7059 | ········} |
7060 | ········catch (Exception) |
7061 | ········{ |
7062 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7063 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7064 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7065 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7066 | ········} |
7067 | ····} |
7068 | ····[Test] |
7069 | ····public void TestSaveReload() |
7070 | ····{ |
7071 | ········CreateObjects(); |
7072 | ········QueryOwn(); |
7073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7074 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7075 | ····} |
7076 | ····[Test] |
7077 | ····public void TestSaveReloadNull() |
7078 | ····{ |
7079 | ········CreateObjects(); |
7080 | ········QueryOwn(); |
7081 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7082 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7083 | ········ownVar.RelField = new List<CmpDirnOthpconTblAutoRightBase>(); |
7084 | ········pm.Save(); |
7085 | ········pm.UnloadCache(); |
7086 | ········QueryOwn(); |
7087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7088 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7089 | ····} |
7090 | ····[Test] |
7091 | ····public void TestSaveReloadRemove() |
7092 | ····{ |
7093 | ········CreateObjects(); |
7094 | ········QueryOwn(); |
7095 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7096 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7097 | ········ownVar.RemoveRelatedObject(); |
7098 | ········pm.Save(); |
7099 | ········pm.UnloadCache(); |
7100 | ········QueryOwn(); |
7101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7102 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7103 | ····} |
7104 | ····void CreateObjects() |
7105 | ····{ |
7106 | ········pm.MakePersistent(ownVar); |
7107 | ········ownVar.AssignRelation(otherVar); |
7108 | ········pm.Save(); |
7109 | ········pm.UnloadCache(); |
7110 | ····} |
7111 | ····void QueryOwn() |
7112 | ····{ |
7113 | ········var q = new NDOQuery<CmpDirnOthpconTblAutoLeft>(pm); |
7114 | ········ownVar = q.ExecuteSingle(); |
7115 | ····} |
7116 | ····void QueryOther() |
7117 | ····{ |
7118 | ········var q = new NDOQuery<CmpDirnOthpconTblAutoRightBase>(pm); |
7119 | ········otherVar = q.ExecuteSingle(); |
7120 | ····} |
7121 | } |
7122 | |
7123 | |
7124 | [TestFixture] |
7125 | public class TestCmpBin1OthpconTblAuto : NDOTest |
7126 | { |
7127 | ····CmpBin1OthpconTblAutoLeft ownVar; |
7128 | ····CmpBin1OthpconTblAutoRightBase otherVar; |
7129 | ····PersistenceManager pm; |
7130 | ····[SetUp] |
7131 | ····public void Setup() |
7132 | ····{ |
7133 | ········pm = PmFactory.NewPersistenceManager(); |
7134 | ········ownVar = new CmpBin1OthpconTblAutoLeft(); |
7135 | ········otherVar = new CmpBin1OthpconTblAutoRightDerived(); |
7136 | ····} |
7137 | ····[TearDown] |
7138 | ····public void TearDown() |
7139 | ····{ |
7140 | ········try |
7141 | ········{ |
7142 | ············pm.UnloadCache(); |
7143 | ············var l = pm.Objects<CmpBin1OthpconTblAutoLeft>().ResultTable; |
7144 | ············pm.Delete(l); |
7145 | ············pm.Save(); |
7146 | ············pm.UnloadCache(); |
7147 | ············decimal count; |
7148 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7150 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7151 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7152 | ········} |
7153 | ········catch (Exception) |
7154 | ········{ |
7155 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7156 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7158 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7159 | ········} |
7160 | ····} |
7161 | ····[Test] |
7162 | ····public void TestSaveReload() |
7163 | ····{ |
7164 | ········CreateObjects(); |
7165 | ········QueryOwn(); |
7166 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7167 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7168 | ····} |
7169 | ····[Test] |
7170 | ····public void TestSaveReloadNull() |
7171 | ····{ |
7172 | ········CreateObjects(); |
7173 | ········QueryOwn(); |
7174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7175 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7176 | ········ownVar.RelField = new List<CmpBin1OthpconTblAutoRightBase>(); |
7177 | ········pm.Save(); |
7178 | ········pm.UnloadCache(); |
7179 | ········QueryOwn(); |
7180 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7181 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7182 | ····} |
7183 | ····[Test] |
7184 | ····public void TestSaveReloadRemove() |
7185 | ····{ |
7186 | ········CreateObjects(); |
7187 | ········QueryOwn(); |
7188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7189 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7190 | ········ownVar.RemoveRelatedObject(); |
7191 | ········pm.Save(); |
7192 | ········pm.UnloadCache(); |
7193 | ········QueryOwn(); |
7194 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7195 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7196 | ····} |
7197 | ····[Test] |
7198 | ····public void TestChangeKeyHolderRight() |
7199 | ····{ |
7200 | ········CreateObjects(); |
7201 | ········QueryOther(); |
7202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7204 | ········int x = otherVar.RelField.Dummy; |
7205 | ········otherVar.Dummy = 4711; |
7206 | ········pm.Save(); |
7207 | ········pm.UnloadCache(); |
7208 | ········QueryOther(); |
7209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7212 | ····} |
7213 | ····[Test] |
7214 | ····public void TestChangeKeyHolderRightNoTouch() |
7215 | ····{ |
7216 | ········CreateObjects(); |
7217 | ········QueryOther(); |
7218 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7219 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7220 | ········otherVar.Dummy = 4711; |
7221 | ········pm.Save(); |
7222 | ········pm.UnloadCache(); |
7223 | ········QueryOther(); |
7224 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7225 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7226 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7227 | ····} |
7228 | ····[Test] |
7229 | ····public void TestRelationHash() |
7230 | ····{ |
7231 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoLeft)); |
7232 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7233 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoRightBase)); |
7234 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7235 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7236 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7237 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoRightDerived)); |
7238 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7239 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7240 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7241 | ····} |
7242 | ····void CreateObjects() |
7243 | ····{ |
7244 | ········pm.MakePersistent(ownVar); |
7245 | ········ownVar.AssignRelation(otherVar); |
7246 | ········pm.Save(); |
7247 | ········pm.UnloadCache(); |
7248 | ····} |
7249 | ····void QueryOwn() |
7250 | ····{ |
7251 | ········var q = new NDOQuery<CmpBin1OthpconTblAutoLeft>(pm); |
7252 | ········ownVar = q.ExecuteSingle(); |
7253 | ····} |
7254 | ····void QueryOther() |
7255 | ····{ |
7256 | ········var q = new NDOQuery<CmpBin1OthpconTblAutoRightBase>(pm); |
7257 | ········otherVar = q.ExecuteSingle(); |
7258 | ····} |
7259 | } |
7260 | |
7261 | |
7262 | [TestFixture] |
7263 | public class TestCmpBi1nOthpconNoTblAuto : NDOTest |
7264 | { |
7265 | ····CmpBi1nOthpconNoTblAutoLeft ownVar; |
7266 | ····CmpBi1nOthpconNoTblAutoRightBase otherVar; |
7267 | ····PersistenceManager pm; |
7268 | ····[SetUp] |
7269 | ····public void Setup() |
7270 | ····{ |
7271 | ········pm = PmFactory.NewPersistenceManager(); |
7272 | ········ownVar = new CmpBi1nOthpconNoTblAutoLeft(); |
7273 | ········otherVar = new CmpBi1nOthpconNoTblAutoRightDerived(); |
7274 | ····} |
7275 | ····[TearDown] |
7276 | ····public void TearDown() |
7277 | ····{ |
7278 | ········try |
7279 | ········{ |
7280 | ············pm.UnloadCache(); |
7281 | ············var l = pm.Objects<CmpBi1nOthpconNoTblAutoLeft>().ResultTable; |
7282 | ············pm.Delete(l); |
7283 | ············pm.Save(); |
7284 | ············pm.UnloadCache(); |
7285 | ············decimal count; |
7286 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7287 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7288 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7289 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7290 | ········} |
7291 | ········catch (Exception) |
7292 | ········{ |
7293 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7294 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7295 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7296 | ········} |
7297 | ····} |
7298 | ····[Test] |
7299 | ····public void TestSaveReload() |
7300 | ····{ |
7301 | ········bool thrown = false; |
7302 | ········try |
7303 | ········{ |
7304 | ············CreateObjects(); |
7305 | ············QueryOwn(); |
7306 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7307 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7308 | ········} |
7309 | ········catch (NDOException) |
7310 | ········{ |
7311 | ············thrown = true; |
7312 | ········} |
7313 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
7314 | ····} |
7315 | ····[Test] |
7316 | ····public void TestSaveReloadNull() |
7317 | ····{ |
7318 | ········bool thrown = false; |
7319 | ········try |
7320 | ········{ |
7321 | ············CreateObjects(); |
7322 | ············QueryOwn(); |
7323 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7324 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7325 | ············ownVar.RelField = null; |
7326 | ············pm.Save(); |
7327 | ············pm.UnloadCache(); |
7328 | ············QueryOwn(); |
7329 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7330 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7331 | ········} |
7332 | ········catch (NDOException) |
7333 | ········{ |
7334 | ············thrown = true; |
7335 | ········} |
7336 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
7337 | ····} |
7338 | ····[Test] |
7339 | ····public void TestRelationHash() |
7340 | ····{ |
7341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoLeft)); |
7342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoRightBase)); |
7344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7347 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoRightDerived)); |
7348 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7349 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7350 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7351 | ····} |
7352 | ····void CreateObjects() |
7353 | ····{ |
7354 | ········pm.MakePersistent(ownVar); |
7355 | ········pm.Save(); |
7356 | ········ownVar.AssignRelation(otherVar); |
7357 | ········pm.Save(); |
7358 | ········pm.UnloadCache(); |
7359 | ····} |
7360 | ····void QueryOwn() |
7361 | ····{ |
7362 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblAutoLeft>(pm); |
7363 | ········ownVar = q.ExecuteSingle(); |
7364 | ····} |
7365 | ····void QueryOther() |
7366 | ····{ |
7367 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblAutoRightBase>(pm); |
7368 | ········otherVar = q.ExecuteSingle(); |
7369 | ····} |
7370 | } |
7371 | |
7372 | |
7373 | [TestFixture] |
7374 | public class TestCmpBi1nOthpconTblAuto : NDOTest |
7375 | { |
7376 | ····CmpBi1nOthpconTblAutoLeft ownVar; |
7377 | ····CmpBi1nOthpconTblAutoRightBase otherVar; |
7378 | ····PersistenceManager pm; |
7379 | ····[SetUp] |
7380 | ····public void Setup() |
7381 | ····{ |
7382 | ········pm = PmFactory.NewPersistenceManager(); |
7383 | ········ownVar = new CmpBi1nOthpconTblAutoLeft(); |
7384 | ········otherVar = new CmpBi1nOthpconTblAutoRightDerived(); |
7385 | ····} |
7386 | ····[TearDown] |
7387 | ····public void TearDown() |
7388 | ····{ |
7389 | ········try |
7390 | ········{ |
7391 | ············pm.UnloadCache(); |
7392 | ············var l = pm.Objects<CmpBi1nOthpconTblAutoLeft>().ResultTable; |
7393 | ············pm.Delete(l); |
7394 | ············pm.Save(); |
7395 | ············pm.UnloadCache(); |
7396 | ············decimal count; |
7397 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7398 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7399 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7400 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7401 | ········} |
7402 | ········catch (Exception) |
7403 | ········{ |
7404 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7405 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7406 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7407 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7408 | ········} |
7409 | ····} |
7410 | ····[Test] |
7411 | ····public void TestSaveReload() |
7412 | ····{ |
7413 | ········CreateObjects(); |
7414 | ········QueryOwn(); |
7415 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7416 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7417 | ····} |
7418 | ····[Test] |
7419 | ····public void TestSaveReloadNull() |
7420 | ····{ |
7421 | ········CreateObjects(); |
7422 | ········QueryOwn(); |
7423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7424 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7425 | ········ownVar.RelField = null; |
7426 | ········pm.Save(); |
7427 | ········pm.UnloadCache(); |
7428 | ········QueryOwn(); |
7429 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7430 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7431 | ····} |
7432 | ····[Test] |
7433 | ····public void TestChangeKeyHolderLeft() |
7434 | ····{ |
7435 | ········CreateObjects(); |
7436 | ········QueryOwn(); |
7437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7438 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7439 | ········int x = ownVar.RelField.Dummy; |
7440 | ········ownVar.Dummy = 4711; |
7441 | ········pm.Save(); |
7442 | ········pm.UnloadCache(); |
7443 | ········QueryOwn(); |
7444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7445 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7447 | ····} |
7448 | ····[Test] |
7449 | ····public void TestChangeKeyHolderLeftNoTouch() |
7450 | ····{ |
7451 | ········CreateObjects(); |
7452 | ········QueryOwn(); |
7453 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7454 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7455 | ········ownVar.Dummy = 4711; |
7456 | ········pm.Save(); |
7457 | ········pm.UnloadCache(); |
7458 | ········QueryOwn(); |
7459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7460 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7462 | ····} |
7463 | ····[Test] |
7464 | ····public void TestRelationHash() |
7465 | ····{ |
7466 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoLeft)); |
7467 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7468 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoRightBase)); |
7469 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7470 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7471 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7472 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoRightDerived)); |
7473 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7474 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7475 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7476 | ····} |
7477 | ····void CreateObjects() |
7478 | ····{ |
7479 | ········pm.MakePersistent(ownVar); |
7480 | ········ownVar.AssignRelation(otherVar); |
7481 | ········pm.Save(); |
7482 | ········pm.UnloadCache(); |
7483 | ····} |
7484 | ····void QueryOwn() |
7485 | ····{ |
7486 | ········var q = new NDOQuery<CmpBi1nOthpconTblAutoLeft>(pm); |
7487 | ········ownVar = q.ExecuteSingle(); |
7488 | ····} |
7489 | ····void QueryOther() |
7490 | ····{ |
7491 | ········var q = new NDOQuery<CmpBi1nOthpconTblAutoRightBase>(pm); |
7492 | ········otherVar = q.ExecuteSingle(); |
7493 | ····} |
7494 | } |
7495 | |
7496 | |
7497 | [TestFixture] |
7498 | public class TestCmpBinnOthpconTblAuto : NDOTest |
7499 | { |
7500 | ····CmpBinnOthpconTblAutoLeft ownVar; |
7501 | ····CmpBinnOthpconTblAutoRightBase otherVar; |
7502 | ····PersistenceManager pm; |
7503 | ····[SetUp] |
7504 | ····public void Setup() |
7505 | ····{ |
7506 | ········pm = PmFactory.NewPersistenceManager(); |
7507 | ········ownVar = new CmpBinnOthpconTblAutoLeft(); |
7508 | ········otherVar = new CmpBinnOthpconTblAutoRightDerived(); |
7509 | ····} |
7510 | ····[TearDown] |
7511 | ····public void TearDown() |
7512 | ····{ |
7513 | ········try |
7514 | ········{ |
7515 | ············pm.UnloadCache(); |
7516 | ············var l = pm.Objects<CmpBinnOthpconTblAutoLeft>().ResultTable; |
7517 | ············pm.Delete(l); |
7518 | ············pm.Save(); |
7519 | ············pm.UnloadCache(); |
7520 | ············decimal count; |
7521 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7522 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7523 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7524 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7525 | ········} |
7526 | ········catch (Exception) |
7527 | ········{ |
7528 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7529 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7530 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7531 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7532 | ········} |
7533 | ····} |
7534 | ····[Test] |
7535 | ····public void TestSaveReload() |
7536 | ····{ |
7537 | ········CreateObjects(); |
7538 | ········QueryOwn(); |
7539 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7540 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7541 | ····} |
7542 | ····[Test] |
7543 | ····public void TestSaveReloadNull() |
7544 | ····{ |
7545 | ········CreateObjects(); |
7546 | ········QueryOwn(); |
7547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7548 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7549 | ········ownVar.RelField = new List<CmpBinnOthpconTblAutoRightBase>(); |
7550 | ········pm.Save(); |
7551 | ········pm.UnloadCache(); |
7552 | ········QueryOwn(); |
7553 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7554 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7555 | ····} |
7556 | ····[Test] |
7557 | ····public void TestSaveReloadRemove() |
7558 | ····{ |
7559 | ········CreateObjects(); |
7560 | ········QueryOwn(); |
7561 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7562 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7563 | ········ownVar.RemoveRelatedObject(); |
7564 | ········pm.Save(); |
7565 | ········pm.UnloadCache(); |
7566 | ········QueryOwn(); |
7567 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7568 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7569 | ····} |
7570 | ····[Test] |
7571 | ····public void TestRelationHash() |
7572 | ····{ |
7573 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoLeft)); |
7574 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7575 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoRightBase)); |
7576 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7577 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7578 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7579 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoRightDerived)); |
7580 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7581 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7582 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7583 | ····} |
7584 | ····void CreateObjects() |
7585 | ····{ |
7586 | ········pm.MakePersistent(ownVar); |
7587 | ········ownVar.AssignRelation(otherVar); |
7588 | ········pm.Save(); |
7589 | ········pm.UnloadCache(); |
7590 | ····} |
7591 | ····void QueryOwn() |
7592 | ····{ |
7593 | ········var q = new NDOQuery<CmpBinnOthpconTblAutoLeft>(pm); |
7594 | ········ownVar = q.ExecuteSingle(); |
7595 | ····} |
7596 | ····void QueryOther() |
7597 | ····{ |
7598 | ········var q = new NDOQuery<CmpBinnOthpconTblAutoRightBase>(pm); |
7599 | ········otherVar = q.ExecuteSingle(); |
7600 | ····} |
7601 | } |
7602 | |
7603 | |
7604 | [TestFixture] |
7605 | public class TestAgrDir1OwnpconOthpconNoTblAuto : NDOTest |
7606 | { |
7607 | ····AgrDir1OwnpconOthpconNoTblAutoLeftBase ownVar; |
7608 | ····AgrDir1OwnpconOthpconNoTblAutoRightBase otherVar; |
7609 | ····PersistenceManager pm; |
7610 | ····[SetUp] |
7611 | ····public void Setup() |
7612 | ····{ |
7613 | ········pm = PmFactory.NewPersistenceManager(); |
7614 | ········ownVar = new AgrDir1OwnpconOthpconNoTblAutoLeftDerived(); |
7615 | ········otherVar = new AgrDir1OwnpconOthpconNoTblAutoRightDerived(); |
7616 | ····} |
7617 | ····[TearDown] |
7618 | ····public void TearDown() |
7619 | ····{ |
7620 | ········try |
7621 | ········{ |
7622 | ············pm.UnloadCache(); |
7623 | ············var l = pm.Objects<AgrDir1OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
7624 | ············pm.Delete(l); |
7625 | ············pm.Save(); |
7626 | ············pm.UnloadCache(); |
7627 | ············var m = pm.Objects<AgrDir1OwnpconOthpconNoTblAutoRightBase>().ResultTable; |
7628 | ············pm.Delete(m); |
7629 | ············pm.Save(); |
7630 | ············pm.UnloadCache(); |
7631 | ············decimal count; |
7632 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7633 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7634 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7636 | ········} |
7637 | ········catch (Exception) |
7638 | ········{ |
7639 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7640 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7641 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7642 | ········} |
7643 | ····} |
7644 | ····[Test] |
7645 | ····public void TestSaveReload() |
7646 | ····{ |
7647 | ········CreateObjects(); |
7648 | ········QueryOwn(); |
7649 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7650 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7651 | ····} |
7652 | ····[Test] |
7653 | ····public void TestSaveReloadNull() |
7654 | ····{ |
7655 | ········CreateObjects(); |
7656 | ········QueryOwn(); |
7657 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7658 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7659 | ········ownVar.RelField = null; |
7660 | ········pm.Save(); |
7661 | ········pm.UnloadCache(); |
7662 | ········QueryOwn(); |
7663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7664 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7665 | ····} |
7666 | ····[Test] |
7667 | ····public void TestChangeKeyHolderLeft() |
7668 | ····{ |
7669 | ········CreateObjects(); |
7670 | ········QueryOwn(); |
7671 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7672 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7673 | ········int x = ownVar.RelField.Dummy; |
7674 | ········ownVar.Dummy = 4711; |
7675 | ········pm.Save(); |
7676 | ········pm.UnloadCache(); |
7677 | ········QueryOwn(); |
7678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7679 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7680 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7681 | ····} |
7682 | ····[Test] |
7683 | ····public void TestChangeKeyHolderLeftNoTouch() |
7684 | ····{ |
7685 | ········CreateObjects(); |
7686 | ········QueryOwn(); |
7687 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7688 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7689 | ········ownVar.Dummy = 4711; |
7690 | ········pm.Save(); |
7691 | ········pm.UnloadCache(); |
7692 | ········QueryOwn(); |
7693 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7694 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7695 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7696 | ····} |
7697 | ····[Test] |
7698 | ····public void TestUpdateOrder() |
7699 | ····{ |
7700 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
7701 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
7702 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoLeftBase)})) |
7703 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoRightBase)})), "Wrong order #1"); |
7704 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoLeftDerived)})) |
7705 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
7706 | ········Debug.WriteLine("AgrDir1OwnpconOthpconNoTblAutoLeftBase"); |
7707 | ····} |
7708 | ····void CreateObjects() |
7709 | ····{ |
7710 | ········pm.MakePersistent(ownVar); |
7711 | ········pm.Save(); |
7712 | ········pm.MakePersistent(otherVar); |
7713 | ········pm.Save(); |
7714 | ········ownVar.AssignRelation(otherVar); |
7715 | ········pm.Save(); |
7716 | ········pm.UnloadCache(); |
7717 | ····} |
7718 | ····void QueryOwn() |
7719 | ····{ |
7720 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoLeftBase>(pm); |
7721 | ········ownVar = q.ExecuteSingle(); |
7722 | ····} |
7723 | ····void QueryOther() |
7724 | ····{ |
7725 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoRightBase>(pm); |
7726 | ········otherVar = q.ExecuteSingle(); |
7727 | ····} |
7728 | } |
7729 | |
7730 | |
7731 | [TestFixture] |
7732 | public class TestAgrDir1OwnpconOthpconTblAuto : NDOTest |
7733 | { |
7734 | ····AgrDir1OwnpconOthpconTblAutoLeftBase ownVar; |
7735 | ····AgrDir1OwnpconOthpconTblAutoRightBase otherVar; |
7736 | ····PersistenceManager pm; |
7737 | ····[SetUp] |
7738 | ····public void Setup() |
7739 | ····{ |
7740 | ········pm = PmFactory.NewPersistenceManager(); |
7741 | ········ownVar = new AgrDir1OwnpconOthpconTblAutoLeftDerived(); |
7742 | ········otherVar = new AgrDir1OwnpconOthpconTblAutoRightDerived(); |
7743 | ····} |
7744 | ····[TearDown] |
7745 | ····public void TearDown() |
7746 | ····{ |
7747 | ········try |
7748 | ········{ |
7749 | ············pm.UnloadCache(); |
7750 | ············var l = pm.Objects<AgrDir1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
7751 | ············pm.Delete(l); |
7752 | ············pm.Save(); |
7753 | ············pm.UnloadCache(); |
7754 | ············var m = pm.Objects<AgrDir1OwnpconOthpconTblAutoRightBase>().ResultTable; |
7755 | ············pm.Delete(m); |
7756 | ············pm.Save(); |
7757 | ············pm.UnloadCache(); |
7758 | ············decimal count; |
7759 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7761 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7763 | ········} |
7764 | ········catch (Exception) |
7765 | ········{ |
7766 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7767 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7768 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7769 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7770 | ········} |
7771 | ····} |
7772 | ····[Test] |
7773 | ····public void TestSaveReload() |
7774 | ····{ |
7775 | ········CreateObjects(); |
7776 | ········QueryOwn(); |
7777 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7778 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7779 | ····} |
7780 | ····[Test] |
7781 | ····public void TestSaveReloadNull() |
7782 | ····{ |
7783 | ········CreateObjects(); |
7784 | ········QueryOwn(); |
7785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7787 | ········ownVar.RelField = null; |
7788 | ········pm.Save(); |
7789 | ········pm.UnloadCache(); |
7790 | ········QueryOwn(); |
7791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7792 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7793 | ····} |
7794 | ····[Test] |
7795 | ····public void TestChangeKeyHolderLeft() |
7796 | ····{ |
7797 | ········CreateObjects(); |
7798 | ········QueryOwn(); |
7799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7800 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7801 | ········int x = ownVar.RelField.Dummy; |
7802 | ········ownVar.Dummy = 4711; |
7803 | ········pm.Save(); |
7804 | ········pm.UnloadCache(); |
7805 | ········QueryOwn(); |
7806 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7807 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7809 | ····} |
7810 | ····[Test] |
7811 | ····public void TestChangeKeyHolderLeftNoTouch() |
7812 | ····{ |
7813 | ········CreateObjects(); |
7814 | ········QueryOwn(); |
7815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7817 | ········ownVar.Dummy = 4711; |
7818 | ········pm.Save(); |
7819 | ········pm.UnloadCache(); |
7820 | ········QueryOwn(); |
7821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7822 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7823 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7824 | ····} |
7825 | ····void CreateObjects() |
7826 | ····{ |
7827 | ········pm.MakePersistent(ownVar); |
7828 | ········pm.MakePersistent(otherVar); |
7829 | ········ownVar.AssignRelation(otherVar); |
7830 | ········pm.Save(); |
7831 | ········pm.UnloadCache(); |
7832 | ····} |
7833 | ····void QueryOwn() |
7834 | ····{ |
7835 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblAutoLeftBase>(pm); |
7836 | ········ownVar = q.ExecuteSingle(); |
7837 | ····} |
7838 | ····void QueryOther() |
7839 | ····{ |
7840 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblAutoRightBase>(pm); |
7841 | ········otherVar = q.ExecuteSingle(); |
7842 | ····} |
7843 | } |
7844 | |
7845 | |
7846 | [TestFixture] |
7847 | public class TestAgrBi11OwnpconOthpconNoTblAuto : NDOTest |
7848 | { |
7849 | ····AgrBi11OwnpconOthpconNoTblAutoLeftBase ownVar; |
7850 | ····AgrBi11OwnpconOthpconNoTblAutoRightBase otherVar; |
7851 | ····PersistenceManager pm; |
7852 | ····[SetUp] |
7853 | ····public void Setup() |
7854 | ····{ |
7855 | ········pm = PmFactory.NewPersistenceManager(); |
7856 | ········ownVar = new AgrBi11OwnpconOthpconNoTblAutoLeftDerived(); |
7857 | ········otherVar = new AgrBi11OwnpconOthpconNoTblAutoRightDerived(); |
7858 | ····} |
7859 | ····[TearDown] |
7860 | ····public void TearDown() |
7861 | ····{ |
7862 | ········try |
7863 | ········{ |
7864 | ············pm.UnloadCache(); |
7865 | ············var l = pm.Objects<AgrBi11OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
7866 | ············pm.Delete(l); |
7867 | ············pm.Save(); |
7868 | ············pm.UnloadCache(); |
7869 | ············var m = pm.Objects<AgrBi11OwnpconOthpconNoTblAutoRightBase>().ResultTable; |
7870 | ············pm.Delete(m); |
7871 | ············pm.Save(); |
7872 | ············pm.UnloadCache(); |
7873 | ············decimal count; |
7874 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7875 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7876 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7877 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7878 | ········} |
7879 | ········catch (Exception) |
7880 | ········{ |
7881 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7882 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7883 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7884 | ········} |
7885 | ····} |
7886 | ····[Test] |
7887 | ····public void TestSaveReload() |
7888 | ····{ |
7889 | ········CreateObjects(); |
7890 | ········QueryOwn(); |
7891 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7892 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7893 | ····} |
7894 | ····[Test] |
7895 | ····public void TestSaveReloadNull() |
7896 | ····{ |
7897 | ········CreateObjects(); |
7898 | ········QueryOwn(); |
7899 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7900 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7901 | ········ownVar.RelField = null; |
7902 | ········pm.Save(); |
7903 | ········pm.UnloadCache(); |
7904 | ········QueryOwn(); |
7905 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7906 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7907 | ····} |
7908 | ····[Test] |
7909 | ····public void TestChangeKeyHolderLeft() |
7910 | ····{ |
7911 | ········CreateObjects(); |
7912 | ········QueryOwn(); |
7913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7915 | ········int x = ownVar.RelField.Dummy; |
7916 | ········ownVar.Dummy = 4711; |
7917 | ········pm.Save(); |
7918 | ········pm.UnloadCache(); |
7919 | ········QueryOwn(); |
7920 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7921 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7922 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7923 | ····} |
7924 | ····[Test] |
7925 | ····public void TestChangeKeyHolderRight() |
7926 | ····{ |
7927 | ········CreateObjects(); |
7928 | ········QueryOther(); |
7929 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7930 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7931 | ········int x = otherVar.RelField.Dummy; |
7932 | ········otherVar.Dummy = 4711; |
7933 | ········pm.Save(); |
7934 | ········pm.UnloadCache(); |
7935 | ········QueryOther(); |
7936 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7937 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7938 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7939 | ····} |
7940 | ····[Test] |
7941 | ····public void TestChangeKeyHolderLeftNoTouch() |
7942 | ····{ |
7943 | ········CreateObjects(); |
7944 | ········QueryOwn(); |
7945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7947 | ········ownVar.Dummy = 4711; |
7948 | ········pm.Save(); |
7949 | ········pm.UnloadCache(); |
7950 | ········QueryOwn(); |
7951 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7952 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7953 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7954 | ····} |
7955 | ····[Test] |
7956 | ····public void TestChangeKeyHolderRightNoTouch() |
7957 | ····{ |
7958 | ········CreateObjects(); |
7959 | ········QueryOther(); |
7960 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7961 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7962 | ········otherVar.Dummy = 4711; |
7963 | ········pm.Save(); |
7964 | ········pm.UnloadCache(); |
7965 | ········QueryOther(); |
7966 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7967 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7968 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7969 | ····} |
7970 | ····[Test] |
7971 | ····public void TestRelationHash() |
7972 | ····{ |
7973 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoLeftBase)); |
7974 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7975 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoRightBase)); |
7976 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7977 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7978 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7979 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoLeftDerived)); |
7980 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
7981 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
7982 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
7983 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoRightDerived)); |
7984 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7985 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7986 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7987 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
7988 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
7989 | ····} |
7990 | ····void CreateObjects() |
7991 | ····{ |
7992 | ········pm.MakePersistent(ownVar); |
7993 | ········pm.Save(); |
7994 | ········pm.MakePersistent(otherVar); |
7995 | ········pm.Save(); |
7996 | ········pm.Save(); |
7997 | ········ownVar.AssignRelation(otherVar); |
7998 | ········pm.Save(); |
7999 | ········pm.UnloadCache(); |
8000 | ····} |
8001 | ····void QueryOwn() |
8002 | ····{ |
8003 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoLeftBase>(pm); |
8004 | ········ownVar = q.ExecuteSingle(); |
8005 | ····} |
8006 | ····void QueryOther() |
8007 | ····{ |
8008 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoRightBase>(pm); |
8009 | ········otherVar = q.ExecuteSingle(); |
8010 | ····} |
8011 | } |
8012 | |
8013 | |
8014 | [TestFixture] |
8015 | public class TestAgrBi11OwnpconOthpconTblAuto : NDOTest |
8016 | { |
8017 | ····AgrBi11OwnpconOthpconTblAutoLeftBase ownVar; |
8018 | ····AgrBi11OwnpconOthpconTblAutoRightBase otherVar; |
8019 | ····PersistenceManager pm; |
8020 | ····[SetUp] |
8021 | ····public void Setup() |
8022 | ····{ |
8023 | ········pm = PmFactory.NewPersistenceManager(); |
8024 | ········ownVar = new AgrBi11OwnpconOthpconTblAutoLeftDerived(); |
8025 | ········otherVar = new AgrBi11OwnpconOthpconTblAutoRightDerived(); |
8026 | ····} |
8027 | ····[TearDown] |
8028 | ····public void TearDown() |
8029 | ····{ |
8030 | ········try |
8031 | ········{ |
8032 | ············pm.UnloadCache(); |
8033 | ············var l = pm.Objects<AgrBi11OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8034 | ············pm.Delete(l); |
8035 | ············pm.Save(); |
8036 | ············pm.UnloadCache(); |
8037 | ············var m = pm.Objects<AgrBi11OwnpconOthpconTblAutoRightBase>().ResultTable; |
8038 | ············pm.Delete(m); |
8039 | ············pm.Save(); |
8040 | ············pm.UnloadCache(); |
8041 | ············decimal count; |
8042 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8044 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8045 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8046 | ········} |
8047 | ········catch (Exception) |
8048 | ········{ |
8049 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8050 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8051 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8052 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8053 | ········} |
8054 | ····} |
8055 | ····[Test] |
8056 | ····public void TestSaveReload() |
8057 | ····{ |
8058 | ········CreateObjects(); |
8059 | ········QueryOwn(); |
8060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8062 | ····} |
8063 | ····[Test] |
8064 | ····public void TestSaveReloadNull() |
8065 | ····{ |
8066 | ········CreateObjects(); |
8067 | ········QueryOwn(); |
8068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8070 | ········ownVar.RelField = null; |
8071 | ········pm.Save(); |
8072 | ········pm.UnloadCache(); |
8073 | ········QueryOwn(); |
8074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8075 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8076 | ····} |
8077 | ····[Test] |
8078 | ····public void TestChangeKeyHolderLeft() |
8079 | ····{ |
8080 | ········CreateObjects(); |
8081 | ········QueryOwn(); |
8082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8083 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8084 | ········int x = ownVar.RelField.Dummy; |
8085 | ········ownVar.Dummy = 4711; |
8086 | ········pm.Save(); |
8087 | ········pm.UnloadCache(); |
8088 | ········QueryOwn(); |
8089 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8090 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8091 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8092 | ····} |
8093 | ····[Test] |
8094 | ····public void TestChangeKeyHolderRight() |
8095 | ····{ |
8096 | ········CreateObjects(); |
8097 | ········QueryOther(); |
8098 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8099 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8100 | ········int x = otherVar.RelField.Dummy; |
8101 | ········otherVar.Dummy = 4711; |
8102 | ········pm.Save(); |
8103 | ········pm.UnloadCache(); |
8104 | ········QueryOther(); |
8105 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8106 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8107 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8108 | ····} |
8109 | ····[Test] |
8110 | ····public void TestChangeKeyHolderLeftNoTouch() |
8111 | ····{ |
8112 | ········CreateObjects(); |
8113 | ········QueryOwn(); |
8114 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8115 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8116 | ········ownVar.Dummy = 4711; |
8117 | ········pm.Save(); |
8118 | ········pm.UnloadCache(); |
8119 | ········QueryOwn(); |
8120 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8121 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8122 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8123 | ····} |
8124 | ····[Test] |
8125 | ····public void TestChangeKeyHolderRightNoTouch() |
8126 | ····{ |
8127 | ········CreateObjects(); |
8128 | ········QueryOther(); |
8129 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8130 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8131 | ········otherVar.Dummy = 4711; |
8132 | ········pm.Save(); |
8133 | ········pm.UnloadCache(); |
8134 | ········QueryOther(); |
8135 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8136 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8137 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8138 | ····} |
8139 | ····[Test] |
8140 | ····public void TestRelationHash() |
8141 | ····{ |
8142 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoLeftBase)); |
8143 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8144 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoRightBase)); |
8145 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8146 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8147 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8148 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoLeftDerived)); |
8149 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8150 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8151 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8152 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoRightDerived)); |
8153 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8154 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8155 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8156 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8157 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8158 | ····} |
8159 | ····void CreateObjects() |
8160 | ····{ |
8161 | ········pm.MakePersistent(ownVar); |
8162 | ········pm.MakePersistent(otherVar); |
8163 | ········pm.Save(); |
8164 | ········ownVar.AssignRelation(otherVar); |
8165 | ········pm.Save(); |
8166 | ········pm.UnloadCache(); |
8167 | ····} |
8168 | ····void QueryOwn() |
8169 | ····{ |
8170 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblAutoLeftBase>(pm); |
8171 | ········ownVar = q.ExecuteSingle(); |
8172 | ····} |
8173 | ····void QueryOther() |
8174 | ····{ |
8175 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblAutoRightBase>(pm); |
8176 | ········otherVar = q.ExecuteSingle(); |
8177 | ····} |
8178 | } |
8179 | |
8180 | |
8181 | [TestFixture] |
8182 | public class TestAgrDirnOwnpconOthpconTblAuto : NDOTest |
8183 | { |
8184 | ····AgrDirnOwnpconOthpconTblAutoLeftBase ownVar; |
8185 | ····AgrDirnOwnpconOthpconTblAutoRightBase otherVar; |
8186 | ····PersistenceManager pm; |
8187 | ····[SetUp] |
8188 | ····public void Setup() |
8189 | ····{ |
8190 | ········pm = PmFactory.NewPersistenceManager(); |
8191 | ········ownVar = new AgrDirnOwnpconOthpconTblAutoLeftDerived(); |
8192 | ········otherVar = new AgrDirnOwnpconOthpconTblAutoRightDerived(); |
8193 | ····} |
8194 | ····[TearDown] |
8195 | ····public void TearDown() |
8196 | ····{ |
8197 | ········try |
8198 | ········{ |
8199 | ············pm.UnloadCache(); |
8200 | ············var l = pm.Objects<AgrDirnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8201 | ············pm.Delete(l); |
8202 | ············pm.Save(); |
8203 | ············pm.UnloadCache(); |
8204 | ············var m = pm.Objects<AgrDirnOwnpconOthpconTblAutoRightBase>().ResultTable; |
8205 | ············pm.Delete(m); |
8206 | ············pm.Save(); |
8207 | ············pm.UnloadCache(); |
8208 | ············decimal count; |
8209 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8210 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8211 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8212 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8213 | ········} |
8214 | ········catch (Exception) |
8215 | ········{ |
8216 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8218 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8219 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8220 | ········} |
8221 | ····} |
8222 | ····[Test] |
8223 | ····public void TestSaveReload() |
8224 | ····{ |
8225 | ········CreateObjects(); |
8226 | ········QueryOwn(); |
8227 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8228 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8229 | ····} |
8230 | ····[Test] |
8231 | ····public void TestSaveReloadNull() |
8232 | ····{ |
8233 | ········CreateObjects(); |
8234 | ········QueryOwn(); |
8235 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8236 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8237 | ········ownVar.RelField = new List<AgrDirnOwnpconOthpconTblAutoRightBase>(); |
8238 | ········pm.Save(); |
8239 | ········pm.UnloadCache(); |
8240 | ········QueryOwn(); |
8241 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8242 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8243 | ····} |
8244 | ····[Test] |
8245 | ····public void TestSaveReloadRemove() |
8246 | ····{ |
8247 | ········CreateObjects(); |
8248 | ········QueryOwn(); |
8249 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8250 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8251 | ········ownVar.RemoveRelatedObject(); |
8252 | ········pm.Save(); |
8253 | ········pm.UnloadCache(); |
8254 | ········QueryOwn(); |
8255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8256 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8257 | ····} |
8258 | ····void CreateObjects() |
8259 | ····{ |
8260 | ········pm.MakePersistent(ownVar); |
8261 | ········pm.MakePersistent(otherVar); |
8262 | ········ownVar.AssignRelation(otherVar); |
8263 | ········pm.Save(); |
8264 | ········pm.UnloadCache(); |
8265 | ····} |
8266 | ····void QueryOwn() |
8267 | ····{ |
8268 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblAutoLeftBase>(pm); |
8269 | ········ownVar = q.ExecuteSingle(); |
8270 | ····} |
8271 | ····void QueryOther() |
8272 | ····{ |
8273 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblAutoRightBase>(pm); |
8274 | ········otherVar = q.ExecuteSingle(); |
8275 | ····} |
8276 | } |
8277 | |
8278 | |
8279 | [TestFixture] |
8280 | public class TestAgrBin1OwnpconOthpconTblAuto : NDOTest |
8281 | { |
8282 | ····AgrBin1OwnpconOthpconTblAutoLeftBase ownVar; |
8283 | ····AgrBin1OwnpconOthpconTblAutoRightBase otherVar; |
8284 | ····PersistenceManager pm; |
8285 | ····[SetUp] |
8286 | ····public void Setup() |
8287 | ····{ |
8288 | ········pm = PmFactory.NewPersistenceManager(); |
8289 | ········ownVar = new AgrBin1OwnpconOthpconTblAutoLeftDerived(); |
8290 | ········otherVar = new AgrBin1OwnpconOthpconTblAutoRightDerived(); |
8291 | ····} |
8292 | ····[TearDown] |
8293 | ····public void TearDown() |
8294 | ····{ |
8295 | ········try |
8296 | ········{ |
8297 | ············pm.UnloadCache(); |
8298 | ············var l = pm.Objects<AgrBin1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8299 | ············pm.Delete(l); |
8300 | ············pm.Save(); |
8301 | ············pm.UnloadCache(); |
8302 | ············var m = pm.Objects<AgrBin1OwnpconOthpconTblAutoRightBase>().ResultTable; |
8303 | ············pm.Delete(m); |
8304 | ············pm.Save(); |
8305 | ············pm.UnloadCache(); |
8306 | ············decimal count; |
8307 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8308 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8309 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8310 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8311 | ········} |
8312 | ········catch (Exception) |
8313 | ········{ |
8314 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8315 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8316 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8317 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8318 | ········} |
8319 | ····} |
8320 | ····[Test] |
8321 | ····public void TestSaveReload() |
8322 | ····{ |
8323 | ········CreateObjects(); |
8324 | ········QueryOwn(); |
8325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8326 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8327 | ····} |
8328 | ····[Test] |
8329 | ····public void TestSaveReloadNull() |
8330 | ····{ |
8331 | ········CreateObjects(); |
8332 | ········QueryOwn(); |
8333 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8334 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8335 | ········ownVar.RelField = new List<AgrBin1OwnpconOthpconTblAutoRightBase>(); |
8336 | ········pm.Save(); |
8337 | ········pm.UnloadCache(); |
8338 | ········QueryOwn(); |
8339 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8340 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8341 | ····} |
8342 | ····[Test] |
8343 | ····public void TestSaveReloadRemove() |
8344 | ····{ |
8345 | ········CreateObjects(); |
8346 | ········QueryOwn(); |
8347 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8348 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8349 | ········ownVar.RemoveRelatedObject(); |
8350 | ········pm.Save(); |
8351 | ········pm.UnloadCache(); |
8352 | ········QueryOwn(); |
8353 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8354 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8355 | ····} |
8356 | ····[Test] |
8357 | ····public void TestChangeKeyHolderRight() |
8358 | ····{ |
8359 | ········CreateObjects(); |
8360 | ········QueryOther(); |
8361 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8362 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8363 | ········int x = otherVar.RelField.Dummy; |
8364 | ········otherVar.Dummy = 4711; |
8365 | ········pm.Save(); |
8366 | ········pm.UnloadCache(); |
8367 | ········QueryOther(); |
8368 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8369 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8370 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8371 | ····} |
8372 | ····[Test] |
8373 | ····public void TestChangeKeyHolderRightNoTouch() |
8374 | ····{ |
8375 | ········CreateObjects(); |
8376 | ········QueryOther(); |
8377 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8378 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8379 | ········otherVar.Dummy = 4711; |
8380 | ········pm.Save(); |
8381 | ········pm.UnloadCache(); |
8382 | ········QueryOther(); |
8383 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8384 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8385 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8386 | ····} |
8387 | ····[Test] |
8388 | ····public void TestRelationHash() |
8389 | ····{ |
8390 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoLeftBase)); |
8391 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8392 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoRightBase)); |
8393 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8394 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8395 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8396 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoLeftDerived)); |
8397 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8398 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8399 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8400 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoRightDerived)); |
8401 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8402 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8403 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8404 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8405 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8406 | ····} |
8407 | ····void CreateObjects() |
8408 | ····{ |
8409 | ········pm.MakePersistent(ownVar); |
8410 | ········pm.MakePersistent(otherVar); |
8411 | ········pm.Save(); |
8412 | ········ownVar.AssignRelation(otherVar); |
8413 | ········pm.Save(); |
8414 | ········pm.UnloadCache(); |
8415 | ····} |
8416 | ····void QueryOwn() |
8417 | ····{ |
8418 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblAutoLeftBase>(pm); |
8419 | ········ownVar = q.ExecuteSingle(); |
8420 | ····} |
8421 | ····void QueryOther() |
8422 | ····{ |
8423 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblAutoRightBase>(pm); |
8424 | ········otherVar = q.ExecuteSingle(); |
8425 | ····} |
8426 | } |
8427 | |
8428 | |
8429 | [TestFixture] |
8430 | public class TestAgrBi1nOwnpconOthpconTblAuto : NDOTest |
8431 | { |
8432 | ····AgrBi1nOwnpconOthpconTblAutoLeftBase ownVar; |
8433 | ····AgrBi1nOwnpconOthpconTblAutoRightBase otherVar; |
8434 | ····PersistenceManager pm; |
8435 | ····[SetUp] |
8436 | ····public void Setup() |
8437 | ····{ |
8438 | ········pm = PmFactory.NewPersistenceManager(); |
8439 | ········ownVar = new AgrBi1nOwnpconOthpconTblAutoLeftDerived(); |
8440 | ········otherVar = new AgrBi1nOwnpconOthpconTblAutoRightDerived(); |
8441 | ····} |
8442 | ····[TearDown] |
8443 | ····public void TearDown() |
8444 | ····{ |
8445 | ········try |
8446 | ········{ |
8447 | ············pm.UnloadCache(); |
8448 | ············var l = pm.Objects<AgrBi1nOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8449 | ············pm.Delete(l); |
8450 | ············pm.Save(); |
8451 | ············pm.UnloadCache(); |
8452 | ············var m = pm.Objects<AgrBi1nOwnpconOthpconTblAutoRightBase>().ResultTable; |
8453 | ············pm.Delete(m); |
8454 | ············pm.Save(); |
8455 | ············pm.UnloadCache(); |
8456 | ············decimal count; |
8457 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8458 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8459 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8460 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8461 | ········} |
8462 | ········catch (Exception) |
8463 | ········{ |
8464 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8465 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8466 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8467 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8468 | ········} |
8469 | ····} |
8470 | ····[Test] |
8471 | ····public void TestSaveReload() |
8472 | ····{ |
8473 | ········CreateObjects(); |
8474 | ········QueryOwn(); |
8475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8476 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8477 | ····} |
8478 | ····[Test] |
8479 | ····public void TestSaveReloadNull() |
8480 | ····{ |
8481 | ········CreateObjects(); |
8482 | ········QueryOwn(); |
8483 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8484 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8485 | ········ownVar.RelField = null; |
8486 | ········pm.Save(); |
8487 | ········pm.UnloadCache(); |
8488 | ········QueryOwn(); |
8489 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8490 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8491 | ····} |
8492 | ····[Test] |
8493 | ····public void TestChangeKeyHolderLeft() |
8494 | ····{ |
8495 | ········CreateObjects(); |
8496 | ········QueryOwn(); |
8497 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8498 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8499 | ········int x = ownVar.RelField.Dummy; |
8500 | ········ownVar.Dummy = 4711; |
8501 | ········pm.Save(); |
8502 | ········pm.UnloadCache(); |
8503 | ········QueryOwn(); |
8504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8505 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8506 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8507 | ····} |
8508 | ····[Test] |
8509 | ····public void TestChangeKeyHolderLeftNoTouch() |
8510 | ····{ |
8511 | ········CreateObjects(); |
8512 | ········QueryOwn(); |
8513 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8514 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8515 | ········ownVar.Dummy = 4711; |
8516 | ········pm.Save(); |
8517 | ········pm.UnloadCache(); |
8518 | ········QueryOwn(); |
8519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8520 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8521 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8522 | ····} |
8523 | ····[Test] |
8524 | ····public void TestRelationHash() |
8525 | ····{ |
8526 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoLeftBase)); |
8527 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8528 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoRightBase)); |
8529 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8530 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8531 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8532 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoLeftDerived)); |
8533 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8534 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8535 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8536 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoRightDerived)); |
8537 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8538 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8539 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8540 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8541 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8542 | ····} |
8543 | ····void CreateObjects() |
8544 | ····{ |
8545 | ········pm.MakePersistent(ownVar); |
8546 | ········pm.MakePersistent(otherVar); |
8547 | ········ownVar.AssignRelation(otherVar); |
8548 | ········pm.Save(); |
8549 | ········pm.UnloadCache(); |
8550 | ····} |
8551 | ····void QueryOwn() |
8552 | ····{ |
8553 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblAutoLeftBase>(pm); |
8554 | ········ownVar = q.ExecuteSingle(); |
8555 | ····} |
8556 | ····void QueryOther() |
8557 | ····{ |
8558 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblAutoRightBase>(pm); |
8559 | ········otherVar = q.ExecuteSingle(); |
8560 | ····} |
8561 | } |
8562 | |
8563 | |
8564 | [TestFixture] |
8565 | public class TestAgrBinnOwnpconOthpconTblAuto : NDOTest |
8566 | { |
8567 | ····AgrBinnOwnpconOthpconTblAutoLeftBase ownVar; |
8568 | ····AgrBinnOwnpconOthpconTblAutoRightBase otherVar; |
8569 | ····PersistenceManager pm; |
8570 | ····[SetUp] |
8571 | ····public void Setup() |
8572 | ····{ |
8573 | ········pm = PmFactory.NewPersistenceManager(); |
8574 | ········ownVar = new AgrBinnOwnpconOthpconTblAutoLeftDerived(); |
8575 | ········otherVar = new AgrBinnOwnpconOthpconTblAutoRightDerived(); |
8576 | ····} |
8577 | ····[TearDown] |
8578 | ····public void TearDown() |
8579 | ····{ |
8580 | ········try |
8581 | ········{ |
8582 | ············pm.UnloadCache(); |
8583 | ············var l = pm.Objects<AgrBinnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8584 | ············pm.Delete(l); |
8585 | ············pm.Save(); |
8586 | ············pm.UnloadCache(); |
8587 | ············var m = pm.Objects<AgrBinnOwnpconOthpconTblAutoRightBase>().ResultTable; |
8588 | ············pm.Delete(m); |
8589 | ············pm.Save(); |
8590 | ············pm.UnloadCache(); |
8591 | ············decimal count; |
8592 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8593 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8594 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8595 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8596 | ········} |
8597 | ········catch (Exception) |
8598 | ········{ |
8599 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8600 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8601 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8602 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8603 | ········} |
8604 | ····} |
8605 | ····[Test] |
8606 | ····public void TestSaveReload() |
8607 | ····{ |
8608 | ········CreateObjects(); |
8609 | ········QueryOwn(); |
8610 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8611 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8612 | ····} |
8613 | ····[Test] |
8614 | ····public void TestSaveReloadNull() |
8615 | ····{ |
8616 | ········CreateObjects(); |
8617 | ········QueryOwn(); |
8618 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8619 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8620 | ········ownVar.RelField = new List<AgrBinnOwnpconOthpconTblAutoRightBase>(); |
8621 | ········pm.Save(); |
8622 | ········pm.UnloadCache(); |
8623 | ········QueryOwn(); |
8624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8625 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8626 | ····} |
8627 | ····[Test] |
8628 | ····public void TestSaveReloadRemove() |
8629 | ····{ |
8630 | ········CreateObjects(); |
8631 | ········QueryOwn(); |
8632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8633 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8634 | ········ownVar.RemoveRelatedObject(); |
8635 | ········pm.Save(); |
8636 | ········pm.UnloadCache(); |
8637 | ········QueryOwn(); |
8638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8639 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8640 | ····} |
8641 | ····[Test] |
8642 | ····public void TestRelationHash() |
8643 | ····{ |
8644 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoLeftBase)); |
8645 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8646 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoRightBase)); |
8647 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8648 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8649 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8650 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoLeftDerived)); |
8651 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8652 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8653 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8654 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoRightDerived)); |
8655 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8656 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8657 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8658 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8659 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8660 | ····} |
8661 | ····void CreateObjects() |
8662 | ····{ |
8663 | ········pm.MakePersistent(ownVar); |
8664 | ········pm.MakePersistent(otherVar); |
8665 | ········ownVar.AssignRelation(otherVar); |
8666 | ········pm.Save(); |
8667 | ········pm.UnloadCache(); |
8668 | ····} |
8669 | ····void QueryOwn() |
8670 | ····{ |
8671 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblAutoLeftBase>(pm); |
8672 | ········ownVar = q.ExecuteSingle(); |
8673 | ····} |
8674 | ····void QueryOther() |
8675 | ····{ |
8676 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblAutoRightBase>(pm); |
8677 | ········otherVar = q.ExecuteSingle(); |
8678 | ····} |
8679 | } |
8680 | |
8681 | |
8682 | [TestFixture] |
8683 | public class TestCmpDir1OwnpconOthpconNoTblAuto : NDOTest |
8684 | { |
8685 | ····CmpDir1OwnpconOthpconNoTblAutoLeftBase ownVar; |
8686 | ····CmpDir1OwnpconOthpconNoTblAutoRightBase otherVar; |
8687 | ····PersistenceManager pm; |
8688 | ····[SetUp] |
8689 | ····public void Setup() |
8690 | ····{ |
8691 | ········pm = PmFactory.NewPersistenceManager(); |
8692 | ········ownVar = new CmpDir1OwnpconOthpconNoTblAutoLeftDerived(); |
8693 | ········otherVar = new CmpDir1OwnpconOthpconNoTblAutoRightDerived(); |
8694 | ····} |
8695 | ····[TearDown] |
8696 | ····public void TearDown() |
8697 | ····{ |
8698 | ········try |
8699 | ········{ |
8700 | ············pm.UnloadCache(); |
8701 | ············var l = pm.Objects<CmpDir1OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
8702 | ············pm.Delete(l); |
8703 | ············pm.Save(); |
8704 | ············pm.UnloadCache(); |
8705 | ············decimal count; |
8706 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8707 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8708 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8709 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8710 | ········} |
8711 | ········catch (Exception) |
8712 | ········{ |
8713 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8714 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8715 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8716 | ········} |
8717 | ····} |
8718 | ····[Test] |
8719 | ····public void TestSaveReload() |
8720 | ····{ |
8721 | ········bool thrown = false; |
8722 | ········try |
8723 | ········{ |
8724 | ············CreateObjects(); |
8725 | ············QueryOwn(); |
8726 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8727 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8728 | ········} |
8729 | ········catch (NDOException) |
8730 | ········{ |
8731 | ············thrown = true; |
8732 | ········} |
8733 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8734 | ····} |
8735 | ····[Test] |
8736 | ····public void TestSaveReloadNull() |
8737 | ····{ |
8738 | ········bool thrown = false; |
8739 | ········try |
8740 | ········{ |
8741 | ············CreateObjects(); |
8742 | ············QueryOwn(); |
8743 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8744 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8745 | ············ownVar.RelField = null; |
8746 | ············pm.Save(); |
8747 | ············pm.UnloadCache(); |
8748 | ············QueryOwn(); |
8749 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8750 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8751 | ········} |
8752 | ········catch (NDOException) |
8753 | ········{ |
8754 | ············thrown = true; |
8755 | ········} |
8756 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8757 | ····} |
8758 | ····void CreateObjects() |
8759 | ····{ |
8760 | ········pm.MakePersistent(ownVar); |
8761 | ········pm.Save(); |
8762 | ········ownVar.AssignRelation(otherVar); |
8763 | ········pm.Save(); |
8764 | ········pm.UnloadCache(); |
8765 | ····} |
8766 | ····void QueryOwn() |
8767 | ····{ |
8768 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoLeftBase>(pm); |
8769 | ········ownVar = q.ExecuteSingle(); |
8770 | ····} |
8771 | ····void QueryOther() |
8772 | ····{ |
8773 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoRightBase>(pm); |
8774 | ········otherVar = q.ExecuteSingle(); |
8775 | ····} |
8776 | } |
8777 | |
8778 | |
8779 | [TestFixture] |
8780 | public class TestCmpDir1OwnpconOthpconTblAuto : NDOTest |
8781 | { |
8782 | ····CmpDir1OwnpconOthpconTblAutoLeftBase ownVar; |
8783 | ····CmpDir1OwnpconOthpconTblAutoRightBase otherVar; |
8784 | ····PersistenceManager pm; |
8785 | ····[SetUp] |
8786 | ····public void Setup() |
8787 | ····{ |
8788 | ········pm = PmFactory.NewPersistenceManager(); |
8789 | ········ownVar = new CmpDir1OwnpconOthpconTblAutoLeftDerived(); |
8790 | ········otherVar = new CmpDir1OwnpconOthpconTblAutoRightDerived(); |
8791 | ····} |
8792 | ····[TearDown] |
8793 | ····public void TearDown() |
8794 | ····{ |
8795 | ········try |
8796 | ········{ |
8797 | ············pm.UnloadCache(); |
8798 | ············var l = pm.Objects<CmpDir1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8799 | ············pm.Delete(l); |
8800 | ············pm.Save(); |
8801 | ············pm.UnloadCache(); |
8802 | ············decimal count; |
8803 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8804 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8805 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8806 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8807 | ········} |
8808 | ········catch (Exception) |
8809 | ········{ |
8810 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8811 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8812 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8813 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8814 | ········} |
8815 | ····} |
8816 | ····[Test] |
8817 | ····public void TestSaveReload() |
8818 | ····{ |
8819 | ········CreateObjects(); |
8820 | ········QueryOwn(); |
8821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8823 | ····} |
8824 | ····[Test] |
8825 | ····public void TestSaveReloadNull() |
8826 | ····{ |
8827 | ········CreateObjects(); |
8828 | ········QueryOwn(); |
8829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8831 | ········ownVar.RelField = null; |
8832 | ········pm.Save(); |
8833 | ········pm.UnloadCache(); |
8834 | ········QueryOwn(); |
8835 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8836 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8837 | ····} |
8838 | ····[Test] |
8839 | ····public void TestChangeKeyHolderLeft() |
8840 | ····{ |
8841 | ········CreateObjects(); |
8842 | ········QueryOwn(); |
8843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8844 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8845 | ········int x = ownVar.RelField.Dummy; |
8846 | ········ownVar.Dummy = 4711; |
8847 | ········pm.Save(); |
8848 | ········pm.UnloadCache(); |
8849 | ········QueryOwn(); |
8850 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8851 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8853 | ····} |
8854 | ····[Test] |
8855 | ····public void TestChangeKeyHolderLeftNoTouch() |
8856 | ····{ |
8857 | ········CreateObjects(); |
8858 | ········QueryOwn(); |
8859 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8861 | ········ownVar.Dummy = 4711; |
8862 | ········pm.Save(); |
8863 | ········pm.UnloadCache(); |
8864 | ········QueryOwn(); |
8865 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8866 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8867 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8868 | ····} |
8869 | ····void CreateObjects() |
8870 | ····{ |
8871 | ········pm.MakePersistent(ownVar); |
8872 | ········ownVar.AssignRelation(otherVar); |
8873 | ········pm.Save(); |
8874 | ········pm.UnloadCache(); |
8875 | ····} |
8876 | ····void QueryOwn() |
8877 | ····{ |
8878 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblAutoLeftBase>(pm); |
8879 | ········ownVar = q.ExecuteSingle(); |
8880 | ····} |
8881 | ····void QueryOther() |
8882 | ····{ |
8883 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblAutoRightBase>(pm); |
8884 | ········otherVar = q.ExecuteSingle(); |
8885 | ····} |
8886 | } |
8887 | |
8888 | |
8889 | [TestFixture] |
8890 | public class TestCmpBi11OwnpconOthpconNoTblAuto : NDOTest |
8891 | { |
8892 | ····CmpBi11OwnpconOthpconNoTblAutoLeftBase ownVar; |
8893 | ····CmpBi11OwnpconOthpconNoTblAutoRightBase otherVar; |
8894 | ····PersistenceManager pm; |
8895 | ····[SetUp] |
8896 | ····public void Setup() |
8897 | ····{ |
8898 | ········pm = PmFactory.NewPersistenceManager(); |
8899 | ········ownVar = new CmpBi11OwnpconOthpconNoTblAutoLeftDerived(); |
8900 | ········otherVar = new CmpBi11OwnpconOthpconNoTblAutoRightDerived(); |
8901 | ····} |
8902 | ····[TearDown] |
8903 | ····public void TearDown() |
8904 | ····{ |
8905 | ········try |
8906 | ········{ |
8907 | ············pm.UnloadCache(); |
8908 | ············var l = pm.Objects<CmpBi11OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
8909 | ············pm.Delete(l); |
8910 | ············pm.Save(); |
8911 | ············pm.UnloadCache(); |
8912 | ············decimal count; |
8913 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8914 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8915 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8916 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8917 | ········} |
8918 | ········catch (Exception) |
8919 | ········{ |
8920 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8921 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8922 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8923 | ········} |
8924 | ····} |
8925 | ····[Test] |
8926 | ····public void TestSaveReload() |
8927 | ····{ |
8928 | ········bool thrown = false; |
8929 | ········try |
8930 | ········{ |
8931 | ············CreateObjects(); |
8932 | ············QueryOwn(); |
8933 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8934 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8935 | ········} |
8936 | ········catch (NDOException) |
8937 | ········{ |
8938 | ············thrown = true; |
8939 | ········} |
8940 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8941 | ····} |
8942 | ····[Test] |
8943 | ····public void TestSaveReloadNull() |
8944 | ····{ |
8945 | ········bool thrown = false; |
8946 | ········try |
8947 | ········{ |
8948 | ············CreateObjects(); |
8949 | ············QueryOwn(); |
8950 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8951 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8952 | ············ownVar.RelField = null; |
8953 | ············pm.Save(); |
8954 | ············pm.UnloadCache(); |
8955 | ············QueryOwn(); |
8956 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8957 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8958 | ········} |
8959 | ········catch (NDOException) |
8960 | ········{ |
8961 | ············thrown = true; |
8962 | ········} |
8963 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8964 | ····} |
8965 | ····[Test] |
8966 | ····public void TestRelationHash() |
8967 | ····{ |
8968 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoLeftBase)); |
8969 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8970 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoRightBase)); |
8971 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8972 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8973 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8974 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoLeftDerived)); |
8975 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8976 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8977 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8978 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoRightDerived)); |
8979 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8980 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8981 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8982 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8983 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8984 | ····} |
8985 | ····void CreateObjects() |
8986 | ····{ |
8987 | ········pm.MakePersistent(ownVar); |
8988 | ········pm.Save(); |
8989 | ········ownVar.AssignRelation(otherVar); |
8990 | ········pm.Save(); |
8991 | ········pm.UnloadCache(); |
8992 | ····} |
8993 | ····void QueryOwn() |
8994 | ····{ |
8995 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoLeftBase>(pm); |
8996 | ········ownVar = q.ExecuteSingle(); |
8997 | ····} |
8998 | ····void QueryOther() |
8999 | ····{ |
9000 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoRightBase>(pm); |
9001 | ········otherVar = q.ExecuteSingle(); |
9002 | ····} |
9003 | } |
9004 | |
9005 | |
9006 | [TestFixture] |
9007 | public class TestCmpBi11OwnpconOthpconTblAuto : NDOTest |
9008 | { |
9009 | ····CmpBi11OwnpconOthpconTblAutoLeftBase ownVar; |
9010 | ····CmpBi11OwnpconOthpconTblAutoRightBase otherVar; |
9011 | ····PersistenceManager pm; |
9012 | ····[SetUp] |
9013 | ····public void Setup() |
9014 | ····{ |
9015 | ········pm = PmFactory.NewPersistenceManager(); |
9016 | ········ownVar = new CmpBi11OwnpconOthpconTblAutoLeftDerived(); |
9017 | ········otherVar = new CmpBi11OwnpconOthpconTblAutoRightDerived(); |
9018 | ····} |
9019 | ····[TearDown] |
9020 | ····public void TearDown() |
9021 | ····{ |
9022 | ········try |
9023 | ········{ |
9024 | ············pm.UnloadCache(); |
9025 | ············var l = pm.Objects<CmpBi11OwnpconOthpconTblAutoLeftBase>().ResultTable; |
9026 | ············pm.Delete(l); |
9027 | ············pm.Save(); |
9028 | ············pm.UnloadCache(); |
9029 | ············decimal count; |
9030 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9031 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9032 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9033 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9034 | ········} |
9035 | ········catch (Exception) |
9036 | ········{ |
9037 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9038 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9039 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9040 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9041 | ········} |
9042 | ····} |
9043 | ····[Test] |
9044 | ····public void TestSaveReload() |
9045 | ····{ |
9046 | ········CreateObjects(); |
9047 | ········QueryOwn(); |
9048 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9049 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9050 | ····} |
9051 | ····[Test] |
9052 | ····public void TestSaveReloadNull() |
9053 | ····{ |
9054 | ········CreateObjects(); |
9055 | ········QueryOwn(); |
9056 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9057 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9058 | ········ownVar.RelField = null; |
9059 | ········pm.Save(); |
9060 | ········pm.UnloadCache(); |
9061 | ········QueryOwn(); |
9062 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9063 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9064 | ····} |
9065 | ····[Test] |
9066 | ····public void TestChangeKeyHolderLeft() |
9067 | ····{ |
9068 | ········CreateObjects(); |
9069 | ········QueryOwn(); |
9070 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9071 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9072 | ········int x = ownVar.RelField.Dummy; |
9073 | ········ownVar.Dummy = 4711; |
9074 | ········pm.Save(); |
9075 | ········pm.UnloadCache(); |
9076 | ········QueryOwn(); |
9077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9078 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9079 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9080 | ····} |
9081 | ····[Test] |
9082 | ····public void TestChangeKeyHolderRight() |
9083 | ····{ |
9084 | ········CreateObjects(); |
9085 | ········QueryOther(); |
9086 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9087 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9088 | ········int x = otherVar.RelField.Dummy; |
9089 | ········otherVar.Dummy = 4711; |
9090 | ········pm.Save(); |
9091 | ········pm.UnloadCache(); |
9092 | ········QueryOther(); |
9093 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9094 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9095 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9096 | ····} |
9097 | ····[Test] |
9098 | ····public void TestChangeKeyHolderLeftNoTouch() |
9099 | ····{ |
9100 | ········CreateObjects(); |
9101 | ········QueryOwn(); |
9102 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9104 | ········ownVar.Dummy = 4711; |
9105 | ········pm.Save(); |
9106 | ········pm.UnloadCache(); |
9107 | ········QueryOwn(); |
9108 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9109 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9110 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9111 | ····} |
9112 | ····[Test] |
9113 | ····public void TestChangeKeyHolderRightNoTouch() |
9114 | ····{ |
9115 | ········CreateObjects(); |
9116 | ········QueryOther(); |
9117 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9118 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9119 | ········otherVar.Dummy = 4711; |
9120 | ········pm.Save(); |
9121 | ········pm.UnloadCache(); |
9122 | ········QueryOther(); |
9123 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9124 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9125 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9126 | ····} |
9127 | ····[Test] |
9128 | ····public void TestRelationHash() |
9129 | ····{ |
9130 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoLeftBase)); |
9131 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9132 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoRightBase)); |
9133 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9134 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9135 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9136 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoLeftDerived)); |
9137 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9138 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9139 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9140 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoRightDerived)); |
9141 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9142 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9143 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9144 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9145 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9146 | ····} |
9147 | ····void CreateObjects() |
9148 | ····{ |
9149 | ········pm.MakePersistent(ownVar); |
9150 | ········ownVar.AssignRelation(otherVar); |
9151 | ········pm.Save(); |
9152 | ········pm.UnloadCache(); |
9153 | ····} |
9154 | ····void QueryOwn() |
9155 | ····{ |
9156 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblAutoLeftBase>(pm); |
9157 | ········ownVar = q.ExecuteSingle(); |
9158 | ····} |
9159 | ····void QueryOther() |
9160 | ····{ |
9161 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblAutoRightBase>(pm); |
9162 | ········otherVar = q.ExecuteSingle(); |
9163 | ····} |
9164 | } |
9165 | |
9166 | |
9167 | [TestFixture] |
9168 | public class TestCmpDirnOwnpconOthpconTblAuto : NDOTest |
9169 | { |
9170 | ····CmpDirnOwnpconOthpconTblAutoLeftBase ownVar; |
9171 | ····CmpDirnOwnpconOthpconTblAutoRightBase otherVar; |
9172 | ····PersistenceManager pm; |
9173 | ····[SetUp] |
9174 | ····public void Setup() |
9175 | ····{ |
9176 | ········pm = PmFactory.NewPersistenceManager(); |
9177 | ········ownVar = new CmpDirnOwnpconOthpconTblAutoLeftDerived(); |
9178 | ········otherVar = new CmpDirnOwnpconOthpconTblAutoRightDerived(); |
9179 | ····} |
9180 | ····[TearDown] |
9181 | ····public void TearDown() |
9182 | ····{ |
9183 | ········try |
9184 | ········{ |
9185 | ············pm.UnloadCache(); |
9186 | ············var l = pm.Objects<CmpDirnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9187 | ············pm.Delete(l); |
9188 | ············pm.Save(); |
9189 | ············pm.UnloadCache(); |
9190 | ············decimal count; |
9191 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9192 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9193 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9194 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9195 | ········} |
9196 | ········catch (Exception) |
9197 | ········{ |
9198 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9199 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9200 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9201 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9202 | ········} |
9203 | ····} |
9204 | ····[Test] |
9205 | ····public void TestSaveReload() |
9206 | ····{ |
9207 | ········CreateObjects(); |
9208 | ········QueryOwn(); |
9209 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9210 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9211 | ····} |
9212 | ····[Test] |
9213 | ····public void TestSaveReloadNull() |
9214 | ····{ |
9215 | ········CreateObjects(); |
9216 | ········QueryOwn(); |
9217 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9218 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9219 | ········ownVar.RelField = new List<CmpDirnOwnpconOthpconTblAutoRightBase>(); |
9220 | ········pm.Save(); |
9221 | ········pm.UnloadCache(); |
9222 | ········QueryOwn(); |
9223 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9224 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9225 | ····} |
9226 | ····[Test] |
9227 | ····public void TestSaveReloadRemove() |
9228 | ····{ |
9229 | ········CreateObjects(); |
9230 | ········QueryOwn(); |
9231 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9232 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9233 | ········ownVar.RemoveRelatedObject(); |
9234 | ········pm.Save(); |
9235 | ········pm.UnloadCache(); |
9236 | ········QueryOwn(); |
9237 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9238 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9239 | ····} |
9240 | ····void CreateObjects() |
9241 | ····{ |
9242 | ········pm.MakePersistent(ownVar); |
9243 | ········ownVar.AssignRelation(otherVar); |
9244 | ········pm.Save(); |
9245 | ········pm.UnloadCache(); |
9246 | ····} |
9247 | ····void QueryOwn() |
9248 | ····{ |
9249 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblAutoLeftBase>(pm); |
9250 | ········ownVar = q.ExecuteSingle(); |
9251 | ····} |
9252 | ····void QueryOther() |
9253 | ····{ |
9254 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblAutoRightBase>(pm); |
9255 | ········otherVar = q.ExecuteSingle(); |
9256 | ····} |
9257 | } |
9258 | |
9259 | |
9260 | [TestFixture] |
9261 | public class TestCmpBin1OwnpconOthpconTblAuto : NDOTest |
9262 | { |
9263 | ····CmpBin1OwnpconOthpconTblAutoLeftBase ownVar; |
9264 | ····CmpBin1OwnpconOthpconTblAutoRightBase otherVar; |
9265 | ····PersistenceManager pm; |
9266 | ····[SetUp] |
9267 | ····public void Setup() |
9268 | ····{ |
9269 | ········pm = PmFactory.NewPersistenceManager(); |
9270 | ········ownVar = new CmpBin1OwnpconOthpconTblAutoLeftDerived(); |
9271 | ········otherVar = new CmpBin1OwnpconOthpconTblAutoRightDerived(); |
9272 | ····} |
9273 | ····[TearDown] |
9274 | ····public void TearDown() |
9275 | ····{ |
9276 | ········try |
9277 | ········{ |
9278 | ············pm.UnloadCache(); |
9279 | ············var l = pm.Objects<CmpBin1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
9280 | ············pm.Delete(l); |
9281 | ············pm.Save(); |
9282 | ············pm.UnloadCache(); |
9283 | ············decimal count; |
9284 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9285 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9286 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9287 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9288 | ········} |
9289 | ········catch (Exception) |
9290 | ········{ |
9291 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9292 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9293 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9294 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9295 | ········} |
9296 | ····} |
9297 | ····[Test] |
9298 | ····public void TestSaveReload() |
9299 | ····{ |
9300 | ········CreateObjects(); |
9301 | ········QueryOwn(); |
9302 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9303 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9304 | ····} |
9305 | ····[Test] |
9306 | ····public void TestSaveReloadNull() |
9307 | ····{ |
9308 | ········CreateObjects(); |
9309 | ········QueryOwn(); |
9310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9311 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9312 | ········ownVar.RelField = new List<CmpBin1OwnpconOthpconTblAutoRightBase>(); |
9313 | ········pm.Save(); |
9314 | ········pm.UnloadCache(); |
9315 | ········QueryOwn(); |
9316 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9317 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9318 | ····} |
9319 | ····[Test] |
9320 | ····public void TestSaveReloadRemove() |
9321 | ····{ |
9322 | ········CreateObjects(); |
9323 | ········QueryOwn(); |
9324 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9325 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9326 | ········ownVar.RemoveRelatedObject(); |
9327 | ········pm.Save(); |
9328 | ········pm.UnloadCache(); |
9329 | ········QueryOwn(); |
9330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9331 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9332 | ····} |
9333 | ····[Test] |
9334 | ····public void TestChangeKeyHolderRight() |
9335 | ····{ |
9336 | ········CreateObjects(); |
9337 | ········QueryOther(); |
9338 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9339 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9340 | ········int x = otherVar.RelField.Dummy; |
9341 | ········otherVar.Dummy = 4711; |
9342 | ········pm.Save(); |
9343 | ········pm.UnloadCache(); |
9344 | ········QueryOther(); |
9345 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9346 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9347 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9348 | ····} |
9349 | ····[Test] |
9350 | ····public void TestChangeKeyHolderRightNoTouch() |
9351 | ····{ |
9352 | ········CreateObjects(); |
9353 | ········QueryOther(); |
9354 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9355 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9356 | ········otherVar.Dummy = 4711; |
9357 | ········pm.Save(); |
9358 | ········pm.UnloadCache(); |
9359 | ········QueryOther(); |
9360 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9361 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9362 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9363 | ····} |
9364 | ····[Test] |
9365 | ····public void TestRelationHash() |
9366 | ····{ |
9367 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoLeftBase)); |
9368 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9369 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoRightBase)); |
9370 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9371 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9372 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9373 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoLeftDerived)); |
9374 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9375 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9376 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9377 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoRightDerived)); |
9378 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9379 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9380 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9381 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9382 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9383 | ····} |
9384 | ····void CreateObjects() |
9385 | ····{ |
9386 | ········pm.MakePersistent(ownVar); |
9387 | ········ownVar.AssignRelation(otherVar); |
9388 | ········pm.Save(); |
9389 | ········pm.UnloadCache(); |
9390 | ····} |
9391 | ····void QueryOwn() |
9392 | ····{ |
9393 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblAutoLeftBase>(pm); |
9394 | ········ownVar = q.ExecuteSingle(); |
9395 | ····} |
9396 | ····void QueryOther() |
9397 | ····{ |
9398 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblAutoRightBase>(pm); |
9399 | ········otherVar = q.ExecuteSingle(); |
9400 | ····} |
9401 | } |
9402 | |
9403 | |
9404 | [TestFixture] |
9405 | public class TestCmpBi1nOwnpconOthpconTblAuto : NDOTest |
9406 | { |
9407 | ····CmpBi1nOwnpconOthpconTblAutoLeftBase ownVar; |
9408 | ····CmpBi1nOwnpconOthpconTblAutoRightBase otherVar; |
9409 | ····PersistenceManager pm; |
9410 | ····[SetUp] |
9411 | ····public void Setup() |
9412 | ····{ |
9413 | ········pm = PmFactory.NewPersistenceManager(); |
9414 | ········ownVar = new CmpBi1nOwnpconOthpconTblAutoLeftDerived(); |
9415 | ········otherVar = new CmpBi1nOwnpconOthpconTblAutoRightDerived(); |
9416 | ····} |
9417 | ····[TearDown] |
9418 | ····public void TearDown() |
9419 | ····{ |
9420 | ········try |
9421 | ········{ |
9422 | ············pm.UnloadCache(); |
9423 | ············var l = pm.Objects<CmpBi1nOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9424 | ············pm.Delete(l); |
9425 | ············pm.Save(); |
9426 | ············pm.UnloadCache(); |
9427 | ············decimal count; |
9428 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9429 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9430 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9431 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9432 | ········} |
9433 | ········catch (Exception) |
9434 | ········{ |
9435 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9436 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9437 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9438 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9439 | ········} |
9440 | ····} |
9441 | ····[Test] |
9442 | ····public void TestSaveReload() |
9443 | ····{ |
9444 | ········CreateObjects(); |
9445 | ········QueryOwn(); |
9446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9447 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9448 | ····} |
9449 | ····[Test] |
9450 | ····public void TestSaveReloadNull() |
9451 | ····{ |
9452 | ········CreateObjects(); |
9453 | ········QueryOwn(); |
9454 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9455 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9456 | ········ownVar.RelField = null; |
9457 | ········pm.Save(); |
9458 | ········pm.UnloadCache(); |
9459 | ········QueryOwn(); |
9460 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9461 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9462 | ····} |
9463 | ····[Test] |
9464 | ····public void TestChangeKeyHolderLeft() |
9465 | ····{ |
9466 | ········CreateObjects(); |
9467 | ········QueryOwn(); |
9468 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9469 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9470 | ········int x = ownVar.RelField.Dummy; |
9471 | ········ownVar.Dummy = 4711; |
9472 | ········pm.Save(); |
9473 | ········pm.UnloadCache(); |
9474 | ········QueryOwn(); |
9475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9476 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9477 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9478 | ····} |
9479 | ····[Test] |
9480 | ····public void TestChangeKeyHolderLeftNoTouch() |
9481 | ····{ |
9482 | ········CreateObjects(); |
9483 | ········QueryOwn(); |
9484 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9485 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9486 | ········ownVar.Dummy = 4711; |
9487 | ········pm.Save(); |
9488 | ········pm.UnloadCache(); |
9489 | ········QueryOwn(); |
9490 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9491 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9492 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9493 | ····} |
9494 | ····[Test] |
9495 | ····public void TestRelationHash() |
9496 | ····{ |
9497 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoLeftBase)); |
9498 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9499 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoRightBase)); |
9500 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9501 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9502 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9503 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoLeftDerived)); |
9504 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9505 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9506 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9507 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoRightDerived)); |
9508 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9509 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9510 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9511 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9512 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9513 | ····} |
9514 | ····void CreateObjects() |
9515 | ····{ |
9516 | ········pm.MakePersistent(ownVar); |
9517 | ········ownVar.AssignRelation(otherVar); |
9518 | ········pm.Save(); |
9519 | ········pm.UnloadCache(); |
9520 | ····} |
9521 | ····void QueryOwn() |
9522 | ····{ |
9523 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblAutoLeftBase>(pm); |
9524 | ········ownVar = q.ExecuteSingle(); |
9525 | ····} |
9526 | ····void QueryOther() |
9527 | ····{ |
9528 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblAutoRightBase>(pm); |
9529 | ········otherVar = q.ExecuteSingle(); |
9530 | ····} |
9531 | } |
9532 | |
9533 | |
9534 | [TestFixture] |
9535 | public class TestCmpBinnOwnpconOthpconTblAuto : NDOTest |
9536 | { |
9537 | ····CmpBinnOwnpconOthpconTblAutoLeftBase ownVar; |
9538 | ····CmpBinnOwnpconOthpconTblAutoRightBase otherVar; |
9539 | ····PersistenceManager pm; |
9540 | ····[SetUp] |
9541 | ····public void Setup() |
9542 | ····{ |
9543 | ········pm = PmFactory.NewPersistenceManager(); |
9544 | ········ownVar = new CmpBinnOwnpconOthpconTblAutoLeftDerived(); |
9545 | ········otherVar = new CmpBinnOwnpconOthpconTblAutoRightDerived(); |
9546 | ····} |
9547 | ····[TearDown] |
9548 | ····public void TearDown() |
9549 | ····{ |
9550 | ········try |
9551 | ········{ |
9552 | ············pm.UnloadCache(); |
9553 | ············var l = pm.Objects<CmpBinnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9554 | ············pm.Delete(l); |
9555 | ············pm.Save(); |
9556 | ············pm.UnloadCache(); |
9557 | ············decimal count; |
9558 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9559 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9560 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9561 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9562 | ········} |
9563 | ········catch (Exception) |
9564 | ········{ |
9565 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9566 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9567 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9568 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9569 | ········} |
9570 | ····} |
9571 | ····[Test] |
9572 | ····public void TestSaveReload() |
9573 | ····{ |
9574 | ········CreateObjects(); |
9575 | ········QueryOwn(); |
9576 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9577 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9578 | ····} |
9579 | ····[Test] |
9580 | ····public void TestSaveReloadNull() |
9581 | ····{ |
9582 | ········CreateObjects(); |
9583 | ········QueryOwn(); |
9584 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9585 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9586 | ········ownVar.RelField = new List<CmpBinnOwnpconOthpconTblAutoRightBase>(); |
9587 | ········pm.Save(); |
9588 | ········pm.UnloadCache(); |
9589 | ········QueryOwn(); |
9590 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9591 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9592 | ····} |
9593 | ····[Test] |
9594 | ····public void TestSaveReloadRemove() |
9595 | ····{ |
9596 | ········CreateObjects(); |
9597 | ········QueryOwn(); |
9598 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9599 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9600 | ········ownVar.RemoveRelatedObject(); |
9601 | ········pm.Save(); |
9602 | ········pm.UnloadCache(); |
9603 | ········QueryOwn(); |
9604 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9605 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9606 | ····} |
9607 | ····[Test] |
9608 | ····public void TestRelationHash() |
9609 | ····{ |
9610 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoLeftBase)); |
9611 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9612 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoRightBase)); |
9613 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9614 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9615 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9616 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoLeftDerived)); |
9617 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9618 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9619 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9620 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoRightDerived)); |
9621 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9622 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9623 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9624 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9625 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9626 | ····} |
9627 | ····void CreateObjects() |
9628 | ····{ |
9629 | ········pm.MakePersistent(ownVar); |
9630 | ········ownVar.AssignRelation(otherVar); |
9631 | ········pm.Save(); |
9632 | ········pm.UnloadCache(); |
9633 | ····} |
9634 | ····void QueryOwn() |
9635 | ····{ |
9636 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblAutoLeftBase>(pm); |
9637 | ········ownVar = q.ExecuteSingle(); |
9638 | ····} |
9639 | ····void QueryOther() |
9640 | ····{ |
9641 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblAutoRightBase>(pm); |
9642 | ········otherVar = q.ExecuteSingle(); |
9643 | ····} |
9644 | } |
9645 | |
9646 | |
9647 | [TestFixture] |
9648 | public class TestAgrDir1NoTblGuid : NDOTest |
9649 | { |
9650 | ····AgrDir1NoTblGuidLeft ownVar; |
9651 | ····AgrDir1NoTblGuidRight otherVar; |
9652 | ····PersistenceManager pm; |
9653 | ····[SetUp] |
9654 | ····public void Setup() |
9655 | ····{ |
9656 | ········pm = PmFactory.NewPersistenceManager(); |
9657 | ········ownVar = new AgrDir1NoTblGuidLeft(); |
9658 | ········otherVar = new AgrDir1NoTblGuidRight(); |
9659 | ····} |
9660 | ····[TearDown] |
9661 | ····public void TearDown() |
9662 | ····{ |
9663 | ········try |
9664 | ········{ |
9665 | ············pm.UnloadCache(); |
9666 | ············var l = pm.Objects<AgrDir1NoTblGuidLeft>().ResultTable; |
9667 | ············pm.Delete(l); |
9668 | ············pm.Save(); |
9669 | ············pm.UnloadCache(); |
9670 | ············var m = pm.Objects<AgrDir1NoTblGuidRight>().ResultTable; |
9671 | ············pm.Delete(m); |
9672 | ············pm.Save(); |
9673 | ············pm.UnloadCache(); |
9674 | ············decimal count; |
9675 | ············count = (decimal) new NDOQuery<AgrDir1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9676 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9677 | ············count = (decimal) new NDOQuery<AgrDir1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9678 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9679 | ········} |
9680 | ········catch (Exception) |
9681 | ········{ |
9682 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9683 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9684 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9685 | ········} |
9686 | ····} |
9687 | ····[Test] |
9688 | ····public void TestSaveReload() |
9689 | ····{ |
9690 | ········CreateObjects(); |
9691 | ········QueryOwn(); |
9692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9693 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9694 | ····} |
9695 | ····[Test] |
9696 | ····public void TestSaveReloadNull() |
9697 | ····{ |
9698 | ········CreateObjects(); |
9699 | ········QueryOwn(); |
9700 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9701 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9702 | ········ownVar.RelField = null; |
9703 | ········pm.Save(); |
9704 | ········pm.UnloadCache(); |
9705 | ········QueryOwn(); |
9706 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9707 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9708 | ····} |
9709 | ····[Test] |
9710 | ····public void TestChangeKeyHolderLeft() |
9711 | ····{ |
9712 | ········CreateObjects(); |
9713 | ········QueryOwn(); |
9714 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9715 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9716 | ········int x = ownVar.RelField.Dummy; |
9717 | ········ownVar.Dummy = 4711; |
9718 | ········pm.Save(); |
9719 | ········pm.UnloadCache(); |
9720 | ········QueryOwn(); |
9721 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9722 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9723 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9724 | ····} |
9725 | ····[Test] |
9726 | ····public void TestChangeKeyHolderLeftNoTouch() |
9727 | ····{ |
9728 | ········CreateObjects(); |
9729 | ········QueryOwn(); |
9730 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9731 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9732 | ········ownVar.Dummy = 4711; |
9733 | ········pm.Save(); |
9734 | ········pm.UnloadCache(); |
9735 | ········QueryOwn(); |
9736 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9737 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9738 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9739 | ····} |
9740 | ····void CreateObjects() |
9741 | ····{ |
9742 | ········pm.MakePersistent(ownVar); |
9743 | ········pm.MakePersistent(otherVar); |
9744 | ········ownVar.AssignRelation(otherVar); |
9745 | ········pm.Save(); |
9746 | ········pm.UnloadCache(); |
9747 | ····} |
9748 | ····void QueryOwn() |
9749 | ····{ |
9750 | ········var q = new NDOQuery<AgrDir1NoTblGuidLeft>(pm); |
9751 | ········ownVar = q.ExecuteSingle(); |
9752 | ····} |
9753 | ····void QueryOther() |
9754 | ····{ |
9755 | ········var q = new NDOQuery<AgrDir1NoTblGuidRight>(pm); |
9756 | ········otherVar = q.ExecuteSingle(); |
9757 | ····} |
9758 | } |
9759 | |
9760 | |
9761 | [TestFixture] |
9762 | public class TestAgrDir1TblGuid : NDOTest |
9763 | { |
9764 | ····AgrDir1TblGuidLeft ownVar; |
9765 | ····AgrDir1TblGuidRight otherVar; |
9766 | ····PersistenceManager pm; |
9767 | ····[SetUp] |
9768 | ····public void Setup() |
9769 | ····{ |
9770 | ········pm = PmFactory.NewPersistenceManager(); |
9771 | ········ownVar = new AgrDir1TblGuidLeft(); |
9772 | ········otherVar = new AgrDir1TblGuidRight(); |
9773 | ····} |
9774 | ····[TearDown] |
9775 | ····public void TearDown() |
9776 | ····{ |
9777 | ········try |
9778 | ········{ |
9779 | ············pm.UnloadCache(); |
9780 | ············var l = pm.Objects<AgrDir1TblGuidLeft>().ResultTable; |
9781 | ············pm.Delete(l); |
9782 | ············pm.Save(); |
9783 | ············pm.UnloadCache(); |
9784 | ············var m = pm.Objects<AgrDir1TblGuidRight>().ResultTable; |
9785 | ············pm.Delete(m); |
9786 | ············pm.Save(); |
9787 | ············pm.UnloadCache(); |
9788 | ············decimal count; |
9789 | ············count = (decimal) new NDOQuery<AgrDir1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9790 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9791 | ············count = (decimal) new NDOQuery<AgrDir1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9792 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9793 | ········} |
9794 | ········catch (Exception) |
9795 | ········{ |
9796 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9797 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9798 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9799 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9800 | ········} |
9801 | ····} |
9802 | ····[Test] |
9803 | ····public void TestSaveReload() |
9804 | ····{ |
9805 | ········CreateObjects(); |
9806 | ········QueryOwn(); |
9807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9809 | ····} |
9810 | ····[Test] |
9811 | ····public void TestSaveReloadNull() |
9812 | ····{ |
9813 | ········CreateObjects(); |
9814 | ········QueryOwn(); |
9815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9817 | ········ownVar.RelField = null; |
9818 | ········pm.Save(); |
9819 | ········pm.UnloadCache(); |
9820 | ········QueryOwn(); |
9821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9822 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9823 | ····} |
9824 | ····[Test] |
9825 | ····public void TestChangeKeyHolderLeft() |
9826 | ····{ |
9827 | ········CreateObjects(); |
9828 | ········QueryOwn(); |
9829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9831 | ········int x = ownVar.RelField.Dummy; |
9832 | ········ownVar.Dummy = 4711; |
9833 | ········pm.Save(); |
9834 | ········pm.UnloadCache(); |
9835 | ········QueryOwn(); |
9836 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9837 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9838 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9839 | ····} |
9840 | ····[Test] |
9841 | ····public void TestChangeKeyHolderLeftNoTouch() |
9842 | ····{ |
9843 | ········CreateObjects(); |
9844 | ········QueryOwn(); |
9845 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9846 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9847 | ········ownVar.Dummy = 4711; |
9848 | ········pm.Save(); |
9849 | ········pm.UnloadCache(); |
9850 | ········QueryOwn(); |
9851 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9852 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9853 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9854 | ····} |
9855 | ····void CreateObjects() |
9856 | ····{ |
9857 | ········pm.MakePersistent(ownVar); |
9858 | ········pm.MakePersistent(otherVar); |
9859 | ········ownVar.AssignRelation(otherVar); |
9860 | ········pm.Save(); |
9861 | ········pm.UnloadCache(); |
9862 | ····} |
9863 | ····void QueryOwn() |
9864 | ····{ |
9865 | ········var q = new NDOQuery<AgrDir1TblGuidLeft>(pm); |
9866 | ········ownVar = q.ExecuteSingle(); |
9867 | ····} |
9868 | ····void QueryOther() |
9869 | ····{ |
9870 | ········var q = new NDOQuery<AgrDir1TblGuidRight>(pm); |
9871 | ········otherVar = q.ExecuteSingle(); |
9872 | ····} |
9873 | } |
9874 | |
9875 | |
9876 | [TestFixture] |
9877 | public class TestAgrBi11NoTblGuid : NDOTest |
9878 | { |
9879 | ····AgrBi11NoTblGuidLeft ownVar; |
9880 | ····AgrBi11NoTblGuidRight otherVar; |
9881 | ····PersistenceManager pm; |
9882 | ····[SetUp] |
9883 | ····public void Setup() |
9884 | ····{ |
9885 | ········pm = PmFactory.NewPersistenceManager(); |
9886 | ········ownVar = new AgrBi11NoTblGuidLeft(); |
9887 | ········otherVar = new AgrBi11NoTblGuidRight(); |
9888 | ····} |
9889 | ····[TearDown] |
9890 | ····public void TearDown() |
9891 | ····{ |
9892 | ········try |
9893 | ········{ |
9894 | ············pm.UnloadCache(); |
9895 | ············var l = pm.Objects<AgrBi11NoTblGuidLeft>().ResultTable; |
9896 | ············pm.Delete(l); |
9897 | ············pm.Save(); |
9898 | ············pm.UnloadCache(); |
9899 | ············var m = pm.Objects<AgrBi11NoTblGuidRight>().ResultTable; |
9900 | ············pm.Delete(m); |
9901 | ············pm.Save(); |
9902 | ············pm.UnloadCache(); |
9903 | ············decimal count; |
9904 | ············count = (decimal) new NDOQuery<AgrBi11NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9905 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9906 | ············count = (decimal) new NDOQuery<AgrBi11NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9907 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9908 | ········} |
9909 | ········catch (Exception) |
9910 | ········{ |
9911 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9912 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9913 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9914 | ········} |
9915 | ····} |
9916 | ····[Test] |
9917 | ····public void TestSaveReload() |
9918 | ····{ |
9919 | ········CreateObjects(); |
9920 | ········QueryOwn(); |
9921 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9922 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9923 | ····} |
9924 | ····[Test] |
9925 | ····public void TestSaveReloadNull() |
9926 | ····{ |
9927 | ········CreateObjects(); |
9928 | ········QueryOwn(); |
9929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9930 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9931 | ········ownVar.RelField = null; |
9932 | ········pm.Save(); |
9933 | ········pm.UnloadCache(); |
9934 | ········QueryOwn(); |
9935 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9936 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9937 | ····} |
9938 | ····[Test] |
9939 | ····public void TestChangeKeyHolderLeft() |
9940 | ····{ |
9941 | ········CreateObjects(); |
9942 | ········QueryOwn(); |
9943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9945 | ········int x = ownVar.RelField.Dummy; |
9946 | ········ownVar.Dummy = 4711; |
9947 | ········pm.Save(); |
9948 | ········pm.UnloadCache(); |
9949 | ········QueryOwn(); |
9950 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9951 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9952 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9953 | ····} |
9954 | ····[Test] |
9955 | ····public void TestChangeKeyHolderRight() |
9956 | ····{ |
9957 | ········CreateObjects(); |
9958 | ········QueryOther(); |
9959 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9960 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9961 | ········int x = otherVar.RelField.Dummy; |
9962 | ········otherVar.Dummy = 4711; |
9963 | ········pm.Save(); |
9964 | ········pm.UnloadCache(); |
9965 | ········QueryOther(); |
9966 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9967 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9968 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9969 | ····} |
9970 | ····[Test] |
9971 | ····public void TestChangeKeyHolderLeftNoTouch() |
9972 | ····{ |
9973 | ········CreateObjects(); |
9974 | ········QueryOwn(); |
9975 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9976 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9977 | ········ownVar.Dummy = 4711; |
9978 | ········pm.Save(); |
9979 | ········pm.UnloadCache(); |
9980 | ········QueryOwn(); |
9981 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9982 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9983 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9984 | ····} |
9985 | ····[Test] |
9986 | ····public void TestChangeKeyHolderRightNoTouch() |
9987 | ····{ |
9988 | ········CreateObjects(); |
9989 | ········QueryOther(); |
9990 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9991 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9992 | ········otherVar.Dummy = 4711; |
9993 | ········pm.Save(); |
9994 | ········pm.UnloadCache(); |
9995 | ········QueryOther(); |
9996 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9997 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9998 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9999 | ····} |
10000 | ····[Test] |
10001 | ····public void TestRelationHash() |
10002 | ····{ |
10003 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblGuidLeft)); |
10004 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10005 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblGuidRight)); |
10006 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10007 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10008 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10009 | ····} |
10010 | ····void CreateObjects() |
10011 | ····{ |
10012 | ········pm.MakePersistent(ownVar); |
10013 | ········pm.MakePersistent(otherVar); |
10014 | ········ownVar.AssignRelation(otherVar); |
10015 | ········pm.Save(); |
10016 | ········pm.UnloadCache(); |
10017 | ····} |
10018 | ····void QueryOwn() |
10019 | ····{ |
10020 | ········var q = new NDOQuery<AgrBi11NoTblGuidLeft>(pm); |
10021 | ········ownVar = q.ExecuteSingle(); |
10022 | ····} |
10023 | ····void QueryOther() |
10024 | ····{ |
10025 | ········var q = new NDOQuery<AgrBi11NoTblGuidRight>(pm); |
10026 | ········otherVar = q.ExecuteSingle(); |
10027 | ····} |
10028 | } |
10029 | |
10030 | |
10031 | [TestFixture] |
10032 | public class TestAgrBi11TblGuid : NDOTest |
10033 | { |
10034 | ····AgrBi11TblGuidLeft ownVar; |
10035 | ····AgrBi11TblGuidRight otherVar; |
10036 | ····PersistenceManager pm; |
10037 | ····[SetUp] |
10038 | ····public void Setup() |
10039 | ····{ |
10040 | ········pm = PmFactory.NewPersistenceManager(); |
10041 | ········ownVar = new AgrBi11TblGuidLeft(); |
10042 | ········otherVar = new AgrBi11TblGuidRight(); |
10043 | ····} |
10044 | ····[TearDown] |
10045 | ····public void TearDown() |
10046 | ····{ |
10047 | ········try |
10048 | ········{ |
10049 | ············pm.UnloadCache(); |
10050 | ············var l = pm.Objects<AgrBi11TblGuidLeft>().ResultTable; |
10051 | ············pm.Delete(l); |
10052 | ············pm.Save(); |
10053 | ············pm.UnloadCache(); |
10054 | ············var m = pm.Objects<AgrBi11TblGuidRight>().ResultTable; |
10055 | ············pm.Delete(m); |
10056 | ············pm.Save(); |
10057 | ············pm.UnloadCache(); |
10058 | ············decimal count; |
10059 | ············count = (decimal) new NDOQuery<AgrBi11TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10060 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10061 | ············count = (decimal) new NDOQuery<AgrBi11TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10063 | ········} |
10064 | ········catch (Exception) |
10065 | ········{ |
10066 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10067 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10068 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10069 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10070 | ········} |
10071 | ····} |
10072 | ····[Test] |
10073 | ····public void TestSaveReload() |
10074 | ····{ |
10075 | ········CreateObjects(); |
10076 | ········QueryOwn(); |
10077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10078 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10079 | ····} |
10080 | ····[Test] |
10081 | ····public void TestSaveReloadNull() |
10082 | ····{ |
10083 | ········CreateObjects(); |
10084 | ········QueryOwn(); |
10085 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10086 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10087 | ········ownVar.RelField = null; |
10088 | ········pm.Save(); |
10089 | ········pm.UnloadCache(); |
10090 | ········QueryOwn(); |
10091 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10092 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10093 | ····} |
10094 | ····[Test] |
10095 | ····public void TestChangeKeyHolderLeft() |
10096 | ····{ |
10097 | ········CreateObjects(); |
10098 | ········QueryOwn(); |
10099 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10100 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10101 | ········int x = ownVar.RelField.Dummy; |
10102 | ········ownVar.Dummy = 4711; |
10103 | ········pm.Save(); |
10104 | ········pm.UnloadCache(); |
10105 | ········QueryOwn(); |
10106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10107 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10108 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10109 | ····} |
10110 | ····[Test] |
10111 | ····public void TestChangeKeyHolderRight() |
10112 | ····{ |
10113 | ········CreateObjects(); |
10114 | ········QueryOther(); |
10115 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10116 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10117 | ········int x = otherVar.RelField.Dummy; |
10118 | ········otherVar.Dummy = 4711; |
10119 | ········pm.Save(); |
10120 | ········pm.UnloadCache(); |
10121 | ········QueryOther(); |
10122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10125 | ····} |
10126 | ····[Test] |
10127 | ····public void TestChangeKeyHolderLeftNoTouch() |
10128 | ····{ |
10129 | ········CreateObjects(); |
10130 | ········QueryOwn(); |
10131 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10132 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10133 | ········ownVar.Dummy = 4711; |
10134 | ········pm.Save(); |
10135 | ········pm.UnloadCache(); |
10136 | ········QueryOwn(); |
10137 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10138 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10139 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10140 | ····} |
10141 | ····[Test] |
10142 | ····public void TestChangeKeyHolderRightNoTouch() |
10143 | ····{ |
10144 | ········CreateObjects(); |
10145 | ········QueryOther(); |
10146 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10147 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10148 | ········otherVar.Dummy = 4711; |
10149 | ········pm.Save(); |
10150 | ········pm.UnloadCache(); |
10151 | ········QueryOther(); |
10152 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10153 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10154 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10155 | ····} |
10156 | ····[Test] |
10157 | ····public void TestRelationHash() |
10158 | ····{ |
10159 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11TblGuidLeft)); |
10160 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10161 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11TblGuidRight)); |
10162 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10163 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10164 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10165 | ····} |
10166 | ····void CreateObjects() |
10167 | ····{ |
10168 | ········pm.MakePersistent(ownVar); |
10169 | ········pm.MakePersistent(otherVar); |
10170 | ········ownVar.AssignRelation(otherVar); |
10171 | ········pm.Save(); |
10172 | ········pm.UnloadCache(); |
10173 | ····} |
10174 | ····void QueryOwn() |
10175 | ····{ |
10176 | ········var q = new NDOQuery<AgrBi11TblGuidLeft>(pm); |
10177 | ········ownVar = q.ExecuteSingle(); |
10178 | ····} |
10179 | ····void QueryOther() |
10180 | ····{ |
10181 | ········var q = new NDOQuery<AgrBi11TblGuidRight>(pm); |
10182 | ········otherVar = q.ExecuteSingle(); |
10183 | ····} |
10184 | } |
10185 | |
10186 | |
10187 | [TestFixture] |
10188 | public class TestAgrDirnNoTblGuid : NDOTest |
10189 | { |
10190 | ····AgrDirnNoTblGuidLeft ownVar; |
10191 | ····AgrDirnNoTblGuidRight otherVar; |
10192 | ····PersistenceManager pm; |
10193 | ····[SetUp] |
10194 | ····public void Setup() |
10195 | ····{ |
10196 | ········pm = PmFactory.NewPersistenceManager(); |
10197 | ········ownVar = new AgrDirnNoTblGuidLeft(); |
10198 | ········otherVar = new AgrDirnNoTblGuidRight(); |
10199 | ····} |
10200 | ····[TearDown] |
10201 | ····public void TearDown() |
10202 | ····{ |
10203 | ········try |
10204 | ········{ |
10205 | ············pm.UnloadCache(); |
10206 | ············var l = pm.Objects<AgrDirnNoTblGuidLeft>().ResultTable; |
10207 | ············pm.Delete(l); |
10208 | ············pm.Save(); |
10209 | ············pm.UnloadCache(); |
10210 | ············var m = pm.Objects<AgrDirnNoTblGuidRight>().ResultTable; |
10211 | ············pm.Delete(m); |
10212 | ············pm.Save(); |
10213 | ············pm.UnloadCache(); |
10214 | ············decimal count; |
10215 | ············count = (decimal) new NDOQuery<AgrDirnNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10216 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10217 | ············count = (decimal) new NDOQuery<AgrDirnNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10218 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10219 | ········} |
10220 | ········catch (Exception) |
10221 | ········{ |
10222 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10223 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10224 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10225 | ········} |
10226 | ····} |
10227 | ····[Test] |
10228 | ····public void TestSaveReload() |
10229 | ····{ |
10230 | ········CreateObjects(); |
10231 | ········QueryOwn(); |
10232 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10233 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10234 | ····} |
10235 | ····[Test] |
10236 | ····public void TestSaveReloadNull() |
10237 | ····{ |
10238 | ········CreateObjects(); |
10239 | ········QueryOwn(); |
10240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10241 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10242 | ········ownVar.RelField = new List<AgrDirnNoTblGuidRight>(); |
10243 | ········pm.Save(); |
10244 | ········pm.UnloadCache(); |
10245 | ········QueryOwn(); |
10246 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10247 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10248 | ····} |
10249 | ····[Test] |
10250 | ····public void TestSaveReloadRemove() |
10251 | ····{ |
10252 | ········CreateObjects(); |
10253 | ········QueryOwn(); |
10254 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10255 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10256 | ········ownVar.RemoveRelatedObject(); |
10257 | ········pm.Save(); |
10258 | ········pm.UnloadCache(); |
10259 | ········QueryOwn(); |
10260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10261 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10262 | ····} |
10263 | ····void CreateObjects() |
10264 | ····{ |
10265 | ········pm.MakePersistent(ownVar); |
10266 | ········pm.MakePersistent(otherVar); |
10267 | ········ownVar.AssignRelation(otherVar); |
10268 | ········pm.Save(); |
10269 | ········pm.UnloadCache(); |
10270 | ····} |
10271 | ····void QueryOwn() |
10272 | ····{ |
10273 | ········var q = new NDOQuery<AgrDirnNoTblGuidLeft>(pm); |
10274 | ········ownVar = q.ExecuteSingle(); |
10275 | ····} |
10276 | ····void QueryOther() |
10277 | ····{ |
10278 | ········var q = new NDOQuery<AgrDirnNoTblGuidRight>(pm); |
10279 | ········otherVar = q.ExecuteSingle(); |
10280 | ····} |
10281 | } |
10282 | |
10283 | |
10284 | [TestFixture] |
10285 | public class TestAgrDirnTblGuid : NDOTest |
10286 | { |
10287 | ····AgrDirnTblGuidLeft ownVar; |
10288 | ····AgrDirnTblGuidRight otherVar; |
10289 | ····PersistenceManager pm; |
10290 | ····[SetUp] |
10291 | ····public void Setup() |
10292 | ····{ |
10293 | ········pm = PmFactory.NewPersistenceManager(); |
10294 | ········ownVar = new AgrDirnTblGuidLeft(); |
10295 | ········otherVar = new AgrDirnTblGuidRight(); |
10296 | ····} |
10297 | ····[TearDown] |
10298 | ····public void TearDown() |
10299 | ····{ |
10300 | ········try |
10301 | ········{ |
10302 | ············pm.UnloadCache(); |
10303 | ············var l = pm.Objects<AgrDirnTblGuidLeft>().ResultTable; |
10304 | ············pm.Delete(l); |
10305 | ············pm.Save(); |
10306 | ············pm.UnloadCache(); |
10307 | ············var m = pm.Objects<AgrDirnTblGuidRight>().ResultTable; |
10308 | ············pm.Delete(m); |
10309 | ············pm.Save(); |
10310 | ············pm.UnloadCache(); |
10311 | ············decimal count; |
10312 | ············count = (decimal) new NDOQuery<AgrDirnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10313 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10314 | ············count = (decimal) new NDOQuery<AgrDirnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10315 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10316 | ········} |
10317 | ········catch (Exception) |
10318 | ········{ |
10319 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10320 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10321 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10322 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10323 | ········} |
10324 | ····} |
10325 | ····[Test] |
10326 | ····public void TestSaveReload() |
10327 | ····{ |
10328 | ········CreateObjects(); |
10329 | ········QueryOwn(); |
10330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10331 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10332 | ····} |
10333 | ····[Test] |
10334 | ····public void TestSaveReloadNull() |
10335 | ····{ |
10336 | ········CreateObjects(); |
10337 | ········QueryOwn(); |
10338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10339 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10340 | ········ownVar.RelField = new List<AgrDirnTblGuidRight>(); |
10341 | ········pm.Save(); |
10342 | ········pm.UnloadCache(); |
10343 | ········QueryOwn(); |
10344 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10345 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10346 | ····} |
10347 | ····[Test] |
10348 | ····public void TestSaveReloadRemove() |
10349 | ····{ |
10350 | ········CreateObjects(); |
10351 | ········QueryOwn(); |
10352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10353 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10354 | ········ownVar.RemoveRelatedObject(); |
10355 | ········pm.Save(); |
10356 | ········pm.UnloadCache(); |
10357 | ········QueryOwn(); |
10358 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10359 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10360 | ····} |
10361 | ····void CreateObjects() |
10362 | ····{ |
10363 | ········pm.MakePersistent(ownVar); |
10364 | ········pm.MakePersistent(otherVar); |
10365 | ········ownVar.AssignRelation(otherVar); |
10366 | ········pm.Save(); |
10367 | ········pm.UnloadCache(); |
10368 | ····} |
10369 | ····void QueryOwn() |
10370 | ····{ |
10371 | ········var q = new NDOQuery<AgrDirnTblGuidLeft>(pm); |
10372 | ········ownVar = q.ExecuteSingle(); |
10373 | ····} |
10374 | ····void QueryOther() |
10375 | ····{ |
10376 | ········var q = new NDOQuery<AgrDirnTblGuidRight>(pm); |
10377 | ········otherVar = q.ExecuteSingle(); |
10378 | ····} |
10379 | } |
10380 | |
10381 | |
10382 | [TestFixture] |
10383 | public class TestAgrBin1NoTblGuid : NDOTest |
10384 | { |
10385 | ····AgrBin1NoTblGuidLeft ownVar; |
10386 | ····AgrBin1NoTblGuidRight otherVar; |
10387 | ····PersistenceManager pm; |
10388 | ····[SetUp] |
10389 | ····public void Setup() |
10390 | ····{ |
10391 | ········pm = PmFactory.NewPersistenceManager(); |
10392 | ········ownVar = new AgrBin1NoTblGuidLeft(); |
10393 | ········otherVar = new AgrBin1NoTblGuidRight(); |
10394 | ····} |
10395 | ····[TearDown] |
10396 | ····public void TearDown() |
10397 | ····{ |
10398 | ········try |
10399 | ········{ |
10400 | ············pm.UnloadCache(); |
10401 | ············var l = pm.Objects<AgrBin1NoTblGuidLeft>().ResultTable; |
10402 | ············pm.Delete(l); |
10403 | ············pm.Save(); |
10404 | ············pm.UnloadCache(); |
10405 | ············var m = pm.Objects<AgrBin1NoTblGuidRight>().ResultTable; |
10406 | ············pm.Delete(m); |
10407 | ············pm.Save(); |
10408 | ············pm.UnloadCache(); |
10409 | ············decimal count; |
10410 | ············count = (decimal) new NDOQuery<AgrBin1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10411 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10412 | ············count = (decimal) new NDOQuery<AgrBin1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10413 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10414 | ········} |
10415 | ········catch (Exception) |
10416 | ········{ |
10417 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10418 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10419 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10420 | ········} |
10421 | ····} |
10422 | ····[Test] |
10423 | ····public void TestSaveReload() |
10424 | ····{ |
10425 | ········CreateObjects(); |
10426 | ········QueryOwn(); |
10427 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10428 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10429 | ····} |
10430 | ····[Test] |
10431 | ····public void TestSaveReloadNull() |
10432 | ····{ |
10433 | ········CreateObjects(); |
10434 | ········QueryOwn(); |
10435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10436 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10437 | ········ownVar.RelField = new List<AgrBin1NoTblGuidRight>(); |
10438 | ········pm.Save(); |
10439 | ········pm.UnloadCache(); |
10440 | ········QueryOwn(); |
10441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10442 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10443 | ····} |
10444 | ····[Test] |
10445 | ····public void TestSaveReloadRemove() |
10446 | ····{ |
10447 | ········CreateObjects(); |
10448 | ········QueryOwn(); |
10449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10450 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10451 | ········ownVar.RemoveRelatedObject(); |
10452 | ········pm.Save(); |
10453 | ········pm.UnloadCache(); |
10454 | ········QueryOwn(); |
10455 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10456 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10457 | ····} |
10458 | ····[Test] |
10459 | ····public void TestChangeKeyHolderRight() |
10460 | ····{ |
10461 | ········CreateObjects(); |
10462 | ········QueryOther(); |
10463 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10464 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10465 | ········int x = otherVar.RelField.Dummy; |
10466 | ········otherVar.Dummy = 4711; |
10467 | ········pm.Save(); |
10468 | ········pm.UnloadCache(); |
10469 | ········QueryOther(); |
10470 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10471 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10472 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10473 | ····} |
10474 | ····[Test] |
10475 | ····public void TestChangeKeyHolderRightNoTouch() |
10476 | ····{ |
10477 | ········CreateObjects(); |
10478 | ········QueryOther(); |
10479 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10480 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10481 | ········otherVar.Dummy = 4711; |
10482 | ········pm.Save(); |
10483 | ········pm.UnloadCache(); |
10484 | ········QueryOther(); |
10485 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10486 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10487 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10488 | ····} |
10489 | ····[Test] |
10490 | ····public void TestRelationHash() |
10491 | ····{ |
10492 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblGuidLeft)); |
10493 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10494 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblGuidRight)); |
10495 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10496 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10497 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10498 | ····} |
10499 | ····void CreateObjects() |
10500 | ····{ |
10501 | ········pm.MakePersistent(ownVar); |
10502 | ········pm.MakePersistent(otherVar); |
10503 | ········ownVar.AssignRelation(otherVar); |
10504 | ········pm.Save(); |
10505 | ········pm.UnloadCache(); |
10506 | ····} |
10507 | ····void QueryOwn() |
10508 | ····{ |
10509 | ········var q = new NDOQuery<AgrBin1NoTblGuidLeft>(pm); |
10510 | ········ownVar = q.ExecuteSingle(); |
10511 | ····} |
10512 | ····void QueryOther() |
10513 | ····{ |
10514 | ········var q = new NDOQuery<AgrBin1NoTblGuidRight>(pm); |
10515 | ········otherVar = q.ExecuteSingle(); |
10516 | ····} |
10517 | } |
10518 | |
10519 | |
10520 | [TestFixture] |
10521 | public class TestAgrBin1TblGuid : NDOTest |
10522 | { |
10523 | ····AgrBin1TblGuidLeft ownVar; |
10524 | ····AgrBin1TblGuidRight otherVar; |
10525 | ····PersistenceManager pm; |
10526 | ····[SetUp] |
10527 | ····public void Setup() |
10528 | ····{ |
10529 | ········pm = PmFactory.NewPersistenceManager(); |
10530 | ········ownVar = new AgrBin1TblGuidLeft(); |
10531 | ········otherVar = new AgrBin1TblGuidRight(); |
10532 | ····} |
10533 | ····[TearDown] |
10534 | ····public void TearDown() |
10535 | ····{ |
10536 | ········try |
10537 | ········{ |
10538 | ············pm.UnloadCache(); |
10539 | ············var l = pm.Objects<AgrBin1TblGuidLeft>().ResultTable; |
10540 | ············pm.Delete(l); |
10541 | ············pm.Save(); |
10542 | ············pm.UnloadCache(); |
10543 | ············var m = pm.Objects<AgrBin1TblGuidRight>().ResultTable; |
10544 | ············pm.Delete(m); |
10545 | ············pm.Save(); |
10546 | ············pm.UnloadCache(); |
10547 | ············decimal count; |
10548 | ············count = (decimal) new NDOQuery<AgrBin1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10550 | ············count = (decimal) new NDOQuery<AgrBin1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10552 | ········} |
10553 | ········catch (Exception) |
10554 | ········{ |
10555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10559 | ········} |
10560 | ····} |
10561 | ····[Test] |
10562 | ····public void TestSaveReload() |
10563 | ····{ |
10564 | ········CreateObjects(); |
10565 | ········QueryOwn(); |
10566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10568 | ····} |
10569 | ····[Test] |
10570 | ····public void TestSaveReloadNull() |
10571 | ····{ |
10572 | ········CreateObjects(); |
10573 | ········QueryOwn(); |
10574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10576 | ········ownVar.RelField = new List<AgrBin1TblGuidRight>(); |
10577 | ········pm.Save(); |
10578 | ········pm.UnloadCache(); |
10579 | ········QueryOwn(); |
10580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10582 | ····} |
10583 | ····[Test] |
10584 | ····public void TestSaveReloadRemove() |
10585 | ····{ |
10586 | ········CreateObjects(); |
10587 | ········QueryOwn(); |
10588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10590 | ········ownVar.RemoveRelatedObject(); |
10591 | ········pm.Save(); |
10592 | ········pm.UnloadCache(); |
10593 | ········QueryOwn(); |
10594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10596 | ····} |
10597 | ····[Test] |
10598 | ····public void TestChangeKeyHolderRight() |
10599 | ····{ |
10600 | ········CreateObjects(); |
10601 | ········QueryOther(); |
10602 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10603 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10604 | ········int x = otherVar.RelField.Dummy; |
10605 | ········otherVar.Dummy = 4711; |
10606 | ········pm.Save(); |
10607 | ········pm.UnloadCache(); |
10608 | ········QueryOther(); |
10609 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10610 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10611 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10612 | ····} |
10613 | ····[Test] |
10614 | ····public void TestChangeKeyHolderRightNoTouch() |
10615 | ····{ |
10616 | ········CreateObjects(); |
10617 | ········QueryOther(); |
10618 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10619 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10620 | ········otherVar.Dummy = 4711; |
10621 | ········pm.Save(); |
10622 | ········pm.UnloadCache(); |
10623 | ········QueryOther(); |
10624 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10625 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10626 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10627 | ····} |
10628 | ····[Test] |
10629 | ····public void TestRelationHash() |
10630 | ····{ |
10631 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1TblGuidLeft)); |
10632 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10633 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1TblGuidRight)); |
10634 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10635 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10636 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10637 | ····} |
10638 | ····void CreateObjects() |
10639 | ····{ |
10640 | ········pm.MakePersistent(ownVar); |
10641 | ········pm.MakePersistent(otherVar); |
10642 | ········ownVar.AssignRelation(otherVar); |
10643 | ········pm.Save(); |
10644 | ········pm.UnloadCache(); |
10645 | ····} |
10646 | ····void QueryOwn() |
10647 | ····{ |
10648 | ········var q = new NDOQuery<AgrBin1TblGuidLeft>(pm); |
10649 | ········ownVar = q.ExecuteSingle(); |
10650 | ····} |
10651 | ····void QueryOther() |
10652 | ····{ |
10653 | ········var q = new NDOQuery<AgrBin1TblGuidRight>(pm); |
10654 | ········otherVar = q.ExecuteSingle(); |
10655 | ····} |
10656 | } |
10657 | |
10658 | |
10659 | [TestFixture] |
10660 | public class TestAgrBi1nNoTblGuid : NDOTest |
10661 | { |
10662 | ····AgrBi1nNoTblGuidLeft ownVar; |
10663 | ····AgrBi1nNoTblGuidRight otherVar; |
10664 | ····PersistenceManager pm; |
10665 | ····[SetUp] |
10666 | ····public void Setup() |
10667 | ····{ |
10668 | ········pm = PmFactory.NewPersistenceManager(); |
10669 | ········ownVar = new AgrBi1nNoTblGuidLeft(); |
10670 | ········otherVar = new AgrBi1nNoTblGuidRight(); |
10671 | ····} |
10672 | ····[TearDown] |
10673 | ····public void TearDown() |
10674 | ····{ |
10675 | ········try |
10676 | ········{ |
10677 | ············pm.UnloadCache(); |
10678 | ············var l = pm.Objects<AgrBi1nNoTblGuidLeft>().ResultTable; |
10679 | ············pm.Delete(l); |
10680 | ············pm.Save(); |
10681 | ············pm.UnloadCache(); |
10682 | ············var m = pm.Objects<AgrBi1nNoTblGuidRight>().ResultTable; |
10683 | ············pm.Delete(m); |
10684 | ············pm.Save(); |
10685 | ············pm.UnloadCache(); |
10686 | ············decimal count; |
10687 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10688 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10689 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10690 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10691 | ········} |
10692 | ········catch (Exception) |
10693 | ········{ |
10694 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10695 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10696 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10697 | ········} |
10698 | ····} |
10699 | ····[Test] |
10700 | ····public void TestSaveReload() |
10701 | ····{ |
10702 | ········CreateObjects(); |
10703 | ········QueryOwn(); |
10704 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10705 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10706 | ····} |
10707 | ····[Test] |
10708 | ····public void TestSaveReloadNull() |
10709 | ····{ |
10710 | ········CreateObjects(); |
10711 | ········QueryOwn(); |
10712 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10713 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10714 | ········ownVar.RelField = null; |
10715 | ········pm.Save(); |
10716 | ········pm.UnloadCache(); |
10717 | ········QueryOwn(); |
10718 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10719 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10720 | ····} |
10721 | ····[Test] |
10722 | ····public void TestChangeKeyHolderLeft() |
10723 | ····{ |
10724 | ········CreateObjects(); |
10725 | ········QueryOwn(); |
10726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10727 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10728 | ········int x = ownVar.RelField.Dummy; |
10729 | ········ownVar.Dummy = 4711; |
10730 | ········pm.Save(); |
10731 | ········pm.UnloadCache(); |
10732 | ········QueryOwn(); |
10733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10734 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10735 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10736 | ····} |
10737 | ····[Test] |
10738 | ····public void TestChangeKeyHolderLeftNoTouch() |
10739 | ····{ |
10740 | ········CreateObjects(); |
10741 | ········QueryOwn(); |
10742 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10744 | ········ownVar.Dummy = 4711; |
10745 | ········pm.Save(); |
10746 | ········pm.UnloadCache(); |
10747 | ········QueryOwn(); |
10748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10749 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10750 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10751 | ····} |
10752 | ····[Test] |
10753 | ····public void TestRelationHash() |
10754 | ····{ |
10755 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblGuidLeft)); |
10756 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10757 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblGuidRight)); |
10758 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10759 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10760 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10761 | ····} |
10762 | ····void CreateObjects() |
10763 | ····{ |
10764 | ········pm.MakePersistent(ownVar); |
10765 | ········pm.MakePersistent(otherVar); |
10766 | ········ownVar.AssignRelation(otherVar); |
10767 | ········pm.Save(); |
10768 | ········pm.UnloadCache(); |
10769 | ····} |
10770 | ····void QueryOwn() |
10771 | ····{ |
10772 | ········var q = new NDOQuery<AgrBi1nNoTblGuidLeft>(pm); |
10773 | ········ownVar = q.ExecuteSingle(); |
10774 | ····} |
10775 | ····void QueryOther() |
10776 | ····{ |
10777 | ········var q = new NDOQuery<AgrBi1nNoTblGuidRight>(pm); |
10778 | ········otherVar = q.ExecuteSingle(); |
10779 | ····} |
10780 | } |
10781 | |
10782 | |
10783 | [TestFixture] |
10784 | public class TestAgrBi1nTblGuid : NDOTest |
10785 | { |
10786 | ····AgrBi1nTblGuidLeft ownVar; |
10787 | ····AgrBi1nTblGuidRight otherVar; |
10788 | ····PersistenceManager pm; |
10789 | ····[SetUp] |
10790 | ····public void Setup() |
10791 | ····{ |
10792 | ········pm = PmFactory.NewPersistenceManager(); |
10793 | ········ownVar = new AgrBi1nTblGuidLeft(); |
10794 | ········otherVar = new AgrBi1nTblGuidRight(); |
10795 | ····} |
10796 | ····[TearDown] |
10797 | ····public void TearDown() |
10798 | ····{ |
10799 | ········try |
10800 | ········{ |
10801 | ············pm.UnloadCache(); |
10802 | ············var l = pm.Objects<AgrBi1nTblGuidLeft>().ResultTable; |
10803 | ············pm.Delete(l); |
10804 | ············pm.Save(); |
10805 | ············pm.UnloadCache(); |
10806 | ············var m = pm.Objects<AgrBi1nTblGuidRight>().ResultTable; |
10807 | ············pm.Delete(m); |
10808 | ············pm.Save(); |
10809 | ············pm.UnloadCache(); |
10810 | ············decimal count; |
10811 | ············count = (decimal) new NDOQuery<AgrBi1nTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10812 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10813 | ············count = (decimal) new NDOQuery<AgrBi1nTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10814 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10815 | ········} |
10816 | ········catch (Exception) |
10817 | ········{ |
10818 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10819 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10820 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10821 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10822 | ········} |
10823 | ····} |
10824 | ····[Test] |
10825 | ····public void TestSaveReload() |
10826 | ····{ |
10827 | ········CreateObjects(); |
10828 | ········QueryOwn(); |
10829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10831 | ····} |
10832 | ····[Test] |
10833 | ····public void TestSaveReloadNull() |
10834 | ····{ |
10835 | ········CreateObjects(); |
10836 | ········QueryOwn(); |
10837 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10838 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10839 | ········ownVar.RelField = null; |
10840 | ········pm.Save(); |
10841 | ········pm.UnloadCache(); |
10842 | ········QueryOwn(); |
10843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10844 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10845 | ····} |
10846 | ····[Test] |
10847 | ····public void TestChangeKeyHolderLeft() |
10848 | ····{ |
10849 | ········CreateObjects(); |
10850 | ········QueryOwn(); |
10851 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10853 | ········int x = ownVar.RelField.Dummy; |
10854 | ········ownVar.Dummy = 4711; |
10855 | ········pm.Save(); |
10856 | ········pm.UnloadCache(); |
10857 | ········QueryOwn(); |
10858 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10859 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10861 | ····} |
10862 | ····[Test] |
10863 | ····public void TestChangeKeyHolderLeftNoTouch() |
10864 | ····{ |
10865 | ········CreateObjects(); |
10866 | ········QueryOwn(); |
10867 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10868 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10869 | ········ownVar.Dummy = 4711; |
10870 | ········pm.Save(); |
10871 | ········pm.UnloadCache(); |
10872 | ········QueryOwn(); |
10873 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10874 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10875 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10876 | ····} |
10877 | ····[Test] |
10878 | ····public void TestRelationHash() |
10879 | ····{ |
10880 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nTblGuidLeft)); |
10881 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10882 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nTblGuidRight)); |
10883 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10884 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10885 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10886 | ····} |
10887 | ····void CreateObjects() |
10888 | ····{ |
10889 | ········pm.MakePersistent(ownVar); |
10890 | ········pm.MakePersistent(otherVar); |
10891 | ········ownVar.AssignRelation(otherVar); |
10892 | ········pm.Save(); |
10893 | ········pm.UnloadCache(); |
10894 | ····} |
10895 | ····void QueryOwn() |
10896 | ····{ |
10897 | ········var q = new NDOQuery<AgrBi1nTblGuidLeft>(pm); |
10898 | ········ownVar = q.ExecuteSingle(); |
10899 | ····} |
10900 | ····void QueryOther() |
10901 | ····{ |
10902 | ········var q = new NDOQuery<AgrBi1nTblGuidRight>(pm); |
10903 | ········otherVar = q.ExecuteSingle(); |
10904 | ····} |
10905 | } |
10906 | |
10907 | |
10908 | [TestFixture] |
10909 | public class TestAgrBinnTblGuid : NDOTest |
10910 | { |
10911 | ····AgrBinnTblGuidLeft ownVar; |
10912 | ····AgrBinnTblGuidRight otherVar; |
10913 | ····PersistenceManager pm; |
10914 | ····[SetUp] |
10915 | ····public void Setup() |
10916 | ····{ |
10917 | ········pm = PmFactory.NewPersistenceManager(); |
10918 | ········ownVar = new AgrBinnTblGuidLeft(); |
10919 | ········otherVar = new AgrBinnTblGuidRight(); |
10920 | ····} |
10921 | ····[TearDown] |
10922 | ····public void TearDown() |
10923 | ····{ |
10924 | ········try |
10925 | ········{ |
10926 | ············pm.UnloadCache(); |
10927 | ············var l = pm.Objects<AgrBinnTblGuidLeft>().ResultTable; |
10928 | ············pm.Delete(l); |
10929 | ············pm.Save(); |
10930 | ············pm.UnloadCache(); |
10931 | ············var m = pm.Objects<AgrBinnTblGuidRight>().ResultTable; |
10932 | ············pm.Delete(m); |
10933 | ············pm.Save(); |
10934 | ············pm.UnloadCache(); |
10935 | ············decimal count; |
10936 | ············count = (decimal) new NDOQuery<AgrBinnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10937 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10938 | ············count = (decimal) new NDOQuery<AgrBinnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10939 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10940 | ········} |
10941 | ········catch (Exception) |
10942 | ········{ |
10943 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10944 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10945 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10946 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10947 | ········} |
10948 | ····} |
10949 | ····[Test] |
10950 | ····public void TestSaveReload() |
10951 | ····{ |
10952 | ········CreateObjects(); |
10953 | ········QueryOwn(); |
10954 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10955 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10956 | ····} |
10957 | ····[Test] |
10958 | ····public void TestSaveReloadNull() |
10959 | ····{ |
10960 | ········CreateObjects(); |
10961 | ········QueryOwn(); |
10962 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10963 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10964 | ········ownVar.RelField = new List<AgrBinnTblGuidRight>(); |
10965 | ········pm.Save(); |
10966 | ········pm.UnloadCache(); |
10967 | ········QueryOwn(); |
10968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10969 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10970 | ····} |
10971 | ····[Test] |
10972 | ····public void TestSaveReloadRemove() |
10973 | ····{ |
10974 | ········CreateObjects(); |
10975 | ········QueryOwn(); |
10976 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10977 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10978 | ········ownVar.RemoveRelatedObject(); |
10979 | ········pm.Save(); |
10980 | ········pm.UnloadCache(); |
10981 | ········QueryOwn(); |
10982 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10983 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10984 | ····} |
10985 | ····[Test] |
10986 | ····public void TestRelationHash() |
10987 | ····{ |
10988 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnTblGuidLeft)); |
10989 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10990 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnTblGuidRight)); |
10991 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10992 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10993 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10994 | ····} |
10995 | ····void CreateObjects() |
10996 | ····{ |
10997 | ········pm.MakePersistent(ownVar); |
10998 | ········pm.MakePersistent(otherVar); |
10999 | ········ownVar.AssignRelation(otherVar); |
11000 | ········pm.Save(); |
11001 | ········pm.UnloadCache(); |
11002 | ····} |
11003 | ····void QueryOwn() |
11004 | ····{ |
11005 | ········var q = new NDOQuery<AgrBinnTblGuidLeft>(pm); |
11006 | ········ownVar = q.ExecuteSingle(); |
11007 | ····} |
11008 | ····void QueryOther() |
11009 | ····{ |
11010 | ········var q = new NDOQuery<AgrBinnTblGuidRight>(pm); |
11011 | ········otherVar = q.ExecuteSingle(); |
11012 | ····} |
11013 | } |
11014 | |
11015 | |
11016 | [TestFixture] |
11017 | public class TestCmpDir1NoTblGuid : NDOTest |
11018 | { |
11019 | ····CmpDir1NoTblGuidLeft ownVar; |
11020 | ····CmpDir1NoTblGuidRight otherVar; |
11021 | ····PersistenceManager pm; |
11022 | ····[SetUp] |
11023 | ····public void Setup() |
11024 | ····{ |
11025 | ········pm = PmFactory.NewPersistenceManager(); |
11026 | ········ownVar = new CmpDir1NoTblGuidLeft(); |
11027 | ········otherVar = new CmpDir1NoTblGuidRight(); |
11028 | ····} |
11029 | ····[TearDown] |
11030 | ····public void TearDown() |
11031 | ····{ |
11032 | ········try |
11033 | ········{ |
11034 | ············pm.UnloadCache(); |
11035 | ············var l = pm.Objects<CmpDir1NoTblGuidLeft>().ResultTable; |
11036 | ············pm.Delete(l); |
11037 | ············pm.Save(); |
11038 | ············pm.UnloadCache(); |
11039 | ············decimal count; |
11040 | ············count = (decimal) new NDOQuery<CmpDir1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11041 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11042 | ············count = (decimal) new NDOQuery<CmpDir1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11044 | ········} |
11045 | ········catch (Exception) |
11046 | ········{ |
11047 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11048 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11049 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11050 | ········} |
11051 | ····} |
11052 | ····[Test] |
11053 | ····public void TestSaveReload() |
11054 | ····{ |
11055 | ········CreateObjects(); |
11056 | ········QueryOwn(); |
11057 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11058 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11059 | ····} |
11060 | ····[Test] |
11061 | ····public void TestSaveReloadNull() |
11062 | ····{ |
11063 | ········CreateObjects(); |
11064 | ········QueryOwn(); |
11065 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11066 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11067 | ········ownVar.RelField = null; |
11068 | ········pm.Save(); |
11069 | ········pm.UnloadCache(); |
11070 | ········QueryOwn(); |
11071 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11072 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11073 | ····} |
11074 | ····[Test] |
11075 | ····public void TestChangeKeyHolderLeft() |
11076 | ····{ |
11077 | ········CreateObjects(); |
11078 | ········QueryOwn(); |
11079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11080 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11081 | ········int x = ownVar.RelField.Dummy; |
11082 | ········ownVar.Dummy = 4711; |
11083 | ········pm.Save(); |
11084 | ········pm.UnloadCache(); |
11085 | ········QueryOwn(); |
11086 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11087 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11088 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11089 | ····} |
11090 | ····[Test] |
11091 | ····public void TestChangeKeyHolderLeftNoTouch() |
11092 | ····{ |
11093 | ········CreateObjects(); |
11094 | ········QueryOwn(); |
11095 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11096 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11097 | ········ownVar.Dummy = 4711; |
11098 | ········pm.Save(); |
11099 | ········pm.UnloadCache(); |
11100 | ········QueryOwn(); |
11101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11102 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11104 | ····} |
11105 | ····void CreateObjects() |
11106 | ····{ |
11107 | ········pm.MakePersistent(ownVar); |
11108 | ········ownVar.AssignRelation(otherVar); |
11109 | ········pm.Save(); |
11110 | ········pm.UnloadCache(); |
11111 | ····} |
11112 | ····void QueryOwn() |
11113 | ····{ |
11114 | ········var q = new NDOQuery<CmpDir1NoTblGuidLeft>(pm); |
11115 | ········ownVar = q.ExecuteSingle(); |
11116 | ····} |
11117 | ····void QueryOther() |
11118 | ····{ |
11119 | ········var q = new NDOQuery<CmpDir1NoTblGuidRight>(pm); |
11120 | ········otherVar = q.ExecuteSingle(); |
11121 | ····} |
11122 | } |
11123 | |
11124 | |
11125 | [TestFixture] |
11126 | public class TestCmpDir1TblGuid : NDOTest |
11127 | { |
11128 | ····CmpDir1TblGuidLeft ownVar; |
11129 | ····CmpDir1TblGuidRight otherVar; |
11130 | ····PersistenceManager pm; |
11131 | ····[SetUp] |
11132 | ····public void Setup() |
11133 | ····{ |
11134 | ········pm = PmFactory.NewPersistenceManager(); |
11135 | ········ownVar = new CmpDir1TblGuidLeft(); |
11136 | ········otherVar = new CmpDir1TblGuidRight(); |
11137 | ····} |
11138 | ····[TearDown] |
11139 | ····public void TearDown() |
11140 | ····{ |
11141 | ········try |
11142 | ········{ |
11143 | ············pm.UnloadCache(); |
11144 | ············var l = pm.Objects<CmpDir1TblGuidLeft>().ResultTable; |
11145 | ············pm.Delete(l); |
11146 | ············pm.Save(); |
11147 | ············pm.UnloadCache(); |
11148 | ············decimal count; |
11149 | ············count = (decimal) new NDOQuery<CmpDir1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11150 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11151 | ············count = (decimal) new NDOQuery<CmpDir1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11152 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11153 | ········} |
11154 | ········catch (Exception) |
11155 | ········{ |
11156 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11158 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11159 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11160 | ········} |
11161 | ····} |
11162 | ····[Test] |
11163 | ····public void TestSaveReload() |
11164 | ····{ |
11165 | ········CreateObjects(); |
11166 | ········QueryOwn(); |
11167 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11168 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11169 | ····} |
11170 | ····[Test] |
11171 | ····public void TestSaveReloadNull() |
11172 | ····{ |
11173 | ········CreateObjects(); |
11174 | ········QueryOwn(); |
11175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11176 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11177 | ········ownVar.RelField = null; |
11178 | ········pm.Save(); |
11179 | ········pm.UnloadCache(); |
11180 | ········QueryOwn(); |
11181 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11182 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11183 | ····} |
11184 | ····[Test] |
11185 | ····public void TestChangeKeyHolderLeft() |
11186 | ····{ |
11187 | ········CreateObjects(); |
11188 | ········QueryOwn(); |
11189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11190 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11191 | ········int x = ownVar.RelField.Dummy; |
11192 | ········ownVar.Dummy = 4711; |
11193 | ········pm.Save(); |
11194 | ········pm.UnloadCache(); |
11195 | ········QueryOwn(); |
11196 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11197 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11198 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11199 | ····} |
11200 | ····[Test] |
11201 | ····public void TestChangeKeyHolderLeftNoTouch() |
11202 | ····{ |
11203 | ········CreateObjects(); |
11204 | ········QueryOwn(); |
11205 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11207 | ········ownVar.Dummy = 4711; |
11208 | ········pm.Save(); |
11209 | ········pm.UnloadCache(); |
11210 | ········QueryOwn(); |
11211 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11212 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11213 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11214 | ····} |
11215 | ····void CreateObjects() |
11216 | ····{ |
11217 | ········pm.MakePersistent(ownVar); |
11218 | ········ownVar.AssignRelation(otherVar); |
11219 | ········pm.Save(); |
11220 | ········pm.UnloadCache(); |
11221 | ····} |
11222 | ····void QueryOwn() |
11223 | ····{ |
11224 | ········var q = new NDOQuery<CmpDir1TblGuidLeft>(pm); |
11225 | ········ownVar = q.ExecuteSingle(); |
11226 | ····} |
11227 | ····void QueryOther() |
11228 | ····{ |
11229 | ········var q = new NDOQuery<CmpDir1TblGuidRight>(pm); |
11230 | ········otherVar = q.ExecuteSingle(); |
11231 | ····} |
11232 | } |
11233 | |
11234 | |
11235 | [TestFixture] |
11236 | public class TestCmpBi11NoTblGuid : NDOTest |
11237 | { |
11238 | ····CmpBi11NoTblGuidLeft ownVar; |
11239 | ····CmpBi11NoTblGuidRight otherVar; |
11240 | ····PersistenceManager pm; |
11241 | ····[SetUp] |
11242 | ····public void Setup() |
11243 | ····{ |
11244 | ········pm = PmFactory.NewPersistenceManager(); |
11245 | ········ownVar = new CmpBi11NoTblGuidLeft(); |
11246 | ········otherVar = new CmpBi11NoTblGuidRight(); |
11247 | ····} |
11248 | ····[TearDown] |
11249 | ····public void TearDown() |
11250 | ····{ |
11251 | ········try |
11252 | ········{ |
11253 | ············pm.UnloadCache(); |
11254 | ············var l = pm.Objects<CmpBi11NoTblGuidLeft>().ResultTable; |
11255 | ············pm.Delete(l); |
11256 | ············pm.Save(); |
11257 | ············pm.UnloadCache(); |
11258 | ············decimal count; |
11259 | ············count = (decimal) new NDOQuery<CmpBi11NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11260 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11261 | ············count = (decimal) new NDOQuery<CmpBi11NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11262 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11263 | ········} |
11264 | ········catch (Exception) |
11265 | ········{ |
11266 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11267 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11268 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11269 | ········} |
11270 | ····} |
11271 | ····[Test] |
11272 | ····public void TestSaveReload() |
11273 | ····{ |
11274 | ········CreateObjects(); |
11275 | ········QueryOwn(); |
11276 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11277 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11278 | ····} |
11279 | ····[Test] |
11280 | ····public void TestSaveReloadNull() |
11281 | ····{ |
11282 | ········CreateObjects(); |
11283 | ········QueryOwn(); |
11284 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11285 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11286 | ········ownVar.RelField = null; |
11287 | ········pm.Save(); |
11288 | ········pm.UnloadCache(); |
11289 | ········QueryOwn(); |
11290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11291 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11292 | ····} |
11293 | ····[Test] |
11294 | ····public void TestChangeKeyHolderLeft() |
11295 | ····{ |
11296 | ········CreateObjects(); |
11297 | ········QueryOwn(); |
11298 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11299 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11300 | ········int x = ownVar.RelField.Dummy; |
11301 | ········ownVar.Dummy = 4711; |
11302 | ········pm.Save(); |
11303 | ········pm.UnloadCache(); |
11304 | ········QueryOwn(); |
11305 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11306 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11307 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11308 | ····} |
11309 | ····[Test] |
11310 | ····public void TestChangeKeyHolderRight() |
11311 | ····{ |
11312 | ········CreateObjects(); |
11313 | ········QueryOther(); |
11314 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11315 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11316 | ········int x = otherVar.RelField.Dummy; |
11317 | ········otherVar.Dummy = 4711; |
11318 | ········pm.Save(); |
11319 | ········pm.UnloadCache(); |
11320 | ········QueryOther(); |
11321 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11322 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11323 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11324 | ····} |
11325 | ····[Test] |
11326 | ····public void TestChangeKeyHolderLeftNoTouch() |
11327 | ····{ |
11328 | ········CreateObjects(); |
11329 | ········QueryOwn(); |
11330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11332 | ········ownVar.Dummy = 4711; |
11333 | ········pm.Save(); |
11334 | ········pm.UnloadCache(); |
11335 | ········QueryOwn(); |
11336 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11337 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11338 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11339 | ····} |
11340 | ····[Test] |
11341 | ····public void TestChangeKeyHolderRightNoTouch() |
11342 | ····{ |
11343 | ········CreateObjects(); |
11344 | ········QueryOther(); |
11345 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11346 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11347 | ········otherVar.Dummy = 4711; |
11348 | ········pm.Save(); |
11349 | ········pm.UnloadCache(); |
11350 | ········QueryOther(); |
11351 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11352 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11353 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11354 | ····} |
11355 | ····[Test] |
11356 | ····public void TestRelationHash() |
11357 | ····{ |
11358 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblGuidLeft)); |
11359 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11360 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblGuidRight)); |
11361 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11362 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11363 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11364 | ····} |
11365 | ····void CreateObjects() |
11366 | ····{ |
11367 | ········pm.MakePersistent(ownVar); |
11368 | ········ownVar.AssignRelation(otherVar); |
11369 | ········pm.Save(); |
11370 | ········pm.UnloadCache(); |
11371 | ····} |
11372 | ····void QueryOwn() |
11373 | ····{ |
11374 | ········var q = new NDOQuery<CmpBi11NoTblGuidLeft>(pm); |
11375 | ········ownVar = q.ExecuteSingle(); |
11376 | ····} |
11377 | ····void QueryOther() |
11378 | ····{ |
11379 | ········var q = new NDOQuery<CmpBi11NoTblGuidRight>(pm); |
11380 | ········otherVar = q.ExecuteSingle(); |
11381 | ····} |
11382 | } |
11383 | |
11384 | |
11385 | [TestFixture] |
11386 | public class TestCmpBi11TblGuid : NDOTest |
11387 | { |
11388 | ····CmpBi11TblGuidLeft ownVar; |
11389 | ····CmpBi11TblGuidRight otherVar; |
11390 | ····PersistenceManager pm; |
11391 | ····[SetUp] |
11392 | ····public void Setup() |
11393 | ····{ |
11394 | ········pm = PmFactory.NewPersistenceManager(); |
11395 | ········ownVar = new CmpBi11TblGuidLeft(); |
11396 | ········otherVar = new CmpBi11TblGuidRight(); |
11397 | ····} |
11398 | ····[TearDown] |
11399 | ····public void TearDown() |
11400 | ····{ |
11401 | ········try |
11402 | ········{ |
11403 | ············pm.UnloadCache(); |
11404 | ············var l = pm.Objects<CmpBi11TblGuidLeft>().ResultTable; |
11405 | ············pm.Delete(l); |
11406 | ············pm.Save(); |
11407 | ············pm.UnloadCache(); |
11408 | ············decimal count; |
11409 | ············count = (decimal) new NDOQuery<CmpBi11TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11410 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11411 | ············count = (decimal) new NDOQuery<CmpBi11TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11412 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11413 | ········} |
11414 | ········catch (Exception) |
11415 | ········{ |
11416 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11417 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11418 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11419 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11420 | ········} |
11421 | ····} |
11422 | ····[Test] |
11423 | ····public void TestSaveReload() |
11424 | ····{ |
11425 | ········CreateObjects(); |
11426 | ········QueryOwn(); |
11427 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11428 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11429 | ····} |
11430 | ····[Test] |
11431 | ····public void TestSaveReloadNull() |
11432 | ····{ |
11433 | ········CreateObjects(); |
11434 | ········QueryOwn(); |
11435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11436 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11437 | ········ownVar.RelField = null; |
11438 | ········pm.Save(); |
11439 | ········pm.UnloadCache(); |
11440 | ········QueryOwn(); |
11441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11442 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11443 | ····} |
11444 | ····[Test] |
11445 | ····public void TestChangeKeyHolderLeft() |
11446 | ····{ |
11447 | ········CreateObjects(); |
11448 | ········QueryOwn(); |
11449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11450 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11451 | ········int x = ownVar.RelField.Dummy; |
11452 | ········ownVar.Dummy = 4711; |
11453 | ········pm.Save(); |
11454 | ········pm.UnloadCache(); |
11455 | ········QueryOwn(); |
11456 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11457 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11458 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11459 | ····} |
11460 | ····[Test] |
11461 | ····public void TestChangeKeyHolderRight() |
11462 | ····{ |
11463 | ········CreateObjects(); |
11464 | ········QueryOther(); |
11465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11466 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11467 | ········int x = otherVar.RelField.Dummy; |
11468 | ········otherVar.Dummy = 4711; |
11469 | ········pm.Save(); |
11470 | ········pm.UnloadCache(); |
11471 | ········QueryOther(); |
11472 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11473 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11474 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11475 | ····} |
11476 | ····[Test] |
11477 | ····public void TestChangeKeyHolderLeftNoTouch() |
11478 | ····{ |
11479 | ········CreateObjects(); |
11480 | ········QueryOwn(); |
11481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11482 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11483 | ········ownVar.Dummy = 4711; |
11484 | ········pm.Save(); |
11485 | ········pm.UnloadCache(); |
11486 | ········QueryOwn(); |
11487 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11488 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11489 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11490 | ····} |
11491 | ····[Test] |
11492 | ····public void TestChangeKeyHolderRightNoTouch() |
11493 | ····{ |
11494 | ········CreateObjects(); |
11495 | ········QueryOther(); |
11496 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11497 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11498 | ········otherVar.Dummy = 4711; |
11499 | ········pm.Save(); |
11500 | ········pm.UnloadCache(); |
11501 | ········QueryOther(); |
11502 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11503 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11504 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11505 | ····} |
11506 | ····[Test] |
11507 | ····public void TestRelationHash() |
11508 | ····{ |
11509 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11TblGuidLeft)); |
11510 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11511 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11TblGuidRight)); |
11512 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11513 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11514 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11515 | ····} |
11516 | ····void CreateObjects() |
11517 | ····{ |
11518 | ········pm.MakePersistent(ownVar); |
11519 | ········ownVar.AssignRelation(otherVar); |
11520 | ········pm.Save(); |
11521 | ········pm.UnloadCache(); |
11522 | ····} |
11523 | ····void QueryOwn() |
11524 | ····{ |
11525 | ········var q = new NDOQuery<CmpBi11TblGuidLeft>(pm); |
11526 | ········ownVar = q.ExecuteSingle(); |
11527 | ····} |
11528 | ····void QueryOther() |
11529 | ····{ |
11530 | ········var q = new NDOQuery<CmpBi11TblGuidRight>(pm); |
11531 | ········otherVar = q.ExecuteSingle(); |
11532 | ····} |
11533 | } |
11534 | |
11535 | |
11536 | [TestFixture] |
11537 | public class TestCmpDirnNoTblGuid : NDOTest |
11538 | { |
11539 | ····CmpDirnNoTblGuidLeft ownVar; |
11540 | ····CmpDirnNoTblGuidRight otherVar; |
11541 | ····PersistenceManager pm; |
11542 | ····[SetUp] |
11543 | ····public void Setup() |
11544 | ····{ |
11545 | ········pm = PmFactory.NewPersistenceManager(); |
11546 | ········ownVar = new CmpDirnNoTblGuidLeft(); |
11547 | ········otherVar = new CmpDirnNoTblGuidRight(); |
11548 | ····} |
11549 | ····[TearDown] |
11550 | ····public void TearDown() |
11551 | ····{ |
11552 | ········try |
11553 | ········{ |
11554 | ············pm.UnloadCache(); |
11555 | ············var l = pm.Objects<CmpDirnNoTblGuidLeft>().ResultTable; |
11556 | ············pm.Delete(l); |
11557 | ············pm.Save(); |
11558 | ············pm.UnloadCache(); |
11559 | ············decimal count; |
11560 | ············count = (decimal) new NDOQuery<CmpDirnNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11561 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11562 | ············count = (decimal) new NDOQuery<CmpDirnNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11563 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11564 | ········} |
11565 | ········catch (Exception) |
11566 | ········{ |
11567 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11568 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11569 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11570 | ········} |
11571 | ····} |
11572 | ····[Test] |
11573 | ····public void TestSaveReload() |
11574 | ····{ |
11575 | ········CreateObjects(); |
11576 | ········QueryOwn(); |
11577 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11578 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11579 | ····} |
11580 | ····[Test] |
11581 | ····public void TestSaveReloadNull() |
11582 | ····{ |
11583 | ········CreateObjects(); |
11584 | ········QueryOwn(); |
11585 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11586 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11587 | ········ownVar.RelField = new List<CmpDirnNoTblGuidRight>(); |
11588 | ········pm.Save(); |
11589 | ········pm.UnloadCache(); |
11590 | ········QueryOwn(); |
11591 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11592 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11593 | ····} |
11594 | ····[Test] |
11595 | ····public void TestSaveReloadRemove() |
11596 | ····{ |
11597 | ········CreateObjects(); |
11598 | ········QueryOwn(); |
11599 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11600 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11601 | ········ownVar.RemoveRelatedObject(); |
11602 | ········pm.Save(); |
11603 | ········pm.UnloadCache(); |
11604 | ········QueryOwn(); |
11605 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11606 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11607 | ····} |
11608 | ····void CreateObjects() |
11609 | ····{ |
11610 | ········pm.MakePersistent(ownVar); |
11611 | ········ownVar.AssignRelation(otherVar); |
11612 | ········pm.Save(); |
11613 | ········pm.UnloadCache(); |
11614 | ····} |
11615 | ····void QueryOwn() |
11616 | ····{ |
11617 | ········var q = new NDOQuery<CmpDirnNoTblGuidLeft>(pm); |
11618 | ········ownVar = q.ExecuteSingle(); |
11619 | ····} |
11620 | ····void QueryOther() |
11621 | ····{ |
11622 | ········var q = new NDOQuery<CmpDirnNoTblGuidRight>(pm); |
11623 | ········otherVar = q.ExecuteSingle(); |
11624 | ····} |
11625 | } |
11626 | |
11627 | |
11628 | [TestFixture] |
11629 | public class TestCmpDirnTblGuid : NDOTest |
11630 | { |
11631 | ····CmpDirnTblGuidLeft ownVar; |
11632 | ····CmpDirnTblGuidRight otherVar; |
11633 | ····PersistenceManager pm; |
11634 | ····[SetUp] |
11635 | ····public void Setup() |
11636 | ····{ |
11637 | ········pm = PmFactory.NewPersistenceManager(); |
11638 | ········ownVar = new CmpDirnTblGuidLeft(); |
11639 | ········otherVar = new CmpDirnTblGuidRight(); |
11640 | ····} |
11641 | ····[TearDown] |
11642 | ····public void TearDown() |
11643 | ····{ |
11644 | ········try |
11645 | ········{ |
11646 | ············pm.UnloadCache(); |
11647 | ············var l = pm.Objects<CmpDirnTblGuidLeft>().ResultTable; |
11648 | ············pm.Delete(l); |
11649 | ············pm.Save(); |
11650 | ············pm.UnloadCache(); |
11651 | ············decimal count; |
11652 | ············count = (decimal) new NDOQuery<CmpDirnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11653 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11654 | ············count = (decimal) new NDOQuery<CmpDirnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11655 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11656 | ········} |
11657 | ········catch (Exception) |
11658 | ········{ |
11659 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11660 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11661 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11662 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11663 | ········} |
11664 | ····} |
11665 | ····[Test] |
11666 | ····public void TestSaveReload() |
11667 | ····{ |
11668 | ········CreateObjects(); |
11669 | ········QueryOwn(); |
11670 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11671 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11672 | ····} |
11673 | ····[Test] |
11674 | ····public void TestSaveReloadNull() |
11675 | ····{ |
11676 | ········CreateObjects(); |
11677 | ········QueryOwn(); |
11678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11679 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11680 | ········ownVar.RelField = new List<CmpDirnTblGuidRight>(); |
11681 | ········pm.Save(); |
11682 | ········pm.UnloadCache(); |
11683 | ········QueryOwn(); |
11684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11685 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11686 | ····} |
11687 | ····[Test] |
11688 | ····public void TestSaveReloadRemove() |
11689 | ····{ |
11690 | ········CreateObjects(); |
11691 | ········QueryOwn(); |
11692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11693 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11694 | ········ownVar.RemoveRelatedObject(); |
11695 | ········pm.Save(); |
11696 | ········pm.UnloadCache(); |
11697 | ········QueryOwn(); |
11698 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11699 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11700 | ····} |
11701 | ····void CreateObjects() |
11702 | ····{ |
11703 | ········pm.MakePersistent(ownVar); |
11704 | ········ownVar.AssignRelation(otherVar); |
11705 | ········pm.Save(); |
11706 | ········pm.UnloadCache(); |
11707 | ····} |
11708 | ····void QueryOwn() |
11709 | ····{ |
11710 | ········var q = new NDOQuery<CmpDirnTblGuidLeft>(pm); |
11711 | ········ownVar = q.ExecuteSingle(); |
11712 | ····} |
11713 | ····void QueryOther() |
11714 | ····{ |
11715 | ········var q = new NDOQuery<CmpDirnTblGuidRight>(pm); |
11716 | ········otherVar = q.ExecuteSingle(); |
11717 | ····} |
11718 | } |
11719 | |
11720 | |
11721 | [TestFixture] |
11722 | public class TestCmpBin1NoTblGuid : NDOTest |
11723 | { |
11724 | ····CmpBin1NoTblGuidLeft ownVar; |
11725 | ····CmpBin1NoTblGuidRight otherVar; |
11726 | ····PersistenceManager pm; |
11727 | ····[SetUp] |
11728 | ····public void Setup() |
11729 | ····{ |
11730 | ········pm = PmFactory.NewPersistenceManager(); |
11731 | ········ownVar = new CmpBin1NoTblGuidLeft(); |
11732 | ········otherVar = new CmpBin1NoTblGuidRight(); |
11733 | ····} |
11734 | ····[TearDown] |
11735 | ····public void TearDown() |
11736 | ····{ |
11737 | ········try |
11738 | ········{ |
11739 | ············pm.UnloadCache(); |
11740 | ············var l = pm.Objects<CmpBin1NoTblGuidLeft>().ResultTable; |
11741 | ············pm.Delete(l); |
11742 | ············pm.Save(); |
11743 | ············pm.UnloadCache(); |
11744 | ············decimal count; |
11745 | ············count = (decimal) new NDOQuery<CmpBin1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11746 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11747 | ············count = (decimal) new NDOQuery<CmpBin1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11748 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11749 | ········} |
11750 | ········catch (Exception) |
11751 | ········{ |
11752 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11753 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11755 | ········} |
11756 | ····} |
11757 | ····[Test] |
11758 | ····public void TestSaveReload() |
11759 | ····{ |
11760 | ········CreateObjects(); |
11761 | ········QueryOwn(); |
11762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11763 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11764 | ····} |
11765 | ····[Test] |
11766 | ····public void TestSaveReloadNull() |
11767 | ····{ |
11768 | ········CreateObjects(); |
11769 | ········QueryOwn(); |
11770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11771 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11772 | ········ownVar.RelField = new List<CmpBin1NoTblGuidRight>(); |
11773 | ········pm.Save(); |
11774 | ········pm.UnloadCache(); |
11775 | ········QueryOwn(); |
11776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11777 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11778 | ····} |
11779 | ····[Test] |
11780 | ····public void TestSaveReloadRemove() |
11781 | ····{ |
11782 | ········CreateObjects(); |
11783 | ········QueryOwn(); |
11784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11785 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11786 | ········ownVar.RemoveRelatedObject(); |
11787 | ········pm.Save(); |
11788 | ········pm.UnloadCache(); |
11789 | ········QueryOwn(); |
11790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11791 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11792 | ····} |
11793 | ····[Test] |
11794 | ····public void TestChangeKeyHolderRight() |
11795 | ····{ |
11796 | ········CreateObjects(); |
11797 | ········QueryOther(); |
11798 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11799 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11800 | ········int x = otherVar.RelField.Dummy; |
11801 | ········otherVar.Dummy = 4711; |
11802 | ········pm.Save(); |
11803 | ········pm.UnloadCache(); |
11804 | ········QueryOther(); |
11805 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11806 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11807 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11808 | ····} |
11809 | ····[Test] |
11810 | ····public void TestChangeKeyHolderRightNoTouch() |
11811 | ····{ |
11812 | ········CreateObjects(); |
11813 | ········QueryOther(); |
11814 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11815 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11816 | ········otherVar.Dummy = 4711; |
11817 | ········pm.Save(); |
11818 | ········pm.UnloadCache(); |
11819 | ········QueryOther(); |
11820 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11821 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11822 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11823 | ····} |
11824 | ····[Test] |
11825 | ····public void TestRelationHash() |
11826 | ····{ |
11827 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblGuidLeft)); |
11828 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11829 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblGuidRight)); |
11830 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11831 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11832 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11833 | ····} |
11834 | ····void CreateObjects() |
11835 | ····{ |
11836 | ········pm.MakePersistent(ownVar); |
11837 | ········ownVar.AssignRelation(otherVar); |
11838 | ········pm.Save(); |
11839 | ········pm.UnloadCache(); |
11840 | ····} |
11841 | ····void QueryOwn() |
11842 | ····{ |
11843 | ········var q = new NDOQuery<CmpBin1NoTblGuidLeft>(pm); |
11844 | ········ownVar = q.ExecuteSingle(); |
11845 | ····} |
11846 | ····void QueryOther() |
11847 | ····{ |
11848 | ········var q = new NDOQuery<CmpBin1NoTblGuidRight>(pm); |
11849 | ········otherVar = q.ExecuteSingle(); |
11850 | ····} |
11851 | } |
11852 | |
11853 | |
11854 | [TestFixture] |
11855 | public class TestCmpBin1TblGuid : NDOTest |
11856 | { |
11857 | ····CmpBin1TblGuidLeft ownVar; |
11858 | ····CmpBin1TblGuidRight otherVar; |
11859 | ····PersistenceManager pm; |
11860 | ····[SetUp] |
11861 | ····public void Setup() |
11862 | ····{ |
11863 | ········pm = PmFactory.NewPersistenceManager(); |
11864 | ········ownVar = new CmpBin1TblGuidLeft(); |
11865 | ········otherVar = new CmpBin1TblGuidRight(); |
11866 | ····} |
11867 | ····[TearDown] |
11868 | ····public void TearDown() |
11869 | ····{ |
11870 | ········try |
11871 | ········{ |
11872 | ············pm.UnloadCache(); |
11873 | ············var l = pm.Objects<CmpBin1TblGuidLeft>().ResultTable; |
11874 | ············pm.Delete(l); |
11875 | ············pm.Save(); |
11876 | ············pm.UnloadCache(); |
11877 | ············decimal count; |
11878 | ············count = (decimal) new NDOQuery<CmpBin1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11879 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11880 | ············count = (decimal) new NDOQuery<CmpBin1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11881 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11882 | ········} |
11883 | ········catch (Exception) |
11884 | ········{ |
11885 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11886 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11887 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11888 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11889 | ········} |
11890 | ····} |
11891 | ····[Test] |
11892 | ····public void TestSaveReload() |
11893 | ····{ |
11894 | ········CreateObjects(); |
11895 | ········QueryOwn(); |
11896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11897 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11898 | ····} |
11899 | ····[Test] |
11900 | ····public void TestSaveReloadNull() |
11901 | ····{ |
11902 | ········CreateObjects(); |
11903 | ········QueryOwn(); |
11904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11905 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11906 | ········ownVar.RelField = new List<CmpBin1TblGuidRight>(); |
11907 | ········pm.Save(); |
11908 | ········pm.UnloadCache(); |
11909 | ········QueryOwn(); |
11910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11911 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11912 | ····} |
11913 | ····[Test] |
11914 | ····public void TestSaveReloadRemove() |
11915 | ····{ |
11916 | ········CreateObjects(); |
11917 | ········QueryOwn(); |
11918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11920 | ········ownVar.RemoveRelatedObject(); |
11921 | ········pm.Save(); |
11922 | ········pm.UnloadCache(); |
11923 | ········QueryOwn(); |
11924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11926 | ····} |
11927 | ····[Test] |
11928 | ····public void TestChangeKeyHolderRight() |
11929 | ····{ |
11930 | ········CreateObjects(); |
11931 | ········QueryOther(); |
11932 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11933 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11934 | ········int x = otherVar.RelField.Dummy; |
11935 | ········otherVar.Dummy = 4711; |
11936 | ········pm.Save(); |
11937 | ········pm.UnloadCache(); |
11938 | ········QueryOther(); |
11939 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11940 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11941 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11942 | ····} |
11943 | ····[Test] |
11944 | ····public void TestChangeKeyHolderRightNoTouch() |
11945 | ····{ |
11946 | ········CreateObjects(); |
11947 | ········QueryOther(); |
11948 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11949 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11950 | ········otherVar.Dummy = 4711; |
11951 | ········pm.Save(); |
11952 | ········pm.UnloadCache(); |
11953 | ········QueryOther(); |
11954 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11955 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11956 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11957 | ····} |
11958 | ····[Test] |
11959 | ····public void TestRelationHash() |
11960 | ····{ |
11961 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1TblGuidLeft)); |
11962 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11963 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1TblGuidRight)); |
11964 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11965 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11966 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11967 | ····} |
11968 | ····void CreateObjects() |
11969 | ····{ |
11970 | ········pm.MakePersistent(ownVar); |
11971 | ········ownVar.AssignRelation(otherVar); |
11972 | ········pm.Save(); |
11973 | ········pm.UnloadCache(); |
11974 | ····} |
11975 | ····void QueryOwn() |
11976 | ····{ |
11977 | ········var q = new NDOQuery<CmpBin1TblGuidLeft>(pm); |
11978 | ········ownVar = q.ExecuteSingle(); |
11979 | ····} |
11980 | ····void QueryOther() |
11981 | ····{ |
11982 | ········var q = new NDOQuery<CmpBin1TblGuidRight>(pm); |
11983 | ········otherVar = q.ExecuteSingle(); |
11984 | ····} |
11985 | } |
11986 | |
11987 | |
11988 | [TestFixture] |
11989 | public class TestCmpBi1nNoTblGuid : NDOTest |
11990 | { |
11991 | ····CmpBi1nNoTblGuidLeft ownVar; |
11992 | ····CmpBi1nNoTblGuidRight otherVar; |
11993 | ····PersistenceManager pm; |
11994 | ····[SetUp] |
11995 | ····public void Setup() |
11996 | ····{ |
11997 | ········pm = PmFactory.NewPersistenceManager(); |
11998 | ········ownVar = new CmpBi1nNoTblGuidLeft(); |
11999 | ········otherVar = new CmpBi1nNoTblGuidRight(); |
12000 | ····} |
12001 | ····[TearDown] |
12002 | ····public void TearDown() |
12003 | ····{ |
12004 | ········try |
12005 | ········{ |
12006 | ············pm.UnloadCache(); |
12007 | ············var l = pm.Objects<CmpBi1nNoTblGuidLeft>().ResultTable; |
12008 | ············pm.Delete(l); |
12009 | ············pm.Save(); |
12010 | ············pm.UnloadCache(); |
12011 | ············decimal count; |
12012 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12013 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12014 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12015 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12016 | ········} |
12017 | ········catch (Exception) |
12018 | ········{ |
12019 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12020 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12021 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12022 | ········} |
12023 | ····} |
12024 | ····[Test] |
12025 | ····public void TestSaveReload() |
12026 | ····{ |
12027 | ········CreateObjects(); |
12028 | ········QueryOwn(); |
12029 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12030 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12031 | ····} |
12032 | ····[Test] |
12033 | ····public void TestSaveReloadNull() |
12034 | ····{ |
12035 | ········CreateObjects(); |
12036 | ········QueryOwn(); |
12037 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12038 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12039 | ········ownVar.RelField = null; |
12040 | ········pm.Save(); |
12041 | ········pm.UnloadCache(); |
12042 | ········QueryOwn(); |
12043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12044 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12045 | ····} |
12046 | ····[Test] |
12047 | ····public void TestChangeKeyHolderLeft() |
12048 | ····{ |
12049 | ········CreateObjects(); |
12050 | ········QueryOwn(); |
12051 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12052 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12053 | ········int x = ownVar.RelField.Dummy; |
12054 | ········ownVar.Dummy = 4711; |
12055 | ········pm.Save(); |
12056 | ········pm.UnloadCache(); |
12057 | ········QueryOwn(); |
12058 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12059 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12060 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12061 | ····} |
12062 | ····[Test] |
12063 | ····public void TestChangeKeyHolderLeftNoTouch() |
12064 | ····{ |
12065 | ········CreateObjects(); |
12066 | ········QueryOwn(); |
12067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12068 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12069 | ········ownVar.Dummy = 4711; |
12070 | ········pm.Save(); |
12071 | ········pm.UnloadCache(); |
12072 | ········QueryOwn(); |
12073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12074 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12075 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12076 | ····} |
12077 | ····[Test] |
12078 | ····public void TestRelationHash() |
12079 | ····{ |
12080 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblGuidLeft)); |
12081 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12082 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblGuidRight)); |
12083 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12084 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12085 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12086 | ····} |
12087 | ····void CreateObjects() |
12088 | ····{ |
12089 | ········pm.MakePersistent(ownVar); |
12090 | ········ownVar.AssignRelation(otherVar); |
12091 | ········pm.Save(); |
12092 | ········pm.UnloadCache(); |
12093 | ····} |
12094 | ····void QueryOwn() |
12095 | ····{ |
12096 | ········var q = new NDOQuery<CmpBi1nNoTblGuidLeft>(pm); |
12097 | ········ownVar = q.ExecuteSingle(); |
12098 | ····} |
12099 | ····void QueryOther() |
12100 | ····{ |
12101 | ········var q = new NDOQuery<CmpBi1nNoTblGuidRight>(pm); |
12102 | ········otherVar = q.ExecuteSingle(); |
12103 | ····} |
12104 | } |
12105 | |
12106 | |
12107 | [TestFixture] |
12108 | public class TestCmpBi1nTblGuid : NDOTest |
12109 | { |
12110 | ····CmpBi1nTblGuidLeft ownVar; |
12111 | ····CmpBi1nTblGuidRight otherVar; |
12112 | ····PersistenceManager pm; |
12113 | ····[SetUp] |
12114 | ····public void Setup() |
12115 | ····{ |
12116 | ········pm = PmFactory.NewPersistenceManager(); |
12117 | ········ownVar = new CmpBi1nTblGuidLeft(); |
12118 | ········otherVar = new CmpBi1nTblGuidRight(); |
12119 | ····} |
12120 | ····[TearDown] |
12121 | ····public void TearDown() |
12122 | ····{ |
12123 | ········try |
12124 | ········{ |
12125 | ············pm.UnloadCache(); |
12126 | ············var l = pm.Objects<CmpBi1nTblGuidLeft>().ResultTable; |
12127 | ············pm.Delete(l); |
12128 | ············pm.Save(); |
12129 | ············pm.UnloadCache(); |
12130 | ············decimal count; |
12131 | ············count = (decimal) new NDOQuery<CmpBi1nTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12132 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12133 | ············count = (decimal) new NDOQuery<CmpBi1nTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12134 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12135 | ········} |
12136 | ········catch (Exception) |
12137 | ········{ |
12138 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12139 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12140 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12141 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12142 | ········} |
12143 | ····} |
12144 | ····[Test] |
12145 | ····public void TestSaveReload() |
12146 | ····{ |
12147 | ········CreateObjects(); |
12148 | ········QueryOwn(); |
12149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12151 | ····} |
12152 | ····[Test] |
12153 | ····public void TestSaveReloadNull() |
12154 | ····{ |
12155 | ········CreateObjects(); |
12156 | ········QueryOwn(); |
12157 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12158 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12159 | ········ownVar.RelField = null; |
12160 | ········pm.Save(); |
12161 | ········pm.UnloadCache(); |
12162 | ········QueryOwn(); |
12163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12164 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12165 | ····} |
12166 | ····[Test] |
12167 | ····public void TestChangeKeyHolderLeft() |
12168 | ····{ |
12169 | ········CreateObjects(); |
12170 | ········QueryOwn(); |
12171 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12172 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12173 | ········int x = ownVar.RelField.Dummy; |
12174 | ········ownVar.Dummy = 4711; |
12175 | ········pm.Save(); |
12176 | ········pm.UnloadCache(); |
12177 | ········QueryOwn(); |
12178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12179 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12181 | ····} |
12182 | ····[Test] |
12183 | ····public void TestChangeKeyHolderLeftNoTouch() |
12184 | ····{ |
12185 | ········CreateObjects(); |
12186 | ········QueryOwn(); |
12187 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12188 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12189 | ········ownVar.Dummy = 4711; |
12190 | ········pm.Save(); |
12191 | ········pm.UnloadCache(); |
12192 | ········QueryOwn(); |
12193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12194 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12195 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12196 | ····} |
12197 | ····[Test] |
12198 | ····public void TestRelationHash() |
12199 | ····{ |
12200 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nTblGuidLeft)); |
12201 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12202 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nTblGuidRight)); |
12203 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12204 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12205 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12206 | ····} |
12207 | ····void CreateObjects() |
12208 | ····{ |
12209 | ········pm.MakePersistent(ownVar); |
12210 | ········ownVar.AssignRelation(otherVar); |
12211 | ········pm.Save(); |
12212 | ········pm.UnloadCache(); |
12213 | ····} |
12214 | ····void QueryOwn() |
12215 | ····{ |
12216 | ········var q = new NDOQuery<CmpBi1nTblGuidLeft>(pm); |
12217 | ········ownVar = q.ExecuteSingle(); |
12218 | ····} |
12219 | ····void QueryOther() |
12220 | ····{ |
12221 | ········var q = new NDOQuery<CmpBi1nTblGuidRight>(pm); |
12222 | ········otherVar = q.ExecuteSingle(); |
12223 | ····} |
12224 | } |
12225 | |
12226 | |
12227 | [TestFixture] |
12228 | public class TestCmpBinnTblGuid : NDOTest |
12229 | { |
12230 | ····CmpBinnTblGuidLeft ownVar; |
12231 | ····CmpBinnTblGuidRight otherVar; |
12232 | ····PersistenceManager pm; |
12233 | ····[SetUp] |
12234 | ····public void Setup() |
12235 | ····{ |
12236 | ········pm = PmFactory.NewPersistenceManager(); |
12237 | ········ownVar = new CmpBinnTblGuidLeft(); |
12238 | ········otherVar = new CmpBinnTblGuidRight(); |
12239 | ····} |
12240 | ····[TearDown] |
12241 | ····public void TearDown() |
12242 | ····{ |
12243 | ········try |
12244 | ········{ |
12245 | ············pm.UnloadCache(); |
12246 | ············var l = pm.Objects<CmpBinnTblGuidLeft>().ResultTable; |
12247 | ············pm.Delete(l); |
12248 | ············pm.Save(); |
12249 | ············pm.UnloadCache(); |
12250 | ············decimal count; |
12251 | ············count = (decimal) new NDOQuery<CmpBinnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12252 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12253 | ············count = (decimal) new NDOQuery<CmpBinnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12254 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12255 | ········} |
12256 | ········catch (Exception) |
12257 | ········{ |
12258 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12259 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12260 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12261 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12262 | ········} |
12263 | ····} |
12264 | ····[Test] |
12265 | ····public void TestSaveReload() |
12266 | ····{ |
12267 | ········CreateObjects(); |
12268 | ········QueryOwn(); |
12269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12271 | ····} |
12272 | ····[Test] |
12273 | ····public void TestSaveReloadNull() |
12274 | ····{ |
12275 | ········CreateObjects(); |
12276 | ········QueryOwn(); |
12277 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12278 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12279 | ········ownVar.RelField = new List<CmpBinnTblGuidRight>(); |
12280 | ········pm.Save(); |
12281 | ········pm.UnloadCache(); |
12282 | ········QueryOwn(); |
12283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12284 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12285 | ····} |
12286 | ····[Test] |
12287 | ····public void TestSaveReloadRemove() |
12288 | ····{ |
12289 | ········CreateObjects(); |
12290 | ········QueryOwn(); |
12291 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12292 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12293 | ········ownVar.RemoveRelatedObject(); |
12294 | ········pm.Save(); |
12295 | ········pm.UnloadCache(); |
12296 | ········QueryOwn(); |
12297 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12298 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12299 | ····} |
12300 | ····[Test] |
12301 | ····public void TestRelationHash() |
12302 | ····{ |
12303 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnTblGuidLeft)); |
12304 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12305 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnTblGuidRight)); |
12306 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12307 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12308 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12309 | ····} |
12310 | ····void CreateObjects() |
12311 | ····{ |
12312 | ········pm.MakePersistent(ownVar); |
12313 | ········ownVar.AssignRelation(otherVar); |
12314 | ········pm.Save(); |
12315 | ········pm.UnloadCache(); |
12316 | ····} |
12317 | ····void QueryOwn() |
12318 | ····{ |
12319 | ········var q = new NDOQuery<CmpBinnTblGuidLeft>(pm); |
12320 | ········ownVar = q.ExecuteSingle(); |
12321 | ····} |
12322 | ····void QueryOther() |
12323 | ····{ |
12324 | ········var q = new NDOQuery<CmpBinnTblGuidRight>(pm); |
12325 | ········otherVar = q.ExecuteSingle(); |
12326 | ····} |
12327 | } |
12328 | |
12329 | |
12330 | [TestFixture] |
12331 | public class TestAgrDir1OwnpconNoTblGuid : NDOTest |
12332 | { |
12333 | ····AgrDir1OwnpconNoTblGuidLeftBase ownVar; |
12334 | ····AgrDir1OwnpconNoTblGuidRight otherVar; |
12335 | ····PersistenceManager pm; |
12336 | ····[SetUp] |
12337 | ····public void Setup() |
12338 | ····{ |
12339 | ········pm = PmFactory.NewPersistenceManager(); |
12340 | ········ownVar = new AgrDir1OwnpconNoTblGuidLeftDerived(); |
12341 | ········otherVar = new AgrDir1OwnpconNoTblGuidRight(); |
12342 | ····} |
12343 | ····[TearDown] |
12344 | ····public void TearDown() |
12345 | ····{ |
12346 | ········try |
12347 | ········{ |
12348 | ············pm.UnloadCache(); |
12349 | ············var l = pm.Objects<AgrDir1OwnpconNoTblGuidLeftBase>().ResultTable; |
12350 | ············pm.Delete(l); |
12351 | ············pm.Save(); |
12352 | ············pm.UnloadCache(); |
12353 | ············var m = pm.Objects<AgrDir1OwnpconNoTblGuidRight>().ResultTable; |
12354 | ············pm.Delete(m); |
12355 | ············pm.Save(); |
12356 | ············pm.UnloadCache(); |
12357 | ············decimal count; |
12358 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12359 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12360 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12361 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12362 | ········} |
12363 | ········catch (Exception) |
12364 | ········{ |
12365 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12366 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12367 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12368 | ········} |
12369 | ····} |
12370 | ····[Test] |
12371 | ····public void TestSaveReload() |
12372 | ····{ |
12373 | ········CreateObjects(); |
12374 | ········QueryOwn(); |
12375 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12376 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12377 | ····} |
12378 | ····[Test] |
12379 | ····public void TestSaveReloadNull() |
12380 | ····{ |
12381 | ········CreateObjects(); |
12382 | ········QueryOwn(); |
12383 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12384 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12385 | ········ownVar.RelField = null; |
12386 | ········pm.Save(); |
12387 | ········pm.UnloadCache(); |
12388 | ········QueryOwn(); |
12389 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12390 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12391 | ····} |
12392 | ····[Test] |
12393 | ····public void TestChangeKeyHolderLeft() |
12394 | ····{ |
12395 | ········CreateObjects(); |
12396 | ········QueryOwn(); |
12397 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12398 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12399 | ········int x = ownVar.RelField.Dummy; |
12400 | ········ownVar.Dummy = 4711; |
12401 | ········pm.Save(); |
12402 | ········pm.UnloadCache(); |
12403 | ········QueryOwn(); |
12404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12405 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12406 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12407 | ····} |
12408 | ····[Test] |
12409 | ····public void TestChangeKeyHolderLeftNoTouch() |
12410 | ····{ |
12411 | ········CreateObjects(); |
12412 | ········QueryOwn(); |
12413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12414 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12415 | ········ownVar.Dummy = 4711; |
12416 | ········pm.Save(); |
12417 | ········pm.UnloadCache(); |
12418 | ········QueryOwn(); |
12419 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12420 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12422 | ····} |
12423 | ····void CreateObjects() |
12424 | ····{ |
12425 | ········pm.MakePersistent(ownVar); |
12426 | ········pm.MakePersistent(otherVar); |
12427 | ········ownVar.AssignRelation(otherVar); |
12428 | ········pm.Save(); |
12429 | ········pm.UnloadCache(); |
12430 | ····} |
12431 | ····void QueryOwn() |
12432 | ····{ |
12433 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblGuidLeftBase>(pm); |
12434 | ········ownVar = q.ExecuteSingle(); |
12435 | ····} |
12436 | ····void QueryOther() |
12437 | ····{ |
12438 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblGuidRight>(pm); |
12439 | ········otherVar = q.ExecuteSingle(); |
12440 | ····} |
12441 | } |
12442 | |
12443 | |
12444 | [TestFixture] |
12445 | public class TestAgrDir1OwnpconTblGuid : NDOTest |
12446 | { |
12447 | ····AgrDir1OwnpconTblGuidLeftBase ownVar; |
12448 | ····AgrDir1OwnpconTblGuidRight otherVar; |
12449 | ····PersistenceManager pm; |
12450 | ····[SetUp] |
12451 | ····public void Setup() |
12452 | ····{ |
12453 | ········pm = PmFactory.NewPersistenceManager(); |
12454 | ········ownVar = new AgrDir1OwnpconTblGuidLeftDerived(); |
12455 | ········otherVar = new AgrDir1OwnpconTblGuidRight(); |
12456 | ····} |
12457 | ····[TearDown] |
12458 | ····public void TearDown() |
12459 | ····{ |
12460 | ········try |
12461 | ········{ |
12462 | ············pm.UnloadCache(); |
12463 | ············var l = pm.Objects<AgrDir1OwnpconTblGuidLeftBase>().ResultTable; |
12464 | ············pm.Delete(l); |
12465 | ············pm.Save(); |
12466 | ············pm.UnloadCache(); |
12467 | ············var m = pm.Objects<AgrDir1OwnpconTblGuidRight>().ResultTable; |
12468 | ············pm.Delete(m); |
12469 | ············pm.Save(); |
12470 | ············pm.UnloadCache(); |
12471 | ············decimal count; |
12472 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12473 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12474 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12475 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12476 | ········} |
12477 | ········catch (Exception) |
12478 | ········{ |
12479 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12480 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12481 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12482 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12483 | ········} |
12484 | ····} |
12485 | ····[Test] |
12486 | ····public void TestSaveReload() |
12487 | ····{ |
12488 | ········CreateObjects(); |
12489 | ········QueryOwn(); |
12490 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12491 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12492 | ····} |
12493 | ····[Test] |
12494 | ····public void TestSaveReloadNull() |
12495 | ····{ |
12496 | ········CreateObjects(); |
12497 | ········QueryOwn(); |
12498 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12499 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12500 | ········ownVar.RelField = null; |
12501 | ········pm.Save(); |
12502 | ········pm.UnloadCache(); |
12503 | ········QueryOwn(); |
12504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12505 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12506 | ····} |
12507 | ····[Test] |
12508 | ····public void TestChangeKeyHolderLeft() |
12509 | ····{ |
12510 | ········CreateObjects(); |
12511 | ········QueryOwn(); |
12512 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12513 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12514 | ········int x = ownVar.RelField.Dummy; |
12515 | ········ownVar.Dummy = 4711; |
12516 | ········pm.Save(); |
12517 | ········pm.UnloadCache(); |
12518 | ········QueryOwn(); |
12519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12520 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12521 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12522 | ····} |
12523 | ····[Test] |
12524 | ····public void TestChangeKeyHolderLeftNoTouch() |
12525 | ····{ |
12526 | ········CreateObjects(); |
12527 | ········QueryOwn(); |
12528 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12529 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12530 | ········ownVar.Dummy = 4711; |
12531 | ········pm.Save(); |
12532 | ········pm.UnloadCache(); |
12533 | ········QueryOwn(); |
12534 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12535 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12536 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12537 | ····} |
12538 | ····void CreateObjects() |
12539 | ····{ |
12540 | ········pm.MakePersistent(ownVar); |
12541 | ········pm.MakePersistent(otherVar); |
12542 | ········ownVar.AssignRelation(otherVar); |
12543 | ········pm.Save(); |
12544 | ········pm.UnloadCache(); |
12545 | ····} |
12546 | ····void QueryOwn() |
12547 | ····{ |
12548 | ········var q = new NDOQuery<AgrDir1OwnpconTblGuidLeftBase>(pm); |
12549 | ········ownVar = q.ExecuteSingle(); |
12550 | ····} |
12551 | ····void QueryOther() |
12552 | ····{ |
12553 | ········var q = new NDOQuery<AgrDir1OwnpconTblGuidRight>(pm); |
12554 | ········otherVar = q.ExecuteSingle(); |
12555 | ····} |
12556 | } |
12557 | |
12558 | |
12559 | [TestFixture] |
12560 | public class TestAgrBi11OwnpconNoTblGuid : NDOTest |
12561 | { |
12562 | ····AgrBi11OwnpconNoTblGuidLeftBase ownVar; |
12563 | ····AgrBi11OwnpconNoTblGuidRight otherVar; |
12564 | ····PersistenceManager pm; |
12565 | ····[SetUp] |
12566 | ····public void Setup() |
12567 | ····{ |
12568 | ········pm = PmFactory.NewPersistenceManager(); |
12569 | ········ownVar = new AgrBi11OwnpconNoTblGuidLeftDerived(); |
12570 | ········otherVar = new AgrBi11OwnpconNoTblGuidRight(); |
12571 | ····} |
12572 | ····[TearDown] |
12573 | ····public void TearDown() |
12574 | ····{ |
12575 | ········try |
12576 | ········{ |
12577 | ············pm.UnloadCache(); |
12578 | ············var l = pm.Objects<AgrBi11OwnpconNoTblGuidLeftBase>().ResultTable; |
12579 | ············pm.Delete(l); |
12580 | ············pm.Save(); |
12581 | ············pm.UnloadCache(); |
12582 | ············var m = pm.Objects<AgrBi11OwnpconNoTblGuidRight>().ResultTable; |
12583 | ············pm.Delete(m); |
12584 | ············pm.Save(); |
12585 | ············pm.UnloadCache(); |
12586 | ············decimal count; |
12587 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12588 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12589 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12590 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12591 | ········} |
12592 | ········catch (Exception) |
12593 | ········{ |
12594 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12595 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12596 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12597 | ········} |
12598 | ····} |
12599 | ····[Test] |
12600 | ····public void TestSaveReload() |
12601 | ····{ |
12602 | ········CreateObjects(); |
12603 | ········QueryOwn(); |
12604 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12605 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12606 | ····} |
12607 | ····[Test] |
12608 | ····public void TestSaveReloadNull() |
12609 | ····{ |
12610 | ········CreateObjects(); |
12611 | ········QueryOwn(); |
12612 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12613 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12614 | ········ownVar.RelField = null; |
12615 | ········pm.Save(); |
12616 | ········pm.UnloadCache(); |
12617 | ········QueryOwn(); |
12618 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12619 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12620 | ····} |
12621 | ····[Test] |
12622 | ····public void TestChangeKeyHolderLeft() |
12623 | ····{ |
12624 | ········CreateObjects(); |
12625 | ········QueryOwn(); |
12626 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12627 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12628 | ········int x = ownVar.RelField.Dummy; |
12629 | ········ownVar.Dummy = 4711; |
12630 | ········pm.Save(); |
12631 | ········pm.UnloadCache(); |
12632 | ········QueryOwn(); |
12633 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12634 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12635 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12636 | ····} |
12637 | ····[Test] |
12638 | ····public void TestChangeKeyHolderRight() |
12639 | ····{ |
12640 | ········CreateObjects(); |
12641 | ········QueryOther(); |
12642 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12643 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12644 | ········int x = otherVar.RelField.Dummy; |
12645 | ········otherVar.Dummy = 4711; |
12646 | ········pm.Save(); |
12647 | ········pm.UnloadCache(); |
12648 | ········QueryOther(); |
12649 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12650 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12651 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12652 | ····} |
12653 | ····[Test] |
12654 | ····public void TestChangeKeyHolderLeftNoTouch() |
12655 | ····{ |
12656 | ········CreateObjects(); |
12657 | ········QueryOwn(); |
12658 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12659 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12660 | ········ownVar.Dummy = 4711; |
12661 | ········pm.Save(); |
12662 | ········pm.UnloadCache(); |
12663 | ········QueryOwn(); |
12664 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12665 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12666 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12667 | ····} |
12668 | ····[Test] |
12669 | ····public void TestChangeKeyHolderRightNoTouch() |
12670 | ····{ |
12671 | ········CreateObjects(); |
12672 | ········QueryOther(); |
12673 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12674 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12675 | ········otherVar.Dummy = 4711; |
12676 | ········pm.Save(); |
12677 | ········pm.UnloadCache(); |
12678 | ········QueryOther(); |
12679 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12680 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12681 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12682 | ····} |
12683 | ····[Test] |
12684 | ····public void TestRelationHash() |
12685 | ····{ |
12686 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidLeftBase)); |
12687 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12688 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidRight)); |
12689 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12690 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12691 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12692 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidLeftDerived)); |
12693 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
12694 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
12695 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
12696 | ····} |
12697 | ····void CreateObjects() |
12698 | ····{ |
12699 | ········pm.MakePersistent(ownVar); |
12700 | ········pm.MakePersistent(otherVar); |
12701 | ········ownVar.AssignRelation(otherVar); |
12702 | ········pm.Save(); |
12703 | ········pm.UnloadCache(); |
12704 | ····} |
12705 | ····void QueryOwn() |
12706 | ····{ |
12707 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblGuidLeftBase>(pm); |
12708 | ········ownVar = q.ExecuteSingle(); |
12709 | ····} |
12710 | ····void QueryOther() |
12711 | ····{ |
12712 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblGuidRight>(pm); |
12713 | ········otherVar = q.ExecuteSingle(); |
12714 | ····} |
12715 | } |
12716 | |
12717 | |
12718 | [TestFixture] |
12719 | public class TestAgrBi11OwnpconTblGuid : NDOTest |
12720 | { |
12721 | ····AgrBi11OwnpconTblGuidLeftBase ownVar; |
12722 | ····AgrBi11OwnpconTblGuidRight otherVar; |
12723 | ····PersistenceManager pm; |
12724 | ····[SetUp] |
12725 | ····public void Setup() |
12726 | ····{ |
12727 | ········pm = PmFactory.NewPersistenceManager(); |
12728 | ········ownVar = new AgrBi11OwnpconTblGuidLeftDerived(); |
12729 | ········otherVar = new AgrBi11OwnpconTblGuidRight(); |
12730 | ····} |
12731 | ····[TearDown] |
12732 | ····public void TearDown() |
12733 | ····{ |
12734 | ········try |
12735 | ········{ |
12736 | ············pm.UnloadCache(); |
12737 | ············var l = pm.Objects<AgrBi11OwnpconTblGuidLeftBase>().ResultTable; |
12738 | ············pm.Delete(l); |
12739 | ············pm.Save(); |
12740 | ············pm.UnloadCache(); |
12741 | ············var m = pm.Objects<AgrBi11OwnpconTblGuidRight>().ResultTable; |
12742 | ············pm.Delete(m); |
12743 | ············pm.Save(); |
12744 | ············pm.UnloadCache(); |
12745 | ············decimal count; |
12746 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12747 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12748 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12749 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12750 | ········} |
12751 | ········catch (Exception) |
12752 | ········{ |
12753 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12755 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12756 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12757 | ········} |
12758 | ····} |
12759 | ····[Test] |
12760 | ····public void TestSaveReload() |
12761 | ····{ |
12762 | ········CreateObjects(); |
12763 | ········QueryOwn(); |
12764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12765 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12766 | ····} |
12767 | ····[Test] |
12768 | ····public void TestSaveReloadNull() |
12769 | ····{ |
12770 | ········CreateObjects(); |
12771 | ········QueryOwn(); |
12772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12773 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12774 | ········ownVar.RelField = null; |
12775 | ········pm.Save(); |
12776 | ········pm.UnloadCache(); |
12777 | ········QueryOwn(); |
12778 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12779 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12780 | ····} |
12781 | ····[Test] |
12782 | ····public void TestChangeKeyHolderLeft() |
12783 | ····{ |
12784 | ········CreateObjects(); |
12785 | ········QueryOwn(); |
12786 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12787 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12788 | ········int x = ownVar.RelField.Dummy; |
12789 | ········ownVar.Dummy = 4711; |
12790 | ········pm.Save(); |
12791 | ········pm.UnloadCache(); |
12792 | ········QueryOwn(); |
12793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12794 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12795 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12796 | ····} |
12797 | ····[Test] |
12798 | ····public void TestChangeKeyHolderRight() |
12799 | ····{ |
12800 | ········CreateObjects(); |
12801 | ········QueryOther(); |
12802 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12803 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12804 | ········int x = otherVar.RelField.Dummy; |
12805 | ········otherVar.Dummy = 4711; |
12806 | ········pm.Save(); |
12807 | ········pm.UnloadCache(); |
12808 | ········QueryOther(); |
12809 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12810 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12811 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12812 | ····} |
12813 | ····[Test] |
12814 | ····public void TestChangeKeyHolderLeftNoTouch() |
12815 | ····{ |
12816 | ········CreateObjects(); |
12817 | ········QueryOwn(); |
12818 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12819 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12820 | ········ownVar.Dummy = 4711; |
12821 | ········pm.Save(); |
12822 | ········pm.UnloadCache(); |
12823 | ········QueryOwn(); |
12824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12825 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12826 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12827 | ····} |
12828 | ····[Test] |
12829 | ····public void TestChangeKeyHolderRightNoTouch() |
12830 | ····{ |
12831 | ········CreateObjects(); |
12832 | ········QueryOther(); |
12833 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12834 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12835 | ········otherVar.Dummy = 4711; |
12836 | ········pm.Save(); |
12837 | ········pm.UnloadCache(); |
12838 | ········QueryOther(); |
12839 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12840 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12841 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12842 | ····} |
12843 | ····[Test] |
12844 | ····public void TestRelationHash() |
12845 | ····{ |
12846 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidLeftBase)); |
12847 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12848 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidRight)); |
12849 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12850 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12851 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12852 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidLeftDerived)); |
12853 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
12854 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
12855 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
12856 | ····} |
12857 | ····void CreateObjects() |
12858 | ····{ |
12859 | ········pm.MakePersistent(ownVar); |
12860 | ········pm.MakePersistent(otherVar); |
12861 | ········ownVar.AssignRelation(otherVar); |
12862 | ········pm.Save(); |
12863 | ········pm.UnloadCache(); |
12864 | ····} |
12865 | ····void QueryOwn() |
12866 | ····{ |
12867 | ········var q = new NDOQuery<AgrBi11OwnpconTblGuidLeftBase>(pm); |
12868 | ········ownVar = q.ExecuteSingle(); |
12869 | ····} |
12870 | ····void QueryOther() |
12871 | ····{ |
12872 | ········var q = new NDOQuery<AgrBi11OwnpconTblGuidRight>(pm); |
12873 | ········otherVar = q.ExecuteSingle(); |
12874 | ····} |
12875 | } |
12876 | |
12877 | |
12878 | [TestFixture] |
12879 | public class TestAgrDirnOwnpconNoTblGuid : NDOTest |
12880 | { |
12881 | ····AgrDirnOwnpconNoTblGuidLeftBase ownVar; |
12882 | ····AgrDirnOwnpconNoTblGuidRight otherVar; |
12883 | ····PersistenceManager pm; |
12884 | ····[SetUp] |
12885 | ····public void Setup() |
12886 | ····{ |
12887 | ········pm = PmFactory.NewPersistenceManager(); |
12888 | ········ownVar = new AgrDirnOwnpconNoTblGuidLeftDerived(); |
12889 | ········otherVar = new AgrDirnOwnpconNoTblGuidRight(); |
12890 | ····} |
12891 | ····[TearDown] |
12892 | ····public void TearDown() |
12893 | ····{ |
12894 | ········try |
12895 | ········{ |
12896 | ············pm.UnloadCache(); |
12897 | ············var l = pm.Objects<AgrDirnOwnpconNoTblGuidLeftBase>().ResultTable; |
12898 | ············pm.Delete(l); |
12899 | ············pm.Save(); |
12900 | ············pm.UnloadCache(); |
12901 | ············var m = pm.Objects<AgrDirnOwnpconNoTblGuidRight>().ResultTable; |
12902 | ············pm.Delete(m); |
12903 | ············pm.Save(); |
12904 | ············pm.UnloadCache(); |
12905 | ············decimal count; |
12906 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12907 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12908 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12909 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12910 | ········} |
12911 | ········catch (Exception) |
12912 | ········{ |
12913 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12914 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12915 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12916 | ········} |
12917 | ····} |
12918 | ····[Test] |
12919 | ····public void TestSaveReload() |
12920 | ····{ |
12921 | ········CreateObjects(); |
12922 | ········QueryOwn(); |
12923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12924 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12925 | ····} |
12926 | ····[Test] |
12927 | ····public void TestSaveReloadNull() |
12928 | ····{ |
12929 | ········CreateObjects(); |
12930 | ········QueryOwn(); |
12931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12932 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12933 | ········ownVar.RelField = new List<AgrDirnOwnpconNoTblGuidRight>(); |
12934 | ········pm.Save(); |
12935 | ········pm.UnloadCache(); |
12936 | ········QueryOwn(); |
12937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12938 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12939 | ····} |
12940 | ····[Test] |
12941 | ····public void TestSaveReloadRemove() |
12942 | ····{ |
12943 | ········CreateObjects(); |
12944 | ········QueryOwn(); |
12945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12946 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12947 | ········ownVar.RemoveRelatedObject(); |
12948 | ········pm.Save(); |
12949 | ········pm.UnloadCache(); |
12950 | ········QueryOwn(); |
12951 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12952 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12953 | ····} |
12954 | ····void CreateObjects() |
12955 | ····{ |
12956 | ········pm.MakePersistent(ownVar); |
12957 | ········pm.MakePersistent(otherVar); |
12958 | ········ownVar.AssignRelation(otherVar); |
12959 | ········pm.Save(); |
12960 | ········pm.UnloadCache(); |
12961 | ····} |
12962 | ····void QueryOwn() |
12963 | ····{ |
12964 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblGuidLeftBase>(pm); |
12965 | ········ownVar = q.ExecuteSingle(); |
12966 | ····} |
12967 | ····void QueryOther() |
12968 | ····{ |
12969 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblGuidRight>(pm); |
12970 | ········otherVar = q.ExecuteSingle(); |
12971 | ····} |
12972 | } |
12973 | |
12974 | |
12975 | [TestFixture] |
12976 | public class TestAgrDirnOwnpconTblGuid : NDOTest |
12977 | { |
12978 | ····AgrDirnOwnpconTblGuidLeftBase ownVar; |
12979 | ····AgrDirnOwnpconTblGuidRight otherVar; |
12980 | ····PersistenceManager pm; |
12981 | ····[SetUp] |
12982 | ····public void Setup() |
12983 | ····{ |
12984 | ········pm = PmFactory.NewPersistenceManager(); |
12985 | ········ownVar = new AgrDirnOwnpconTblGuidLeftDerived(); |
12986 | ········otherVar = new AgrDirnOwnpconTblGuidRight(); |
12987 | ····} |
12988 | ····[TearDown] |
12989 | ····public void TearDown() |
12990 | ····{ |
12991 | ········try |
12992 | ········{ |
12993 | ············pm.UnloadCache(); |
12994 | ············var l = pm.Objects<AgrDirnOwnpconTblGuidLeftBase>().ResultTable; |
12995 | ············pm.Delete(l); |
12996 | ············pm.Save(); |
12997 | ············pm.UnloadCache(); |
12998 | ············var m = pm.Objects<AgrDirnOwnpconTblGuidRight>().ResultTable; |
12999 | ············pm.Delete(m); |
13000 | ············pm.Save(); |
13001 | ············pm.UnloadCache(); |
13002 | ············decimal count; |
13003 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13004 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13005 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13006 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13007 | ········} |
13008 | ········catch (Exception) |
13009 | ········{ |
13010 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13011 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13012 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13013 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13014 | ········} |
13015 | ····} |
13016 | ····[Test] |
13017 | ····public void TestSaveReload() |
13018 | ····{ |
13019 | ········CreateObjects(); |
13020 | ········QueryOwn(); |
13021 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13022 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13023 | ····} |
13024 | ····[Test] |
13025 | ····public void TestSaveReloadNull() |
13026 | ····{ |
13027 | ········CreateObjects(); |
13028 | ········QueryOwn(); |
13029 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13030 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13031 | ········ownVar.RelField = new List<AgrDirnOwnpconTblGuidRight>(); |
13032 | ········pm.Save(); |
13033 | ········pm.UnloadCache(); |
13034 | ········QueryOwn(); |
13035 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13036 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13037 | ····} |
13038 | ····[Test] |
13039 | ····public void TestSaveReloadRemove() |
13040 | ····{ |
13041 | ········CreateObjects(); |
13042 | ········QueryOwn(); |
13043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13044 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13045 | ········ownVar.RemoveRelatedObject(); |
13046 | ········pm.Save(); |
13047 | ········pm.UnloadCache(); |
13048 | ········QueryOwn(); |
13049 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13050 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13051 | ····} |
13052 | ····void CreateObjects() |
13053 | ····{ |
13054 | ········pm.MakePersistent(ownVar); |
13055 | ········pm.MakePersistent(otherVar); |
13056 | ········ownVar.AssignRelation(otherVar); |
13057 | ········pm.Save(); |
13058 | ········pm.UnloadCache(); |
13059 | ····} |
13060 | ····void QueryOwn() |
13061 | ····{ |
13062 | ········var q = new NDOQuery<AgrDirnOwnpconTblGuidLeftBase>(pm); |
13063 | ········ownVar = q.ExecuteSingle(); |
13064 | ····} |
13065 | ····void QueryOther() |
13066 | ····{ |
13067 | ········var q = new NDOQuery<AgrDirnOwnpconTblGuidRight>(pm); |
13068 | ········otherVar = q.ExecuteSingle(); |
13069 | ····} |
13070 | } |
13071 | |
13072 | |
13073 | [TestFixture] |
13074 | public class TestAgrBin1OwnpconNoTblGuid : NDOTest |
13075 | { |
13076 | ····AgrBin1OwnpconNoTblGuidLeftBase ownVar; |
13077 | ····AgrBin1OwnpconNoTblGuidRight otherVar; |
13078 | ····PersistenceManager pm; |
13079 | ····[SetUp] |
13080 | ····public void Setup() |
13081 | ····{ |
13082 | ········pm = PmFactory.NewPersistenceManager(); |
13083 | ········ownVar = new AgrBin1OwnpconNoTblGuidLeftDerived(); |
13084 | ········otherVar = new AgrBin1OwnpconNoTblGuidRight(); |
13085 | ····} |
13086 | ····[TearDown] |
13087 | ····public void TearDown() |
13088 | ····{ |
13089 | ········try |
13090 | ········{ |
13091 | ············pm.UnloadCache(); |
13092 | ············var l = pm.Objects<AgrBin1OwnpconNoTblGuidLeftBase>().ResultTable; |
13093 | ············pm.Delete(l); |
13094 | ············pm.Save(); |
13095 | ············pm.UnloadCache(); |
13096 | ············var m = pm.Objects<AgrBin1OwnpconNoTblGuidRight>().ResultTable; |
13097 | ············pm.Delete(m); |
13098 | ············pm.Save(); |
13099 | ············pm.UnloadCache(); |
13100 | ············decimal count; |
13101 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13102 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13103 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13104 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13105 | ········} |
13106 | ········catch (Exception) |
13107 | ········{ |
13108 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13109 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13110 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13111 | ········} |
13112 | ····} |
13113 | ····[Test] |
13114 | ····public void TestSaveReload() |
13115 | ····{ |
13116 | ········CreateObjects(); |
13117 | ········QueryOwn(); |
13118 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13119 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13120 | ····} |
13121 | ····[Test] |
13122 | ····public void TestSaveReloadNull() |
13123 | ····{ |
13124 | ········CreateObjects(); |
13125 | ········QueryOwn(); |
13126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13127 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13128 | ········ownVar.RelField = new List<AgrBin1OwnpconNoTblGuidRight>(); |
13129 | ········pm.Save(); |
13130 | ········pm.UnloadCache(); |
13131 | ········QueryOwn(); |
13132 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13133 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13134 | ····} |
13135 | ····[Test] |
13136 | ····public void TestSaveReloadRemove() |
13137 | ····{ |
13138 | ········CreateObjects(); |
13139 | ········QueryOwn(); |
13140 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13141 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13142 | ········ownVar.RemoveRelatedObject(); |
13143 | ········pm.Save(); |
13144 | ········pm.UnloadCache(); |
13145 | ········QueryOwn(); |
13146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13147 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13148 | ····} |
13149 | ····[Test] |
13150 | ····public void TestChangeKeyHolderRight() |
13151 | ····{ |
13152 | ········CreateObjects(); |
13153 | ········QueryOther(); |
13154 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13155 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13156 | ········int x = otherVar.RelField.Dummy; |
13157 | ········otherVar.Dummy = 4711; |
13158 | ········pm.Save(); |
13159 | ········pm.UnloadCache(); |
13160 | ········QueryOther(); |
13161 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13162 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13163 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13164 | ····} |
13165 | ····[Test] |
13166 | ····public void TestChangeKeyHolderRightNoTouch() |
13167 | ····{ |
13168 | ········CreateObjects(); |
13169 | ········QueryOther(); |
13170 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13171 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13172 | ········otherVar.Dummy = 4711; |
13173 | ········pm.Save(); |
13174 | ········pm.UnloadCache(); |
13175 | ········QueryOther(); |
13176 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13177 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13178 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13179 | ····} |
13180 | ····[Test] |
13181 | ····public void TestRelationHash() |
13182 | ····{ |
13183 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidLeftBase)); |
13184 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13185 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidRight)); |
13186 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13187 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13188 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13189 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidLeftDerived)); |
13190 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13191 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13192 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13193 | ····} |
13194 | ····void CreateObjects() |
13195 | ····{ |
13196 | ········pm.MakePersistent(ownVar); |
13197 | ········pm.MakePersistent(otherVar); |
13198 | ········ownVar.AssignRelation(otherVar); |
13199 | ········pm.Save(); |
13200 | ········pm.UnloadCache(); |
13201 | ····} |
13202 | ····void QueryOwn() |
13203 | ····{ |
13204 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblGuidLeftBase>(pm); |
13205 | ········ownVar = q.ExecuteSingle(); |
13206 | ····} |
13207 | ····void QueryOther() |
13208 | ····{ |
13209 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblGuidRight>(pm); |
13210 | ········otherVar = q.ExecuteSingle(); |
13211 | ····} |
13212 | } |
13213 | |
13214 | |
13215 | [TestFixture] |
13216 | public class TestAgrBin1OwnpconTblGuid : NDOTest |
13217 | { |
13218 | ····AgrBin1OwnpconTblGuidLeftBase ownVar; |
13219 | ····AgrBin1OwnpconTblGuidRight otherVar; |
13220 | ····PersistenceManager pm; |
13221 | ····[SetUp] |
13222 | ····public void Setup() |
13223 | ····{ |
13224 | ········pm = PmFactory.NewPersistenceManager(); |
13225 | ········ownVar = new AgrBin1OwnpconTblGuidLeftDerived(); |
13226 | ········otherVar = new AgrBin1OwnpconTblGuidRight(); |
13227 | ····} |
13228 | ····[TearDown] |
13229 | ····public void TearDown() |
13230 | ····{ |
13231 | ········try |
13232 | ········{ |
13233 | ············pm.UnloadCache(); |
13234 | ············var l = pm.Objects<AgrBin1OwnpconTblGuidLeftBase>().ResultTable; |
13235 | ············pm.Delete(l); |
13236 | ············pm.Save(); |
13237 | ············pm.UnloadCache(); |
13238 | ············var m = pm.Objects<AgrBin1OwnpconTblGuidRight>().ResultTable; |
13239 | ············pm.Delete(m); |
13240 | ············pm.Save(); |
13241 | ············pm.UnloadCache(); |
13242 | ············decimal count; |
13243 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13245 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13247 | ········} |
13248 | ········catch (Exception) |
13249 | ········{ |
13250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13253 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13254 | ········} |
13255 | ····} |
13256 | ····[Test] |
13257 | ····public void TestSaveReload() |
13258 | ····{ |
13259 | ········CreateObjects(); |
13260 | ········QueryOwn(); |
13261 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13262 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13263 | ····} |
13264 | ····[Test] |
13265 | ····public void TestSaveReloadNull() |
13266 | ····{ |
13267 | ········CreateObjects(); |
13268 | ········QueryOwn(); |
13269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13271 | ········ownVar.RelField = new List<AgrBin1OwnpconTblGuidRight>(); |
13272 | ········pm.Save(); |
13273 | ········pm.UnloadCache(); |
13274 | ········QueryOwn(); |
13275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13276 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13277 | ····} |
13278 | ····[Test] |
13279 | ····public void TestSaveReloadRemove() |
13280 | ····{ |
13281 | ········CreateObjects(); |
13282 | ········QueryOwn(); |
13283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13284 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13285 | ········ownVar.RemoveRelatedObject(); |
13286 | ········pm.Save(); |
13287 | ········pm.UnloadCache(); |
13288 | ········QueryOwn(); |
13289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13290 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13291 | ····} |
13292 | ····[Test] |
13293 | ····public void TestChangeKeyHolderRight() |
13294 | ····{ |
13295 | ········CreateObjects(); |
13296 | ········QueryOther(); |
13297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13298 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13299 | ········int x = otherVar.RelField.Dummy; |
13300 | ········otherVar.Dummy = 4711; |
13301 | ········pm.Save(); |
13302 | ········pm.UnloadCache(); |
13303 | ········QueryOther(); |
13304 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13305 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13307 | ····} |
13308 | ····[Test] |
13309 | ····public void TestChangeKeyHolderRightNoTouch() |
13310 | ····{ |
13311 | ········CreateObjects(); |
13312 | ········QueryOther(); |
13313 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13314 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13315 | ········otherVar.Dummy = 4711; |
13316 | ········pm.Save(); |
13317 | ········pm.UnloadCache(); |
13318 | ········QueryOther(); |
13319 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13320 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13321 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13322 | ····} |
13323 | ····[Test] |
13324 | ····public void TestRelationHash() |
13325 | ····{ |
13326 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidLeftBase)); |
13327 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13328 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidRight)); |
13329 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13330 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13331 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13332 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidLeftDerived)); |
13333 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13334 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13335 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13336 | ····} |
13337 | ····void CreateObjects() |
13338 | ····{ |
13339 | ········pm.MakePersistent(ownVar); |
13340 | ········pm.MakePersistent(otherVar); |
13341 | ········ownVar.AssignRelation(otherVar); |
13342 | ········pm.Save(); |
13343 | ········pm.UnloadCache(); |
13344 | ····} |
13345 | ····void QueryOwn() |
13346 | ····{ |
13347 | ········var q = new NDOQuery<AgrBin1OwnpconTblGuidLeftBase>(pm); |
13348 | ········ownVar = q.ExecuteSingle(); |
13349 | ····} |
13350 | ····void QueryOther() |
13351 | ····{ |
13352 | ········var q = new NDOQuery<AgrBin1OwnpconTblGuidRight>(pm); |
13353 | ········otherVar = q.ExecuteSingle(); |
13354 | ····} |
13355 | } |
13356 | |
13357 | |
13358 | [TestFixture] |
13359 | public class TestAgrBi1nOwnpconTblGuid : NDOTest |
13360 | { |
13361 | ····AgrBi1nOwnpconTblGuidLeftBase ownVar; |
13362 | ····AgrBi1nOwnpconTblGuidRight otherVar; |
13363 | ····PersistenceManager pm; |
13364 | ····[SetUp] |
13365 | ····public void Setup() |
13366 | ····{ |
13367 | ········pm = PmFactory.NewPersistenceManager(); |
13368 | ········ownVar = new AgrBi1nOwnpconTblGuidLeftDerived(); |
13369 | ········otherVar = new AgrBi1nOwnpconTblGuidRight(); |
13370 | ····} |
13371 | ····[TearDown] |
13372 | ····public void TearDown() |
13373 | ····{ |
13374 | ········try |
13375 | ········{ |
13376 | ············pm.UnloadCache(); |
13377 | ············var l = pm.Objects<AgrBi1nOwnpconTblGuidLeftBase>().ResultTable; |
13378 | ············pm.Delete(l); |
13379 | ············pm.Save(); |
13380 | ············pm.UnloadCache(); |
13381 | ············var m = pm.Objects<AgrBi1nOwnpconTblGuidRight>().ResultTable; |
13382 | ············pm.Delete(m); |
13383 | ············pm.Save(); |
13384 | ············pm.UnloadCache(); |
13385 | ············decimal count; |
13386 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13387 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13388 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13389 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13390 | ········} |
13391 | ········catch (Exception) |
13392 | ········{ |
13393 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13394 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13395 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13396 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13397 | ········} |
13398 | ····} |
13399 | ····[Test] |
13400 | ····public void TestSaveReload() |
13401 | ····{ |
13402 | ········CreateObjects(); |
13403 | ········QueryOwn(); |
13404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13405 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13406 | ····} |
13407 | ····[Test] |
13408 | ····public void TestSaveReloadNull() |
13409 | ····{ |
13410 | ········CreateObjects(); |
13411 | ········QueryOwn(); |
13412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13413 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13414 | ········ownVar.RelField = null; |
13415 | ········pm.Save(); |
13416 | ········pm.UnloadCache(); |
13417 | ········QueryOwn(); |
13418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13419 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13420 | ····} |
13421 | ····[Test] |
13422 | ····public void TestChangeKeyHolderLeft() |
13423 | ····{ |
13424 | ········CreateObjects(); |
13425 | ········QueryOwn(); |
13426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13427 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13428 | ········int x = ownVar.RelField.Dummy; |
13429 | ········ownVar.Dummy = 4711; |
13430 | ········pm.Save(); |
13431 | ········pm.UnloadCache(); |
13432 | ········QueryOwn(); |
13433 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13434 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13435 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13436 | ····} |
13437 | ····[Test] |
13438 | ····public void TestChangeKeyHolderLeftNoTouch() |
13439 | ····{ |
13440 | ········CreateObjects(); |
13441 | ········QueryOwn(); |
13442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13443 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13444 | ········ownVar.Dummy = 4711; |
13445 | ········pm.Save(); |
13446 | ········pm.UnloadCache(); |
13447 | ········QueryOwn(); |
13448 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13449 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13450 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13451 | ····} |
13452 | ····[Test] |
13453 | ····public void TestRelationHash() |
13454 | ····{ |
13455 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidLeftBase)); |
13456 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13457 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidRight)); |
13458 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13459 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13460 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13461 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidLeftDerived)); |
13462 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13463 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13464 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13465 | ····} |
13466 | ····void CreateObjects() |
13467 | ····{ |
13468 | ········pm.MakePersistent(ownVar); |
13469 | ········pm.MakePersistent(otherVar); |
13470 | ········ownVar.AssignRelation(otherVar); |
13471 | ········pm.Save(); |
13472 | ········pm.UnloadCache(); |
13473 | ····} |
13474 | ····void QueryOwn() |
13475 | ····{ |
13476 | ········var q = new NDOQuery<AgrBi1nOwnpconTblGuidLeftBase>(pm); |
13477 | ········ownVar = q.ExecuteSingle(); |
13478 | ····} |
13479 | ····void QueryOther() |
13480 | ····{ |
13481 | ········var q = new NDOQuery<AgrBi1nOwnpconTblGuidRight>(pm); |
13482 | ········otherVar = q.ExecuteSingle(); |
13483 | ····} |
13484 | } |
13485 | |
13486 | |
13487 | [TestFixture] |
13488 | public class TestAgrBinnOwnpconTblGuid : NDOTest |
13489 | { |
13490 | ····AgrBinnOwnpconTblGuidLeftBase ownVar; |
13491 | ····AgrBinnOwnpconTblGuidRight otherVar; |
13492 | ····PersistenceManager pm; |
13493 | ····[SetUp] |
13494 | ····public void Setup() |
13495 | ····{ |
13496 | ········pm = PmFactory.NewPersistenceManager(); |
13497 | ········ownVar = new AgrBinnOwnpconTblGuidLeftDerived(); |
13498 | ········otherVar = new AgrBinnOwnpconTblGuidRight(); |
13499 | ····} |
13500 | ····[TearDown] |
13501 | ····public void TearDown() |
13502 | ····{ |
13503 | ········try |
13504 | ········{ |
13505 | ············pm.UnloadCache(); |
13506 | ············var l = pm.Objects<AgrBinnOwnpconTblGuidLeftBase>().ResultTable; |
13507 | ············pm.Delete(l); |
13508 | ············pm.Save(); |
13509 | ············pm.UnloadCache(); |
13510 | ············var m = pm.Objects<AgrBinnOwnpconTblGuidRight>().ResultTable; |
13511 | ············pm.Delete(m); |
13512 | ············pm.Save(); |
13513 | ············pm.UnloadCache(); |
13514 | ············decimal count; |
13515 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13516 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13517 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13518 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13519 | ········} |
13520 | ········catch (Exception) |
13521 | ········{ |
13522 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13523 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13524 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13525 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13526 | ········} |
13527 | ····} |
13528 | ····[Test] |
13529 | ····public void TestSaveReload() |
13530 | ····{ |
13531 | ········CreateObjects(); |
13532 | ········QueryOwn(); |
13533 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13534 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13535 | ····} |
13536 | ····[Test] |
13537 | ····public void TestSaveReloadNull() |
13538 | ····{ |
13539 | ········CreateObjects(); |
13540 | ········QueryOwn(); |
13541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13542 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13543 | ········ownVar.RelField = new List<AgrBinnOwnpconTblGuidRight>(); |
13544 | ········pm.Save(); |
13545 | ········pm.UnloadCache(); |
13546 | ········QueryOwn(); |
13547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13548 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13549 | ····} |
13550 | ····[Test] |
13551 | ····public void TestSaveReloadRemove() |
13552 | ····{ |
13553 | ········CreateObjects(); |
13554 | ········QueryOwn(); |
13555 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13556 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13557 | ········ownVar.RemoveRelatedObject(); |
13558 | ········pm.Save(); |
13559 | ········pm.UnloadCache(); |
13560 | ········QueryOwn(); |
13561 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13562 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13563 | ····} |
13564 | ····[Test] |
13565 | ····public void TestRelationHash() |
13566 | ····{ |
13567 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidLeftBase)); |
13568 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13569 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidRight)); |
13570 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13571 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13572 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13573 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidLeftDerived)); |
13574 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13575 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13576 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13577 | ····} |
13578 | ····void CreateObjects() |
13579 | ····{ |
13580 | ········pm.MakePersistent(ownVar); |
13581 | ········pm.MakePersistent(otherVar); |
13582 | ········ownVar.AssignRelation(otherVar); |
13583 | ········pm.Save(); |
13584 | ········pm.UnloadCache(); |
13585 | ····} |
13586 | ····void QueryOwn() |
13587 | ····{ |
13588 | ········var q = new NDOQuery<AgrBinnOwnpconTblGuidLeftBase>(pm); |
13589 | ········ownVar = q.ExecuteSingle(); |
13590 | ····} |
13591 | ····void QueryOther() |
13592 | ····{ |
13593 | ········var q = new NDOQuery<AgrBinnOwnpconTblGuidRight>(pm); |
13594 | ········otherVar = q.ExecuteSingle(); |
13595 | ····} |
13596 | } |
13597 | |
13598 | |
13599 | [TestFixture] |
13600 | public class TestCmpDir1OwnpconNoTblGuid : NDOTest |
13601 | { |
13602 | ····CmpDir1OwnpconNoTblGuidLeftBase ownVar; |
13603 | ····CmpDir1OwnpconNoTblGuidRight otherVar; |
13604 | ····PersistenceManager pm; |
13605 | ····[SetUp] |
13606 | ····public void Setup() |
13607 | ····{ |
13608 | ········pm = PmFactory.NewPersistenceManager(); |
13609 | ········ownVar = new CmpDir1OwnpconNoTblGuidLeftDerived(); |
13610 | ········otherVar = new CmpDir1OwnpconNoTblGuidRight(); |
13611 | ····} |
13612 | ····[TearDown] |
13613 | ····public void TearDown() |
13614 | ····{ |
13615 | ········try |
13616 | ········{ |
13617 | ············pm.UnloadCache(); |
13618 | ············var l = pm.Objects<CmpDir1OwnpconNoTblGuidLeftBase>().ResultTable; |
13619 | ············pm.Delete(l); |
13620 | ············pm.Save(); |
13621 | ············pm.UnloadCache(); |
13622 | ············decimal count; |
13623 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13625 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13626 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13627 | ········} |
13628 | ········catch (Exception) |
13629 | ········{ |
13630 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13631 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13632 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13633 | ········} |
13634 | ····} |
13635 | ····[Test] |
13636 | ····public void TestSaveReload() |
13637 | ····{ |
13638 | ········CreateObjects(); |
13639 | ········QueryOwn(); |
13640 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13641 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13642 | ····} |
13643 | ····[Test] |
13644 | ····public void TestSaveReloadNull() |
13645 | ····{ |
13646 | ········CreateObjects(); |
13647 | ········QueryOwn(); |
13648 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13649 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13650 | ········ownVar.RelField = null; |
13651 | ········pm.Save(); |
13652 | ········pm.UnloadCache(); |
13653 | ········QueryOwn(); |
13654 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13655 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13656 | ····} |
13657 | ····[Test] |
13658 | ····public void TestChangeKeyHolderLeft() |
13659 | ····{ |
13660 | ········CreateObjects(); |
13661 | ········QueryOwn(); |
13662 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13663 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13664 | ········int x = ownVar.RelField.Dummy; |
13665 | ········ownVar.Dummy = 4711; |
13666 | ········pm.Save(); |
13667 | ········pm.UnloadCache(); |
13668 | ········QueryOwn(); |
13669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13670 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13671 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13672 | ····} |
13673 | ····[Test] |
13674 | ····public void TestChangeKeyHolderLeftNoTouch() |
13675 | ····{ |
13676 | ········CreateObjects(); |
13677 | ········QueryOwn(); |
13678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13679 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13680 | ········ownVar.Dummy = 4711; |
13681 | ········pm.Save(); |
13682 | ········pm.UnloadCache(); |
13683 | ········QueryOwn(); |
13684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13685 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13686 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13687 | ····} |
13688 | ····void CreateObjects() |
13689 | ····{ |
13690 | ········pm.MakePersistent(ownVar); |
13691 | ········ownVar.AssignRelation(otherVar); |
13692 | ········pm.Save(); |
13693 | ········pm.UnloadCache(); |
13694 | ····} |
13695 | ····void QueryOwn() |
13696 | ····{ |
13697 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblGuidLeftBase>(pm); |
13698 | ········ownVar = q.ExecuteSingle(); |
13699 | ····} |
13700 | ····void QueryOther() |
13701 | ····{ |
13702 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblGuidRight>(pm); |
13703 | ········otherVar = q.ExecuteSingle(); |
13704 | ····} |
13705 | } |
13706 | |
13707 | |
13708 | [TestFixture] |
13709 | public class TestCmpDir1OwnpconTblGuid : NDOTest |
13710 | { |
13711 | ····CmpDir1OwnpconTblGuidLeftBase ownVar; |
13712 | ····CmpDir1OwnpconTblGuidRight otherVar; |
13713 | ····PersistenceManager pm; |
13714 | ····[SetUp] |
13715 | ····public void Setup() |
13716 | ····{ |
13717 | ········pm = PmFactory.NewPersistenceManager(); |
13718 | ········ownVar = new CmpDir1OwnpconTblGuidLeftDerived(); |
13719 | ········otherVar = new CmpDir1OwnpconTblGuidRight(); |
13720 | ····} |
13721 | ····[TearDown] |
13722 | ····public void TearDown() |
13723 | ····{ |
13724 | ········try |
13725 | ········{ |
13726 | ············pm.UnloadCache(); |
13727 | ············var l = pm.Objects<CmpDir1OwnpconTblGuidLeftBase>().ResultTable; |
13728 | ············pm.Delete(l); |
13729 | ············pm.Save(); |
13730 | ············pm.UnloadCache(); |
13731 | ············decimal count; |
13732 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13733 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13734 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13735 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13736 | ········} |
13737 | ········catch (Exception) |
13738 | ········{ |
13739 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13740 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13741 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13742 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13743 | ········} |
13744 | ····} |
13745 | ····[Test] |
13746 | ····public void TestSaveReload() |
13747 | ····{ |
13748 | ········CreateObjects(); |
13749 | ········QueryOwn(); |
13750 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13751 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13752 | ····} |
13753 | ····[Test] |
13754 | ····public void TestSaveReloadNull() |
13755 | ····{ |
13756 | ········CreateObjects(); |
13757 | ········QueryOwn(); |
13758 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13759 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13760 | ········ownVar.RelField = null; |
13761 | ········pm.Save(); |
13762 | ········pm.UnloadCache(); |
13763 | ········QueryOwn(); |
13764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13765 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13766 | ····} |
13767 | ····[Test] |
13768 | ····public void TestChangeKeyHolderLeft() |
13769 | ····{ |
13770 | ········CreateObjects(); |
13771 | ········QueryOwn(); |
13772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13773 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13774 | ········int x = ownVar.RelField.Dummy; |
13775 | ········ownVar.Dummy = 4711; |
13776 | ········pm.Save(); |
13777 | ········pm.UnloadCache(); |
13778 | ········QueryOwn(); |
13779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13780 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13781 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13782 | ····} |
13783 | ····[Test] |
13784 | ····public void TestChangeKeyHolderLeftNoTouch() |
13785 | ····{ |
13786 | ········CreateObjects(); |
13787 | ········QueryOwn(); |
13788 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13789 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13790 | ········ownVar.Dummy = 4711; |
13791 | ········pm.Save(); |
13792 | ········pm.UnloadCache(); |
13793 | ········QueryOwn(); |
13794 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13795 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13796 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13797 | ····} |
13798 | ····void CreateObjects() |
13799 | ····{ |
13800 | ········pm.MakePersistent(ownVar); |
13801 | ········ownVar.AssignRelation(otherVar); |
13802 | ········pm.Save(); |
13803 | ········pm.UnloadCache(); |
13804 | ····} |
13805 | ····void QueryOwn() |
13806 | ····{ |
13807 | ········var q = new NDOQuery<CmpDir1OwnpconTblGuidLeftBase>(pm); |
13808 | ········ownVar = q.ExecuteSingle(); |
13809 | ····} |
13810 | ····void QueryOther() |
13811 | ····{ |
13812 | ········var q = new NDOQuery<CmpDir1OwnpconTblGuidRight>(pm); |
13813 | ········otherVar = q.ExecuteSingle(); |
13814 | ····} |
13815 | } |
13816 | |
13817 | |
13818 | [TestFixture] |
13819 | public class TestCmpBi11OwnpconNoTblGuid : NDOTest |
13820 | { |
13821 | ····CmpBi11OwnpconNoTblGuidLeftBase ownVar; |
13822 | ····CmpBi11OwnpconNoTblGuidRight otherVar; |
13823 | ····PersistenceManager pm; |
13824 | ····[SetUp] |
13825 | ····public void Setup() |
13826 | ····{ |
13827 | ········pm = PmFactory.NewPersistenceManager(); |
13828 | ········ownVar = new CmpBi11OwnpconNoTblGuidLeftDerived(); |
13829 | ········otherVar = new CmpBi11OwnpconNoTblGuidRight(); |
13830 | ····} |
13831 | ····[TearDown] |
13832 | ····public void TearDown() |
13833 | ····{ |
13834 | ········try |
13835 | ········{ |
13836 | ············pm.UnloadCache(); |
13837 | ············var l = pm.Objects<CmpBi11OwnpconNoTblGuidLeftBase>().ResultTable; |
13838 | ············pm.Delete(l); |
13839 | ············pm.Save(); |
13840 | ············pm.UnloadCache(); |
13841 | ············decimal count; |
13842 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13843 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13844 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13845 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13846 | ········} |
13847 | ········catch (Exception) |
13848 | ········{ |
13849 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13850 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13851 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13852 | ········} |
13853 | ····} |
13854 | ····[Test] |
13855 | ····public void TestSaveReload() |
13856 | ····{ |
13857 | ········CreateObjects(); |
13858 | ········QueryOwn(); |
13859 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13861 | ····} |
13862 | ····[Test] |
13863 | ····public void TestSaveReloadNull() |
13864 | ····{ |
13865 | ········CreateObjects(); |
13866 | ········QueryOwn(); |
13867 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13868 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13869 | ········ownVar.RelField = null; |
13870 | ········pm.Save(); |
13871 | ········pm.UnloadCache(); |
13872 | ········QueryOwn(); |
13873 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13874 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13875 | ····} |
13876 | ····[Test] |
13877 | ····public void TestChangeKeyHolderLeft() |
13878 | ····{ |
13879 | ········CreateObjects(); |
13880 | ········QueryOwn(); |
13881 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13882 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13883 | ········int x = ownVar.RelField.Dummy; |
13884 | ········ownVar.Dummy = 4711; |
13885 | ········pm.Save(); |
13886 | ········pm.UnloadCache(); |
13887 | ········QueryOwn(); |
13888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13889 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13890 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13891 | ····} |
13892 | ····[Test] |
13893 | ····public void TestChangeKeyHolderRight() |
13894 | ····{ |
13895 | ········CreateObjects(); |
13896 | ········QueryOther(); |
13897 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13898 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13899 | ········int x = otherVar.RelField.Dummy; |
13900 | ········otherVar.Dummy = 4711; |
13901 | ········pm.Save(); |
13902 | ········pm.UnloadCache(); |
13903 | ········QueryOther(); |
13904 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13905 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13906 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13907 | ····} |
13908 | ····[Test] |
13909 | ····public void TestChangeKeyHolderLeftNoTouch() |
13910 | ····{ |
13911 | ········CreateObjects(); |
13912 | ········QueryOwn(); |
13913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13915 | ········ownVar.Dummy = 4711; |
13916 | ········pm.Save(); |
13917 | ········pm.UnloadCache(); |
13918 | ········QueryOwn(); |
13919 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13920 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13921 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13922 | ····} |
13923 | ····[Test] |
13924 | ····public void TestChangeKeyHolderRightNoTouch() |
13925 | ····{ |
13926 | ········CreateObjects(); |
13927 | ········QueryOther(); |
13928 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13929 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13930 | ········otherVar.Dummy = 4711; |
13931 | ········pm.Save(); |
13932 | ········pm.UnloadCache(); |
13933 | ········QueryOther(); |
13934 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13935 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13936 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13937 | ····} |
13938 | ····[Test] |
13939 | ····public void TestRelationHash() |
13940 | ····{ |
13941 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidLeftBase)); |
13942 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13943 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidRight)); |
13944 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13945 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13946 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13947 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidLeftDerived)); |
13948 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13949 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13950 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13951 | ····} |
13952 | ····void CreateObjects() |
13953 | ····{ |
13954 | ········pm.MakePersistent(ownVar); |
13955 | ········ownVar.AssignRelation(otherVar); |
13956 | ········pm.Save(); |
13957 | ········pm.UnloadCache(); |
13958 | ····} |
13959 | ····void QueryOwn() |
13960 | ····{ |
13961 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblGuidLeftBase>(pm); |
13962 | ········ownVar = q.ExecuteSingle(); |
13963 | ····} |
13964 | ····void QueryOther() |
13965 | ····{ |
13966 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblGuidRight>(pm); |
13967 | ········otherVar = q.ExecuteSingle(); |
13968 | ····} |
13969 | } |
13970 | |
13971 | |
13972 | [TestFixture] |
13973 | public class TestCmpBi11OwnpconTblGuid : NDOTest |
13974 | { |
13975 | ····CmpBi11OwnpconTblGuidLeftBase ownVar; |
13976 | ····CmpBi11OwnpconTblGuidRight otherVar; |
13977 | ····PersistenceManager pm; |
13978 | ····[SetUp] |
13979 | ····public void Setup() |
13980 | ····{ |
13981 | ········pm = PmFactory.NewPersistenceManager(); |
13982 | ········ownVar = new CmpBi11OwnpconTblGuidLeftDerived(); |
13983 | ········otherVar = new CmpBi11OwnpconTblGuidRight(); |
13984 | ····} |
13985 | ····[TearDown] |
13986 | ····public void TearDown() |
13987 | ····{ |
13988 | ········try |
13989 | ········{ |
13990 | ············pm.UnloadCache(); |
13991 | ············var l = pm.Objects<CmpBi11OwnpconTblGuidLeftBase>().ResultTable; |
13992 | ············pm.Delete(l); |
13993 | ············pm.Save(); |
13994 | ············pm.UnloadCache(); |
13995 | ············decimal count; |
13996 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13997 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13998 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13999 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14000 | ········} |
14001 | ········catch (Exception) |
14002 | ········{ |
14003 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14004 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14005 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14006 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14007 | ········} |
14008 | ····} |
14009 | ····[Test] |
14010 | ····public void TestSaveReload() |
14011 | ····{ |
14012 | ········CreateObjects(); |
14013 | ········QueryOwn(); |
14014 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14015 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14016 | ····} |
14017 | ····[Test] |
14018 | ····public void TestSaveReloadNull() |
14019 | ····{ |
14020 | ········CreateObjects(); |
14021 | ········QueryOwn(); |
14022 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14023 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14024 | ········ownVar.RelField = null; |
14025 | ········pm.Save(); |
14026 | ········pm.UnloadCache(); |
14027 | ········QueryOwn(); |
14028 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14029 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14030 | ····} |
14031 | ····[Test] |
14032 | ····public void TestChangeKeyHolderLeft() |
14033 | ····{ |
14034 | ········CreateObjects(); |
14035 | ········QueryOwn(); |
14036 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14037 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14038 | ········int x = ownVar.RelField.Dummy; |
14039 | ········ownVar.Dummy = 4711; |
14040 | ········pm.Save(); |
14041 | ········pm.UnloadCache(); |
14042 | ········QueryOwn(); |
14043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14044 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14045 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14046 | ····} |
14047 | ····[Test] |
14048 | ····public void TestChangeKeyHolderRight() |
14049 | ····{ |
14050 | ········CreateObjects(); |
14051 | ········QueryOther(); |
14052 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14053 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14054 | ········int x = otherVar.RelField.Dummy; |
14055 | ········otherVar.Dummy = 4711; |
14056 | ········pm.Save(); |
14057 | ········pm.UnloadCache(); |
14058 | ········QueryOther(); |
14059 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14060 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14061 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14062 | ····} |
14063 | ····[Test] |
14064 | ····public void TestChangeKeyHolderLeftNoTouch() |
14065 | ····{ |
14066 | ········CreateObjects(); |
14067 | ········QueryOwn(); |
14068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14070 | ········ownVar.Dummy = 4711; |
14071 | ········pm.Save(); |
14072 | ········pm.UnloadCache(); |
14073 | ········QueryOwn(); |
14074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14075 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14076 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14077 | ····} |
14078 | ····[Test] |
14079 | ····public void TestChangeKeyHolderRightNoTouch() |
14080 | ····{ |
14081 | ········CreateObjects(); |
14082 | ········QueryOther(); |
14083 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14084 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14085 | ········otherVar.Dummy = 4711; |
14086 | ········pm.Save(); |
14087 | ········pm.UnloadCache(); |
14088 | ········QueryOther(); |
14089 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14090 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14091 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14092 | ····} |
14093 | ····[Test] |
14094 | ····public void TestRelationHash() |
14095 | ····{ |
14096 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidLeftBase)); |
14097 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14098 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidRight)); |
14099 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14100 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14101 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14102 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidLeftDerived)); |
14103 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14104 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14105 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14106 | ····} |
14107 | ····void CreateObjects() |
14108 | ····{ |
14109 | ········pm.MakePersistent(ownVar); |
14110 | ········ownVar.AssignRelation(otherVar); |
14111 | ········pm.Save(); |
14112 | ········pm.UnloadCache(); |
14113 | ····} |
14114 | ····void QueryOwn() |
14115 | ····{ |
14116 | ········var q = new NDOQuery<CmpBi11OwnpconTblGuidLeftBase>(pm); |
14117 | ········ownVar = q.ExecuteSingle(); |
14118 | ····} |
14119 | ····void QueryOther() |
14120 | ····{ |
14121 | ········var q = new NDOQuery<CmpBi11OwnpconTblGuidRight>(pm); |
14122 | ········otherVar = q.ExecuteSingle(); |
14123 | ····} |
14124 | } |
14125 | |
14126 | |
14127 | [TestFixture] |
14128 | public class TestCmpDirnOwnpconNoTblGuid : NDOTest |
14129 | { |
14130 | ····CmpDirnOwnpconNoTblGuidLeftBase ownVar; |
14131 | ····CmpDirnOwnpconNoTblGuidRight otherVar; |
14132 | ····PersistenceManager pm; |
14133 | ····[SetUp] |
14134 | ····public void Setup() |
14135 | ····{ |
14136 | ········pm = PmFactory.NewPersistenceManager(); |
14137 | ········ownVar = new CmpDirnOwnpconNoTblGuidLeftDerived(); |
14138 | ········otherVar = new CmpDirnOwnpconNoTblGuidRight(); |
14139 | ····} |
14140 | ····[TearDown] |
14141 | ····public void TearDown() |
14142 | ····{ |
14143 | ········try |
14144 | ········{ |
14145 | ············pm.UnloadCache(); |
14146 | ············var l = pm.Objects<CmpDirnOwnpconNoTblGuidLeftBase>().ResultTable; |
14147 | ············pm.Delete(l); |
14148 | ············pm.Save(); |
14149 | ············pm.UnloadCache(); |
14150 | ············decimal count; |
14151 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14152 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14153 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14154 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14155 | ········} |
14156 | ········catch (Exception) |
14157 | ········{ |
14158 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14159 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14160 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14161 | ········} |
14162 | ····} |
14163 | ····[Test] |
14164 | ····public void TestSaveReload() |
14165 | ····{ |
14166 | ········CreateObjects(); |
14167 | ········QueryOwn(); |
14168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14169 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14170 | ····} |
14171 | ····[Test] |
14172 | ····public void TestSaveReloadNull() |
14173 | ····{ |
14174 | ········CreateObjects(); |
14175 | ········QueryOwn(); |
14176 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14177 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14178 | ········ownVar.RelField = new List<CmpDirnOwnpconNoTblGuidRight>(); |
14179 | ········pm.Save(); |
14180 | ········pm.UnloadCache(); |
14181 | ········QueryOwn(); |
14182 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14183 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14184 | ····} |
14185 | ····[Test] |
14186 | ····public void TestSaveReloadRemove() |
14187 | ····{ |
14188 | ········CreateObjects(); |
14189 | ········QueryOwn(); |
14190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14191 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14192 | ········ownVar.RemoveRelatedObject(); |
14193 | ········pm.Save(); |
14194 | ········pm.UnloadCache(); |
14195 | ········QueryOwn(); |
14196 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14197 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14198 | ····} |
14199 | ····void CreateObjects() |
14200 | ····{ |
14201 | ········pm.MakePersistent(ownVar); |
14202 | ········ownVar.AssignRelation(otherVar); |
14203 | ········pm.Save(); |
14204 | ········pm.UnloadCache(); |
14205 | ····} |
14206 | ····void QueryOwn() |
14207 | ····{ |
14208 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblGuidLeftBase>(pm); |
14209 | ········ownVar = q.ExecuteSingle(); |
14210 | ····} |
14211 | ····void QueryOther() |
14212 | ····{ |
14213 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblGuidRight>(pm); |
14214 | ········otherVar = q.ExecuteSingle(); |
14215 | ····} |
14216 | } |
14217 | |
14218 | |
14219 | [TestFixture] |
14220 | public class TestCmpDirnOwnpconTblGuid : NDOTest |
14221 | { |
14222 | ····CmpDirnOwnpconTblGuidLeftBase ownVar; |
14223 | ····CmpDirnOwnpconTblGuidRight otherVar; |
14224 | ····PersistenceManager pm; |
14225 | ····[SetUp] |
14226 | ····public void Setup() |
14227 | ····{ |
14228 | ········pm = PmFactory.NewPersistenceManager(); |
14229 | ········ownVar = new CmpDirnOwnpconTblGuidLeftDerived(); |
14230 | ········otherVar = new CmpDirnOwnpconTblGuidRight(); |
14231 | ····} |
14232 | ····[TearDown] |
14233 | ····public void TearDown() |
14234 | ····{ |
14235 | ········try |
14236 | ········{ |
14237 | ············pm.UnloadCache(); |
14238 | ············var l = pm.Objects<CmpDirnOwnpconTblGuidLeftBase>().ResultTable; |
14239 | ············pm.Delete(l); |
14240 | ············pm.Save(); |
14241 | ············pm.UnloadCache(); |
14242 | ············decimal count; |
14243 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14245 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14247 | ········} |
14248 | ········catch (Exception) |
14249 | ········{ |
14250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14253 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14254 | ········} |
14255 | ····} |
14256 | ····[Test] |
14257 | ····public void TestSaveReload() |
14258 | ····{ |
14259 | ········CreateObjects(); |
14260 | ········QueryOwn(); |
14261 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14262 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14263 | ····} |
14264 | ····[Test] |
14265 | ····public void TestSaveReloadNull() |
14266 | ····{ |
14267 | ········CreateObjects(); |
14268 | ········QueryOwn(); |
14269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14271 | ········ownVar.RelField = new List<CmpDirnOwnpconTblGuidRight>(); |
14272 | ········pm.Save(); |
14273 | ········pm.UnloadCache(); |
14274 | ········QueryOwn(); |
14275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14276 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14277 | ····} |
14278 | ····[Test] |
14279 | ····public void TestSaveReloadRemove() |
14280 | ····{ |
14281 | ········CreateObjects(); |
14282 | ········QueryOwn(); |
14283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14284 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14285 | ········ownVar.RemoveRelatedObject(); |
14286 | ········pm.Save(); |
14287 | ········pm.UnloadCache(); |
14288 | ········QueryOwn(); |
14289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14290 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14291 | ····} |
14292 | ····void CreateObjects() |
14293 | ····{ |
14294 | ········pm.MakePersistent(ownVar); |
14295 | ········ownVar.AssignRelation(otherVar); |
14296 | ········pm.Save(); |
14297 | ········pm.UnloadCache(); |
14298 | ····} |
14299 | ····void QueryOwn() |
14300 | ····{ |
14301 | ········var q = new NDOQuery<CmpDirnOwnpconTblGuidLeftBase>(pm); |
14302 | ········ownVar = q.ExecuteSingle(); |
14303 | ····} |
14304 | ····void QueryOther() |
14305 | ····{ |
14306 | ········var q = new NDOQuery<CmpDirnOwnpconTblGuidRight>(pm); |
14307 | ········otherVar = q.ExecuteSingle(); |
14308 | ····} |
14309 | } |
14310 | |
14311 | |
14312 | [TestFixture] |
14313 | public class TestCmpBin1OwnpconNoTblGuid : NDOTest |
14314 | { |
14315 | ····CmpBin1OwnpconNoTblGuidLeftBase ownVar; |
14316 | ····CmpBin1OwnpconNoTblGuidRight otherVar; |
14317 | ····PersistenceManager pm; |
14318 | ····[SetUp] |
14319 | ····public void Setup() |
14320 | ····{ |
14321 | ········pm = PmFactory.NewPersistenceManager(); |
14322 | ········ownVar = new CmpBin1OwnpconNoTblGuidLeftDerived(); |
14323 | ········otherVar = new CmpBin1OwnpconNoTblGuidRight(); |
14324 | ····} |
14325 | ····[TearDown] |
14326 | ····public void TearDown() |
14327 | ····{ |
14328 | ········try |
14329 | ········{ |
14330 | ············pm.UnloadCache(); |
14331 | ············var l = pm.Objects<CmpBin1OwnpconNoTblGuidLeftBase>().ResultTable; |
14332 | ············pm.Delete(l); |
14333 | ············pm.Save(); |
14334 | ············pm.UnloadCache(); |
14335 | ············decimal count; |
14336 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14337 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14338 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14339 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14340 | ········} |
14341 | ········catch (Exception) |
14342 | ········{ |
14343 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14344 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14345 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14346 | ········} |
14347 | ····} |
14348 | ····[Test] |
14349 | ····public void TestSaveReload() |
14350 | ····{ |
14351 | ········CreateObjects(); |
14352 | ········QueryOwn(); |
14353 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14354 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14355 | ····} |
14356 | ····[Test] |
14357 | ····public void TestSaveReloadNull() |
14358 | ····{ |
14359 | ········CreateObjects(); |
14360 | ········QueryOwn(); |
14361 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14362 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14363 | ········ownVar.RelField = new List<CmpBin1OwnpconNoTblGuidRight>(); |
14364 | ········pm.Save(); |
14365 | ········pm.UnloadCache(); |
14366 | ········QueryOwn(); |
14367 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14368 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14369 | ····} |
14370 | ····[Test] |
14371 | ····public void TestSaveReloadRemove() |
14372 | ····{ |
14373 | ········CreateObjects(); |
14374 | ········QueryOwn(); |
14375 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14376 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14377 | ········ownVar.RemoveRelatedObject(); |
14378 | ········pm.Save(); |
14379 | ········pm.UnloadCache(); |
14380 | ········QueryOwn(); |
14381 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14382 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14383 | ····} |
14384 | ····[Test] |
14385 | ····public void TestChangeKeyHolderRight() |
14386 | ····{ |
14387 | ········CreateObjects(); |
14388 | ········QueryOther(); |
14389 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14390 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14391 | ········int x = otherVar.RelField.Dummy; |
14392 | ········otherVar.Dummy = 4711; |
14393 | ········pm.Save(); |
14394 | ········pm.UnloadCache(); |
14395 | ········QueryOther(); |
14396 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14397 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14398 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14399 | ····} |
14400 | ····[Test] |
14401 | ····public void TestChangeKeyHolderRightNoTouch() |
14402 | ····{ |
14403 | ········CreateObjects(); |
14404 | ········QueryOther(); |
14405 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14406 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14407 | ········otherVar.Dummy = 4711; |
14408 | ········pm.Save(); |
14409 | ········pm.UnloadCache(); |
14410 | ········QueryOther(); |
14411 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14412 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14413 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14414 | ····} |
14415 | ····[Test] |
14416 | ····public void TestRelationHash() |
14417 | ····{ |
14418 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidLeftBase)); |
14419 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14420 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidRight)); |
14421 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14422 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14423 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14424 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidLeftDerived)); |
14425 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14426 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14427 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14428 | ····} |
14429 | ····void CreateObjects() |
14430 | ····{ |
14431 | ········pm.MakePersistent(ownVar); |
14432 | ········ownVar.AssignRelation(otherVar); |
14433 | ········pm.Save(); |
14434 | ········pm.UnloadCache(); |
14435 | ····} |
14436 | ····void QueryOwn() |
14437 | ····{ |
14438 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblGuidLeftBase>(pm); |
14439 | ········ownVar = q.ExecuteSingle(); |
14440 | ····} |
14441 | ····void QueryOther() |
14442 | ····{ |
14443 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblGuidRight>(pm); |
14444 | ········otherVar = q.ExecuteSingle(); |
14445 | ····} |
14446 | } |
14447 | |
14448 | |
14449 | [TestFixture] |
14450 | public class TestCmpBin1OwnpconTblGuid : NDOTest |
14451 | { |
14452 | ····CmpBin1OwnpconTblGuidLeftBase ownVar; |
14453 | ····CmpBin1OwnpconTblGuidRight otherVar; |
14454 | ····PersistenceManager pm; |
14455 | ····[SetUp] |
14456 | ····public void Setup() |
14457 | ····{ |
14458 | ········pm = PmFactory.NewPersistenceManager(); |
14459 | ········ownVar = new CmpBin1OwnpconTblGuidLeftDerived(); |
14460 | ········otherVar = new CmpBin1OwnpconTblGuidRight(); |
14461 | ····} |
14462 | ····[TearDown] |
14463 | ····public void TearDown() |
14464 | ····{ |
14465 | ········try |
14466 | ········{ |
14467 | ············pm.UnloadCache(); |
14468 | ············var l = pm.Objects<CmpBin1OwnpconTblGuidLeftBase>().ResultTable; |
14469 | ············pm.Delete(l); |
14470 | ············pm.Save(); |
14471 | ············pm.UnloadCache(); |
14472 | ············decimal count; |
14473 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14474 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14475 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14476 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14477 | ········} |
14478 | ········catch (Exception) |
14479 | ········{ |
14480 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14481 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14482 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14483 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14484 | ········} |
14485 | ····} |
14486 | ····[Test] |
14487 | ····public void TestSaveReload() |
14488 | ····{ |
14489 | ········CreateObjects(); |
14490 | ········QueryOwn(); |
14491 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14492 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14493 | ····} |
14494 | ····[Test] |
14495 | ····public void TestSaveReloadNull() |
14496 | ····{ |
14497 | ········CreateObjects(); |
14498 | ········QueryOwn(); |
14499 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14500 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14501 | ········ownVar.RelField = new List<CmpBin1OwnpconTblGuidRight>(); |
14502 | ········pm.Save(); |
14503 | ········pm.UnloadCache(); |
14504 | ········QueryOwn(); |
14505 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14506 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14507 | ····} |
14508 | ····[Test] |
14509 | ····public void TestSaveReloadRemove() |
14510 | ····{ |
14511 | ········CreateObjects(); |
14512 | ········QueryOwn(); |
14513 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14514 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14515 | ········ownVar.RemoveRelatedObject(); |
14516 | ········pm.Save(); |
14517 | ········pm.UnloadCache(); |
14518 | ········QueryOwn(); |
14519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14520 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14521 | ····} |
14522 | ····[Test] |
14523 | ····public void TestChangeKeyHolderRight() |
14524 | ····{ |
14525 | ········CreateObjects(); |
14526 | ········QueryOther(); |
14527 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14528 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14529 | ········int x = otherVar.RelField.Dummy; |
14530 | ········otherVar.Dummy = 4711; |
14531 | ········pm.Save(); |
14532 | ········pm.UnloadCache(); |
14533 | ········QueryOther(); |
14534 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14535 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14536 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14537 | ····} |
14538 | ····[Test] |
14539 | ····public void TestChangeKeyHolderRightNoTouch() |
14540 | ····{ |
14541 | ········CreateObjects(); |
14542 | ········QueryOther(); |
14543 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14544 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14545 | ········otherVar.Dummy = 4711; |
14546 | ········pm.Save(); |
14547 | ········pm.UnloadCache(); |
14548 | ········QueryOther(); |
14549 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14550 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14551 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14552 | ····} |
14553 | ····[Test] |
14554 | ····public void TestRelationHash() |
14555 | ····{ |
14556 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidLeftBase)); |
14557 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14558 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidRight)); |
14559 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14560 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14561 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14562 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidLeftDerived)); |
14563 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14564 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14565 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14566 | ····} |
14567 | ····void CreateObjects() |
14568 | ····{ |
14569 | ········pm.MakePersistent(ownVar); |
14570 | ········ownVar.AssignRelation(otherVar); |
14571 | ········pm.Save(); |
14572 | ········pm.UnloadCache(); |
14573 | ····} |
14574 | ····void QueryOwn() |
14575 | ····{ |
14576 | ········var q = new NDOQuery<CmpBin1OwnpconTblGuidLeftBase>(pm); |
14577 | ········ownVar = q.ExecuteSingle(); |
14578 | ····} |
14579 | ····void QueryOther() |
14580 | ····{ |
14581 | ········var q = new NDOQuery<CmpBin1OwnpconTblGuidRight>(pm); |
14582 | ········otherVar = q.ExecuteSingle(); |
14583 | ····} |
14584 | } |
14585 | |
14586 | |
14587 | [TestFixture] |
14588 | public class TestCmpBi1nOwnpconTblGuid : NDOTest |
14589 | { |
14590 | ····CmpBi1nOwnpconTblGuidLeftBase ownVar; |
14591 | ····CmpBi1nOwnpconTblGuidRight otherVar; |
14592 | ····PersistenceManager pm; |
14593 | ····[SetUp] |
14594 | ····public void Setup() |
14595 | ····{ |
14596 | ········pm = PmFactory.NewPersistenceManager(); |
14597 | ········ownVar = new CmpBi1nOwnpconTblGuidLeftDerived(); |
14598 | ········otherVar = new CmpBi1nOwnpconTblGuidRight(); |
14599 | ····} |
14600 | ····[TearDown] |
14601 | ····public void TearDown() |
14602 | ····{ |
14603 | ········try |
14604 | ········{ |
14605 | ············pm.UnloadCache(); |
14606 | ············var l = pm.Objects<CmpBi1nOwnpconTblGuidLeftBase>().ResultTable; |
14607 | ············pm.Delete(l); |
14608 | ············pm.Save(); |
14609 | ············pm.UnloadCache(); |
14610 | ············decimal count; |
14611 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14612 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14613 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14614 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14615 | ········} |
14616 | ········catch (Exception) |
14617 | ········{ |
14618 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14619 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14620 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14621 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14622 | ········} |
14623 | ····} |
14624 | ····[Test] |
14625 | ····public void TestSaveReload() |
14626 | ····{ |
14627 | ········CreateObjects(); |
14628 | ········QueryOwn(); |
14629 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14630 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14631 | ····} |
14632 | ····[Test] |
14633 | ····public void TestSaveReloadNull() |
14634 | ····{ |
14635 | ········CreateObjects(); |
14636 | ········QueryOwn(); |
14637 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14638 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14639 | ········ownVar.RelField = null; |
14640 | ········pm.Save(); |
14641 | ········pm.UnloadCache(); |
14642 | ········QueryOwn(); |
14643 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14644 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14645 | ····} |
14646 | ····[Test] |
14647 | ····public void TestChangeKeyHolderLeft() |
14648 | ····{ |
14649 | ········CreateObjects(); |
14650 | ········QueryOwn(); |
14651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14652 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14653 | ········int x = ownVar.RelField.Dummy; |
14654 | ········ownVar.Dummy = 4711; |
14655 | ········pm.Save(); |
14656 | ········pm.UnloadCache(); |
14657 | ········QueryOwn(); |
14658 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14659 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14660 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14661 | ····} |
14662 | ····[Test] |
14663 | ····public void TestChangeKeyHolderLeftNoTouch() |
14664 | ····{ |
14665 | ········CreateObjects(); |
14666 | ········QueryOwn(); |
14667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14669 | ········ownVar.Dummy = 4711; |
14670 | ········pm.Save(); |
14671 | ········pm.UnloadCache(); |
14672 | ········QueryOwn(); |
14673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14674 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14676 | ····} |
14677 | ····[Test] |
14678 | ····public void TestRelationHash() |
14679 | ····{ |
14680 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidLeftBase)); |
14681 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14682 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidRight)); |
14683 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14684 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14685 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14686 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidLeftDerived)); |
14687 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14688 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14689 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14690 | ····} |
14691 | ····void CreateObjects() |
14692 | ····{ |
14693 | ········pm.MakePersistent(ownVar); |
14694 | ········ownVar.AssignRelation(otherVar); |
14695 | ········pm.Save(); |
14696 | ········pm.UnloadCache(); |
14697 | ····} |
14698 | ····void QueryOwn() |
14699 | ····{ |
14700 | ········var q = new NDOQuery<CmpBi1nOwnpconTblGuidLeftBase>(pm); |
14701 | ········ownVar = q.ExecuteSingle(); |
14702 | ····} |
14703 | ····void QueryOther() |
14704 | ····{ |
14705 | ········var q = new NDOQuery<CmpBi1nOwnpconTblGuidRight>(pm); |
14706 | ········otherVar = q.ExecuteSingle(); |
14707 | ····} |
14708 | } |
14709 | |
14710 | |
14711 | [TestFixture] |
14712 | public class TestCmpBinnOwnpconTblGuid : NDOTest |
14713 | { |
14714 | ····CmpBinnOwnpconTblGuidLeftBase ownVar; |
14715 | ····CmpBinnOwnpconTblGuidRight otherVar; |
14716 | ····PersistenceManager pm; |
14717 | ····[SetUp] |
14718 | ····public void Setup() |
14719 | ····{ |
14720 | ········pm = PmFactory.NewPersistenceManager(); |
14721 | ········ownVar = new CmpBinnOwnpconTblGuidLeftDerived(); |
14722 | ········otherVar = new CmpBinnOwnpconTblGuidRight(); |
14723 | ····} |
14724 | ····[TearDown] |
14725 | ····public void TearDown() |
14726 | ····{ |
14727 | ········try |
14728 | ········{ |
14729 | ············pm.UnloadCache(); |
14730 | ············var l = pm.Objects<CmpBinnOwnpconTblGuidLeftBase>().ResultTable; |
14731 | ············pm.Delete(l); |
14732 | ············pm.Save(); |
14733 | ············pm.UnloadCache(); |
14734 | ············decimal count; |
14735 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14736 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14737 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14738 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14739 | ········} |
14740 | ········catch (Exception) |
14741 | ········{ |
14742 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14743 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14744 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14745 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14746 | ········} |
14747 | ····} |
14748 | ····[Test] |
14749 | ····public void TestSaveReload() |
14750 | ····{ |
14751 | ········CreateObjects(); |
14752 | ········QueryOwn(); |
14753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14754 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14755 | ····} |
14756 | ····[Test] |
14757 | ····public void TestSaveReloadNull() |
14758 | ····{ |
14759 | ········CreateObjects(); |
14760 | ········QueryOwn(); |
14761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14762 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14763 | ········ownVar.RelField = new List<CmpBinnOwnpconTblGuidRight>(); |
14764 | ········pm.Save(); |
14765 | ········pm.UnloadCache(); |
14766 | ········QueryOwn(); |
14767 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14768 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14769 | ····} |
14770 | ····[Test] |
14771 | ····public void TestSaveReloadRemove() |
14772 | ····{ |
14773 | ········CreateObjects(); |
14774 | ········QueryOwn(); |
14775 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14776 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14777 | ········ownVar.RemoveRelatedObject(); |
14778 | ········pm.Save(); |
14779 | ········pm.UnloadCache(); |
14780 | ········QueryOwn(); |
14781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14782 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14783 | ····} |
14784 | ····[Test] |
14785 | ····public void TestRelationHash() |
14786 | ····{ |
14787 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidLeftBase)); |
14788 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14789 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidRight)); |
14790 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14791 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14792 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14793 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidLeftDerived)); |
14794 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14795 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14796 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14797 | ····} |
14798 | ····void CreateObjects() |
14799 | ····{ |
14800 | ········pm.MakePersistent(ownVar); |
14801 | ········ownVar.AssignRelation(otherVar); |
14802 | ········pm.Save(); |
14803 | ········pm.UnloadCache(); |
14804 | ····} |
14805 | ····void QueryOwn() |
14806 | ····{ |
14807 | ········var q = new NDOQuery<CmpBinnOwnpconTblGuidLeftBase>(pm); |
14808 | ········ownVar = q.ExecuteSingle(); |
14809 | ····} |
14810 | ····void QueryOther() |
14811 | ····{ |
14812 | ········var q = new NDOQuery<CmpBinnOwnpconTblGuidRight>(pm); |
14813 | ········otherVar = q.ExecuteSingle(); |
14814 | ····} |
14815 | } |
14816 | |
14817 | |
14818 | [TestFixture] |
14819 | public class TestAgrDir1OthpconNoTblGuid : NDOTest |
14820 | { |
14821 | ····AgrDir1OthpconNoTblGuidLeft ownVar; |
14822 | ····AgrDir1OthpconNoTblGuidRightBase otherVar; |
14823 | ····PersistenceManager pm; |
14824 | ····[SetUp] |
14825 | ····public void Setup() |
14826 | ····{ |
14827 | ········pm = PmFactory.NewPersistenceManager(); |
14828 | ········ownVar = new AgrDir1OthpconNoTblGuidLeft(); |
14829 | ········otherVar = new AgrDir1OthpconNoTblGuidRightDerived(); |
14830 | ····} |
14831 | ····[TearDown] |
14832 | ····public void TearDown() |
14833 | ····{ |
14834 | ········try |
14835 | ········{ |
14836 | ············pm.UnloadCache(); |
14837 | ············var l = pm.Objects<AgrDir1OthpconNoTblGuidLeft>().ResultTable; |
14838 | ············pm.Delete(l); |
14839 | ············pm.Save(); |
14840 | ············pm.UnloadCache(); |
14841 | ············var m = pm.Objects<AgrDir1OthpconNoTblGuidRightBase>().ResultTable; |
14842 | ············pm.Delete(m); |
14843 | ············pm.Save(); |
14844 | ············pm.UnloadCache(); |
14845 | ············decimal count; |
14846 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14847 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14848 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14849 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14850 | ········} |
14851 | ········catch (Exception) |
14852 | ········{ |
14853 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14854 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14855 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14856 | ········} |
14857 | ····} |
14858 | ····[Test] |
14859 | ····public void TestSaveReload() |
14860 | ····{ |
14861 | ········CreateObjects(); |
14862 | ········QueryOwn(); |
14863 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14864 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14865 | ····} |
14866 | ····[Test] |
14867 | ····public void TestSaveReloadNull() |
14868 | ····{ |
14869 | ········CreateObjects(); |
14870 | ········QueryOwn(); |
14871 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14872 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14873 | ········ownVar.RelField = null; |
14874 | ········pm.Save(); |
14875 | ········pm.UnloadCache(); |
14876 | ········QueryOwn(); |
14877 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14878 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14879 | ····} |
14880 | ····[Test] |
14881 | ····public void TestChangeKeyHolderLeft() |
14882 | ····{ |
14883 | ········CreateObjects(); |
14884 | ········QueryOwn(); |
14885 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14886 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14887 | ········int x = ownVar.RelField.Dummy; |
14888 | ········ownVar.Dummy = 4711; |
14889 | ········pm.Save(); |
14890 | ········pm.UnloadCache(); |
14891 | ········QueryOwn(); |
14892 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14893 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14894 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14895 | ····} |
14896 | ····[Test] |
14897 | ····public void TestChangeKeyHolderLeftNoTouch() |
14898 | ····{ |
14899 | ········CreateObjects(); |
14900 | ········QueryOwn(); |
14901 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14902 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14903 | ········ownVar.Dummy = 4711; |
14904 | ········pm.Save(); |
14905 | ········pm.UnloadCache(); |
14906 | ········QueryOwn(); |
14907 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14908 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14910 | ····} |
14911 | ····void CreateObjects() |
14912 | ····{ |
14913 | ········pm.MakePersistent(ownVar); |
14914 | ········pm.MakePersistent(otherVar); |
14915 | ········ownVar.AssignRelation(otherVar); |
14916 | ········pm.Save(); |
14917 | ········pm.UnloadCache(); |
14918 | ····} |
14919 | ····void QueryOwn() |
14920 | ····{ |
14921 | ········var q = new NDOQuery<AgrDir1OthpconNoTblGuidLeft>(pm); |
14922 | ········ownVar = q.ExecuteSingle(); |
14923 | ····} |
14924 | ····void QueryOther() |
14925 | ····{ |
14926 | ········var q = new NDOQuery<AgrDir1OthpconNoTblGuidRightBase>(pm); |
14927 | ········otherVar = q.ExecuteSingle(); |
14928 | ····} |
14929 | } |
14930 | |
14931 | |
14932 | [TestFixture] |
14933 | public class TestAgrDir1OthpconTblGuid : NDOTest |
14934 | { |
14935 | ····AgrDir1OthpconTblGuidLeft ownVar; |
14936 | ····AgrDir1OthpconTblGuidRightBase otherVar; |
14937 | ····PersistenceManager pm; |
14938 | ····[SetUp] |
14939 | ····public void Setup() |
14940 | ····{ |
14941 | ········pm = PmFactory.NewPersistenceManager(); |
14942 | ········ownVar = new AgrDir1OthpconTblGuidLeft(); |
14943 | ········otherVar = new AgrDir1OthpconTblGuidRightDerived(); |
14944 | ····} |
14945 | ····[TearDown] |
14946 | ····public void TearDown() |
14947 | ····{ |
14948 | ········try |
14949 | ········{ |
14950 | ············pm.UnloadCache(); |
14951 | ············var l = pm.Objects<AgrDir1OthpconTblGuidLeft>().ResultTable; |
14952 | ············pm.Delete(l); |
14953 | ············pm.Save(); |
14954 | ············pm.UnloadCache(); |
14955 | ············var m = pm.Objects<AgrDir1OthpconTblGuidRightBase>().ResultTable; |
14956 | ············pm.Delete(m); |
14957 | ············pm.Save(); |
14958 | ············pm.UnloadCache(); |
14959 | ············decimal count; |
14960 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14961 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14962 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14963 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14964 | ········} |
14965 | ········catch (Exception) |
14966 | ········{ |
14967 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14968 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14969 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14970 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14971 | ········} |
14972 | ····} |
14973 | ····[Test] |
14974 | ····public void TestSaveReload() |
14975 | ····{ |
14976 | ········CreateObjects(); |
14977 | ········QueryOwn(); |
14978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14979 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14980 | ····} |
14981 | ····[Test] |
14982 | ····public void TestSaveReloadNull() |
14983 | ····{ |
14984 | ········CreateObjects(); |
14985 | ········QueryOwn(); |
14986 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14987 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14988 | ········ownVar.RelField = null; |
14989 | ········pm.Save(); |
14990 | ········pm.UnloadCache(); |
14991 | ········QueryOwn(); |
14992 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14993 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14994 | ····} |
14995 | ····[Test] |
14996 | ····public void TestChangeKeyHolderLeft() |
14997 | ····{ |
14998 | ········CreateObjects(); |
14999 | ········QueryOwn(); |
15000 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15001 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15002 | ········int x = ownVar.RelField.Dummy; |
15003 | ········ownVar.Dummy = 4711; |
15004 | ········pm.Save(); |
15005 | ········pm.UnloadCache(); |
15006 | ········QueryOwn(); |
15007 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15008 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15009 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15010 | ····} |
15011 | ····[Test] |
15012 | ····public void TestChangeKeyHolderLeftNoTouch() |
15013 | ····{ |
15014 | ········CreateObjects(); |
15015 | ········QueryOwn(); |
15016 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15017 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15018 | ········ownVar.Dummy = 4711; |
15019 | ········pm.Save(); |
15020 | ········pm.UnloadCache(); |
15021 | ········QueryOwn(); |
15022 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15023 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15024 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15025 | ····} |
15026 | ····void CreateObjects() |
15027 | ····{ |
15028 | ········pm.MakePersistent(ownVar); |
15029 | ········pm.MakePersistent(otherVar); |
15030 | ········ownVar.AssignRelation(otherVar); |
15031 | ········pm.Save(); |
15032 | ········pm.UnloadCache(); |
15033 | ····} |
15034 | ····void QueryOwn() |
15035 | ····{ |
15036 | ········var q = new NDOQuery<AgrDir1OthpconTblGuidLeft>(pm); |
15037 | ········ownVar = q.ExecuteSingle(); |
15038 | ····} |
15039 | ····void QueryOther() |
15040 | ····{ |
15041 | ········var q = new NDOQuery<AgrDir1OthpconTblGuidRightBase>(pm); |
15042 | ········otherVar = q.ExecuteSingle(); |
15043 | ····} |
15044 | } |
15045 | |
15046 | |
15047 | [TestFixture] |
15048 | public class TestAgrBi11OthpconNoTblGuid : NDOTest |
15049 | { |
15050 | ····AgrBi11OthpconNoTblGuidLeft ownVar; |
15051 | ····AgrBi11OthpconNoTblGuidRightBase otherVar; |
15052 | ····PersistenceManager pm; |
15053 | ····[SetUp] |
15054 | ····public void Setup() |
15055 | ····{ |
15056 | ········pm = PmFactory.NewPersistenceManager(); |
15057 | ········ownVar = new AgrBi11OthpconNoTblGuidLeft(); |
15058 | ········otherVar = new AgrBi11OthpconNoTblGuidRightDerived(); |
15059 | ····} |
15060 | ····[TearDown] |
15061 | ····public void TearDown() |
15062 | ····{ |
15063 | ········try |
15064 | ········{ |
15065 | ············pm.UnloadCache(); |
15066 | ············var l = pm.Objects<AgrBi11OthpconNoTblGuidLeft>().ResultTable; |
15067 | ············pm.Delete(l); |
15068 | ············pm.Save(); |
15069 | ············pm.UnloadCache(); |
15070 | ············var m = pm.Objects<AgrBi11OthpconNoTblGuidRightBase>().ResultTable; |
15071 | ············pm.Delete(m); |
15072 | ············pm.Save(); |
15073 | ············pm.UnloadCache(); |
15074 | ············decimal count; |
15075 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15076 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15077 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15078 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15079 | ········} |
15080 | ········catch (Exception) |
15081 | ········{ |
15082 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15083 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15084 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15085 | ········} |
15086 | ····} |
15087 | ····[Test] |
15088 | ····public void TestSaveReload() |
15089 | ····{ |
15090 | ········CreateObjects(); |
15091 | ········QueryOwn(); |
15092 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15093 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15094 | ····} |
15095 | ····[Test] |
15096 | ····public void TestSaveReloadNull() |
15097 | ····{ |
15098 | ········CreateObjects(); |
15099 | ········QueryOwn(); |
15100 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15101 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15102 | ········ownVar.RelField = null; |
15103 | ········pm.Save(); |
15104 | ········pm.UnloadCache(); |
15105 | ········QueryOwn(); |
15106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15107 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15108 | ····} |
15109 | ····[Test] |
15110 | ····public void TestChangeKeyHolderLeft() |
15111 | ····{ |
15112 | ········CreateObjects(); |
15113 | ········QueryOwn(); |
15114 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15115 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15116 | ········int x = ownVar.RelField.Dummy; |
15117 | ········ownVar.Dummy = 4711; |
15118 | ········pm.Save(); |
15119 | ········pm.UnloadCache(); |
15120 | ········QueryOwn(); |
15121 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15122 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15123 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15124 | ····} |
15125 | ····[Test] |
15126 | ····public void TestChangeKeyHolderRight() |
15127 | ····{ |
15128 | ········CreateObjects(); |
15129 | ········QueryOther(); |
15130 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15131 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15132 | ········int x = otherVar.RelField.Dummy; |
15133 | ········otherVar.Dummy = 4711; |
15134 | ········pm.Save(); |
15135 | ········pm.UnloadCache(); |
15136 | ········QueryOther(); |
15137 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15138 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15139 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15140 | ····} |
15141 | ····[Test] |
15142 | ····public void TestChangeKeyHolderLeftNoTouch() |
15143 | ····{ |
15144 | ········CreateObjects(); |
15145 | ········QueryOwn(); |
15146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15148 | ········ownVar.Dummy = 4711; |
15149 | ········pm.Save(); |
15150 | ········pm.UnloadCache(); |
15151 | ········QueryOwn(); |
15152 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15153 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15154 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15155 | ····} |
15156 | ····[Test] |
15157 | ····public void TestChangeKeyHolderRightNoTouch() |
15158 | ····{ |
15159 | ········CreateObjects(); |
15160 | ········QueryOther(); |
15161 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15162 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15163 | ········otherVar.Dummy = 4711; |
15164 | ········pm.Save(); |
15165 | ········pm.UnloadCache(); |
15166 | ········QueryOther(); |
15167 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15168 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15169 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15170 | ····} |
15171 | ····[Test] |
15172 | ····public void TestRelationHash() |
15173 | ····{ |
15174 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidLeft)); |
15175 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15176 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidRightBase)); |
15177 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15178 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15179 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15180 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidRightDerived)); |
15181 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15182 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15183 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15184 | ····} |
15185 | ····void CreateObjects() |
15186 | ····{ |
15187 | ········pm.MakePersistent(ownVar); |
15188 | ········pm.MakePersistent(otherVar); |
15189 | ········ownVar.AssignRelation(otherVar); |
15190 | ········pm.Save(); |
15191 | ········pm.UnloadCache(); |
15192 | ····} |
15193 | ····void QueryOwn() |
15194 | ····{ |
15195 | ········var q = new NDOQuery<AgrBi11OthpconNoTblGuidLeft>(pm); |
15196 | ········ownVar = q.ExecuteSingle(); |
15197 | ····} |
15198 | ····void QueryOther() |
15199 | ····{ |
15200 | ········var q = new NDOQuery<AgrBi11OthpconNoTblGuidRightBase>(pm); |
15201 | ········otherVar = q.ExecuteSingle(); |
15202 | ····} |
15203 | } |
15204 | |
15205 | |
15206 | [TestFixture] |
15207 | public class TestAgrBi11OthpconTblGuid : NDOTest |
15208 | { |
15209 | ····AgrBi11OthpconTblGuidLeft ownVar; |
15210 | ····AgrBi11OthpconTblGuidRightBase otherVar; |
15211 | ····PersistenceManager pm; |
15212 | ····[SetUp] |
15213 | ····public void Setup() |
15214 | ····{ |
15215 | ········pm = PmFactory.NewPersistenceManager(); |
15216 | ········ownVar = new AgrBi11OthpconTblGuidLeft(); |
15217 | ········otherVar = new AgrBi11OthpconTblGuidRightDerived(); |
15218 | ····} |
15219 | ····[TearDown] |
15220 | ····public void TearDown() |
15221 | ····{ |
15222 | ········try |
15223 | ········{ |
15224 | ············pm.UnloadCache(); |
15225 | ············var l = pm.Objects<AgrBi11OthpconTblGuidLeft>().ResultTable; |
15226 | ············pm.Delete(l); |
15227 | ············pm.Save(); |
15228 | ············pm.UnloadCache(); |
15229 | ············var m = pm.Objects<AgrBi11OthpconTblGuidRightBase>().ResultTable; |
15230 | ············pm.Delete(m); |
15231 | ············pm.Save(); |
15232 | ············pm.UnloadCache(); |
15233 | ············decimal count; |
15234 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15235 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15236 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15237 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15238 | ········} |
15239 | ········catch (Exception) |
15240 | ········{ |
15241 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15242 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15243 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15244 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15245 | ········} |
15246 | ····} |
15247 | ····[Test] |
15248 | ····public void TestSaveReload() |
15249 | ····{ |
15250 | ········CreateObjects(); |
15251 | ········QueryOwn(); |
15252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15254 | ····} |
15255 | ····[Test] |
15256 | ····public void TestSaveReloadNull() |
15257 | ····{ |
15258 | ········CreateObjects(); |
15259 | ········QueryOwn(); |
15260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15262 | ········ownVar.RelField = null; |
15263 | ········pm.Save(); |
15264 | ········pm.UnloadCache(); |
15265 | ········QueryOwn(); |
15266 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15267 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15268 | ····} |
15269 | ····[Test] |
15270 | ····public void TestChangeKeyHolderLeft() |
15271 | ····{ |
15272 | ········CreateObjects(); |
15273 | ········QueryOwn(); |
15274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15275 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15276 | ········int x = ownVar.RelField.Dummy; |
15277 | ········ownVar.Dummy = 4711; |
15278 | ········pm.Save(); |
15279 | ········pm.UnloadCache(); |
15280 | ········QueryOwn(); |
15281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15282 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15284 | ····} |
15285 | ····[Test] |
15286 | ····public void TestChangeKeyHolderRight() |
15287 | ····{ |
15288 | ········CreateObjects(); |
15289 | ········QueryOther(); |
15290 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15291 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15292 | ········int x = otherVar.RelField.Dummy; |
15293 | ········otherVar.Dummy = 4711; |
15294 | ········pm.Save(); |
15295 | ········pm.UnloadCache(); |
15296 | ········QueryOther(); |
15297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15298 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15299 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15300 | ····} |
15301 | ····[Test] |
15302 | ····public void TestChangeKeyHolderLeftNoTouch() |
15303 | ····{ |
15304 | ········CreateObjects(); |
15305 | ········QueryOwn(); |
15306 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15307 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15308 | ········ownVar.Dummy = 4711; |
15309 | ········pm.Save(); |
15310 | ········pm.UnloadCache(); |
15311 | ········QueryOwn(); |
15312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15313 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15315 | ····} |
15316 | ····[Test] |
15317 | ····public void TestChangeKeyHolderRightNoTouch() |
15318 | ····{ |
15319 | ········CreateObjects(); |
15320 | ········QueryOther(); |
15321 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15322 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15323 | ········otherVar.Dummy = 4711; |
15324 | ········pm.Save(); |
15325 | ········pm.UnloadCache(); |
15326 | ········QueryOther(); |
15327 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15328 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15329 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15330 | ····} |
15331 | ····[Test] |
15332 | ····public void TestRelationHash() |
15333 | ····{ |
15334 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidLeft)); |
15335 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15336 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidRightBase)); |
15337 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15338 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15339 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15340 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidRightDerived)); |
15341 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15342 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15343 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15344 | ····} |
15345 | ····void CreateObjects() |
15346 | ····{ |
15347 | ········pm.MakePersistent(ownVar); |
15348 | ········pm.MakePersistent(otherVar); |
15349 | ········ownVar.AssignRelation(otherVar); |
15350 | ········pm.Save(); |
15351 | ········pm.UnloadCache(); |
15352 | ····} |
15353 | ····void QueryOwn() |
15354 | ····{ |
15355 | ········var q = new NDOQuery<AgrBi11OthpconTblGuidLeft>(pm); |
15356 | ········ownVar = q.ExecuteSingle(); |
15357 | ····} |
15358 | ····void QueryOther() |
15359 | ····{ |
15360 | ········var q = new NDOQuery<AgrBi11OthpconTblGuidRightBase>(pm); |
15361 | ········otherVar = q.ExecuteSingle(); |
15362 | ····} |
15363 | } |
15364 | |
15365 | |
15366 | [TestFixture] |
15367 | public class TestAgrDirnOthpconTblGuid : NDOTest |
15368 | { |
15369 | ····AgrDirnOthpconTblGuidLeft ownVar; |
15370 | ····AgrDirnOthpconTblGuidRightBase otherVar; |
15371 | ····PersistenceManager pm; |
15372 | ····[SetUp] |
15373 | ····public void Setup() |
15374 | ····{ |
15375 | ········pm = PmFactory.NewPersistenceManager(); |
15376 | ········ownVar = new AgrDirnOthpconTblGuidLeft(); |
15377 | ········otherVar = new AgrDirnOthpconTblGuidRightDerived(); |
15378 | ····} |
15379 | ····[TearDown] |
15380 | ····public void TearDown() |
15381 | ····{ |
15382 | ········try |
15383 | ········{ |
15384 | ············pm.UnloadCache(); |
15385 | ············var l = pm.Objects<AgrDirnOthpconTblGuidLeft>().ResultTable; |
15386 | ············pm.Delete(l); |
15387 | ············pm.Save(); |
15388 | ············pm.UnloadCache(); |
15389 | ············var m = pm.Objects<AgrDirnOthpconTblGuidRightBase>().ResultTable; |
15390 | ············pm.Delete(m); |
15391 | ············pm.Save(); |
15392 | ············pm.UnloadCache(); |
15393 | ············decimal count; |
15394 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15395 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15396 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15397 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15398 | ········} |
15399 | ········catch (Exception) |
15400 | ········{ |
15401 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15402 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15403 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15404 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15405 | ········} |
15406 | ····} |
15407 | ····[Test] |
15408 | ····public void TestSaveReload() |
15409 | ····{ |
15410 | ········CreateObjects(); |
15411 | ········QueryOwn(); |
15412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15413 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15414 | ····} |
15415 | ····[Test] |
15416 | ····public void TestSaveReloadNull() |
15417 | ····{ |
15418 | ········CreateObjects(); |
15419 | ········QueryOwn(); |
15420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15421 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15422 | ········ownVar.RelField = new List<AgrDirnOthpconTblGuidRightBase>(); |
15423 | ········pm.Save(); |
15424 | ········pm.UnloadCache(); |
15425 | ········QueryOwn(); |
15426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15427 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15428 | ····} |
15429 | ····[Test] |
15430 | ····public void TestSaveReloadRemove() |
15431 | ····{ |
15432 | ········CreateObjects(); |
15433 | ········QueryOwn(); |
15434 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15435 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15436 | ········ownVar.RemoveRelatedObject(); |
15437 | ········pm.Save(); |
15438 | ········pm.UnloadCache(); |
15439 | ········QueryOwn(); |
15440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15441 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15442 | ····} |
15443 | ····void CreateObjects() |
15444 | ····{ |
15445 | ········pm.MakePersistent(ownVar); |
15446 | ········pm.MakePersistent(otherVar); |
15447 | ········ownVar.AssignRelation(otherVar); |
15448 | ········pm.Save(); |
15449 | ········pm.UnloadCache(); |
15450 | ····} |
15451 | ····void QueryOwn() |
15452 | ····{ |
15453 | ········var q = new NDOQuery<AgrDirnOthpconTblGuidLeft>(pm); |
15454 | ········ownVar = q.ExecuteSingle(); |
15455 | ····} |
15456 | ····void QueryOther() |
15457 | ····{ |
15458 | ········var q = new NDOQuery<AgrDirnOthpconTblGuidRightBase>(pm); |
15459 | ········otherVar = q.ExecuteSingle(); |
15460 | ····} |
15461 | } |
15462 | |
15463 | |
15464 | [TestFixture] |
15465 | public class TestAgrBin1OthpconTblGuid : NDOTest |
15466 | { |
15467 | ····AgrBin1OthpconTblGuidLeft ownVar; |
15468 | ····AgrBin1OthpconTblGuidRightBase otherVar; |
15469 | ····PersistenceManager pm; |
15470 | ····[SetUp] |
15471 | ····public void Setup() |
15472 | ····{ |
15473 | ········pm = PmFactory.NewPersistenceManager(); |
15474 | ········ownVar = new AgrBin1OthpconTblGuidLeft(); |
15475 | ········otherVar = new AgrBin1OthpconTblGuidRightDerived(); |
15476 | ····} |
15477 | ····[TearDown] |
15478 | ····public void TearDown() |
15479 | ····{ |
15480 | ········try |
15481 | ········{ |
15482 | ············pm.UnloadCache(); |
15483 | ············var l = pm.Objects<AgrBin1OthpconTblGuidLeft>().ResultTable; |
15484 | ············pm.Delete(l); |
15485 | ············pm.Save(); |
15486 | ············pm.UnloadCache(); |
15487 | ············var m = pm.Objects<AgrBin1OthpconTblGuidRightBase>().ResultTable; |
15488 | ············pm.Delete(m); |
15489 | ············pm.Save(); |
15490 | ············pm.UnloadCache(); |
15491 | ············decimal count; |
15492 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15493 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15494 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15495 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15496 | ········} |
15497 | ········catch (Exception) |
15498 | ········{ |
15499 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15500 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15501 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15502 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15503 | ········} |
15504 | ····} |
15505 | ····[Test] |
15506 | ····public void TestSaveReload() |
15507 | ····{ |
15508 | ········CreateObjects(); |
15509 | ········QueryOwn(); |
15510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15511 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15512 | ····} |
15513 | ····[Test] |
15514 | ····public void TestSaveReloadNull() |
15515 | ····{ |
15516 | ········CreateObjects(); |
15517 | ········QueryOwn(); |
15518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15519 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15520 | ········ownVar.RelField = new List<AgrBin1OthpconTblGuidRightBase>(); |
15521 | ········pm.Save(); |
15522 | ········pm.UnloadCache(); |
15523 | ········QueryOwn(); |
15524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15525 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15526 | ····} |
15527 | ····[Test] |
15528 | ····public void TestSaveReloadRemove() |
15529 | ····{ |
15530 | ········CreateObjects(); |
15531 | ········QueryOwn(); |
15532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15533 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15534 | ········ownVar.RemoveRelatedObject(); |
15535 | ········pm.Save(); |
15536 | ········pm.UnloadCache(); |
15537 | ········QueryOwn(); |
15538 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15539 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15540 | ····} |
15541 | ····[Test] |
15542 | ····public void TestChangeKeyHolderRight() |
15543 | ····{ |
15544 | ········CreateObjects(); |
15545 | ········QueryOther(); |
15546 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15547 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15548 | ········int x = otherVar.RelField.Dummy; |
15549 | ········otherVar.Dummy = 4711; |
15550 | ········pm.Save(); |
15551 | ········pm.UnloadCache(); |
15552 | ········QueryOther(); |
15553 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15554 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15555 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15556 | ····} |
15557 | ····[Test] |
15558 | ····public void TestChangeKeyHolderRightNoTouch() |
15559 | ····{ |
15560 | ········CreateObjects(); |
15561 | ········QueryOther(); |
15562 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15563 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15564 | ········otherVar.Dummy = 4711; |
15565 | ········pm.Save(); |
15566 | ········pm.UnloadCache(); |
15567 | ········QueryOther(); |
15568 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15569 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15570 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15571 | ····} |
15572 | ····[Test] |
15573 | ····public void TestRelationHash() |
15574 | ····{ |
15575 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidLeft)); |
15576 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15577 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidRightBase)); |
15578 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15579 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15580 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15581 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidRightDerived)); |
15582 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15583 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15584 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15585 | ····} |
15586 | ····void CreateObjects() |
15587 | ····{ |
15588 | ········pm.MakePersistent(ownVar); |
15589 | ········pm.MakePersistent(otherVar); |
15590 | ········ownVar.AssignRelation(otherVar); |
15591 | ········pm.Save(); |
15592 | ········pm.UnloadCache(); |
15593 | ····} |
15594 | ····void QueryOwn() |
15595 | ····{ |
15596 | ········var q = new NDOQuery<AgrBin1OthpconTblGuidLeft>(pm); |
15597 | ········ownVar = q.ExecuteSingle(); |
15598 | ····} |
15599 | ····void QueryOther() |
15600 | ····{ |
15601 | ········var q = new NDOQuery<AgrBin1OthpconTblGuidRightBase>(pm); |
15602 | ········otherVar = q.ExecuteSingle(); |
15603 | ····} |
15604 | } |
15605 | |
15606 | |
15607 | [TestFixture] |
15608 | public class TestAgrBi1nOthpconNoTblGuid : NDOTest |
15609 | { |
15610 | ····AgrBi1nOthpconNoTblGuidLeft ownVar; |
15611 | ····AgrBi1nOthpconNoTblGuidRightBase otherVar; |
15612 | ····PersistenceManager pm; |
15613 | ····[SetUp] |
15614 | ····public void Setup() |
15615 | ····{ |
15616 | ········pm = PmFactory.NewPersistenceManager(); |
15617 | ········ownVar = new AgrBi1nOthpconNoTblGuidLeft(); |
15618 | ········otherVar = new AgrBi1nOthpconNoTblGuidRightDerived(); |
15619 | ····} |
15620 | ····[TearDown] |
15621 | ····public void TearDown() |
15622 | ····{ |
15623 | ········try |
15624 | ········{ |
15625 | ············pm.UnloadCache(); |
15626 | ············var l = pm.Objects<AgrBi1nOthpconNoTblGuidLeft>().ResultTable; |
15627 | ············pm.Delete(l); |
15628 | ············pm.Save(); |
15629 | ············pm.UnloadCache(); |
15630 | ············var m = pm.Objects<AgrBi1nOthpconNoTblGuidRightBase>().ResultTable; |
15631 | ············pm.Delete(m); |
15632 | ············pm.Save(); |
15633 | ············pm.UnloadCache(); |
15634 | ············decimal count; |
15635 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15636 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15637 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15638 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15639 | ········} |
15640 | ········catch (Exception) |
15641 | ········{ |
15642 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15644 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15645 | ········} |
15646 | ····} |
15647 | ····[Test] |
15648 | ····public void TestSaveReload() |
15649 | ····{ |
15650 | ········CreateObjects(); |
15651 | ········QueryOwn(); |
15652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15654 | ····} |
15655 | ····[Test] |
15656 | ····public void TestSaveReloadNull() |
15657 | ····{ |
15658 | ········CreateObjects(); |
15659 | ········QueryOwn(); |
15660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15662 | ········ownVar.RelField = null; |
15663 | ········pm.Save(); |
15664 | ········pm.UnloadCache(); |
15665 | ········QueryOwn(); |
15666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15667 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15668 | ····} |
15669 | ····[Test] |
15670 | ····public void TestChangeKeyHolderLeft() |
15671 | ····{ |
15672 | ········CreateObjects(); |
15673 | ········QueryOwn(); |
15674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15676 | ········int x = ownVar.RelField.Dummy; |
15677 | ········ownVar.Dummy = 4711; |
15678 | ········pm.Save(); |
15679 | ········pm.UnloadCache(); |
15680 | ········QueryOwn(); |
15681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15682 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15683 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15684 | ····} |
15685 | ····[Test] |
15686 | ····public void TestChangeKeyHolderLeftNoTouch() |
15687 | ····{ |
15688 | ········CreateObjects(); |
15689 | ········QueryOwn(); |
15690 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15691 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15692 | ········ownVar.Dummy = 4711; |
15693 | ········pm.Save(); |
15694 | ········pm.UnloadCache(); |
15695 | ········QueryOwn(); |
15696 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15697 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15698 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15699 | ····} |
15700 | ····[Test] |
15701 | ····public void TestRelationHash() |
15702 | ····{ |
15703 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidLeft)); |
15704 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15705 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidRightBase)); |
15706 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15707 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15708 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15709 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidRightDerived)); |
15710 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15711 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15712 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15713 | ····} |
15714 | ····void CreateObjects() |
15715 | ····{ |
15716 | ········pm.MakePersistent(ownVar); |
15717 | ········pm.MakePersistent(otherVar); |
15718 | ········ownVar.AssignRelation(otherVar); |
15719 | ········pm.Save(); |
15720 | ········pm.UnloadCache(); |
15721 | ····} |
15722 | ····void QueryOwn() |
15723 | ····{ |
15724 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblGuidLeft>(pm); |
15725 | ········ownVar = q.ExecuteSingle(); |
15726 | ····} |
15727 | ····void QueryOther() |
15728 | ····{ |
15729 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblGuidRightBase>(pm); |
15730 | ········otherVar = q.ExecuteSingle(); |
15731 | ····} |
15732 | } |
15733 | |
15734 | |
15735 | [TestFixture] |
15736 | public class TestAgrBi1nOthpconTblGuid : NDOTest |
15737 | { |
15738 | ····AgrBi1nOthpconTblGuidLeft ownVar; |
15739 | ····AgrBi1nOthpconTblGuidRightBase otherVar; |
15740 | ····PersistenceManager pm; |
15741 | ····[SetUp] |
15742 | ····public void Setup() |
15743 | ····{ |
15744 | ········pm = PmFactory.NewPersistenceManager(); |
15745 | ········ownVar = new AgrBi1nOthpconTblGuidLeft(); |
15746 | ········otherVar = new AgrBi1nOthpconTblGuidRightDerived(); |
15747 | ····} |
15748 | ····[TearDown] |
15749 | ····public void TearDown() |
15750 | ····{ |
15751 | ········try |
15752 | ········{ |
15753 | ············pm.UnloadCache(); |
15754 | ············var l = pm.Objects<AgrBi1nOthpconTblGuidLeft>().ResultTable; |
15755 | ············pm.Delete(l); |
15756 | ············pm.Save(); |
15757 | ············pm.UnloadCache(); |
15758 | ············var m = pm.Objects<AgrBi1nOthpconTblGuidRightBase>().ResultTable; |
15759 | ············pm.Delete(m); |
15760 | ············pm.Save(); |
15761 | ············pm.UnloadCache(); |
15762 | ············decimal count; |
15763 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15764 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15765 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15766 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15767 | ········} |
15768 | ········catch (Exception) |
15769 | ········{ |
15770 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15771 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15772 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15773 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15774 | ········} |
15775 | ····} |
15776 | ····[Test] |
15777 | ····public void TestSaveReload() |
15778 | ····{ |
15779 | ········CreateObjects(); |
15780 | ········QueryOwn(); |
15781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15782 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15783 | ····} |
15784 | ····[Test] |
15785 | ····public void TestSaveReloadNull() |
15786 | ····{ |
15787 | ········CreateObjects(); |
15788 | ········QueryOwn(); |
15789 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15790 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15791 | ········ownVar.RelField = null; |
15792 | ········pm.Save(); |
15793 | ········pm.UnloadCache(); |
15794 | ········QueryOwn(); |
15795 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15796 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15797 | ····} |
15798 | ····[Test] |
15799 | ····public void TestChangeKeyHolderLeft() |
15800 | ····{ |
15801 | ········CreateObjects(); |
15802 | ········QueryOwn(); |
15803 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15804 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15805 | ········int x = ownVar.RelField.Dummy; |
15806 | ········ownVar.Dummy = 4711; |
15807 | ········pm.Save(); |
15808 | ········pm.UnloadCache(); |
15809 | ········QueryOwn(); |
15810 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15811 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15812 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15813 | ····} |
15814 | ····[Test] |
15815 | ····public void TestChangeKeyHolderLeftNoTouch() |
15816 | ····{ |
15817 | ········CreateObjects(); |
15818 | ········QueryOwn(); |
15819 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15820 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15821 | ········ownVar.Dummy = 4711; |
15822 | ········pm.Save(); |
15823 | ········pm.UnloadCache(); |
15824 | ········QueryOwn(); |
15825 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15826 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15827 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15828 | ····} |
15829 | ····[Test] |
15830 | ····public void TestRelationHash() |
15831 | ····{ |
15832 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidLeft)); |
15833 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15834 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidRightBase)); |
15835 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15836 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15837 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15838 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidRightDerived)); |
15839 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15840 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15841 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15842 | ····} |
15843 | ····void CreateObjects() |
15844 | ····{ |
15845 | ········pm.MakePersistent(ownVar); |
15846 | ········pm.MakePersistent(otherVar); |
15847 | ········ownVar.AssignRelation(otherVar); |
15848 | ········pm.Save(); |
15849 | ········pm.UnloadCache(); |
15850 | ····} |
15851 | ····void QueryOwn() |
15852 | ····{ |
15853 | ········var q = new NDOQuery<AgrBi1nOthpconTblGuidLeft>(pm); |
15854 | ········ownVar = q.ExecuteSingle(); |
15855 | ····} |
15856 | ····void QueryOther() |
15857 | ····{ |
15858 | ········var q = new NDOQuery<AgrBi1nOthpconTblGuidRightBase>(pm); |
15859 | ········otherVar = q.ExecuteSingle(); |
15860 | ····} |
15861 | } |
15862 | |
15863 | |
15864 | [TestFixture] |
15865 | public class TestAgrBinnOthpconTblGuid : NDOTest |
15866 | { |
15867 | ····AgrBinnOthpconTblGuidLeft ownVar; |
15868 | ····AgrBinnOthpconTblGuidRightBase otherVar; |
15869 | ····PersistenceManager pm; |
15870 | ····[SetUp] |
15871 | ····public void Setup() |
15872 | ····{ |
15873 | ········pm = PmFactory.NewPersistenceManager(); |
15874 | ········ownVar = new AgrBinnOthpconTblGuidLeft(); |
15875 | ········otherVar = new AgrBinnOthpconTblGuidRightDerived(); |
15876 | ····} |
15877 | ····[TearDown] |
15878 | ····public void TearDown() |
15879 | ····{ |
15880 | ········try |
15881 | ········{ |
15882 | ············pm.UnloadCache(); |
15883 | ············var l = pm.Objects<AgrBinnOthpconTblGuidLeft>().ResultTable; |
15884 | ············pm.Delete(l); |
15885 | ············pm.Save(); |
15886 | ············pm.UnloadCache(); |
15887 | ············var m = pm.Objects<AgrBinnOthpconTblGuidRightBase>().ResultTable; |
15888 | ············pm.Delete(m); |
15889 | ············pm.Save(); |
15890 | ············pm.UnloadCache(); |
15891 | ············decimal count; |
15892 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15893 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15894 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15895 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15896 | ········} |
15897 | ········catch (Exception) |
15898 | ········{ |
15899 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15900 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15901 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15902 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15903 | ········} |
15904 | ····} |
15905 | ····[Test] |
15906 | ····public void TestSaveReload() |
15907 | ····{ |
15908 | ········CreateObjects(); |
15909 | ········QueryOwn(); |
15910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15911 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15912 | ····} |
15913 | ····[Test] |
15914 | ····public void TestSaveReloadNull() |
15915 | ····{ |
15916 | ········CreateObjects(); |
15917 | ········QueryOwn(); |
15918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15920 | ········ownVar.RelField = new List<AgrBinnOthpconTblGuidRightBase>(); |
15921 | ········pm.Save(); |
15922 | ········pm.UnloadCache(); |
15923 | ········QueryOwn(); |
15924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15926 | ····} |
15927 | ····[Test] |
15928 | ····public void TestSaveReloadRemove() |
15929 | ····{ |
15930 | ········CreateObjects(); |
15931 | ········QueryOwn(); |
15932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15933 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15934 | ········ownVar.RemoveRelatedObject(); |
15935 | ········pm.Save(); |
15936 | ········pm.UnloadCache(); |
15937 | ········QueryOwn(); |
15938 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15939 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15940 | ····} |
15941 | ····[Test] |
15942 | ····public void TestRelationHash() |
15943 | ····{ |
15944 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidLeft)); |
15945 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15946 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidRightBase)); |
15947 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15948 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15949 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15950 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidRightDerived)); |
15951 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15952 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15953 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15954 | ····} |
15955 | ····void CreateObjects() |
15956 | ····{ |
15957 | ········pm.MakePersistent(ownVar); |
15958 | ········pm.MakePersistent(otherVar); |
15959 | ········ownVar.AssignRelation(otherVar); |
15960 | ········pm.Save(); |
15961 | ········pm.UnloadCache(); |
15962 | ····} |
15963 | ····void QueryOwn() |
15964 | ····{ |
15965 | ········var q = new NDOQuery<AgrBinnOthpconTblGuidLeft>(pm); |
15966 | ········ownVar = q.ExecuteSingle(); |
15967 | ····} |
15968 | ····void QueryOther() |
15969 | ····{ |
15970 | ········var q = new NDOQuery<AgrBinnOthpconTblGuidRightBase>(pm); |
15971 | ········otherVar = q.ExecuteSingle(); |
15972 | ····} |
15973 | } |
15974 | |
15975 | |
15976 | [TestFixture] |
15977 | public class TestCmpDir1OthpconNoTblGuid : NDOTest |
15978 | { |
15979 | ····CmpDir1OthpconNoTblGuidLeft ownVar; |
15980 | ····CmpDir1OthpconNoTblGuidRightBase otherVar; |
15981 | ····PersistenceManager pm; |
15982 | ····[SetUp] |
15983 | ····public void Setup() |
15984 | ····{ |
15985 | ········pm = PmFactory.NewPersistenceManager(); |
15986 | ········ownVar = new CmpDir1OthpconNoTblGuidLeft(); |
15987 | ········otherVar = new CmpDir1OthpconNoTblGuidRightDerived(); |
15988 | ····} |
15989 | ····[TearDown] |
15990 | ····public void TearDown() |
15991 | ····{ |
15992 | ········try |
15993 | ········{ |
15994 | ············pm.UnloadCache(); |
15995 | ············var l = pm.Objects<CmpDir1OthpconNoTblGuidLeft>().ResultTable; |
15996 | ············pm.Delete(l); |
15997 | ············pm.Save(); |
15998 | ············pm.UnloadCache(); |
15999 | ············decimal count; |
16000 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16001 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16002 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16003 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16004 | ········} |
16005 | ········catch (Exception) |
16006 | ········{ |
16007 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16008 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16009 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16010 | ········} |
16011 | ····} |
16012 | ····[Test] |
16013 | ····public void TestSaveReload() |
16014 | ····{ |
16015 | ········CreateObjects(); |
16016 | ········QueryOwn(); |
16017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16018 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16019 | ····} |
16020 | ····[Test] |
16021 | ····public void TestSaveReloadNull() |
16022 | ····{ |
16023 | ········CreateObjects(); |
16024 | ········QueryOwn(); |
16025 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16026 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16027 | ········ownVar.RelField = null; |
16028 | ········pm.Save(); |
16029 | ········pm.UnloadCache(); |
16030 | ········QueryOwn(); |
16031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16032 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16033 | ····} |
16034 | ····[Test] |
16035 | ····public void TestChangeKeyHolderLeft() |
16036 | ····{ |
16037 | ········CreateObjects(); |
16038 | ········QueryOwn(); |
16039 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16040 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16041 | ········int x = ownVar.RelField.Dummy; |
16042 | ········ownVar.Dummy = 4711; |
16043 | ········pm.Save(); |
16044 | ········pm.UnloadCache(); |
16045 | ········QueryOwn(); |
16046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16047 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16048 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16049 | ····} |
16050 | ····[Test] |
16051 | ····public void TestChangeKeyHolderLeftNoTouch() |
16052 | ····{ |
16053 | ········CreateObjects(); |
16054 | ········QueryOwn(); |
16055 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16056 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16057 | ········ownVar.Dummy = 4711; |
16058 | ········pm.Save(); |
16059 | ········pm.UnloadCache(); |
16060 | ········QueryOwn(); |
16061 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16062 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16063 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16064 | ····} |
16065 | ····void CreateObjects() |
16066 | ····{ |
16067 | ········pm.MakePersistent(ownVar); |
16068 | ········ownVar.AssignRelation(otherVar); |
16069 | ········pm.Save(); |
16070 | ········pm.UnloadCache(); |
16071 | ····} |
16072 | ····void QueryOwn() |
16073 | ····{ |
16074 | ········var q = new NDOQuery<CmpDir1OthpconNoTblGuidLeft>(pm); |
16075 | ········ownVar = q.ExecuteSingle(); |
16076 | ····} |
16077 | ····void QueryOther() |
16078 | ····{ |
16079 | ········var q = new NDOQuery<CmpDir1OthpconNoTblGuidRightBase>(pm); |
16080 | ········otherVar = q.ExecuteSingle(); |
16081 | ····} |
16082 | } |
16083 | |
16084 | |
16085 | [TestFixture] |
16086 | public class TestCmpDir1OthpconTblGuid : NDOTest |
16087 | { |
16088 | ····CmpDir1OthpconTblGuidLeft ownVar; |
16089 | ····CmpDir1OthpconTblGuidRightBase otherVar; |
16090 | ····PersistenceManager pm; |
16091 | ····[SetUp] |
16092 | ····public void Setup() |
16093 | ····{ |
16094 | ········pm = PmFactory.NewPersistenceManager(); |
16095 | ········ownVar = new CmpDir1OthpconTblGuidLeft(); |
16096 | ········otherVar = new CmpDir1OthpconTblGuidRightDerived(); |
16097 | ····} |
16098 | ····[TearDown] |
16099 | ····public void TearDown() |
16100 | ····{ |
16101 | ········try |
16102 | ········{ |
16103 | ············pm.UnloadCache(); |
16104 | ············var l = pm.Objects<CmpDir1OthpconTblGuidLeft>().ResultTable; |
16105 | ············pm.Delete(l); |
16106 | ············pm.Save(); |
16107 | ············pm.UnloadCache(); |
16108 | ············decimal count; |
16109 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16110 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16111 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16112 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16113 | ········} |
16114 | ········catch (Exception) |
16115 | ········{ |
16116 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16117 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16118 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16119 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16120 | ········} |
16121 | ····} |
16122 | ····[Test] |
16123 | ····public void TestSaveReload() |
16124 | ····{ |
16125 | ········CreateObjects(); |
16126 | ········QueryOwn(); |
16127 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16128 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16129 | ····} |
16130 | ····[Test] |
16131 | ····public void TestSaveReloadNull() |
16132 | ····{ |
16133 | ········CreateObjects(); |
16134 | ········QueryOwn(); |
16135 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16136 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16137 | ········ownVar.RelField = null; |
16138 | ········pm.Save(); |
16139 | ········pm.UnloadCache(); |
16140 | ········QueryOwn(); |
16141 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16142 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16143 | ····} |
16144 | ····[Test] |
16145 | ····public void TestChangeKeyHolderLeft() |
16146 | ····{ |
16147 | ········CreateObjects(); |
16148 | ········QueryOwn(); |
16149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16151 | ········int x = ownVar.RelField.Dummy; |
16152 | ········ownVar.Dummy = 4711; |
16153 | ········pm.Save(); |
16154 | ········pm.UnloadCache(); |
16155 | ········QueryOwn(); |
16156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16157 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16158 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16159 | ····} |
16160 | ····[Test] |
16161 | ····public void TestChangeKeyHolderLeftNoTouch() |
16162 | ····{ |
16163 | ········CreateObjects(); |
16164 | ········QueryOwn(); |
16165 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16166 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16167 | ········ownVar.Dummy = 4711; |
16168 | ········pm.Save(); |
16169 | ········pm.UnloadCache(); |
16170 | ········QueryOwn(); |
16171 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16172 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16174 | ····} |
16175 | ····void CreateObjects() |
16176 | ····{ |
16177 | ········pm.MakePersistent(ownVar); |
16178 | ········ownVar.AssignRelation(otherVar); |
16179 | ········pm.Save(); |
16180 | ········pm.UnloadCache(); |
16181 | ····} |
16182 | ····void QueryOwn() |
16183 | ····{ |
16184 | ········var q = new NDOQuery<CmpDir1OthpconTblGuidLeft>(pm); |
16185 | ········ownVar = q.ExecuteSingle(); |
16186 | ····} |
16187 | ····void QueryOther() |
16188 | ····{ |
16189 | ········var q = new NDOQuery<CmpDir1OthpconTblGuidRightBase>(pm); |
16190 | ········otherVar = q.ExecuteSingle(); |
16191 | ····} |
16192 | } |
16193 | |
16194 | |
16195 | [TestFixture] |
16196 | public class TestCmpBi11OthpconNoTblGuid : NDOTest |
16197 | { |
16198 | ····CmpBi11OthpconNoTblGuidLeft ownVar; |
16199 | ····CmpBi11OthpconNoTblGuidRightBase otherVar; |
16200 | ····PersistenceManager pm; |
16201 | ····[SetUp] |
16202 | ····public void Setup() |
16203 | ····{ |
16204 | ········pm = PmFactory.NewPersistenceManager(); |
16205 | ········ownVar = new CmpBi11OthpconNoTblGuidLeft(); |
16206 | ········otherVar = new CmpBi11OthpconNoTblGuidRightDerived(); |
16207 | ····} |
16208 | ····[TearDown] |
16209 | ····public void TearDown() |
16210 | ····{ |
16211 | ········try |
16212 | ········{ |
16213 | ············pm.UnloadCache(); |
16214 | ············var l = pm.Objects<CmpBi11OthpconNoTblGuidLeft>().ResultTable; |
16215 | ············pm.Delete(l); |
16216 | ············pm.Save(); |
16217 | ············pm.UnloadCache(); |
16218 | ············decimal count; |
16219 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16220 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16221 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16222 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16223 | ········} |
16224 | ········catch (Exception) |
16225 | ········{ |
16226 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16227 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16228 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16229 | ········} |
16230 | ····} |
16231 | ····[Test] |
16232 | ····public void TestSaveReload() |
16233 | ····{ |
16234 | ········CreateObjects(); |
16235 | ········QueryOwn(); |
16236 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16237 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16238 | ····} |
16239 | ····[Test] |
16240 | ····public void TestSaveReloadNull() |
16241 | ····{ |
16242 | ········CreateObjects(); |
16243 | ········QueryOwn(); |
16244 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16245 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16246 | ········ownVar.RelField = null; |
16247 | ········pm.Save(); |
16248 | ········pm.UnloadCache(); |
16249 | ········QueryOwn(); |
16250 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16251 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16252 | ····} |
16253 | ····[Test] |
16254 | ····public void TestChangeKeyHolderLeft() |
16255 | ····{ |
16256 | ········CreateObjects(); |
16257 | ········QueryOwn(); |
16258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16259 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16260 | ········int x = ownVar.RelField.Dummy; |
16261 | ········ownVar.Dummy = 4711; |
16262 | ········pm.Save(); |
16263 | ········pm.UnloadCache(); |
16264 | ········QueryOwn(); |
16265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16266 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16268 | ····} |
16269 | ····[Test] |
16270 | ····public void TestChangeKeyHolderRight() |
16271 | ····{ |
16272 | ········CreateObjects(); |
16273 | ········QueryOther(); |
16274 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16275 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16276 | ········int x = otherVar.RelField.Dummy; |
16277 | ········otherVar.Dummy = 4711; |
16278 | ········pm.Save(); |
16279 | ········pm.UnloadCache(); |
16280 | ········QueryOther(); |
16281 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16282 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16283 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16284 | ····} |
16285 | ····[Test] |
16286 | ····public void TestChangeKeyHolderLeftNoTouch() |
16287 | ····{ |
16288 | ········CreateObjects(); |
16289 | ········QueryOwn(); |
16290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16291 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16292 | ········ownVar.Dummy = 4711; |
16293 | ········pm.Save(); |
16294 | ········pm.UnloadCache(); |
16295 | ········QueryOwn(); |
16296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16297 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16298 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16299 | ····} |
16300 | ····[Test] |
16301 | ····public void TestChangeKeyHolderRightNoTouch() |
16302 | ····{ |
16303 | ········CreateObjects(); |
16304 | ········QueryOther(); |
16305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16307 | ········otherVar.Dummy = 4711; |
16308 | ········pm.Save(); |
16309 | ········pm.UnloadCache(); |
16310 | ········QueryOther(); |
16311 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16312 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16313 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16314 | ····} |
16315 | ····[Test] |
16316 | ····public void TestRelationHash() |
16317 | ····{ |
16318 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidLeft)); |
16319 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16320 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidRightBase)); |
16321 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16322 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16323 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16324 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidRightDerived)); |
16325 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16326 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16327 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16328 | ····} |
16329 | ····void CreateObjects() |
16330 | ····{ |
16331 | ········pm.MakePersistent(ownVar); |
16332 | ········ownVar.AssignRelation(otherVar); |
16333 | ········pm.Save(); |
16334 | ········pm.UnloadCache(); |
16335 | ····} |
16336 | ····void QueryOwn() |
16337 | ····{ |
16338 | ········var q = new NDOQuery<CmpBi11OthpconNoTblGuidLeft>(pm); |
16339 | ········ownVar = q.ExecuteSingle(); |
16340 | ····} |
16341 | ····void QueryOther() |
16342 | ····{ |
16343 | ········var q = new NDOQuery<CmpBi11OthpconNoTblGuidRightBase>(pm); |
16344 | ········otherVar = q.ExecuteSingle(); |
16345 | ····} |
16346 | } |
16347 | |
16348 | |
16349 | [TestFixture] |
16350 | public class TestCmpBi11OthpconTblGuid : NDOTest |
16351 | { |
16352 | ····CmpBi11OthpconTblGuidLeft ownVar; |
16353 | ····CmpBi11OthpconTblGuidRightBase otherVar; |
16354 | ····PersistenceManager pm; |
16355 | ····[SetUp] |
16356 | ····public void Setup() |
16357 | ····{ |
16358 | ········pm = PmFactory.NewPersistenceManager(); |
16359 | ········ownVar = new CmpBi11OthpconTblGuidLeft(); |
16360 | ········otherVar = new CmpBi11OthpconTblGuidRightDerived(); |
16361 | ····} |
16362 | ····[TearDown] |
16363 | ····public void TearDown() |
16364 | ····{ |
16365 | ········try |
16366 | ········{ |
16367 | ············pm.UnloadCache(); |
16368 | ············var l = pm.Objects<CmpBi11OthpconTblGuidLeft>().ResultTable; |
16369 | ············pm.Delete(l); |
16370 | ············pm.Save(); |
16371 | ············pm.UnloadCache(); |
16372 | ············decimal count; |
16373 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16374 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16375 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16376 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16377 | ········} |
16378 | ········catch (Exception) |
16379 | ········{ |
16380 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16382 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16383 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16384 | ········} |
16385 | ····} |
16386 | ····[Test] |
16387 | ····public void TestSaveReload() |
16388 | ····{ |
16389 | ········CreateObjects(); |
16390 | ········QueryOwn(); |
16391 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16392 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16393 | ····} |
16394 | ····[Test] |
16395 | ····public void TestSaveReloadNull() |
16396 | ····{ |
16397 | ········CreateObjects(); |
16398 | ········QueryOwn(); |
16399 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16400 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16401 | ········ownVar.RelField = null; |
16402 | ········pm.Save(); |
16403 | ········pm.UnloadCache(); |
16404 | ········QueryOwn(); |
16405 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16406 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16407 | ····} |
16408 | ····[Test] |
16409 | ····public void TestChangeKeyHolderLeft() |
16410 | ····{ |
16411 | ········CreateObjects(); |
16412 | ········QueryOwn(); |
16413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16414 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16415 | ········int x = ownVar.RelField.Dummy; |
16416 | ········ownVar.Dummy = 4711; |
16417 | ········pm.Save(); |
16418 | ········pm.UnloadCache(); |
16419 | ········QueryOwn(); |
16420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16421 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16422 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16423 | ····} |
16424 | ····[Test] |
16425 | ····public void TestChangeKeyHolderRight() |
16426 | ····{ |
16427 | ········CreateObjects(); |
16428 | ········QueryOther(); |
16429 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16430 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16431 | ········int x = otherVar.RelField.Dummy; |
16432 | ········otherVar.Dummy = 4711; |
16433 | ········pm.Save(); |
16434 | ········pm.UnloadCache(); |
16435 | ········QueryOther(); |
16436 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16437 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16438 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16439 | ····} |
16440 | ····[Test] |
16441 | ····public void TestChangeKeyHolderLeftNoTouch() |
16442 | ····{ |
16443 | ········CreateObjects(); |
16444 | ········QueryOwn(); |
16445 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16447 | ········ownVar.Dummy = 4711; |
16448 | ········pm.Save(); |
16449 | ········pm.UnloadCache(); |
16450 | ········QueryOwn(); |
16451 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16452 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16453 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16454 | ····} |
16455 | ····[Test] |
16456 | ····public void TestChangeKeyHolderRightNoTouch() |
16457 | ····{ |
16458 | ········CreateObjects(); |
16459 | ········QueryOther(); |
16460 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16461 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16462 | ········otherVar.Dummy = 4711; |
16463 | ········pm.Save(); |
16464 | ········pm.UnloadCache(); |
16465 | ········QueryOther(); |
16466 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16467 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16468 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16469 | ····} |
16470 | ····[Test] |
16471 | ····public void TestRelationHash() |
16472 | ····{ |
16473 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidLeft)); |
16474 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16475 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidRightBase)); |
16476 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16477 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16478 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16479 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidRightDerived)); |
16480 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16481 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16482 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16483 | ····} |
16484 | ····void CreateObjects() |
16485 | ····{ |
16486 | ········pm.MakePersistent(ownVar); |
16487 | ········ownVar.AssignRelation(otherVar); |
16488 | ········pm.Save(); |
16489 | ········pm.UnloadCache(); |
16490 | ····} |
16491 | ····void QueryOwn() |
16492 | ····{ |
16493 | ········var q = new NDOQuery<CmpBi11OthpconTblGuidLeft>(pm); |
16494 | ········ownVar = q.ExecuteSingle(); |
16495 | ····} |
16496 | ····void QueryOther() |
16497 | ····{ |
16498 | ········var q = new NDOQuery<CmpBi11OthpconTblGuidRightBase>(pm); |
16499 | ········otherVar = q.ExecuteSingle(); |
16500 | ····} |
16501 | } |
16502 | |
16503 | |
16504 | [TestFixture] |
16505 | public class TestCmpDirnOthpconTblGuid : NDOTest |
16506 | { |
16507 | ····CmpDirnOthpconTblGuidLeft ownVar; |
16508 | ····CmpDirnOthpconTblGuidRightBase otherVar; |
16509 | ····PersistenceManager pm; |
16510 | ····[SetUp] |
16511 | ····public void Setup() |
16512 | ····{ |
16513 | ········pm = PmFactory.NewPersistenceManager(); |
16514 | ········ownVar = new CmpDirnOthpconTblGuidLeft(); |
16515 | ········otherVar = new CmpDirnOthpconTblGuidRightDerived(); |
16516 | ····} |
16517 | ····[TearDown] |
16518 | ····public void TearDown() |
16519 | ····{ |
16520 | ········try |
16521 | ········{ |
16522 | ············pm.UnloadCache(); |
16523 | ············var l = pm.Objects<CmpDirnOthpconTblGuidLeft>().ResultTable; |
16524 | ············pm.Delete(l); |
16525 | ············pm.Save(); |
16526 | ············pm.UnloadCache(); |
16527 | ············decimal count; |
16528 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16529 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16530 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16532 | ········} |
16533 | ········catch (Exception) |
16534 | ········{ |
16535 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16537 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16538 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16539 | ········} |
16540 | ····} |
16541 | ····[Test] |
16542 | ····public void TestSaveReload() |
16543 | ····{ |
16544 | ········CreateObjects(); |
16545 | ········QueryOwn(); |
16546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16547 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16548 | ····} |
16549 | ····[Test] |
16550 | ····public void TestSaveReloadNull() |
16551 | ····{ |
16552 | ········CreateObjects(); |
16553 | ········QueryOwn(); |
16554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16555 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16556 | ········ownVar.RelField = new List<CmpDirnOthpconTblGuidRightBase>(); |
16557 | ········pm.Save(); |
16558 | ········pm.UnloadCache(); |
16559 | ········QueryOwn(); |
16560 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16561 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16562 | ····} |
16563 | ····[Test] |
16564 | ····public void TestSaveReloadRemove() |
16565 | ····{ |
16566 | ········CreateObjects(); |
16567 | ········QueryOwn(); |
16568 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16569 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16570 | ········ownVar.RemoveRelatedObject(); |
16571 | ········pm.Save(); |
16572 | ········pm.UnloadCache(); |
16573 | ········QueryOwn(); |
16574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16575 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16576 | ····} |
16577 | ····void CreateObjects() |
16578 | ····{ |
16579 | ········pm.MakePersistent(ownVar); |
16580 | ········ownVar.AssignRelation(otherVar); |
16581 | ········pm.Save(); |
16582 | ········pm.UnloadCache(); |
16583 | ····} |
16584 | ····void QueryOwn() |
16585 | ····{ |
16586 | ········var q = new NDOQuery<CmpDirnOthpconTblGuidLeft>(pm); |
16587 | ········ownVar = q.ExecuteSingle(); |
16588 | ····} |
16589 | ····void QueryOther() |
16590 | ····{ |
16591 | ········var q = new NDOQuery<CmpDirnOthpconTblGuidRightBase>(pm); |
16592 | ········otherVar = q.ExecuteSingle(); |
16593 | ····} |
16594 | } |
16595 | |
16596 | |
16597 | [TestFixture] |
16598 | public class TestCmpBin1OthpconTblGuid : NDOTest |
16599 | { |
16600 | ····CmpBin1OthpconTblGuidLeft ownVar; |
16601 | ····CmpBin1OthpconTblGuidRightBase otherVar; |
16602 | ····PersistenceManager pm; |
16603 | ····[SetUp] |
16604 | ····public void Setup() |
16605 | ····{ |
16606 | ········pm = PmFactory.NewPersistenceManager(); |
16607 | ········ownVar = new CmpBin1OthpconTblGuidLeft(); |
16608 | ········otherVar = new CmpBin1OthpconTblGuidRightDerived(); |
16609 | ····} |
16610 | ····[TearDown] |
16611 | ····public void TearDown() |
16612 | ····{ |
16613 | ········try |
16614 | ········{ |
16615 | ············pm.UnloadCache(); |
16616 | ············var l = pm.Objects<CmpBin1OthpconTblGuidLeft>().ResultTable; |
16617 | ············pm.Delete(l); |
16618 | ············pm.Save(); |
16619 | ············pm.UnloadCache(); |
16620 | ············decimal count; |
16621 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16622 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16623 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16625 | ········} |
16626 | ········catch (Exception) |
16627 | ········{ |
16628 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16629 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16630 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16631 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16632 | ········} |
16633 | ····} |
16634 | ····[Test] |
16635 | ····public void TestSaveReload() |
16636 | ····{ |
16637 | ········CreateObjects(); |
16638 | ········QueryOwn(); |
16639 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16640 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16641 | ····} |
16642 | ····[Test] |
16643 | ····public void TestSaveReloadNull() |
16644 | ····{ |
16645 | ········CreateObjects(); |
16646 | ········QueryOwn(); |
16647 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16648 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16649 | ········ownVar.RelField = new List<CmpBin1OthpconTblGuidRightBase>(); |
16650 | ········pm.Save(); |
16651 | ········pm.UnloadCache(); |
16652 | ········QueryOwn(); |
16653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16654 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16655 | ····} |
16656 | ····[Test] |
16657 | ····public void TestSaveReloadRemove() |
16658 | ····{ |
16659 | ········CreateObjects(); |
16660 | ········QueryOwn(); |
16661 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16662 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16663 | ········ownVar.RemoveRelatedObject(); |
16664 | ········pm.Save(); |
16665 | ········pm.UnloadCache(); |
16666 | ········QueryOwn(); |
16667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16668 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16669 | ····} |
16670 | ····[Test] |
16671 | ····public void TestChangeKeyHolderRight() |
16672 | ····{ |
16673 | ········CreateObjects(); |
16674 | ········QueryOther(); |
16675 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16676 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16677 | ········int x = otherVar.RelField.Dummy; |
16678 | ········otherVar.Dummy = 4711; |
16679 | ········pm.Save(); |
16680 | ········pm.UnloadCache(); |
16681 | ········QueryOther(); |
16682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16683 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16684 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16685 | ····} |
16686 | ····[Test] |
16687 | ····public void TestChangeKeyHolderRightNoTouch() |
16688 | ····{ |
16689 | ········CreateObjects(); |
16690 | ········QueryOther(); |
16691 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16692 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16693 | ········otherVar.Dummy = 4711; |
16694 | ········pm.Save(); |
16695 | ········pm.UnloadCache(); |
16696 | ········QueryOther(); |
16697 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16698 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16699 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16700 | ····} |
16701 | ····[Test] |
16702 | ····public void TestRelationHash() |
16703 | ····{ |
16704 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidLeft)); |
16705 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16706 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidRightBase)); |
16707 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16708 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16709 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16710 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidRightDerived)); |
16711 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16712 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16713 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16714 | ····} |
16715 | ····void CreateObjects() |
16716 | ····{ |
16717 | ········pm.MakePersistent(ownVar); |
16718 | ········ownVar.AssignRelation(otherVar); |
16719 | ········pm.Save(); |
16720 | ········pm.UnloadCache(); |
16721 | ····} |
16722 | ····void QueryOwn() |
16723 | ····{ |
16724 | ········var q = new NDOQuery<CmpBin1OthpconTblGuidLeft>(pm); |
16725 | ········ownVar = q.ExecuteSingle(); |
16726 | ····} |
16727 | ····void QueryOther() |
16728 | ····{ |
16729 | ········var q = new NDOQuery<CmpBin1OthpconTblGuidRightBase>(pm); |
16730 | ········otherVar = q.ExecuteSingle(); |
16731 | ····} |
16732 | } |
16733 | |
16734 | |
16735 | [TestFixture] |
16736 | public class TestCmpBi1nOthpconNoTblGuid : NDOTest |
16737 | { |
16738 | ····CmpBi1nOthpconNoTblGuidLeft ownVar; |
16739 | ····CmpBi1nOthpconNoTblGuidRightBase otherVar; |
16740 | ····PersistenceManager pm; |
16741 | ····[SetUp] |
16742 | ····public void Setup() |
16743 | ····{ |
16744 | ········pm = PmFactory.NewPersistenceManager(); |
16745 | ········ownVar = new CmpBi1nOthpconNoTblGuidLeft(); |
16746 | ········otherVar = new CmpBi1nOthpconNoTblGuidRightDerived(); |
16747 | ····} |
16748 | ····[TearDown] |
16749 | ····public void TearDown() |
16750 | ····{ |
16751 | ········try |
16752 | ········{ |
16753 | ············pm.UnloadCache(); |
16754 | ············var l = pm.Objects<CmpBi1nOthpconNoTblGuidLeft>().ResultTable; |
16755 | ············pm.Delete(l); |
16756 | ············pm.Save(); |
16757 | ············pm.UnloadCache(); |
16758 | ············decimal count; |
16759 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16761 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16763 | ········} |
16764 | ········catch (Exception) |
16765 | ········{ |
16766 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16767 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16768 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16769 | ········} |
16770 | ····} |
16771 | ····[Test] |
16772 | ····public void TestSaveReload() |
16773 | ····{ |
16774 | ········CreateObjects(); |
16775 | ········QueryOwn(); |
16776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16777 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16778 | ····} |
16779 | ····[Test] |
16780 | ····public void TestSaveReloadNull() |
16781 | ····{ |
16782 | ········CreateObjects(); |
16783 | ········QueryOwn(); |
16784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16785 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16786 | ········ownVar.RelField = null; |
16787 | ········pm.Save(); |
16788 | ········pm.UnloadCache(); |
16789 | ········QueryOwn(); |
16790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16791 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16792 | ····} |
16793 | ····[Test] |
16794 | ····public void TestChangeKeyHolderLeft() |
16795 | ····{ |
16796 | ········CreateObjects(); |
16797 | ········QueryOwn(); |
16798 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16799 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16800 | ········int x = ownVar.RelField.Dummy; |
16801 | ········ownVar.Dummy = 4711; |
16802 | ········pm.Save(); |
16803 | ········pm.UnloadCache(); |
16804 | ········QueryOwn(); |
16805 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16806 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16807 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16808 | ····} |
16809 | ····[Test] |
16810 | ····public void TestChangeKeyHolderLeftNoTouch() |
16811 | ····{ |
16812 | ········CreateObjects(); |
16813 | ········QueryOwn(); |
16814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16815 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16816 | ········ownVar.Dummy = 4711; |
16817 | ········pm.Save(); |
16818 | ········pm.UnloadCache(); |
16819 | ········QueryOwn(); |
16820 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16821 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16823 | ····} |
16824 | ····[Test] |
16825 | ····public void TestRelationHash() |
16826 | ····{ |
16827 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidLeft)); |
16828 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16829 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidRightBase)); |
16830 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16831 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16832 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16833 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidRightDerived)); |
16834 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16835 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16836 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16837 | ····} |
16838 | ····void CreateObjects() |
16839 | ····{ |
16840 | ········pm.MakePersistent(ownVar); |
16841 | ········ownVar.AssignRelation(otherVar); |
16842 | ········pm.Save(); |
16843 | ········pm.UnloadCache(); |
16844 | ····} |
16845 | ····void QueryOwn() |
16846 | ····{ |
16847 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblGuidLeft>(pm); |
16848 | ········ownVar = q.ExecuteSingle(); |
16849 | ····} |
16850 | ····void QueryOther() |
16851 | ····{ |
16852 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblGuidRightBase>(pm); |
16853 | ········otherVar = q.ExecuteSingle(); |
16854 | ····} |
16855 | } |
16856 | |
16857 | |
16858 | [TestFixture] |
16859 | public class TestCmpBi1nOthpconTblGuid : NDOTest |
16860 | { |
16861 | ····CmpBi1nOthpconTblGuidLeft ownVar; |
16862 | ····CmpBi1nOthpconTblGuidRightBase otherVar; |
16863 | ····PersistenceManager pm; |
16864 | ····[SetUp] |
16865 | ····public void Setup() |
16866 | ····{ |
16867 | ········pm = PmFactory.NewPersistenceManager(); |
16868 | ········ownVar = new CmpBi1nOthpconTblGuidLeft(); |
16869 | ········otherVar = new CmpBi1nOthpconTblGuidRightDerived(); |
16870 | ····} |
16871 | ····[TearDown] |
16872 | ····public void TearDown() |
16873 | ····{ |
16874 | ········try |
16875 | ········{ |
16876 | ············pm.UnloadCache(); |
16877 | ············var l = pm.Objects<CmpBi1nOthpconTblGuidLeft>().ResultTable; |
16878 | ············pm.Delete(l); |
16879 | ············pm.Save(); |
16880 | ············pm.UnloadCache(); |
16881 | ············decimal count; |
16882 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16883 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16884 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16885 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16886 | ········} |
16887 | ········catch (Exception) |
16888 | ········{ |
16889 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16890 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16891 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16892 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16893 | ········} |
16894 | ····} |
16895 | ····[Test] |
16896 | ····public void TestSaveReload() |
16897 | ····{ |
16898 | ········CreateObjects(); |
16899 | ········QueryOwn(); |
16900 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16901 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16902 | ····} |
16903 | ····[Test] |
16904 | ····public void TestSaveReloadNull() |
16905 | ····{ |
16906 | ········CreateObjects(); |
16907 | ········QueryOwn(); |
16908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16910 | ········ownVar.RelField = null; |
16911 | ········pm.Save(); |
16912 | ········pm.UnloadCache(); |
16913 | ········QueryOwn(); |
16914 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16915 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16916 | ····} |
16917 | ····[Test] |
16918 | ····public void TestChangeKeyHolderLeft() |
16919 | ····{ |
16920 | ········CreateObjects(); |
16921 | ········QueryOwn(); |
16922 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16923 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16924 | ········int x = ownVar.RelField.Dummy; |
16925 | ········ownVar.Dummy = 4711; |
16926 | ········pm.Save(); |
16927 | ········pm.UnloadCache(); |
16928 | ········QueryOwn(); |
16929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16930 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16931 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16932 | ····} |
16933 | ····[Test] |
16934 | ····public void TestChangeKeyHolderLeftNoTouch() |
16935 | ····{ |
16936 | ········CreateObjects(); |
16937 | ········QueryOwn(); |
16938 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16939 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16940 | ········ownVar.Dummy = 4711; |
16941 | ········pm.Save(); |
16942 | ········pm.UnloadCache(); |
16943 | ········QueryOwn(); |
16944 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16945 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16947 | ····} |
16948 | ····[Test] |
16949 | ····public void TestRelationHash() |
16950 | ····{ |
16951 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidLeft)); |
16952 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16953 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidRightBase)); |
16954 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16955 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16956 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16957 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidRightDerived)); |
16958 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16959 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16960 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16961 | ····} |
16962 | ····void CreateObjects() |
16963 | ····{ |
16964 | ········pm.MakePersistent(ownVar); |
16965 | ········ownVar.AssignRelation(otherVar); |
16966 | ········pm.Save(); |
16967 | ········pm.UnloadCache(); |
16968 | ····} |
16969 | ····void QueryOwn() |
16970 | ····{ |
16971 | ········var q = new NDOQuery<CmpBi1nOthpconTblGuidLeft>(pm); |
16972 | ········ownVar = q.ExecuteSingle(); |
16973 | ····} |
16974 | ····void QueryOther() |
16975 | ····{ |
16976 | ········var q = new NDOQuery<CmpBi1nOthpconTblGuidRightBase>(pm); |
16977 | ········otherVar = q.ExecuteSingle(); |
16978 | ····} |
16979 | } |
16980 | |
16981 | |
16982 | [TestFixture] |
16983 | public class TestCmpBinnOthpconTblGuid : NDOTest |
16984 | { |
16985 | ····CmpBinnOthpconTblGuidLeft ownVar; |
16986 | ····CmpBinnOthpconTblGuidRightBase otherVar; |
16987 | ····PersistenceManager pm; |
16988 | ····[SetUp] |
16989 | ····public void Setup() |
16990 | ····{ |
16991 | ········pm = PmFactory.NewPersistenceManager(); |
16992 | ········ownVar = new CmpBinnOthpconTblGuidLeft(); |
16993 | ········otherVar = new CmpBinnOthpconTblGuidRightDerived(); |
16994 | ····} |
16995 | ····[TearDown] |
16996 | ····public void TearDown() |
16997 | ····{ |
16998 | ········try |
16999 | ········{ |
17000 | ············pm.UnloadCache(); |
17001 | ············var l = pm.Objects<CmpBinnOthpconTblGuidLeft>().ResultTable; |
17002 | ············pm.Delete(l); |
17003 | ············pm.Save(); |
17004 | ············pm.UnloadCache(); |
17005 | ············decimal count; |
17006 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17007 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17008 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17009 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17010 | ········} |
17011 | ········catch (Exception) |
17012 | ········{ |
17013 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17014 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17015 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17016 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17017 | ········} |
17018 | ····} |
17019 | ····[Test] |
17020 | ····public void TestSaveReload() |
17021 | ····{ |
17022 | ········CreateObjects(); |
17023 | ········QueryOwn(); |
17024 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17025 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17026 | ····} |
17027 | ····[Test] |
17028 | ····public void TestSaveReloadNull() |
17029 | ····{ |
17030 | ········CreateObjects(); |
17031 | ········QueryOwn(); |
17032 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17033 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17034 | ········ownVar.RelField = new List<CmpBinnOthpconTblGuidRightBase>(); |
17035 | ········pm.Save(); |
17036 | ········pm.UnloadCache(); |
17037 | ········QueryOwn(); |
17038 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17039 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17040 | ····} |
17041 | ····[Test] |
17042 | ····public void TestSaveReloadRemove() |
17043 | ····{ |
17044 | ········CreateObjects(); |
17045 | ········QueryOwn(); |
17046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17047 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17048 | ········ownVar.RemoveRelatedObject(); |
17049 | ········pm.Save(); |
17050 | ········pm.UnloadCache(); |
17051 | ········QueryOwn(); |
17052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17053 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17054 | ····} |
17055 | ····[Test] |
17056 | ····public void TestRelationHash() |
17057 | ····{ |
17058 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidLeft)); |
17059 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17060 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidRightBase)); |
17061 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17062 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17063 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17064 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidRightDerived)); |
17065 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17066 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17067 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17068 | ····} |
17069 | ····void CreateObjects() |
17070 | ····{ |
17071 | ········pm.MakePersistent(ownVar); |
17072 | ········ownVar.AssignRelation(otherVar); |
17073 | ········pm.Save(); |
17074 | ········pm.UnloadCache(); |
17075 | ····} |
17076 | ····void QueryOwn() |
17077 | ····{ |
17078 | ········var q = new NDOQuery<CmpBinnOthpconTblGuidLeft>(pm); |
17079 | ········ownVar = q.ExecuteSingle(); |
17080 | ····} |
17081 | ····void QueryOther() |
17082 | ····{ |
17083 | ········var q = new NDOQuery<CmpBinnOthpconTblGuidRightBase>(pm); |
17084 | ········otherVar = q.ExecuteSingle(); |
17085 | ····} |
17086 | } |
17087 | |
17088 | |
17089 | [TestFixture] |
17090 | public class TestAgrDir1OwnpconOthpconNoTblGuid : NDOTest |
17091 | { |
17092 | ····AgrDir1OwnpconOthpconNoTblGuidLeftBase ownVar; |
17093 | ····AgrDir1OwnpconOthpconNoTblGuidRightBase otherVar; |
17094 | ····PersistenceManager pm; |
17095 | ····[SetUp] |
17096 | ····public void Setup() |
17097 | ····{ |
17098 | ········pm = PmFactory.NewPersistenceManager(); |
17099 | ········ownVar = new AgrDir1OwnpconOthpconNoTblGuidLeftDerived(); |
17100 | ········otherVar = new AgrDir1OwnpconOthpconNoTblGuidRightDerived(); |
17101 | ····} |
17102 | ····[TearDown] |
17103 | ····public void TearDown() |
17104 | ····{ |
17105 | ········try |
17106 | ········{ |
17107 | ············pm.UnloadCache(); |
17108 | ············var l = pm.Objects<AgrDir1OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
17109 | ············pm.Delete(l); |
17110 | ············pm.Save(); |
17111 | ············pm.UnloadCache(); |
17112 | ············var m = pm.Objects<AgrDir1OwnpconOthpconNoTblGuidRightBase>().ResultTable; |
17113 | ············pm.Delete(m); |
17114 | ············pm.Save(); |
17115 | ············pm.UnloadCache(); |
17116 | ············decimal count; |
17117 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17118 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17119 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17120 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17121 | ········} |
17122 | ········catch (Exception) |
17123 | ········{ |
17124 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17125 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17126 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17127 | ········} |
17128 | ····} |
17129 | ····[Test] |
17130 | ····public void TestSaveReload() |
17131 | ····{ |
17132 | ········CreateObjects(); |
17133 | ········QueryOwn(); |
17134 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17135 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17136 | ····} |
17137 | ····[Test] |
17138 | ····public void TestSaveReloadNull() |
17139 | ····{ |
17140 | ········CreateObjects(); |
17141 | ········QueryOwn(); |
17142 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17143 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17144 | ········ownVar.RelField = null; |
17145 | ········pm.Save(); |
17146 | ········pm.UnloadCache(); |
17147 | ········QueryOwn(); |
17148 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17149 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17150 | ····} |
17151 | ····[Test] |
17152 | ····public void TestChangeKeyHolderLeft() |
17153 | ····{ |
17154 | ········CreateObjects(); |
17155 | ········QueryOwn(); |
17156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17157 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17158 | ········int x = ownVar.RelField.Dummy; |
17159 | ········ownVar.Dummy = 4711; |
17160 | ········pm.Save(); |
17161 | ········pm.UnloadCache(); |
17162 | ········QueryOwn(); |
17163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17164 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17165 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17166 | ····} |
17167 | ····[Test] |
17168 | ····public void TestChangeKeyHolderLeftNoTouch() |
17169 | ····{ |
17170 | ········CreateObjects(); |
17171 | ········QueryOwn(); |
17172 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17174 | ········ownVar.Dummy = 4711; |
17175 | ········pm.Save(); |
17176 | ········pm.UnloadCache(); |
17177 | ········QueryOwn(); |
17178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17179 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17181 | ····} |
17182 | ····void CreateObjects() |
17183 | ····{ |
17184 | ········pm.MakePersistent(ownVar); |
17185 | ········pm.MakePersistent(otherVar); |
17186 | ········ownVar.AssignRelation(otherVar); |
17187 | ········pm.Save(); |
17188 | ········pm.UnloadCache(); |
17189 | ····} |
17190 | ····void QueryOwn() |
17191 | ····{ |
17192 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidLeftBase>(pm); |
17193 | ········ownVar = q.ExecuteSingle(); |
17194 | ····} |
17195 | ····void QueryOther() |
17196 | ····{ |
17197 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidRightBase>(pm); |
17198 | ········otherVar = q.ExecuteSingle(); |
17199 | ····} |
17200 | } |
17201 | |
17202 | |
17203 | [TestFixture] |
17204 | public class TestAgrDir1OwnpconOthpconTblGuid : NDOTest |
17205 | { |
17206 | ····AgrDir1OwnpconOthpconTblGuidLeftBase ownVar; |
17207 | ····AgrDir1OwnpconOthpconTblGuidRightBase otherVar; |
17208 | ····PersistenceManager pm; |
17209 | ····[SetUp] |
17210 | ····public void Setup() |
17211 | ····{ |
17212 | ········pm = PmFactory.NewPersistenceManager(); |
17213 | ········ownVar = new AgrDir1OwnpconOthpconTblGuidLeftDerived(); |
17214 | ········otherVar = new AgrDir1OwnpconOthpconTblGuidRightDerived(); |
17215 | ····} |
17216 | ····[TearDown] |
17217 | ····public void TearDown() |
17218 | ····{ |
17219 | ········try |
17220 | ········{ |
17221 | ············pm.UnloadCache(); |
17222 | ············var l = pm.Objects<AgrDir1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17223 | ············pm.Delete(l); |
17224 | ············pm.Save(); |
17225 | ············pm.UnloadCache(); |
17226 | ············var m = pm.Objects<AgrDir1OwnpconOthpconTblGuidRightBase>().ResultTable; |
17227 | ············pm.Delete(m); |
17228 | ············pm.Save(); |
17229 | ············pm.UnloadCache(); |
17230 | ············decimal count; |
17231 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17232 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17233 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17234 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17235 | ········} |
17236 | ········catch (Exception) |
17237 | ········{ |
17238 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17239 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17240 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17241 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17242 | ········} |
17243 | ····} |
17244 | ····[Test] |
17245 | ····public void TestSaveReload() |
17246 | ····{ |
17247 | ········CreateObjects(); |
17248 | ········QueryOwn(); |
17249 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17250 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17251 | ····} |
17252 | ····[Test] |
17253 | ····public void TestSaveReloadNull() |
17254 | ····{ |
17255 | ········CreateObjects(); |
17256 | ········QueryOwn(); |
17257 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17258 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17259 | ········ownVar.RelField = null; |
17260 | ········pm.Save(); |
17261 | ········pm.UnloadCache(); |
17262 | ········QueryOwn(); |
17263 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17264 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17265 | ····} |
17266 | ····[Test] |
17267 | ····public void TestChangeKeyHolderLeft() |
17268 | ····{ |
17269 | ········CreateObjects(); |
17270 | ········QueryOwn(); |
17271 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17272 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17273 | ········int x = ownVar.RelField.Dummy; |
17274 | ········ownVar.Dummy = 4711; |
17275 | ········pm.Save(); |
17276 | ········pm.UnloadCache(); |
17277 | ········QueryOwn(); |
17278 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17279 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17280 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17281 | ····} |
17282 | ····[Test] |
17283 | ····public void TestChangeKeyHolderLeftNoTouch() |
17284 | ····{ |
17285 | ········CreateObjects(); |
17286 | ········QueryOwn(); |
17287 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17288 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17289 | ········ownVar.Dummy = 4711; |
17290 | ········pm.Save(); |
17291 | ········pm.UnloadCache(); |
17292 | ········QueryOwn(); |
17293 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17294 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17295 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17296 | ····} |
17297 | ····void CreateObjects() |
17298 | ····{ |
17299 | ········pm.MakePersistent(ownVar); |
17300 | ········pm.MakePersistent(otherVar); |
17301 | ········ownVar.AssignRelation(otherVar); |
17302 | ········pm.Save(); |
17303 | ········pm.UnloadCache(); |
17304 | ····} |
17305 | ····void QueryOwn() |
17306 | ····{ |
17307 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblGuidLeftBase>(pm); |
17308 | ········ownVar = q.ExecuteSingle(); |
17309 | ····} |
17310 | ····void QueryOther() |
17311 | ····{ |
17312 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblGuidRightBase>(pm); |
17313 | ········otherVar = q.ExecuteSingle(); |
17314 | ····} |
17315 | } |
17316 | |
17317 | |
17318 | [TestFixture] |
17319 | public class TestAgrBi11OwnpconOthpconNoTblGuid : NDOTest |
17320 | { |
17321 | ····AgrBi11OwnpconOthpconNoTblGuidLeftBase ownVar; |
17322 | ····AgrBi11OwnpconOthpconNoTblGuidRightBase otherVar; |
17323 | ····PersistenceManager pm; |
17324 | ····[SetUp] |
17325 | ····public void Setup() |
17326 | ····{ |
17327 | ········pm = PmFactory.NewPersistenceManager(); |
17328 | ········ownVar = new AgrBi11OwnpconOthpconNoTblGuidLeftDerived(); |
17329 | ········otherVar = new AgrBi11OwnpconOthpconNoTblGuidRightDerived(); |
17330 | ····} |
17331 | ····[TearDown] |
17332 | ····public void TearDown() |
17333 | ····{ |
17334 | ········try |
17335 | ········{ |
17336 | ············pm.UnloadCache(); |
17337 | ············var l = pm.Objects<AgrBi11OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
17338 | ············pm.Delete(l); |
17339 | ············pm.Save(); |
17340 | ············pm.UnloadCache(); |
17341 | ············var m = pm.Objects<AgrBi11OwnpconOthpconNoTblGuidRightBase>().ResultTable; |
17342 | ············pm.Delete(m); |
17343 | ············pm.Save(); |
17344 | ············pm.UnloadCache(); |
17345 | ············decimal count; |
17346 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17347 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17348 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17349 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17350 | ········} |
17351 | ········catch (Exception) |
17352 | ········{ |
17353 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17354 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17355 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17356 | ········} |
17357 | ····} |
17358 | ····[Test] |
17359 | ····public void TestSaveReload() |
17360 | ····{ |
17361 | ········CreateObjects(); |
17362 | ········QueryOwn(); |
17363 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17364 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17365 | ····} |
17366 | ····[Test] |
17367 | ····public void TestSaveReloadNull() |
17368 | ····{ |
17369 | ········CreateObjects(); |
17370 | ········QueryOwn(); |
17371 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17372 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17373 | ········ownVar.RelField = null; |
17374 | ········pm.Save(); |
17375 | ········pm.UnloadCache(); |
17376 | ········QueryOwn(); |
17377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17378 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17379 | ····} |
17380 | ····[Test] |
17381 | ····public void TestChangeKeyHolderLeft() |
17382 | ····{ |
17383 | ········CreateObjects(); |
17384 | ········QueryOwn(); |
17385 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17386 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17387 | ········int x = ownVar.RelField.Dummy; |
17388 | ········ownVar.Dummy = 4711; |
17389 | ········pm.Save(); |
17390 | ········pm.UnloadCache(); |
17391 | ········QueryOwn(); |
17392 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17393 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17394 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17395 | ····} |
17396 | ····[Test] |
17397 | ····public void TestChangeKeyHolderRight() |
17398 | ····{ |
17399 | ········CreateObjects(); |
17400 | ········QueryOther(); |
17401 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17402 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17403 | ········int x = otherVar.RelField.Dummy; |
17404 | ········otherVar.Dummy = 4711; |
17405 | ········pm.Save(); |
17406 | ········pm.UnloadCache(); |
17407 | ········QueryOther(); |
17408 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17409 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17410 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17411 | ····} |
17412 | ····[Test] |
17413 | ····public void TestChangeKeyHolderLeftNoTouch() |
17414 | ····{ |
17415 | ········CreateObjects(); |
17416 | ········QueryOwn(); |
17417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17419 | ········ownVar.Dummy = 4711; |
17420 | ········pm.Save(); |
17421 | ········pm.UnloadCache(); |
17422 | ········QueryOwn(); |
17423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17424 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17425 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17426 | ····} |
17427 | ····[Test] |
17428 | ····public void TestChangeKeyHolderRightNoTouch() |
17429 | ····{ |
17430 | ········CreateObjects(); |
17431 | ········QueryOther(); |
17432 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17433 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17434 | ········otherVar.Dummy = 4711; |
17435 | ········pm.Save(); |
17436 | ········pm.UnloadCache(); |
17437 | ········QueryOther(); |
17438 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17439 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17440 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17441 | ····} |
17442 | ····[Test] |
17443 | ····public void TestRelationHash() |
17444 | ····{ |
17445 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidLeftBase)); |
17446 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17447 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidRightBase)); |
17448 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17449 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17450 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17451 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidLeftDerived)); |
17452 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17453 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17454 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17455 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidRightDerived)); |
17456 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17457 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17458 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17459 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17460 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17461 | ····} |
17462 | ····void CreateObjects() |
17463 | ····{ |
17464 | ········pm.MakePersistent(ownVar); |
17465 | ········pm.MakePersistent(otherVar); |
17466 | ········ownVar.AssignRelation(otherVar); |
17467 | ········pm.Save(); |
17468 | ········pm.UnloadCache(); |
17469 | ····} |
17470 | ····void QueryOwn() |
17471 | ····{ |
17472 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidLeftBase>(pm); |
17473 | ········ownVar = q.ExecuteSingle(); |
17474 | ····} |
17475 | ····void QueryOther() |
17476 | ····{ |
17477 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidRightBase>(pm); |
17478 | ········otherVar = q.ExecuteSingle(); |
17479 | ····} |
17480 | } |
17481 | |
17482 | |
17483 | [TestFixture] |
17484 | public class TestAgrBi11OwnpconOthpconTblGuid : NDOTest |
17485 | { |
17486 | ····AgrBi11OwnpconOthpconTblGuidLeftBase ownVar; |
17487 | ····AgrBi11OwnpconOthpconTblGuidRightBase otherVar; |
17488 | ····PersistenceManager pm; |
17489 | ····[SetUp] |
17490 | ····public void Setup() |
17491 | ····{ |
17492 | ········pm = PmFactory.NewPersistenceManager(); |
17493 | ········ownVar = new AgrBi11OwnpconOthpconTblGuidLeftDerived(); |
17494 | ········otherVar = new AgrBi11OwnpconOthpconTblGuidRightDerived(); |
17495 | ····} |
17496 | ····[TearDown] |
17497 | ····public void TearDown() |
17498 | ····{ |
17499 | ········try |
17500 | ········{ |
17501 | ············pm.UnloadCache(); |
17502 | ············var l = pm.Objects<AgrBi11OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17503 | ············pm.Delete(l); |
17504 | ············pm.Save(); |
17505 | ············pm.UnloadCache(); |
17506 | ············var m = pm.Objects<AgrBi11OwnpconOthpconTblGuidRightBase>().ResultTable; |
17507 | ············pm.Delete(m); |
17508 | ············pm.Save(); |
17509 | ············pm.UnloadCache(); |
17510 | ············decimal count; |
17511 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17512 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17513 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17514 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17515 | ········} |
17516 | ········catch (Exception) |
17517 | ········{ |
17518 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17519 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17520 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17521 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17522 | ········} |
17523 | ····} |
17524 | ····[Test] |
17525 | ····public void TestSaveReload() |
17526 | ····{ |
17527 | ········CreateObjects(); |
17528 | ········QueryOwn(); |
17529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17530 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17531 | ····} |
17532 | ····[Test] |
17533 | ····public void TestSaveReloadNull() |
17534 | ····{ |
17535 | ········CreateObjects(); |
17536 | ········QueryOwn(); |
17537 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17538 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17539 | ········ownVar.RelField = null; |
17540 | ········pm.Save(); |
17541 | ········pm.UnloadCache(); |
17542 | ········QueryOwn(); |
17543 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17544 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17545 | ····} |
17546 | ····[Test] |
17547 | ····public void TestChangeKeyHolderLeft() |
17548 | ····{ |
17549 | ········CreateObjects(); |
17550 | ········QueryOwn(); |
17551 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17552 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17553 | ········int x = ownVar.RelField.Dummy; |
17554 | ········ownVar.Dummy = 4711; |
17555 | ········pm.Save(); |
17556 | ········pm.UnloadCache(); |
17557 | ········QueryOwn(); |
17558 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17559 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17560 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17561 | ····} |
17562 | ····[Test] |
17563 | ····public void TestChangeKeyHolderRight() |
17564 | ····{ |
17565 | ········CreateObjects(); |
17566 | ········QueryOther(); |
17567 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17568 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17569 | ········int x = otherVar.RelField.Dummy; |
17570 | ········otherVar.Dummy = 4711; |
17571 | ········pm.Save(); |
17572 | ········pm.UnloadCache(); |
17573 | ········QueryOther(); |
17574 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17575 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17576 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17577 | ····} |
17578 | ····[Test] |
17579 | ····public void TestChangeKeyHolderLeftNoTouch() |
17580 | ····{ |
17581 | ········CreateObjects(); |
17582 | ········QueryOwn(); |
17583 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17584 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17585 | ········ownVar.Dummy = 4711; |
17586 | ········pm.Save(); |
17587 | ········pm.UnloadCache(); |
17588 | ········QueryOwn(); |
17589 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17590 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17591 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17592 | ····} |
17593 | ····[Test] |
17594 | ····public void TestChangeKeyHolderRightNoTouch() |
17595 | ····{ |
17596 | ········CreateObjects(); |
17597 | ········QueryOther(); |
17598 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17599 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17600 | ········otherVar.Dummy = 4711; |
17601 | ········pm.Save(); |
17602 | ········pm.UnloadCache(); |
17603 | ········QueryOther(); |
17604 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17605 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17606 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17607 | ····} |
17608 | ····[Test] |
17609 | ····public void TestRelationHash() |
17610 | ····{ |
17611 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidLeftBase)); |
17612 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17613 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidRightBase)); |
17614 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17615 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17616 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17617 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidLeftDerived)); |
17618 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17619 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17620 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17621 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidRightDerived)); |
17622 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17623 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17624 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17625 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17626 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17627 | ····} |
17628 | ····void CreateObjects() |
17629 | ····{ |
17630 | ········pm.MakePersistent(ownVar); |
17631 | ········pm.MakePersistent(otherVar); |
17632 | ········ownVar.AssignRelation(otherVar); |
17633 | ········pm.Save(); |
17634 | ········pm.UnloadCache(); |
17635 | ····} |
17636 | ····void QueryOwn() |
17637 | ····{ |
17638 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblGuidLeftBase>(pm); |
17639 | ········ownVar = q.ExecuteSingle(); |
17640 | ····} |
17641 | ····void QueryOther() |
17642 | ····{ |
17643 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblGuidRightBase>(pm); |
17644 | ········otherVar = q.ExecuteSingle(); |
17645 | ····} |
17646 | } |
17647 | |
17648 | |
17649 | [TestFixture] |
17650 | public class TestAgrDirnOwnpconOthpconTblGuid : NDOTest |
17651 | { |
17652 | ····AgrDirnOwnpconOthpconTblGuidLeftBase ownVar; |
17653 | ····AgrDirnOwnpconOthpconTblGuidRightBase otherVar; |
17654 | ····PersistenceManager pm; |
17655 | ····[SetUp] |
17656 | ····public void Setup() |
17657 | ····{ |
17658 | ········pm = PmFactory.NewPersistenceManager(); |
17659 | ········ownVar = new AgrDirnOwnpconOthpconTblGuidLeftDerived(); |
17660 | ········otherVar = new AgrDirnOwnpconOthpconTblGuidRightDerived(); |
17661 | ····} |
17662 | ····[TearDown] |
17663 | ····public void TearDown() |
17664 | ····{ |
17665 | ········try |
17666 | ········{ |
17667 | ············pm.UnloadCache(); |
17668 | ············var l = pm.Objects<AgrDirnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
17669 | ············pm.Delete(l); |
17670 | ············pm.Save(); |
17671 | ············pm.UnloadCache(); |
17672 | ············var m = pm.Objects<AgrDirnOwnpconOthpconTblGuidRightBase>().ResultTable; |
17673 | ············pm.Delete(m); |
17674 | ············pm.Save(); |
17675 | ············pm.UnloadCache(); |
17676 | ············decimal count; |
17677 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17678 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17679 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17680 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17681 | ········} |
17682 | ········catch (Exception) |
17683 | ········{ |
17684 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17685 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17686 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17687 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17688 | ········} |
17689 | ····} |
17690 | ····[Test] |
17691 | ····public void TestSaveReload() |
17692 | ····{ |
17693 | ········CreateObjects(); |
17694 | ········QueryOwn(); |
17695 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17696 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17697 | ····} |
17698 | ····[Test] |
17699 | ····public void TestSaveReloadNull() |
17700 | ····{ |
17701 | ········CreateObjects(); |
17702 | ········QueryOwn(); |
17703 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17704 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17705 | ········ownVar.RelField = new List<AgrDirnOwnpconOthpconTblGuidRightBase>(); |
17706 | ········pm.Save(); |
17707 | ········pm.UnloadCache(); |
17708 | ········QueryOwn(); |
17709 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17710 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17711 | ····} |
17712 | ····[Test] |
17713 | ····public void TestSaveReloadRemove() |
17714 | ····{ |
17715 | ········CreateObjects(); |
17716 | ········QueryOwn(); |
17717 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17718 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17719 | ········ownVar.RemoveRelatedObject(); |
17720 | ········pm.Save(); |
17721 | ········pm.UnloadCache(); |
17722 | ········QueryOwn(); |
17723 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17724 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17725 | ····} |
17726 | ····void CreateObjects() |
17727 | ····{ |
17728 | ········pm.MakePersistent(ownVar); |
17729 | ········pm.MakePersistent(otherVar); |
17730 | ········ownVar.AssignRelation(otherVar); |
17731 | ········pm.Save(); |
17732 | ········pm.UnloadCache(); |
17733 | ····} |
17734 | ····void QueryOwn() |
17735 | ····{ |
17736 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblGuidLeftBase>(pm); |
17737 | ········ownVar = q.ExecuteSingle(); |
17738 | ····} |
17739 | ····void QueryOther() |
17740 | ····{ |
17741 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblGuidRightBase>(pm); |
17742 | ········otherVar = q.ExecuteSingle(); |
17743 | ····} |
17744 | } |
17745 | |
17746 | |
17747 | [TestFixture] |
17748 | public class TestAgrBin1OwnpconOthpconTblGuid : NDOTest |
17749 | { |
17750 | ····AgrBin1OwnpconOthpconTblGuidLeftBase ownVar; |
17751 | ····AgrBin1OwnpconOthpconTblGuidRightBase otherVar; |
17752 | ····PersistenceManager pm; |
17753 | ····[SetUp] |
17754 | ····public void Setup() |
17755 | ····{ |
17756 | ········pm = PmFactory.NewPersistenceManager(); |
17757 | ········ownVar = new AgrBin1OwnpconOthpconTblGuidLeftDerived(); |
17758 | ········otherVar = new AgrBin1OwnpconOthpconTblGuidRightDerived(); |
17759 | ····} |
17760 | ····[TearDown] |
17761 | ····public void TearDown() |
17762 | ····{ |
17763 | ········try |
17764 | ········{ |
17765 | ············pm.UnloadCache(); |
17766 | ············var l = pm.Objects<AgrBin1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17767 | ············pm.Delete(l); |
17768 | ············pm.Save(); |
17769 | ············pm.UnloadCache(); |
17770 | ············var m = pm.Objects<AgrBin1OwnpconOthpconTblGuidRightBase>().ResultTable; |
17771 | ············pm.Delete(m); |
17772 | ············pm.Save(); |
17773 | ············pm.UnloadCache(); |
17774 | ············decimal count; |
17775 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17776 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17777 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17778 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17779 | ········} |
17780 | ········catch (Exception) |
17781 | ········{ |
17782 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17783 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17784 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17785 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17786 | ········} |
17787 | ····} |
17788 | ····[Test] |
17789 | ····public void TestSaveReload() |
17790 | ····{ |
17791 | ········CreateObjects(); |
17792 | ········QueryOwn(); |
17793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17794 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17795 | ····} |
17796 | ····[Test] |
17797 | ····public void TestSaveReloadNull() |
17798 | ····{ |
17799 | ········CreateObjects(); |
17800 | ········QueryOwn(); |
17801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17802 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17803 | ········ownVar.RelField = new List<AgrBin1OwnpconOthpconTblGuidRightBase>(); |
17804 | ········pm.Save(); |
17805 | ········pm.UnloadCache(); |
17806 | ········QueryOwn(); |
17807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17808 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17809 | ····} |
17810 | ····[Test] |
17811 | ····public void TestSaveReloadRemove() |
17812 | ····{ |
17813 | ········CreateObjects(); |
17814 | ········QueryOwn(); |
17815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17816 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17817 | ········ownVar.RemoveRelatedObject(); |
17818 | ········pm.Save(); |
17819 | ········pm.UnloadCache(); |
17820 | ········QueryOwn(); |
17821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17822 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17823 | ····} |
17824 | ····[Test] |
17825 | ····public void TestChangeKeyHolderRight() |
17826 | ····{ |
17827 | ········CreateObjects(); |
17828 | ········QueryOther(); |
17829 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17830 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17831 | ········int x = otherVar.RelField.Dummy; |
17832 | ········otherVar.Dummy = 4711; |
17833 | ········pm.Save(); |
17834 | ········pm.UnloadCache(); |
17835 | ········QueryOther(); |
17836 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17837 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17838 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17839 | ····} |
17840 | ····[Test] |
17841 | ····public void TestChangeKeyHolderRightNoTouch() |
17842 | ····{ |
17843 | ········CreateObjects(); |
17844 | ········QueryOther(); |
17845 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17846 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17847 | ········otherVar.Dummy = 4711; |
17848 | ········pm.Save(); |
17849 | ········pm.UnloadCache(); |
17850 | ········QueryOther(); |
17851 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17852 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17853 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17854 | ····} |
17855 | ····[Test] |
17856 | ····public void TestRelationHash() |
17857 | ····{ |
17858 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidLeftBase)); |
17859 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17860 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidRightBase)); |
17861 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17862 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17863 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17864 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidLeftDerived)); |
17865 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17866 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17867 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17868 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidRightDerived)); |
17869 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17870 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17871 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17872 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17873 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17874 | ····} |
17875 | ····void CreateObjects() |
17876 | ····{ |
17877 | ········pm.MakePersistent(ownVar); |
17878 | ········pm.MakePersistent(otherVar); |
17879 | ········ownVar.AssignRelation(otherVar); |
17880 | ········pm.Save(); |
17881 | ········pm.UnloadCache(); |
17882 | ····} |
17883 | ····void QueryOwn() |
17884 | ····{ |
17885 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblGuidLeftBase>(pm); |
17886 | ········ownVar = q.ExecuteSingle(); |
17887 | ····} |
17888 | ····void QueryOther() |
17889 | ····{ |
17890 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblGuidRightBase>(pm); |
17891 | ········otherVar = q.ExecuteSingle(); |
17892 | ····} |
17893 | } |
17894 | |
17895 | |
17896 | [TestFixture] |
17897 | public class TestAgrBi1nOwnpconOthpconTblGuid : NDOTest |
17898 | { |
17899 | ····AgrBi1nOwnpconOthpconTblGuidLeftBase ownVar; |
17900 | ····AgrBi1nOwnpconOthpconTblGuidRightBase otherVar; |
17901 | ····PersistenceManager pm; |
17902 | ····[SetUp] |
17903 | ····public void Setup() |
17904 | ····{ |
17905 | ········pm = PmFactory.NewPersistenceManager(); |
17906 | ········ownVar = new AgrBi1nOwnpconOthpconTblGuidLeftDerived(); |
17907 | ········otherVar = new AgrBi1nOwnpconOthpconTblGuidRightDerived(); |
17908 | ····} |
17909 | ····[TearDown] |
17910 | ····public void TearDown() |
17911 | ····{ |
17912 | ········try |
17913 | ········{ |
17914 | ············pm.UnloadCache(); |
17915 | ············var l = pm.Objects<AgrBi1nOwnpconOthpconTblGuidLeftBase>().ResultTable; |
17916 | ············pm.Delete(l); |
17917 | ············pm.Save(); |
17918 | ············pm.UnloadCache(); |
17919 | ············var m = pm.Objects<AgrBi1nOwnpconOthpconTblGuidRightBase>().ResultTable; |
17920 | ············pm.Delete(m); |
17921 | ············pm.Save(); |
17922 | ············pm.UnloadCache(); |
17923 | ············decimal count; |
17924 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17925 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17926 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17927 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17928 | ········} |
17929 | ········catch (Exception) |
17930 | ········{ |
17931 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17932 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17933 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17934 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17935 | ········} |
17936 | ····} |
17937 | ····[Test] |
17938 | ····public void TestSaveReload() |
17939 | ····{ |
17940 | ········CreateObjects(); |
17941 | ········QueryOwn(); |
17942 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17943 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17944 | ····} |
17945 | ····[Test] |
17946 | ····public void TestSaveReloadNull() |
17947 | ····{ |
17948 | ········CreateObjects(); |
17949 | ········QueryOwn(); |
17950 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17951 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17952 | ········ownVar.RelField = null; |
17953 | ········pm.Save(); |
17954 | ········pm.UnloadCache(); |
17955 | ········QueryOwn(); |
17956 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17957 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17958 | ····} |
17959 | ····[Test] |
17960 | ····public void TestChangeKeyHolderLeft() |
17961 | ····{ |
17962 | ········CreateObjects(); |
17963 | ········QueryOwn(); |
17964 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17965 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17966 | ········int x = ownVar.RelField.Dummy; |
17967 | ········ownVar.Dummy = 4711; |
17968 | ········pm.Save(); |
17969 | ········pm.UnloadCache(); |
17970 | ········QueryOwn(); |
17971 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17972 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17973 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17974 | ····} |
17975 | ····[Test] |
17976 | ····public void TestChangeKeyHolderLeftNoTouch() |
17977 | ····{ |
17978 | ········CreateObjects(); |
17979 | ········QueryOwn(); |
17980 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17981 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17982 | ········ownVar.Dummy = 4711; |
17983 | ········pm.Save(); |
17984 | ········pm.UnloadCache(); |
17985 | ········QueryOwn(); |
17986 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17987 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17988 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17989 | ····} |
17990 | ····[Test] |
17991 | ····public void TestRelationHash() |
17992 | ····{ |
17993 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidLeftBase)); |
17994 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17995 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidRightBase)); |
17996 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17997 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17998 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17999 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidLeftDerived)); |
18000 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18001 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18002 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18003 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidRightDerived)); |
18004 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18005 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18006 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18007 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18008 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18009 | ····} |
18010 | ····void CreateObjects() |
18011 | ····{ |
18012 | ········pm.MakePersistent(ownVar); |
18013 | ········pm.MakePersistent(otherVar); |
18014 | ········ownVar.AssignRelation(otherVar); |
18015 | ········pm.Save(); |
18016 | ········pm.UnloadCache(); |
18017 | ····} |
18018 | ····void QueryOwn() |
18019 | ····{ |
18020 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblGuidLeftBase>(pm); |
18021 | ········ownVar = q.ExecuteSingle(); |
18022 | ····} |
18023 | ····void QueryOther() |
18024 | ····{ |
18025 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblGuidRightBase>(pm); |
18026 | ········otherVar = q.ExecuteSingle(); |
18027 | ····} |
18028 | } |
18029 | |
18030 | |
18031 | [TestFixture] |
18032 | public class TestAgrBinnOwnpconOthpconTblGuid : NDOTest |
18033 | { |
18034 | ····AgrBinnOwnpconOthpconTblGuidLeftBase ownVar; |
18035 | ····AgrBinnOwnpconOthpconTblGuidRightBase otherVar; |
18036 | ····PersistenceManager pm; |
18037 | ····[SetUp] |
18038 | ····public void Setup() |
18039 | ····{ |
18040 | ········pm = PmFactory.NewPersistenceManager(); |
18041 | ········ownVar = new AgrBinnOwnpconOthpconTblGuidLeftDerived(); |
18042 | ········otherVar = new AgrBinnOwnpconOthpconTblGuidRightDerived(); |
18043 | ····} |
18044 | ····[TearDown] |
18045 | ····public void TearDown() |
18046 | ····{ |
18047 | ········try |
18048 | ········{ |
18049 | ············pm.UnloadCache(); |
18050 | ············var l = pm.Objects<AgrBinnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18051 | ············pm.Delete(l); |
18052 | ············pm.Save(); |
18053 | ············pm.UnloadCache(); |
18054 | ············var m = pm.Objects<AgrBinnOwnpconOthpconTblGuidRightBase>().ResultTable; |
18055 | ············pm.Delete(m); |
18056 | ············pm.Save(); |
18057 | ············pm.UnloadCache(); |
18058 | ············decimal count; |
18059 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18060 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18061 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18063 | ········} |
18064 | ········catch (Exception) |
18065 | ········{ |
18066 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18067 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18068 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18069 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18070 | ········} |
18071 | ····} |
18072 | ····[Test] |
18073 | ····public void TestSaveReload() |
18074 | ····{ |
18075 | ········CreateObjects(); |
18076 | ········QueryOwn(); |
18077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18078 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18079 | ····} |
18080 | ····[Test] |
18081 | ····public void TestSaveReloadNull() |
18082 | ····{ |
18083 | ········CreateObjects(); |
18084 | ········QueryOwn(); |
18085 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18086 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18087 | ········ownVar.RelField = new List<AgrBinnOwnpconOthpconTblGuidRightBase>(); |
18088 | ········pm.Save(); |
18089 | ········pm.UnloadCache(); |
18090 | ········QueryOwn(); |
18091 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18092 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18093 | ····} |
18094 | ····[Test] |
18095 | ····public void TestSaveReloadRemove() |
18096 | ····{ |
18097 | ········CreateObjects(); |
18098 | ········QueryOwn(); |
18099 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18100 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18101 | ········ownVar.RemoveRelatedObject(); |
18102 | ········pm.Save(); |
18103 | ········pm.UnloadCache(); |
18104 | ········QueryOwn(); |
18105 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18106 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18107 | ····} |
18108 | ····[Test] |
18109 | ····public void TestRelationHash() |
18110 | ····{ |
18111 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidLeftBase)); |
18112 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18113 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidRightBase)); |
18114 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18115 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18116 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18117 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidLeftDerived)); |
18118 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18119 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18120 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18121 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidRightDerived)); |
18122 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18123 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18124 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18125 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18126 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18127 | ····} |
18128 | ····void CreateObjects() |
18129 | ····{ |
18130 | ········pm.MakePersistent(ownVar); |
18131 | ········pm.MakePersistent(otherVar); |
18132 | ········ownVar.AssignRelation(otherVar); |
18133 | ········pm.Save(); |
18134 | ········pm.UnloadCache(); |
18135 | ····} |
18136 | ····void QueryOwn() |
18137 | ····{ |
18138 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblGuidLeftBase>(pm); |
18139 | ········ownVar = q.ExecuteSingle(); |
18140 | ····} |
18141 | ····void QueryOther() |
18142 | ····{ |
18143 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblGuidRightBase>(pm); |
18144 | ········otherVar = q.ExecuteSingle(); |
18145 | ····} |
18146 | } |
18147 | |
18148 | |
18149 | [TestFixture] |
18150 | public class TestCmpDir1OwnpconOthpconNoTblGuid : NDOTest |
18151 | { |
18152 | ····CmpDir1OwnpconOthpconNoTblGuidLeftBase ownVar; |
18153 | ····CmpDir1OwnpconOthpconNoTblGuidRightBase otherVar; |
18154 | ····PersistenceManager pm; |
18155 | ····[SetUp] |
18156 | ····public void Setup() |
18157 | ····{ |
18158 | ········pm = PmFactory.NewPersistenceManager(); |
18159 | ········ownVar = new CmpDir1OwnpconOthpconNoTblGuidLeftDerived(); |
18160 | ········otherVar = new CmpDir1OwnpconOthpconNoTblGuidRightDerived(); |
18161 | ····} |
18162 | ····[TearDown] |
18163 | ····public void TearDown() |
18164 | ····{ |
18165 | ········try |
18166 | ········{ |
18167 | ············pm.UnloadCache(); |
18168 | ············var l = pm.Objects<CmpDir1OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
18169 | ············pm.Delete(l); |
18170 | ············pm.Save(); |
18171 | ············pm.UnloadCache(); |
18172 | ············decimal count; |
18173 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18174 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18175 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18176 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18177 | ········} |
18178 | ········catch (Exception) |
18179 | ········{ |
18180 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18181 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18182 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18183 | ········} |
18184 | ····} |
18185 | ····[Test] |
18186 | ····public void TestSaveReload() |
18187 | ····{ |
18188 | ········CreateObjects(); |
18189 | ········QueryOwn(); |
18190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18191 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18192 | ····} |
18193 | ····[Test] |
18194 | ····public void TestSaveReloadNull() |
18195 | ····{ |
18196 | ········CreateObjects(); |
18197 | ········QueryOwn(); |
18198 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18199 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18200 | ········ownVar.RelField = null; |
18201 | ········pm.Save(); |
18202 | ········pm.UnloadCache(); |
18203 | ········QueryOwn(); |
18204 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18205 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18206 | ····} |
18207 | ····[Test] |
18208 | ····public void TestChangeKeyHolderLeft() |
18209 | ····{ |
18210 | ········CreateObjects(); |
18211 | ········QueryOwn(); |
18212 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18213 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18214 | ········int x = ownVar.RelField.Dummy; |
18215 | ········ownVar.Dummy = 4711; |
18216 | ········pm.Save(); |
18217 | ········pm.UnloadCache(); |
18218 | ········QueryOwn(); |
18219 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18220 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18221 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18222 | ····} |
18223 | ····[Test] |
18224 | ····public void TestChangeKeyHolderLeftNoTouch() |
18225 | ····{ |
18226 | ········CreateObjects(); |
18227 | ········QueryOwn(); |
18228 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18229 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18230 | ········ownVar.Dummy = 4711; |
18231 | ········pm.Save(); |
18232 | ········pm.UnloadCache(); |
18233 | ········QueryOwn(); |
18234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18235 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18236 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18237 | ····} |
18238 | ····void CreateObjects() |
18239 | ····{ |
18240 | ········pm.MakePersistent(ownVar); |
18241 | ········ownVar.AssignRelation(otherVar); |
18242 | ········pm.Save(); |
18243 | ········pm.UnloadCache(); |
18244 | ····} |
18245 | ····void QueryOwn() |
18246 | ····{ |
18247 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidLeftBase>(pm); |
18248 | ········ownVar = q.ExecuteSingle(); |
18249 | ····} |
18250 | ····void QueryOther() |
18251 | ····{ |
18252 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidRightBase>(pm); |
18253 | ········otherVar = q.ExecuteSingle(); |
18254 | ····} |
18255 | } |
18256 | |
18257 | |
18258 | [TestFixture] |
18259 | public class TestCmpDir1OwnpconOthpconTblGuid : NDOTest |
18260 | { |
18261 | ····CmpDir1OwnpconOthpconTblGuidLeftBase ownVar; |
18262 | ····CmpDir1OwnpconOthpconTblGuidRightBase otherVar; |
18263 | ····PersistenceManager pm; |
18264 | ····[SetUp] |
18265 | ····public void Setup() |
18266 | ····{ |
18267 | ········pm = PmFactory.NewPersistenceManager(); |
18268 | ········ownVar = new CmpDir1OwnpconOthpconTblGuidLeftDerived(); |
18269 | ········otherVar = new CmpDir1OwnpconOthpconTblGuidRightDerived(); |
18270 | ····} |
18271 | ····[TearDown] |
18272 | ····public void TearDown() |
18273 | ····{ |
18274 | ········try |
18275 | ········{ |
18276 | ············pm.UnloadCache(); |
18277 | ············var l = pm.Objects<CmpDir1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18278 | ············pm.Delete(l); |
18279 | ············pm.Save(); |
18280 | ············pm.UnloadCache(); |
18281 | ············decimal count; |
18282 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18283 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18284 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18285 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18286 | ········} |
18287 | ········catch (Exception) |
18288 | ········{ |
18289 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18290 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18291 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18292 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18293 | ········} |
18294 | ····} |
18295 | ····[Test] |
18296 | ····public void TestSaveReload() |
18297 | ····{ |
18298 | ········CreateObjects(); |
18299 | ········QueryOwn(); |
18300 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18301 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18302 | ····} |
18303 | ····[Test] |
18304 | ····public void TestSaveReloadNull() |
18305 | ····{ |
18306 | ········CreateObjects(); |
18307 | ········QueryOwn(); |
18308 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18309 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18310 | ········ownVar.RelField = null; |
18311 | ········pm.Save(); |
18312 | ········pm.UnloadCache(); |
18313 | ········QueryOwn(); |
18314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18315 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18316 | ····} |
18317 | ····[Test] |
18318 | ····public void TestChangeKeyHolderLeft() |
18319 | ····{ |
18320 | ········CreateObjects(); |
18321 | ········QueryOwn(); |
18322 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18323 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18324 | ········int x = ownVar.RelField.Dummy; |
18325 | ········ownVar.Dummy = 4711; |
18326 | ········pm.Save(); |
18327 | ········pm.UnloadCache(); |
18328 | ········QueryOwn(); |
18329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18330 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18332 | ····} |
18333 | ····[Test] |
18334 | ····public void TestChangeKeyHolderLeftNoTouch() |
18335 | ····{ |
18336 | ········CreateObjects(); |
18337 | ········QueryOwn(); |
18338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18340 | ········ownVar.Dummy = 4711; |
18341 | ········pm.Save(); |
18342 | ········pm.UnloadCache(); |
18343 | ········QueryOwn(); |
18344 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18345 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18346 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18347 | ····} |
18348 | ····void CreateObjects() |
18349 | ····{ |
18350 | ········pm.MakePersistent(ownVar); |
18351 | ········ownVar.AssignRelation(otherVar); |
18352 | ········pm.Save(); |
18353 | ········pm.UnloadCache(); |
18354 | ····} |
18355 | ····void QueryOwn() |
18356 | ····{ |
18357 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblGuidLeftBase>(pm); |
18358 | ········ownVar = q.ExecuteSingle(); |
18359 | ····} |
18360 | ····void QueryOther() |
18361 | ····{ |
18362 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblGuidRightBase>(pm); |
18363 | ········otherVar = q.ExecuteSingle(); |
18364 | ····} |
18365 | } |
18366 | |
18367 | |
18368 | [TestFixture] |
18369 | public class TestCmpBi11OwnpconOthpconNoTblGuid : NDOTest |
18370 | { |
18371 | ····CmpBi11OwnpconOthpconNoTblGuidLeftBase ownVar; |
18372 | ····CmpBi11OwnpconOthpconNoTblGuidRightBase otherVar; |
18373 | ····PersistenceManager pm; |
18374 | ····[SetUp] |
18375 | ····public void Setup() |
18376 | ····{ |
18377 | ········pm = PmFactory.NewPersistenceManager(); |
18378 | ········ownVar = new CmpBi11OwnpconOthpconNoTblGuidLeftDerived(); |
18379 | ········otherVar = new CmpBi11OwnpconOthpconNoTblGuidRightDerived(); |
18380 | ····} |
18381 | ····[TearDown] |
18382 | ····public void TearDown() |
18383 | ····{ |
18384 | ········try |
18385 | ········{ |
18386 | ············pm.UnloadCache(); |
18387 | ············var l = pm.Objects<CmpBi11OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
18388 | ············pm.Delete(l); |
18389 | ············pm.Save(); |
18390 | ············pm.UnloadCache(); |
18391 | ············decimal count; |
18392 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18393 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18394 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18395 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18396 | ········} |
18397 | ········catch (Exception) |
18398 | ········{ |
18399 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18400 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18401 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18402 | ········} |
18403 | ····} |
18404 | ····[Test] |
18405 | ····public void TestSaveReload() |
18406 | ····{ |
18407 | ········CreateObjects(); |
18408 | ········QueryOwn(); |
18409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18410 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18411 | ····} |
18412 | ····[Test] |
18413 | ····public void TestSaveReloadNull() |
18414 | ····{ |
18415 | ········CreateObjects(); |
18416 | ········QueryOwn(); |
18417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18419 | ········ownVar.RelField = null; |
18420 | ········pm.Save(); |
18421 | ········pm.UnloadCache(); |
18422 | ········QueryOwn(); |
18423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18424 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18425 | ····} |
18426 | ····[Test] |
18427 | ····public void TestChangeKeyHolderLeft() |
18428 | ····{ |
18429 | ········CreateObjects(); |
18430 | ········QueryOwn(); |
18431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18432 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18433 | ········int x = ownVar.RelField.Dummy; |
18434 | ········ownVar.Dummy = 4711; |
18435 | ········pm.Save(); |
18436 | ········pm.UnloadCache(); |
18437 | ········QueryOwn(); |
18438 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18439 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18440 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18441 | ····} |
18442 | ····[Test] |
18443 | ····public void TestChangeKeyHolderRight() |
18444 | ····{ |
18445 | ········CreateObjects(); |
18446 | ········QueryOther(); |
18447 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18448 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18449 | ········int x = otherVar.RelField.Dummy; |
18450 | ········otherVar.Dummy = 4711; |
18451 | ········pm.Save(); |
18452 | ········pm.UnloadCache(); |
18453 | ········QueryOther(); |
18454 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18455 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18456 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18457 | ····} |
18458 | ····[Test] |
18459 | ····public void TestChangeKeyHolderLeftNoTouch() |
18460 | ····{ |
18461 | ········CreateObjects(); |
18462 | ········QueryOwn(); |
18463 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18464 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18465 | ········ownVar.Dummy = 4711; |
18466 | ········pm.Save(); |
18467 | ········pm.UnloadCache(); |
18468 | ········QueryOwn(); |
18469 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18470 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18471 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18472 | ····} |
18473 | ····[Test] |
18474 | ····public void TestChangeKeyHolderRightNoTouch() |
18475 | ····{ |
18476 | ········CreateObjects(); |
18477 | ········QueryOther(); |
18478 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18479 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18480 | ········otherVar.Dummy = 4711; |
18481 | ········pm.Save(); |
18482 | ········pm.UnloadCache(); |
18483 | ········QueryOther(); |
18484 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18485 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18486 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18487 | ····} |
18488 | ····[Test] |
18489 | ····public void TestRelationHash() |
18490 | ····{ |
18491 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidLeftBase)); |
18492 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18493 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidRightBase)); |
18494 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18495 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18496 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18497 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidLeftDerived)); |
18498 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18499 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18500 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18501 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidRightDerived)); |
18502 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18503 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18504 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18505 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18506 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18507 | ····} |
18508 | ····void CreateObjects() |
18509 | ····{ |
18510 | ········pm.MakePersistent(ownVar); |
18511 | ········ownVar.AssignRelation(otherVar); |
18512 | ········pm.Save(); |
18513 | ········pm.UnloadCache(); |
18514 | ····} |
18515 | ····void QueryOwn() |
18516 | ····{ |
18517 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidLeftBase>(pm); |
18518 | ········ownVar = q.ExecuteSingle(); |
18519 | ····} |
18520 | ····void QueryOther() |
18521 | ····{ |
18522 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidRightBase>(pm); |
18523 | ········otherVar = q.ExecuteSingle(); |
18524 | ····} |
18525 | } |
18526 | |
18527 | |
18528 | [TestFixture] |
18529 | public class TestCmpBi11OwnpconOthpconTblGuid : NDOTest |
18530 | { |
18531 | ····CmpBi11OwnpconOthpconTblGuidLeftBase ownVar; |
18532 | ····CmpBi11OwnpconOthpconTblGuidRightBase otherVar; |
18533 | ····PersistenceManager pm; |
18534 | ····[SetUp] |
18535 | ····public void Setup() |
18536 | ····{ |
18537 | ········pm = PmFactory.NewPersistenceManager(); |
18538 | ········ownVar = new CmpBi11OwnpconOthpconTblGuidLeftDerived(); |
18539 | ········otherVar = new CmpBi11OwnpconOthpconTblGuidRightDerived(); |
18540 | ····} |
18541 | ····[TearDown] |
18542 | ····public void TearDown() |
18543 | ····{ |
18544 | ········try |
18545 | ········{ |
18546 | ············pm.UnloadCache(); |
18547 | ············var l = pm.Objects<CmpBi11OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18548 | ············pm.Delete(l); |
18549 | ············pm.Save(); |
18550 | ············pm.UnloadCache(); |
18551 | ············decimal count; |
18552 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18553 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18554 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18555 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18556 | ········} |
18557 | ········catch (Exception) |
18558 | ········{ |
18559 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18560 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18561 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18562 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18563 | ········} |
18564 | ····} |
18565 | ····[Test] |
18566 | ····public void TestSaveReload() |
18567 | ····{ |
18568 | ········CreateObjects(); |
18569 | ········QueryOwn(); |
18570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18571 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18572 | ····} |
18573 | ····[Test] |
18574 | ····public void TestSaveReloadNull() |
18575 | ····{ |
18576 | ········CreateObjects(); |
18577 | ········QueryOwn(); |
18578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18579 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18580 | ········ownVar.RelField = null; |
18581 | ········pm.Save(); |
18582 | ········pm.UnloadCache(); |
18583 | ········QueryOwn(); |
18584 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18585 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18586 | ····} |
18587 | ····[Test] |
18588 | ····public void TestChangeKeyHolderLeft() |
18589 | ····{ |
18590 | ········CreateObjects(); |
18591 | ········QueryOwn(); |
18592 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18593 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18594 | ········int x = ownVar.RelField.Dummy; |
18595 | ········ownVar.Dummy = 4711; |
18596 | ········pm.Save(); |
18597 | ········pm.UnloadCache(); |
18598 | ········QueryOwn(); |
18599 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18600 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18601 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18602 | ····} |
18603 | ····[Test] |
18604 | ····public void TestChangeKeyHolderRight() |
18605 | ····{ |
18606 | ········CreateObjects(); |
18607 | ········QueryOther(); |
18608 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18609 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18610 | ········int x = otherVar.RelField.Dummy; |
18611 | ········otherVar.Dummy = 4711; |
18612 | ········pm.Save(); |
18613 | ········pm.UnloadCache(); |
18614 | ········QueryOther(); |
18615 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18616 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18617 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18618 | ····} |
18619 | ····[Test] |
18620 | ····public void TestChangeKeyHolderLeftNoTouch() |
18621 | ····{ |
18622 | ········CreateObjects(); |
18623 | ········QueryOwn(); |
18624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18625 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18626 | ········ownVar.Dummy = 4711; |
18627 | ········pm.Save(); |
18628 | ········pm.UnloadCache(); |
18629 | ········QueryOwn(); |
18630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18631 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18632 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18633 | ····} |
18634 | ····[Test] |
18635 | ····public void TestChangeKeyHolderRightNoTouch() |
18636 | ····{ |
18637 | ········CreateObjects(); |
18638 | ········QueryOther(); |
18639 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18640 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18641 | ········otherVar.Dummy = 4711; |
18642 | ········pm.Save(); |
18643 | ········pm.UnloadCache(); |
18644 | ········QueryOther(); |
18645 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18646 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18647 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18648 | ····} |
18649 | ····[Test] |
18650 | ····public void TestRelationHash() |
18651 | ····{ |
18652 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidLeftBase)); |
18653 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18654 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidRightBase)); |
18655 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18656 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18657 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18658 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidLeftDerived)); |
18659 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18660 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18661 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18662 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidRightDerived)); |
18663 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18664 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18665 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18666 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18667 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18668 | ····} |
18669 | ····void CreateObjects() |
18670 | ····{ |
18671 | ········pm.MakePersistent(ownVar); |
18672 | ········ownVar.AssignRelation(otherVar); |
18673 | ········pm.Save(); |
18674 | ········pm.UnloadCache(); |
18675 | ····} |
18676 | ····void QueryOwn() |
18677 | ····{ |
18678 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblGuidLeftBase>(pm); |
18679 | ········ownVar = q.ExecuteSingle(); |
18680 | ····} |
18681 | ····void QueryOther() |
18682 | ····{ |
18683 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblGuidRightBase>(pm); |
18684 | ········otherVar = q.ExecuteSingle(); |
18685 | ····} |
18686 | } |
18687 | |
18688 | |
18689 | [TestFixture] |
18690 | public class TestCmpDirnOwnpconOthpconTblGuid : NDOTest |
18691 | { |
18692 | ····CmpDirnOwnpconOthpconTblGuidLeftBase ownVar; |
18693 | ····CmpDirnOwnpconOthpconTblGuidRightBase otherVar; |
18694 | ····PersistenceManager pm; |
18695 | ····[SetUp] |
18696 | ····public void Setup() |
18697 | ····{ |
18698 | ········pm = PmFactory.NewPersistenceManager(); |
18699 | ········ownVar = new CmpDirnOwnpconOthpconTblGuidLeftDerived(); |
18700 | ········otherVar = new CmpDirnOwnpconOthpconTblGuidRightDerived(); |
18701 | ····} |
18702 | ····[TearDown] |
18703 | ····public void TearDown() |
18704 | ····{ |
18705 | ········try |
18706 | ········{ |
18707 | ············pm.UnloadCache(); |
18708 | ············var l = pm.Objects<CmpDirnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18709 | ············pm.Delete(l); |
18710 | ············pm.Save(); |
18711 | ············pm.UnloadCache(); |
18712 | ············decimal count; |
18713 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18714 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18715 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18716 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18717 | ········} |
18718 | ········catch (Exception) |
18719 | ········{ |
18720 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18721 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18722 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18723 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18724 | ········} |
18725 | ····} |
18726 | ····[Test] |
18727 | ····public void TestSaveReload() |
18728 | ····{ |
18729 | ········CreateObjects(); |
18730 | ········QueryOwn(); |
18731 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18732 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18733 | ····} |
18734 | ····[Test] |
18735 | ····public void TestSaveReloadNull() |
18736 | ····{ |
18737 | ········CreateObjects(); |
18738 | ········QueryOwn(); |
18739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18740 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18741 | ········ownVar.RelField = new List<CmpDirnOwnpconOthpconTblGuidRightBase>(); |
18742 | ········pm.Save(); |
18743 | ········pm.UnloadCache(); |
18744 | ········QueryOwn(); |
18745 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18746 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18747 | ····} |
18748 | ····[Test] |
18749 | ····public void TestSaveReloadRemove() |
18750 | ····{ |
18751 | ········CreateObjects(); |
18752 | ········QueryOwn(); |
18753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18754 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18755 | ········ownVar.RemoveRelatedObject(); |
18756 | ········pm.Save(); |
18757 | ········pm.UnloadCache(); |
18758 | ········QueryOwn(); |
18759 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18760 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18761 | ····} |
18762 | ····void CreateObjects() |
18763 | ····{ |
18764 | ········pm.MakePersistent(ownVar); |
18765 | ········ownVar.AssignRelation(otherVar); |
18766 | ········pm.Save(); |
18767 | ········pm.UnloadCache(); |
18768 | ····} |
18769 | ····void QueryOwn() |
18770 | ····{ |
18771 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblGuidLeftBase>(pm); |
18772 | ········ownVar = q.ExecuteSingle(); |
18773 | ····} |
18774 | ····void QueryOther() |
18775 | ····{ |
18776 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblGuidRightBase>(pm); |
18777 | ········otherVar = q.ExecuteSingle(); |
18778 | ····} |
18779 | } |
18780 | |
18781 | |
18782 | [TestFixture] |
18783 | public class TestCmpBin1OwnpconOthpconTblGuid : NDOTest |
18784 | { |
18785 | ····CmpBin1OwnpconOthpconTblGuidLeftBase ownVar; |
18786 | ····CmpBin1OwnpconOthpconTblGuidRightBase otherVar; |
18787 | ····PersistenceManager pm; |
18788 | ····[SetUp] |
18789 | ····public void Setup() |
18790 | ····{ |
18791 | ········pm = PmFactory.NewPersistenceManager(); |
18792 | ········ownVar = new CmpBin1OwnpconOthpconTblGuidLeftDerived(); |
18793 | ········otherVar = new CmpBin1OwnpconOthpconTblGuidRightDerived(); |
18794 | ····} |
18795 | ····[TearDown] |
18796 | ····public void TearDown() |
18797 | ····{ |
18798 | ········try |
18799 | ········{ |
18800 | ············pm.UnloadCache(); |
18801 | ············var l = pm.Objects<CmpBin1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18802 | ············pm.Delete(l); |
18803 | ············pm.Save(); |
18804 | ············pm.UnloadCache(); |
18805 | ············decimal count; |
18806 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18807 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18808 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18809 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18810 | ········} |
18811 | ········catch (Exception) |
18812 | ········{ |
18813 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18814 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18815 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18816 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18817 | ········} |
18818 | ····} |
18819 | ····[Test] |
18820 | ····public void TestSaveReload() |
18821 | ····{ |
18822 | ········CreateObjects(); |
18823 | ········QueryOwn(); |
18824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18825 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18826 | ····} |
18827 | ····[Test] |
18828 | ····public void TestSaveReloadNull() |
18829 | ····{ |
18830 | ········CreateObjects(); |
18831 | ········QueryOwn(); |
18832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18833 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18834 | ········ownVar.RelField = new List<CmpBin1OwnpconOthpconTblGuidRightBase>(); |
18835 | ········pm.Save(); |
18836 | ········pm.UnloadCache(); |
18837 | ········QueryOwn(); |
18838 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18839 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18840 | ····} |
18841 | ····[Test] |
18842 | ····public void TestSaveReloadRemove() |
18843 | ····{ |
18844 | ········CreateObjects(); |
18845 | ········QueryOwn(); |
18846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18847 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18848 | ········ownVar.RemoveRelatedObject(); |
18849 | ········pm.Save(); |
18850 | ········pm.UnloadCache(); |
18851 | ········QueryOwn(); |
18852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18853 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18854 | ····} |
18855 | ····[Test] |
18856 | ····public void TestChangeKeyHolderRight() |
18857 | ····{ |
18858 | ········CreateObjects(); |
18859 | ········QueryOther(); |
18860 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18861 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18862 | ········int x = otherVar.RelField.Dummy; |
18863 | ········otherVar.Dummy = 4711; |
18864 | ········pm.Save(); |
18865 | ········pm.UnloadCache(); |
18866 | ········QueryOther(); |
18867 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18868 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18869 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18870 | ····} |
18871 | ····[Test] |
18872 | ····public void TestChangeKeyHolderRightNoTouch() |
18873 | ····{ |
18874 | ········CreateObjects(); |
18875 | ········QueryOther(); |
18876 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18877 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18878 | ········otherVar.Dummy = 4711; |
18879 | ········pm.Save(); |
18880 | ········pm.UnloadCache(); |
18881 | ········QueryOther(); |
18882 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18883 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18884 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18885 | ····} |
18886 | ····[Test] |
18887 | ····public void TestRelationHash() |
18888 | ····{ |
18889 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidLeftBase)); |
18890 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18891 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidRightBase)); |
18892 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18893 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18894 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18895 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidLeftDerived)); |
18896 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18897 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18898 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18899 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidRightDerived)); |
18900 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18901 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18902 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18903 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18904 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18905 | ····} |
18906 | ····void CreateObjects() |
18907 | ····{ |
18908 | ········pm.MakePersistent(ownVar); |
18909 | ········ownVar.AssignRelation(otherVar); |
18910 | ········pm.Save(); |
18911 | ········pm.UnloadCache(); |
18912 | ····} |
18913 | ····void QueryOwn() |
18914 | ····{ |
18915 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblGuidLeftBase>(pm); |
18916 | ········ownVar = q.ExecuteSingle(); |
18917 | ····} |
18918 | ····void QueryOther() |
18919 | ····{ |
18920 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblGuidRightBase>(pm); |
18921 | ········otherVar = q.ExecuteSingle(); |
18922 | ····} |
18923 | } |
18924 | |
18925 | |
18926 | [TestFixture] |
18927 | public class TestCmpBi1nOwnpconOthpconTblGuid : NDOTest |
18928 | { |
18929 | ····CmpBi1nOwnpconOthpconTblGuidLeftBase ownVar; |
18930 | ····CmpBi1nOwnpconOthpconTblGuidRightBase otherVar; |
18931 | ····PersistenceManager pm; |
18932 | ····[SetUp] |
18933 | ····public void Setup() |
18934 | ····{ |
18935 | ········pm = PmFactory.NewPersistenceManager(); |
18936 | ········ownVar = new CmpBi1nOwnpconOthpconTblGuidLeftDerived(); |
18937 | ········otherVar = new CmpBi1nOwnpconOthpconTblGuidRightDerived(); |
18938 | ····} |
18939 | ····[TearDown] |
18940 | ····public void TearDown() |
18941 | ····{ |
18942 | ········try |
18943 | ········{ |
18944 | ············pm.UnloadCache(); |
18945 | ············var l = pm.Objects<CmpBi1nOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18946 | ············pm.Delete(l); |
18947 | ············pm.Save(); |
18948 | ············pm.UnloadCache(); |
18949 | ············decimal count; |
18950 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18951 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18952 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18953 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18954 | ········} |
18955 | ········catch (Exception) |
18956 | ········{ |
18957 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18958 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18959 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18960 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18961 | ········} |
18962 | ····} |
18963 | ····[Test] |
18964 | ····public void TestSaveReload() |
18965 | ····{ |
18966 | ········CreateObjects(); |
18967 | ········QueryOwn(); |
18968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18969 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18970 | ····} |
18971 | ····[Test] |
18972 | ····public void TestSaveReloadNull() |
18973 | ····{ |
18974 | ········CreateObjects(); |
18975 | ········QueryOwn(); |
18976 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18977 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18978 | ········ownVar.RelField = null; |
18979 | ········pm.Save(); |
18980 | ········pm.UnloadCache(); |
18981 | ········QueryOwn(); |
18982 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18983 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18984 | ····} |
18985 | ····[Test] |
18986 | ····public void TestChangeKeyHolderLeft() |
18987 | ····{ |
18988 | ········CreateObjects(); |
18989 | ········QueryOwn(); |
18990 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18991 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18992 | ········int x = ownVar.RelField.Dummy; |
18993 | ········ownVar.Dummy = 4711; |
18994 | ········pm.Save(); |
18995 | ········pm.UnloadCache(); |
18996 | ········QueryOwn(); |
18997 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18998 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18999 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19000 | ····} |
19001 | ····[Test] |
19002 | ····public void TestChangeKeyHolderLeftNoTouch() |
19003 | ····{ |
19004 | ········CreateObjects(); |
19005 | ········QueryOwn(); |
19006 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19007 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19008 | ········ownVar.Dummy = 4711; |
19009 | ········pm.Save(); |
19010 | ········pm.UnloadCache(); |
19011 | ········QueryOwn(); |
19012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19013 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19014 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19015 | ····} |
19016 | ····[Test] |
19017 | ····public void TestRelationHash() |
19018 | ····{ |
19019 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidLeftBase)); |
19020 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19021 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidRightBase)); |
19022 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19023 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19024 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19025 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidLeftDerived)); |
19026 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19027 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19028 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19029 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidRightDerived)); |
19030 | ········Relation relderRight = clderRight.FindRelation("relField"); |
19031 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
19032 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
19033 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
19034 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
19035 | ····} |
19036 | ····void CreateObjects() |
19037 | ····{ |
19038 | ········pm.MakePersistent(ownVar); |
19039 | ········ownVar.AssignRelation(otherVar); |
19040 | ········pm.Save(); |
19041 | ········pm.UnloadCache(); |
19042 | ····} |
19043 | ····void QueryOwn() |
19044 | ····{ |
19045 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblGuidLeftBase>(pm); |
19046 | ········ownVar = q.ExecuteSingle(); |
19047 | ····} |
19048 | ····void QueryOther() |
19049 | ····{ |
19050 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblGuidRightBase>(pm); |
19051 | ········otherVar = q.ExecuteSingle(); |
19052 | ····} |
19053 | } |
19054 | |
19055 | |
19056 | [TestFixture] |
19057 | public class TestCmpBinnOwnpconOthpconTblGuid : NDOTest |
19058 | { |
19059 | ····CmpBinnOwnpconOthpconTblGuidLeftBase ownVar; |
19060 | ····CmpBinnOwnpconOthpconTblGuidRightBase otherVar; |
19061 | ····PersistenceManager pm; |
19062 | ····[SetUp] |
19063 | ····public void Setup() |
19064 | ····{ |
19065 | ········pm = PmFactory.NewPersistenceManager(); |
19066 | ········ownVar = new CmpBinnOwnpconOthpconTblGuidLeftDerived(); |
19067 | ········otherVar = new CmpBinnOwnpconOthpconTblGuidRightDerived(); |
19068 | ····} |
19069 | ····[TearDown] |
19070 | ····public void TearDown() |
19071 | ····{ |
19072 | ········try |
19073 | ········{ |
19074 | ············pm.UnloadCache(); |
19075 | ············var l = pm.Objects<CmpBinnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
19076 | ············pm.Delete(l); |
19077 | ············pm.Save(); |
19078 | ············pm.UnloadCache(); |
19079 | ············decimal count; |
19080 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19081 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19082 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19083 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19084 | ········} |
19085 | ········catch (Exception) |
19086 | ········{ |
19087 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19088 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19089 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19090 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19091 | ········} |
19092 | ····} |
19093 | ····[Test] |
19094 | ····public void TestSaveReload() |
19095 | ····{ |
19096 | ········CreateObjects(); |
19097 | ········QueryOwn(); |
19098 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19099 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19100 | ····} |
19101 | ····[Test] |
19102 | ····public void TestSaveReloadNull() |
19103 | ····{ |
19104 | ········CreateObjects(); |
19105 | ········QueryOwn(); |
19106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19107 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19108 | ········ownVar.RelField = new List<CmpBinnOwnpconOthpconTblGuidRightBase>(); |
19109 | ········pm.Save(); |
19110 | ········pm.UnloadCache(); |
19111 | ········QueryOwn(); |
19112 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19113 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19114 | ····} |
19115 | ····[Test] |
19116 | ····public void TestSaveReloadRemove() |
19117 | ····{ |
19118 | ········CreateObjects(); |
19119 | ········QueryOwn(); |
19120 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19121 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19122 | ········ownVar.RemoveRelatedObject(); |
19123 | ········pm.Save(); |
19124 | ········pm.UnloadCache(); |
19125 | ········QueryOwn(); |
19126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19127 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19128 | ····} |
19129 | ····[Test] |
19130 | ····public void TestRelationHash() |
19131 | ····{ |
19132 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidLeftBase)); |
19133 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19134 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidRightBase)); |
19135 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19136 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19137 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19138 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidLeftDerived)); |
19139 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19140 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19141 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19142 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidRightDerived)); |
19143 | ········Relation relderRight = clderRight.FindRelation("relField"); |
19144 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
19145 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
19146 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
19147 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
19148 | ····} |
19149 | ····void CreateObjects() |
19150 | ····{ |
19151 | ········pm.MakePersistent(ownVar); |
19152 | ········ownVar.AssignRelation(otherVar); |
19153 | ········pm.Save(); |
19154 | ········pm.UnloadCache(); |
19155 | ····} |
19156 | ····void QueryOwn() |
19157 | ····{ |
19158 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblGuidLeftBase>(pm); |
19159 | ········ownVar = q.ExecuteSingle(); |
19160 | ····} |
19161 | ····void QueryOther() |
19162 | ····{ |
19163 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblGuidRightBase>(pm); |
19164 | ········otherVar = q.ExecuteSingle(); |
19165 | ····} |
19166 | } |
19167 | |
19168 | |
19169 | [TestFixture] |
19170 | public class TestAgrDir1OwnpabsNoTblAuto : NDOTest |
19171 | { |
19172 | ····AgrDir1OwnpabsNoTblAutoLeftBase ownVar; |
19173 | ····AgrDir1OwnpabsNoTblAutoRight otherVar; |
19174 | ····PersistenceManager pm; |
19175 | ····[SetUp] |
19176 | ····public void Setup() |
19177 | ····{ |
19178 | ········pm = PmFactory.NewPersistenceManager(); |
19179 | ········ownVar = new AgrDir1OwnpabsNoTblAutoLeftDerived(); |
19180 | ········otherVar = new AgrDir1OwnpabsNoTblAutoRight(); |
19181 | ····} |
19182 | ····[TearDown] |
19183 | ····public void TearDown() |
19184 | ····{ |
19185 | ········try |
19186 | ········{ |
19187 | ············pm.UnloadCache(); |
19188 | ············var l = pm.Objects<AgrDir1OwnpabsNoTblAutoLeftBase>().ResultTable; |
19189 | ············pm.Delete(l); |
19190 | ············pm.Save(); |
19191 | ············pm.UnloadCache(); |
19192 | ············var m = pm.Objects<AgrDir1OwnpabsNoTblAutoRight>().ResultTable; |
19193 | ············pm.Delete(m); |
19194 | ············pm.Save(); |
19195 | ············pm.UnloadCache(); |
19196 | ············decimal count; |
19197 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19198 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19199 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19200 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19201 | ········} |
19202 | ········catch (Exception) |
19203 | ········{ |
19204 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19205 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19206 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19207 | ········} |
19208 | ····} |
19209 | ····[Test] |
19210 | ····public void TestSaveReload() |
19211 | ····{ |
19212 | ········CreateObjects(); |
19213 | ········QueryOwn(); |
19214 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19215 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19216 | ····} |
19217 | ····[Test] |
19218 | ····public void TestSaveReloadNull() |
19219 | ····{ |
19220 | ········CreateObjects(); |
19221 | ········QueryOwn(); |
19222 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19223 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19224 | ········ownVar.RelField = null; |
19225 | ········pm.Save(); |
19226 | ········pm.UnloadCache(); |
19227 | ········QueryOwn(); |
19228 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19229 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19230 | ····} |
19231 | ····[Test] |
19232 | ····public void TestChangeKeyHolderLeft() |
19233 | ····{ |
19234 | ········CreateObjects(); |
19235 | ········QueryOwn(); |
19236 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19237 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19238 | ········int x = ownVar.RelField.Dummy; |
19239 | ········ownVar.Dummy = 4711; |
19240 | ········pm.Save(); |
19241 | ········pm.UnloadCache(); |
19242 | ········QueryOwn(); |
19243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19244 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19245 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19246 | ····} |
19247 | ····[Test] |
19248 | ····public void TestChangeKeyHolderLeftNoTouch() |
19249 | ····{ |
19250 | ········CreateObjects(); |
19251 | ········QueryOwn(); |
19252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19254 | ········ownVar.Dummy = 4711; |
19255 | ········pm.Save(); |
19256 | ········pm.UnloadCache(); |
19257 | ········QueryOwn(); |
19258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19259 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19261 | ····} |
19262 | ····[Test] |
19263 | ····public void TestUpdateOrder() |
19264 | ····{ |
19265 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
19266 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
19267 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsNoTblAutoLeftDerived)})) |
19268 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
19269 | ········Debug.WriteLine("AgrDir1OwnpabsNoTblAutoLeftBase"); |
19270 | ····} |
19271 | ····void CreateObjects() |
19272 | ····{ |
19273 | ········pm.MakePersistent(ownVar); |
19274 | ········pm.MakePersistent(otherVar); |
19275 | ········ownVar.AssignRelation(otherVar); |
19276 | ········pm.Save(); |
19277 | ········pm.UnloadCache(); |
19278 | ····} |
19279 | ····void QueryOwn() |
19280 | ····{ |
19281 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblAutoLeftBase>(pm); |
19282 | ········ownVar = q.ExecuteSingle(); |
19283 | ····} |
19284 | ····void QueryOther() |
19285 | ····{ |
19286 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblAutoRight>(pm); |
19287 | ········otherVar = q.ExecuteSingle(); |
19288 | ····} |
19289 | } |
19290 | |
19291 | |
19292 | [TestFixture] |
19293 | public class TestAgrDir1OwnpabsTblAuto : NDOTest |
19294 | { |
19295 | ····AgrDir1OwnpabsTblAutoLeftBase ownVar; |
19296 | ····AgrDir1OwnpabsTblAutoRight otherVar; |
19297 | ····PersistenceManager pm; |
19298 | ····[SetUp] |
19299 | ····public void Setup() |
19300 | ····{ |
19301 | ········pm = PmFactory.NewPersistenceManager(); |
19302 | ········ownVar = new AgrDir1OwnpabsTblAutoLeftDerived(); |
19303 | ········otherVar = new AgrDir1OwnpabsTblAutoRight(); |
19304 | ····} |
19305 | ····[TearDown] |
19306 | ····public void TearDown() |
19307 | ····{ |
19308 | ········try |
19309 | ········{ |
19310 | ············pm.UnloadCache(); |
19311 | ············var l = pm.Objects<AgrDir1OwnpabsTblAutoLeftBase>().ResultTable; |
19312 | ············pm.Delete(l); |
19313 | ············pm.Save(); |
19314 | ············pm.UnloadCache(); |
19315 | ············var m = pm.Objects<AgrDir1OwnpabsTblAutoRight>().ResultTable; |
19316 | ············pm.Delete(m); |
19317 | ············pm.Save(); |
19318 | ············pm.UnloadCache(); |
19319 | ············decimal count; |
19320 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19321 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19322 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19323 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19324 | ········} |
19325 | ········catch (Exception) |
19326 | ········{ |
19327 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19328 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19329 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19330 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19331 | ········} |
19332 | ····} |
19333 | ····[Test] |
19334 | ····public void TestSaveReload() |
19335 | ····{ |
19336 | ········CreateObjects(); |
19337 | ········QueryOwn(); |
19338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19340 | ····} |
19341 | ····[Test] |
19342 | ····public void TestSaveReloadNull() |
19343 | ····{ |
19344 | ········CreateObjects(); |
19345 | ········QueryOwn(); |
19346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19347 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19348 | ········ownVar.RelField = null; |
19349 | ········pm.Save(); |
19350 | ········pm.UnloadCache(); |
19351 | ········QueryOwn(); |
19352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19353 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19354 | ····} |
19355 | ····[Test] |
19356 | ····public void TestChangeKeyHolderLeft() |
19357 | ····{ |
19358 | ········CreateObjects(); |
19359 | ········QueryOwn(); |
19360 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19361 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19362 | ········int x = ownVar.RelField.Dummy; |
19363 | ········ownVar.Dummy = 4711; |
19364 | ········pm.Save(); |
19365 | ········pm.UnloadCache(); |
19366 | ········QueryOwn(); |
19367 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19368 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19369 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19370 | ····} |
19371 | ····[Test] |
19372 | ····public void TestChangeKeyHolderLeftNoTouch() |
19373 | ····{ |
19374 | ········CreateObjects(); |
19375 | ········QueryOwn(); |
19376 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19377 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19378 | ········ownVar.Dummy = 4711; |
19379 | ········pm.Save(); |
19380 | ········pm.UnloadCache(); |
19381 | ········QueryOwn(); |
19382 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19383 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19384 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19385 | ····} |
19386 | ····void CreateObjects() |
19387 | ····{ |
19388 | ········pm.MakePersistent(ownVar); |
19389 | ········pm.MakePersistent(otherVar); |
19390 | ········ownVar.AssignRelation(otherVar); |
19391 | ········pm.Save(); |
19392 | ········pm.UnloadCache(); |
19393 | ····} |
19394 | ····void QueryOwn() |
19395 | ····{ |
19396 | ········var q = new NDOQuery<AgrDir1OwnpabsTblAutoLeftBase>(pm); |
19397 | ········ownVar = q.ExecuteSingle(); |
19398 | ····} |
19399 | ····void QueryOther() |
19400 | ····{ |
19401 | ········var q = new NDOQuery<AgrDir1OwnpabsTblAutoRight>(pm); |
19402 | ········otherVar = q.ExecuteSingle(); |
19403 | ····} |
19404 | } |
19405 | |
19406 | |
19407 | [TestFixture] |
19408 | public class TestAgrBi11OwnpabsNoTblAuto : NDOTest |
19409 | { |
19410 | ····AgrBi11OwnpabsNoTblAutoLeftBase ownVar; |
19411 | ····AgrBi11OwnpabsNoTblAutoRight otherVar; |
19412 | ····PersistenceManager pm; |
19413 | ····[SetUp] |
19414 | ····public void Setup() |
19415 | ····{ |
19416 | ········pm = PmFactory.NewPersistenceManager(); |
19417 | ········ownVar = new AgrBi11OwnpabsNoTblAutoLeftDerived(); |
19418 | ········otherVar = new AgrBi11OwnpabsNoTblAutoRight(); |
19419 | ····} |
19420 | ····[TearDown] |
19421 | ····public void TearDown() |
19422 | ····{ |
19423 | ········try |
19424 | ········{ |
19425 | ············pm.UnloadCache(); |
19426 | ············var l = pm.Objects<AgrBi11OwnpabsNoTblAutoLeftBase>().ResultTable; |
19427 | ············pm.Delete(l); |
19428 | ············pm.Save(); |
19429 | ············pm.UnloadCache(); |
19430 | ············var m = pm.Objects<AgrBi11OwnpabsNoTblAutoRight>().ResultTable; |
19431 | ············pm.Delete(m); |
19432 | ············pm.Save(); |
19433 | ············pm.UnloadCache(); |
19434 | ············decimal count; |
19435 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19436 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19437 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19438 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19439 | ········} |
19440 | ········catch (Exception) |
19441 | ········{ |
19442 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19443 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19444 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19445 | ········} |
19446 | ····} |
19447 | ····[Test] |
19448 | ····public void TestSaveReload() |
19449 | ····{ |
19450 | ········CreateObjects(); |
19451 | ········QueryOwn(); |
19452 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19453 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19454 | ····} |
19455 | ····[Test] |
19456 | ····public void TestSaveReloadNull() |
19457 | ····{ |
19458 | ········CreateObjects(); |
19459 | ········QueryOwn(); |
19460 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19462 | ········ownVar.RelField = null; |
19463 | ········pm.Save(); |
19464 | ········pm.UnloadCache(); |
19465 | ········QueryOwn(); |
19466 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19467 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19468 | ····} |
19469 | ····[Test] |
19470 | ····public void TestChangeKeyHolderLeft() |
19471 | ····{ |
19472 | ········CreateObjects(); |
19473 | ········QueryOwn(); |
19474 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19475 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19476 | ········int x = ownVar.RelField.Dummy; |
19477 | ········ownVar.Dummy = 4711; |
19478 | ········pm.Save(); |
19479 | ········pm.UnloadCache(); |
19480 | ········QueryOwn(); |
19481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19482 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19483 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19484 | ····} |
19485 | ····[Test] |
19486 | ····public void TestChangeKeyHolderRight() |
19487 | ····{ |
19488 | ········CreateObjects(); |
19489 | ········QueryOther(); |
19490 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19491 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19492 | ········int x = otherVar.RelField.Dummy; |
19493 | ········otherVar.Dummy = 4711; |
19494 | ········pm.Save(); |
19495 | ········pm.UnloadCache(); |
19496 | ········QueryOther(); |
19497 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19498 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19499 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19500 | ····} |
19501 | ····[Test] |
19502 | ····public void TestChangeKeyHolderLeftNoTouch() |
19503 | ····{ |
19504 | ········CreateObjects(); |
19505 | ········QueryOwn(); |
19506 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19507 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19508 | ········ownVar.Dummy = 4711; |
19509 | ········pm.Save(); |
19510 | ········pm.UnloadCache(); |
19511 | ········QueryOwn(); |
19512 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19513 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19514 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19515 | ····} |
19516 | ····[Test] |
19517 | ····public void TestChangeKeyHolderRightNoTouch() |
19518 | ····{ |
19519 | ········CreateObjects(); |
19520 | ········QueryOther(); |
19521 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19522 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19523 | ········otherVar.Dummy = 4711; |
19524 | ········pm.Save(); |
19525 | ········pm.UnloadCache(); |
19526 | ········QueryOther(); |
19527 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19528 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19529 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19530 | ····} |
19531 | ····[Test] |
19532 | ····public void TestRelationHash() |
19533 | ····{ |
19534 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoLeftBase)); |
19535 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19536 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoRight)); |
19537 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19538 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19539 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19540 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoLeftDerived)); |
19541 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19542 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19543 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19544 | ····} |
19545 | ····void CreateObjects() |
19546 | ····{ |
19547 | ········pm.MakePersistent(ownVar); |
19548 | ········pm.MakePersistent(otherVar); |
19549 | ········pm.Save(); |
19550 | ········ownVar.AssignRelation(otherVar); |
19551 | ········pm.Save(); |
19552 | ········pm.UnloadCache(); |
19553 | ····} |
19554 | ····void QueryOwn() |
19555 | ····{ |
19556 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblAutoLeftBase>(pm); |
19557 | ········ownVar = q.ExecuteSingle(); |
19558 | ····} |
19559 | ····void QueryOther() |
19560 | ····{ |
19561 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblAutoRight>(pm); |
19562 | ········otherVar = q.ExecuteSingle(); |
19563 | ····} |
19564 | } |
19565 | |
19566 | |
19567 | [TestFixture] |
19568 | public class TestAgrBi11OwnpabsTblAuto : NDOTest |
19569 | { |
19570 | ····AgrBi11OwnpabsTblAutoLeftBase ownVar; |
19571 | ····AgrBi11OwnpabsTblAutoRight otherVar; |
19572 | ····PersistenceManager pm; |
19573 | ····[SetUp] |
19574 | ····public void Setup() |
19575 | ····{ |
19576 | ········pm = PmFactory.NewPersistenceManager(); |
19577 | ········ownVar = new AgrBi11OwnpabsTblAutoLeftDerived(); |
19578 | ········otherVar = new AgrBi11OwnpabsTblAutoRight(); |
19579 | ····} |
19580 | ····[TearDown] |
19581 | ····public void TearDown() |
19582 | ····{ |
19583 | ········try |
19584 | ········{ |
19585 | ············pm.UnloadCache(); |
19586 | ············var l = pm.Objects<AgrBi11OwnpabsTblAutoLeftBase>().ResultTable; |
19587 | ············pm.Delete(l); |
19588 | ············pm.Save(); |
19589 | ············pm.UnloadCache(); |
19590 | ············var m = pm.Objects<AgrBi11OwnpabsTblAutoRight>().ResultTable; |
19591 | ············pm.Delete(m); |
19592 | ············pm.Save(); |
19593 | ············pm.UnloadCache(); |
19594 | ············decimal count; |
19595 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19596 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19597 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19598 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19599 | ········} |
19600 | ········catch (Exception) |
19601 | ········{ |
19602 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19603 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19604 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19605 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19606 | ········} |
19607 | ····} |
19608 | ····[Test] |
19609 | ····public void TestSaveReload() |
19610 | ····{ |
19611 | ········CreateObjects(); |
19612 | ········QueryOwn(); |
19613 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19614 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19615 | ····} |
19616 | ····[Test] |
19617 | ····public void TestSaveReloadNull() |
19618 | ····{ |
19619 | ········CreateObjects(); |
19620 | ········QueryOwn(); |
19621 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19622 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19623 | ········ownVar.RelField = null; |
19624 | ········pm.Save(); |
19625 | ········pm.UnloadCache(); |
19626 | ········QueryOwn(); |
19627 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19628 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19629 | ····} |
19630 | ····[Test] |
19631 | ····public void TestChangeKeyHolderLeft() |
19632 | ····{ |
19633 | ········CreateObjects(); |
19634 | ········QueryOwn(); |
19635 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19636 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19637 | ········int x = ownVar.RelField.Dummy; |
19638 | ········ownVar.Dummy = 4711; |
19639 | ········pm.Save(); |
19640 | ········pm.UnloadCache(); |
19641 | ········QueryOwn(); |
19642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19643 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19644 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19645 | ····} |
19646 | ····[Test] |
19647 | ····public void TestChangeKeyHolderRight() |
19648 | ····{ |
19649 | ········CreateObjects(); |
19650 | ········QueryOther(); |
19651 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19652 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19653 | ········int x = otherVar.RelField.Dummy; |
19654 | ········otherVar.Dummy = 4711; |
19655 | ········pm.Save(); |
19656 | ········pm.UnloadCache(); |
19657 | ········QueryOther(); |
19658 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19659 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19660 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19661 | ····} |
19662 | ····[Test] |
19663 | ····public void TestChangeKeyHolderLeftNoTouch() |
19664 | ····{ |
19665 | ········CreateObjects(); |
19666 | ········QueryOwn(); |
19667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19669 | ········ownVar.Dummy = 4711; |
19670 | ········pm.Save(); |
19671 | ········pm.UnloadCache(); |
19672 | ········QueryOwn(); |
19673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19674 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19676 | ····} |
19677 | ····[Test] |
19678 | ····public void TestChangeKeyHolderRightNoTouch() |
19679 | ····{ |
19680 | ········CreateObjects(); |
19681 | ········QueryOther(); |
19682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19683 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19684 | ········otherVar.Dummy = 4711; |
19685 | ········pm.Save(); |
19686 | ········pm.UnloadCache(); |
19687 | ········QueryOther(); |
19688 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19689 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19690 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19691 | ····} |
19692 | ····[Test] |
19693 | ····public void TestRelationHash() |
19694 | ····{ |
19695 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoLeftBase)); |
19696 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19697 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoRight)); |
19698 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19699 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19700 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19701 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoLeftDerived)); |
19702 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19703 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19704 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19705 | ····} |
19706 | ····void CreateObjects() |
19707 | ····{ |
19708 | ········pm.MakePersistent(ownVar); |
19709 | ········pm.MakePersistent(otherVar); |
19710 | ········pm.Save(); |
19711 | ········ownVar.AssignRelation(otherVar); |
19712 | ········pm.Save(); |
19713 | ········pm.UnloadCache(); |
19714 | ····} |
19715 | ····void QueryOwn() |
19716 | ····{ |
19717 | ········var q = new NDOQuery<AgrBi11OwnpabsTblAutoLeftBase>(pm); |
19718 | ········ownVar = q.ExecuteSingle(); |
19719 | ····} |
19720 | ····void QueryOther() |
19721 | ····{ |
19722 | ········var q = new NDOQuery<AgrBi11OwnpabsTblAutoRight>(pm); |
19723 | ········otherVar = q.ExecuteSingle(); |
19724 | ····} |
19725 | } |
19726 | |
19727 | |
19728 | [TestFixture] |
19729 | public class TestAgrDirnOwnpabsNoTblAuto : NDOTest |
19730 | { |
19731 | ····AgrDirnOwnpabsNoTblAutoLeftBase ownVar; |
19732 | ····AgrDirnOwnpabsNoTblAutoRight otherVar; |
19733 | ····PersistenceManager pm; |
19734 | ····[SetUp] |
19735 | ····public void Setup() |
19736 | ····{ |
19737 | ········pm = PmFactory.NewPersistenceManager(); |
19738 | ········ownVar = new AgrDirnOwnpabsNoTblAutoLeftDerived(); |
19739 | ········otherVar = new AgrDirnOwnpabsNoTblAutoRight(); |
19740 | ····} |
19741 | ····[TearDown] |
19742 | ····public void TearDown() |
19743 | ····{ |
19744 | ········try |
19745 | ········{ |
19746 | ············pm.UnloadCache(); |
19747 | ············var l = pm.Objects<AgrDirnOwnpabsNoTblAutoLeftBase>().ResultTable; |
19748 | ············pm.Delete(l); |
19749 | ············pm.Save(); |
19750 | ············pm.UnloadCache(); |
19751 | ············var m = pm.Objects<AgrDirnOwnpabsNoTblAutoRight>().ResultTable; |
19752 | ············pm.Delete(m); |
19753 | ············pm.Save(); |
19754 | ············pm.UnloadCache(); |
19755 | ············decimal count; |
19756 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19757 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19758 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19759 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19760 | ········} |
19761 | ········catch (Exception) |
19762 | ········{ |
19763 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19764 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19765 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19766 | ········} |
19767 | ····} |
19768 | ····[Test] |
19769 | ····public void TestSaveReload() |
19770 | ····{ |
19771 | ········CreateObjects(); |
19772 | ········QueryOwn(); |
19773 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19774 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19775 | ····} |
19776 | ····[Test] |
19777 | ····public void TestSaveReloadNull() |
19778 | ····{ |
19779 | ········CreateObjects(); |
19780 | ········QueryOwn(); |
19781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19782 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19783 | ········ownVar.RelField = new List<AgrDirnOwnpabsNoTblAutoRight>(); |
19784 | ········pm.Save(); |
19785 | ········pm.UnloadCache(); |
19786 | ········QueryOwn(); |
19787 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19788 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19789 | ····} |
19790 | ····[Test] |
19791 | ····public void TestSaveReloadRemove() |
19792 | ····{ |
19793 | ········CreateObjects(); |
19794 | ········QueryOwn(); |
19795 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19796 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19797 | ········ownVar.RemoveRelatedObject(); |
19798 | ········pm.Save(); |
19799 | ········pm.UnloadCache(); |
19800 | ········QueryOwn(); |
19801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19802 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19803 | ····} |
19804 | ····[Test] |
19805 | ····public void TestUpdateOrder() |
19806 | ····{ |
19807 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
19808 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
19809 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpabsNoTblAutoLeftDerived)})) |
19810 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpabsNoTblAutoRight)})), "Wrong order #2"); |
19811 | ········Debug.WriteLine("AgrDirnOwnpabsNoTblAutoLeftBase"); |
19812 | ····} |
19813 | ····void CreateObjects() |
19814 | ····{ |
19815 | ········pm.MakePersistent(ownVar); |
19816 | ········pm.MakePersistent(otherVar); |
19817 | ········ownVar.AssignRelation(otherVar); |
19818 | ········pm.Save(); |
19819 | ········pm.UnloadCache(); |
19820 | ····} |
19821 | ····void QueryOwn() |
19822 | ····{ |
19823 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblAutoLeftBase>(pm); |
19824 | ········ownVar = q.ExecuteSingle(); |
19825 | ····} |
19826 | ····void QueryOther() |
19827 | ····{ |
19828 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblAutoRight>(pm); |
19829 | ········otherVar = q.ExecuteSingle(); |
19830 | ····} |
19831 | } |
19832 | |
19833 | |
19834 | [TestFixture] |
19835 | public class TestAgrDirnOwnpabsTblAuto : NDOTest |
19836 | { |
19837 | ····AgrDirnOwnpabsTblAutoLeftBase ownVar; |
19838 | ····AgrDirnOwnpabsTblAutoRight otherVar; |
19839 | ····PersistenceManager pm; |
19840 | ····[SetUp] |
19841 | ····public void Setup() |
19842 | ····{ |
19843 | ········pm = PmFactory.NewPersistenceManager(); |
19844 | ········ownVar = new AgrDirnOwnpabsTblAutoLeftDerived(); |
19845 | ········otherVar = new AgrDirnOwnpabsTblAutoRight(); |
19846 | ····} |
19847 | ····[TearDown] |
19848 | ····public void TearDown() |
19849 | ····{ |
19850 | ········try |
19851 | ········{ |
19852 | ············pm.UnloadCache(); |
19853 | ············var l = pm.Objects<AgrDirnOwnpabsTblAutoLeftBase>().ResultTable; |
19854 | ············pm.Delete(l); |
19855 | ············pm.Save(); |
19856 | ············pm.UnloadCache(); |
19857 | ············var m = pm.Objects<AgrDirnOwnpabsTblAutoRight>().ResultTable; |
19858 | ············pm.Delete(m); |
19859 | ············pm.Save(); |
19860 | ············pm.UnloadCache(); |
19861 | ············decimal count; |
19862 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19863 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19864 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19866 | ········} |
19867 | ········catch (Exception) |
19868 | ········{ |
19869 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19870 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19871 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19872 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19873 | ········} |
19874 | ····} |
19875 | ····[Test] |
19876 | ····public void TestSaveReload() |
19877 | ····{ |
19878 | ········CreateObjects(); |
19879 | ········QueryOwn(); |
19880 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19881 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19882 | ····} |
19883 | ····[Test] |
19884 | ····public void TestSaveReloadNull() |
19885 | ····{ |
19886 | ········CreateObjects(); |
19887 | ········QueryOwn(); |
19888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19889 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19890 | ········ownVar.RelField = new List<AgrDirnOwnpabsTblAutoRight>(); |
19891 | ········pm.Save(); |
19892 | ········pm.UnloadCache(); |
19893 | ········QueryOwn(); |
19894 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19895 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19896 | ····} |
19897 | ····[Test] |
19898 | ····public void TestSaveReloadRemove() |
19899 | ····{ |
19900 | ········CreateObjects(); |
19901 | ········QueryOwn(); |
19902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19903 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19904 | ········ownVar.RemoveRelatedObject(); |
19905 | ········pm.Save(); |
19906 | ········pm.UnloadCache(); |
19907 | ········QueryOwn(); |
19908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19909 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19910 | ····} |
19911 | ····void CreateObjects() |
19912 | ····{ |
19913 | ········pm.MakePersistent(ownVar); |
19914 | ········pm.MakePersistent(otherVar); |
19915 | ········ownVar.AssignRelation(otherVar); |
19916 | ········pm.Save(); |
19917 | ········pm.UnloadCache(); |
19918 | ····} |
19919 | ····void QueryOwn() |
19920 | ····{ |
19921 | ········var q = new NDOQuery<AgrDirnOwnpabsTblAutoLeftBase>(pm); |
19922 | ········ownVar = q.ExecuteSingle(); |
19923 | ····} |
19924 | ····void QueryOther() |
19925 | ····{ |
19926 | ········var q = new NDOQuery<AgrDirnOwnpabsTblAutoRight>(pm); |
19927 | ········otherVar = q.ExecuteSingle(); |
19928 | ····} |
19929 | } |
19930 | |
19931 | |
19932 | [TestFixture] |
19933 | public class TestAgrBin1OwnpabsNoTblAuto : NDOTest |
19934 | { |
19935 | ····AgrBin1OwnpabsNoTblAutoLeftBase ownVar; |
19936 | ····AgrBin1OwnpabsNoTblAutoRight otherVar; |
19937 | ····PersistenceManager pm; |
19938 | ····[SetUp] |
19939 | ····public void Setup() |
19940 | ····{ |
19941 | ········pm = PmFactory.NewPersistenceManager(); |
19942 | ········ownVar = new AgrBin1OwnpabsNoTblAutoLeftDerived(); |
19943 | ········otherVar = new AgrBin1OwnpabsNoTblAutoRight(); |
19944 | ····} |
19945 | ····[TearDown] |
19946 | ····public void TearDown() |
19947 | ····{ |
19948 | ········try |
19949 | ········{ |
19950 | ············pm.UnloadCache(); |
19951 | ············var l = pm.Objects<AgrBin1OwnpabsNoTblAutoLeftBase>().ResultTable; |
19952 | ············pm.Delete(l); |
19953 | ············pm.Save(); |
19954 | ············pm.UnloadCache(); |
19955 | ············var m = pm.Objects<AgrBin1OwnpabsNoTblAutoRight>().ResultTable; |
19956 | ············pm.Delete(m); |
19957 | ············pm.Save(); |
19958 | ············pm.UnloadCache(); |
19959 | ············decimal count; |
19960 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19961 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19962 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19963 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19964 | ········} |
19965 | ········catch (Exception) |
19966 | ········{ |
19967 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19968 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19969 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19970 | ········} |
19971 | ····} |
19972 | ····[Test] |
19973 | ····public void TestSaveReload() |
19974 | ····{ |
19975 | ········CreateObjects(); |
19976 | ········QueryOwn(); |
19977 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19978 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19979 | ····} |
19980 | ····[Test] |
19981 | ····public void TestSaveReloadNull() |
19982 | ····{ |
19983 | ········CreateObjects(); |
19984 | ········QueryOwn(); |
19985 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19986 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19987 | ········ownVar.RelField = new List<AgrBin1OwnpabsNoTblAutoRight>(); |
19988 | ········pm.Save(); |
19989 | ········pm.UnloadCache(); |
19990 | ········QueryOwn(); |
19991 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19992 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19993 | ····} |
19994 | ····[Test] |
19995 | ····public void TestSaveReloadRemove() |
19996 | ····{ |
19997 | ········CreateObjects(); |
19998 | ········QueryOwn(); |
19999 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20000 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20001 | ········ownVar.RemoveRelatedObject(); |
20002 | ········pm.Save(); |
20003 | ········pm.UnloadCache(); |
20004 | ········QueryOwn(); |
20005 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20006 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20007 | ····} |
20008 | ····[Test] |
20009 | ····public void TestChangeKeyHolderRight() |
20010 | ····{ |
20011 | ········CreateObjects(); |
20012 | ········QueryOther(); |
20013 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20014 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20015 | ········int x = otherVar.RelField.Dummy; |
20016 | ········otherVar.Dummy = 4711; |
20017 | ········pm.Save(); |
20018 | ········pm.UnloadCache(); |
20019 | ········QueryOther(); |
20020 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20021 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20022 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20023 | ····} |
20024 | ····[Test] |
20025 | ····public void TestChangeKeyHolderRightNoTouch() |
20026 | ····{ |
20027 | ········CreateObjects(); |
20028 | ········QueryOther(); |
20029 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20030 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20031 | ········otherVar.Dummy = 4711; |
20032 | ········pm.Save(); |
20033 | ········pm.UnloadCache(); |
20034 | ········QueryOther(); |
20035 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20036 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20037 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20038 | ····} |
20039 | ····[Test] |
20040 | ····public void TestUpdateOrder() |
20041 | ····{ |
20042 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
20043 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
20044 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpabsNoTblAutoLeftDerived)})) |
20045 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
20046 | ········Debug.WriteLine("AgrBin1OwnpabsNoTblAutoLeftBase"); |
20047 | ····} |
20048 | ····[Test] |
20049 | ····public void TestRelationHash() |
20050 | ····{ |
20051 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoLeftBase)); |
20052 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20053 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoRight)); |
20054 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20055 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20056 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20057 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoLeftDerived)); |
20058 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20059 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20060 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20061 | ····} |
20062 | ····void CreateObjects() |
20063 | ····{ |
20064 | ········pm.MakePersistent(ownVar); |
20065 | ········pm.MakePersistent(otherVar); |
20066 | ········pm.Save(); |
20067 | ········ownVar.AssignRelation(otherVar); |
20068 | ········pm.Save(); |
20069 | ········pm.UnloadCache(); |
20070 | ····} |
20071 | ····void QueryOwn() |
20072 | ····{ |
20073 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblAutoLeftBase>(pm); |
20074 | ········ownVar = q.ExecuteSingle(); |
20075 | ····} |
20076 | ····void QueryOther() |
20077 | ····{ |
20078 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblAutoRight>(pm); |
20079 | ········otherVar = q.ExecuteSingle(); |
20080 | ····} |
20081 | } |
20082 | |
20083 | |
20084 | [TestFixture] |
20085 | public class TestAgrBin1OwnpabsTblAuto : NDOTest |
20086 | { |
20087 | ····AgrBin1OwnpabsTblAutoLeftBase ownVar; |
20088 | ····AgrBin1OwnpabsTblAutoRight otherVar; |
20089 | ····PersistenceManager pm; |
20090 | ····[SetUp] |
20091 | ····public void Setup() |
20092 | ····{ |
20093 | ········pm = PmFactory.NewPersistenceManager(); |
20094 | ········ownVar = new AgrBin1OwnpabsTblAutoLeftDerived(); |
20095 | ········otherVar = new AgrBin1OwnpabsTblAutoRight(); |
20096 | ····} |
20097 | ····[TearDown] |
20098 | ····public void TearDown() |
20099 | ····{ |
20100 | ········try |
20101 | ········{ |
20102 | ············pm.UnloadCache(); |
20103 | ············var l = pm.Objects<AgrBin1OwnpabsTblAutoLeftBase>().ResultTable; |
20104 | ············pm.Delete(l); |
20105 | ············pm.Save(); |
20106 | ············pm.UnloadCache(); |
20107 | ············var m = pm.Objects<AgrBin1OwnpabsTblAutoRight>().ResultTable; |
20108 | ············pm.Delete(m); |
20109 | ············pm.Save(); |
20110 | ············pm.UnloadCache(); |
20111 | ············decimal count; |
20112 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20113 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20114 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20115 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20116 | ········} |
20117 | ········catch (Exception) |
20118 | ········{ |
20119 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20120 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20121 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20122 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20123 | ········} |
20124 | ····} |
20125 | ····[Test] |
20126 | ····public void TestSaveReload() |
20127 | ····{ |
20128 | ········CreateObjects(); |
20129 | ········QueryOwn(); |
20130 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20131 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20132 | ····} |
20133 | ····[Test] |
20134 | ····public void TestSaveReloadNull() |
20135 | ····{ |
20136 | ········CreateObjects(); |
20137 | ········QueryOwn(); |
20138 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20139 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20140 | ········ownVar.RelField = new List<AgrBin1OwnpabsTblAutoRight>(); |
20141 | ········pm.Save(); |
20142 | ········pm.UnloadCache(); |
20143 | ········QueryOwn(); |
20144 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20145 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20146 | ····} |
20147 | ····[Test] |
20148 | ····public void TestSaveReloadRemove() |
20149 | ····{ |
20150 | ········CreateObjects(); |
20151 | ········QueryOwn(); |
20152 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20153 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20154 | ········ownVar.RemoveRelatedObject(); |
20155 | ········pm.Save(); |
20156 | ········pm.UnloadCache(); |
20157 | ········QueryOwn(); |
20158 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20159 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20160 | ····} |
20161 | ····[Test] |
20162 | ····public void TestChangeKeyHolderRight() |
20163 | ····{ |
20164 | ········CreateObjects(); |
20165 | ········QueryOther(); |
20166 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20167 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20168 | ········int x = otherVar.RelField.Dummy; |
20169 | ········otherVar.Dummy = 4711; |
20170 | ········pm.Save(); |
20171 | ········pm.UnloadCache(); |
20172 | ········QueryOther(); |
20173 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20174 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20175 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20176 | ····} |
20177 | ····[Test] |
20178 | ····public void TestChangeKeyHolderRightNoTouch() |
20179 | ····{ |
20180 | ········CreateObjects(); |
20181 | ········QueryOther(); |
20182 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20183 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20184 | ········otherVar.Dummy = 4711; |
20185 | ········pm.Save(); |
20186 | ········pm.UnloadCache(); |
20187 | ········QueryOther(); |
20188 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20189 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20190 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20191 | ····} |
20192 | ····[Test] |
20193 | ····public void TestRelationHash() |
20194 | ····{ |
20195 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoLeftBase)); |
20196 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20197 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoRight)); |
20198 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20199 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20200 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20201 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoLeftDerived)); |
20202 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20203 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20204 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20205 | ····} |
20206 | ····void CreateObjects() |
20207 | ····{ |
20208 | ········pm.MakePersistent(ownVar); |
20209 | ········pm.MakePersistent(otherVar); |
20210 | ········pm.Save(); |
20211 | ········ownVar.AssignRelation(otherVar); |
20212 | ········pm.Save(); |
20213 | ········pm.UnloadCache(); |
20214 | ····} |
20215 | ····void QueryOwn() |
20216 | ····{ |
20217 | ········var q = new NDOQuery<AgrBin1OwnpabsTblAutoLeftBase>(pm); |
20218 | ········ownVar = q.ExecuteSingle(); |
20219 | ····} |
20220 | ····void QueryOther() |
20221 | ····{ |
20222 | ········var q = new NDOQuery<AgrBin1OwnpabsTblAutoRight>(pm); |
20223 | ········otherVar = q.ExecuteSingle(); |
20224 | ····} |
20225 | } |
20226 | |
20227 | |
20228 | [TestFixture] |
20229 | public class TestAgrBi1nOwnpabsTblAuto : NDOTest |
20230 | { |
20231 | ····AgrBi1nOwnpabsTblAutoLeftBase ownVar; |
20232 | ····AgrBi1nOwnpabsTblAutoRight otherVar; |
20233 | ····PersistenceManager pm; |
20234 | ····[SetUp] |
20235 | ····public void Setup() |
20236 | ····{ |
20237 | ········pm = PmFactory.NewPersistenceManager(); |
20238 | ········ownVar = new AgrBi1nOwnpabsTblAutoLeftDerived(); |
20239 | ········otherVar = new AgrBi1nOwnpabsTblAutoRight(); |
20240 | ····} |
20241 | ····[TearDown] |
20242 | ····public void TearDown() |
20243 | ····{ |
20244 | ········try |
20245 | ········{ |
20246 | ············pm.UnloadCache(); |
20247 | ············var l = pm.Objects<AgrBi1nOwnpabsTblAutoLeftBase>().ResultTable; |
20248 | ············pm.Delete(l); |
20249 | ············pm.Save(); |
20250 | ············pm.UnloadCache(); |
20251 | ············var m = pm.Objects<AgrBi1nOwnpabsTblAutoRight>().ResultTable; |
20252 | ············pm.Delete(m); |
20253 | ············pm.Save(); |
20254 | ············pm.UnloadCache(); |
20255 | ············decimal count; |
20256 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20257 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20258 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20259 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20260 | ········} |
20261 | ········catch (Exception) |
20262 | ········{ |
20263 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20264 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20265 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20266 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20267 | ········} |
20268 | ····} |
20269 | ····[Test] |
20270 | ····public void TestSaveReload() |
20271 | ····{ |
20272 | ········CreateObjects(); |
20273 | ········QueryOwn(); |
20274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20275 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20276 | ····} |
20277 | ····[Test] |
20278 | ····public void TestSaveReloadNull() |
20279 | ····{ |
20280 | ········CreateObjects(); |
20281 | ········QueryOwn(); |
20282 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20284 | ········ownVar.RelField = null; |
20285 | ········pm.Save(); |
20286 | ········pm.UnloadCache(); |
20287 | ········QueryOwn(); |
20288 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20289 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20290 | ····} |
20291 | ····[Test] |
20292 | ····public void TestChangeKeyHolderLeft() |
20293 | ····{ |
20294 | ········CreateObjects(); |
20295 | ········QueryOwn(); |
20296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20297 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20298 | ········int x = ownVar.RelField.Dummy; |
20299 | ········ownVar.Dummy = 4711; |
20300 | ········pm.Save(); |
20301 | ········pm.UnloadCache(); |
20302 | ········QueryOwn(); |
20303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20304 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20305 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20306 | ····} |
20307 | ····[Test] |
20308 | ····public void TestChangeKeyHolderLeftNoTouch() |
20309 | ····{ |
20310 | ········CreateObjects(); |
20311 | ········QueryOwn(); |
20312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20313 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20314 | ········ownVar.Dummy = 4711; |
20315 | ········pm.Save(); |
20316 | ········pm.UnloadCache(); |
20317 | ········QueryOwn(); |
20318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20319 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20321 | ····} |
20322 | ····[Test] |
20323 | ····public void TestRelationHash() |
20324 | ····{ |
20325 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoLeftBase)); |
20326 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20327 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoRight)); |
20328 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20329 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20330 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20331 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoLeftDerived)); |
20332 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20333 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20334 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20335 | ····} |
20336 | ····void CreateObjects() |
20337 | ····{ |
20338 | ········pm.MakePersistent(ownVar); |
20339 | ········pm.MakePersistent(otherVar); |
20340 | ········ownVar.AssignRelation(otherVar); |
20341 | ········pm.Save(); |
20342 | ········pm.UnloadCache(); |
20343 | ····} |
20344 | ····void QueryOwn() |
20345 | ····{ |
20346 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblAutoLeftBase>(pm); |
20347 | ········ownVar = q.ExecuteSingle(); |
20348 | ····} |
20349 | ····void QueryOther() |
20350 | ····{ |
20351 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblAutoRight>(pm); |
20352 | ········otherVar = q.ExecuteSingle(); |
20353 | ····} |
20354 | } |
20355 | |
20356 | |
20357 | [TestFixture] |
20358 | public class TestAgrBinnOwnpabsTblAuto : NDOTest |
20359 | { |
20360 | ····AgrBinnOwnpabsTblAutoLeftBase ownVar; |
20361 | ····AgrBinnOwnpabsTblAutoRight otherVar; |
20362 | ····PersistenceManager pm; |
20363 | ····[SetUp] |
20364 | ····public void Setup() |
20365 | ····{ |
20366 | ········pm = PmFactory.NewPersistenceManager(); |
20367 | ········ownVar = new AgrBinnOwnpabsTblAutoLeftDerived(); |
20368 | ········otherVar = new AgrBinnOwnpabsTblAutoRight(); |
20369 | ····} |
20370 | ····[TearDown] |
20371 | ····public void TearDown() |
20372 | ····{ |
20373 | ········try |
20374 | ········{ |
20375 | ············pm.UnloadCache(); |
20376 | ············var l = pm.Objects<AgrBinnOwnpabsTblAutoLeftBase>().ResultTable; |
20377 | ············pm.Delete(l); |
20378 | ············pm.Save(); |
20379 | ············pm.UnloadCache(); |
20380 | ············var m = pm.Objects<AgrBinnOwnpabsTblAutoRight>().ResultTable; |
20381 | ············pm.Delete(m); |
20382 | ············pm.Save(); |
20383 | ············pm.UnloadCache(); |
20384 | ············decimal count; |
20385 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20386 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20387 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20388 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20389 | ········} |
20390 | ········catch (Exception) |
20391 | ········{ |
20392 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20393 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20394 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20395 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20396 | ········} |
20397 | ····} |
20398 | ····[Test] |
20399 | ····public void TestSaveReload() |
20400 | ····{ |
20401 | ········CreateObjects(); |
20402 | ········QueryOwn(); |
20403 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20404 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20405 | ····} |
20406 | ····[Test] |
20407 | ····public void TestSaveReloadNull() |
20408 | ····{ |
20409 | ········CreateObjects(); |
20410 | ········QueryOwn(); |
20411 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20412 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20413 | ········ownVar.RelField = new List<AgrBinnOwnpabsTblAutoRight>(); |
20414 | ········pm.Save(); |
20415 | ········pm.UnloadCache(); |
20416 | ········QueryOwn(); |
20417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20418 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20419 | ····} |
20420 | ····[Test] |
20421 | ····public void TestSaveReloadRemove() |
20422 | ····{ |
20423 | ········CreateObjects(); |
20424 | ········QueryOwn(); |
20425 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20426 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20427 | ········ownVar.RemoveRelatedObject(); |
20428 | ········pm.Save(); |
20429 | ········pm.UnloadCache(); |
20430 | ········QueryOwn(); |
20431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20432 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20433 | ····} |
20434 | ····[Test] |
20435 | ····public void TestRelationHash() |
20436 | ····{ |
20437 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoLeftBase)); |
20438 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20439 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoRight)); |
20440 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20441 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20442 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20443 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoLeftDerived)); |
20444 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20445 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20446 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20447 | ····} |
20448 | ····void CreateObjects() |
20449 | ····{ |
20450 | ········pm.MakePersistent(ownVar); |
20451 | ········pm.MakePersistent(otherVar); |
20452 | ········ownVar.AssignRelation(otherVar); |
20453 | ········pm.Save(); |
20454 | ········pm.UnloadCache(); |
20455 | ····} |
20456 | ····void QueryOwn() |
20457 | ····{ |
20458 | ········var q = new NDOQuery<AgrBinnOwnpabsTblAutoLeftBase>(pm); |
20459 | ········ownVar = q.ExecuteSingle(); |
20460 | ····} |
20461 | ····void QueryOther() |
20462 | ····{ |
20463 | ········var q = new NDOQuery<AgrBinnOwnpabsTblAutoRight>(pm); |
20464 | ········otherVar = q.ExecuteSingle(); |
20465 | ····} |
20466 | } |
20467 | |
20468 | |
20469 | [TestFixture] |
20470 | public class TestCmpDir1OwnpabsNoTblAuto : NDOTest |
20471 | { |
20472 | ····CmpDir1OwnpabsNoTblAutoLeftBase ownVar; |
20473 | ····CmpDir1OwnpabsNoTblAutoRight otherVar; |
20474 | ····PersistenceManager pm; |
20475 | ····[SetUp] |
20476 | ····public void Setup() |
20477 | ····{ |
20478 | ········pm = PmFactory.NewPersistenceManager(); |
20479 | ········ownVar = new CmpDir1OwnpabsNoTblAutoLeftDerived(); |
20480 | ········otherVar = new CmpDir1OwnpabsNoTblAutoRight(); |
20481 | ····} |
20482 | ····[TearDown] |
20483 | ····public void TearDown() |
20484 | ····{ |
20485 | ········try |
20486 | ········{ |
20487 | ············pm.UnloadCache(); |
20488 | ············var l = pm.Objects<CmpDir1OwnpabsNoTblAutoLeftBase>().ResultTable; |
20489 | ············pm.Delete(l); |
20490 | ············pm.Save(); |
20491 | ············pm.UnloadCache(); |
20492 | ············decimal count; |
20493 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20494 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20495 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20496 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20497 | ········} |
20498 | ········catch (Exception) |
20499 | ········{ |
20500 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20501 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20502 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20503 | ········} |
20504 | ····} |
20505 | ····[Test] |
20506 | ····public void TestSaveReload() |
20507 | ····{ |
20508 | ········CreateObjects(); |
20509 | ········QueryOwn(); |
20510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20511 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20512 | ····} |
20513 | ····[Test] |
20514 | ····public void TestSaveReloadNull() |
20515 | ····{ |
20516 | ········CreateObjects(); |
20517 | ········QueryOwn(); |
20518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20519 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20520 | ········ownVar.RelField = null; |
20521 | ········pm.Save(); |
20522 | ········pm.UnloadCache(); |
20523 | ········QueryOwn(); |
20524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20525 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20526 | ····} |
20527 | ····[Test] |
20528 | ····public void TestChangeKeyHolderLeft() |
20529 | ····{ |
20530 | ········CreateObjects(); |
20531 | ········QueryOwn(); |
20532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20533 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20534 | ········int x = ownVar.RelField.Dummy; |
20535 | ········ownVar.Dummy = 4711; |
20536 | ········pm.Save(); |
20537 | ········pm.UnloadCache(); |
20538 | ········QueryOwn(); |
20539 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20540 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20541 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20542 | ····} |
20543 | ····[Test] |
20544 | ····public void TestChangeKeyHolderLeftNoTouch() |
20545 | ····{ |
20546 | ········CreateObjects(); |
20547 | ········QueryOwn(); |
20548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20549 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20550 | ········ownVar.Dummy = 4711; |
20551 | ········pm.Save(); |
20552 | ········pm.UnloadCache(); |
20553 | ········QueryOwn(); |
20554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20555 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20556 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20557 | ····} |
20558 | ····[Test] |
20559 | ····public void TestUpdateOrder() |
20560 | ····{ |
20561 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
20562 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
20563 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpabsNoTblAutoLeftDerived)})) |
20564 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
20565 | ········Debug.WriteLine("CmpDir1OwnpabsNoTblAutoLeftBase"); |
20566 | ····} |
20567 | ····void CreateObjects() |
20568 | ····{ |
20569 | ········pm.MakePersistent(ownVar); |
20570 | ········pm.Save(); |
20571 | ········ownVar.AssignRelation(otherVar); |
20572 | ········pm.Save(); |
20573 | ········pm.UnloadCache(); |
20574 | ····} |
20575 | ····void QueryOwn() |
20576 | ····{ |
20577 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblAutoLeftBase>(pm); |
20578 | ········ownVar = q.ExecuteSingle(); |
20579 | ····} |
20580 | ····void QueryOther() |
20581 | ····{ |
20582 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblAutoRight>(pm); |
20583 | ········otherVar = q.ExecuteSingle(); |
20584 | ····} |
20585 | } |
20586 | |
20587 | |
20588 | [TestFixture] |
20589 | public class TestCmpDir1OwnpabsTblAuto : NDOTest |
20590 | { |
20591 | ····CmpDir1OwnpabsTblAutoLeftBase ownVar; |
20592 | ····CmpDir1OwnpabsTblAutoRight otherVar; |
20593 | ····PersistenceManager pm; |
20594 | ····[SetUp] |
20595 | ····public void Setup() |
20596 | ····{ |
20597 | ········pm = PmFactory.NewPersistenceManager(); |
20598 | ········ownVar = new CmpDir1OwnpabsTblAutoLeftDerived(); |
20599 | ········otherVar = new CmpDir1OwnpabsTblAutoRight(); |
20600 | ····} |
20601 | ····[TearDown] |
20602 | ····public void TearDown() |
20603 | ····{ |
20604 | ········try |
20605 | ········{ |
20606 | ············pm.UnloadCache(); |
20607 | ············var l = pm.Objects<CmpDir1OwnpabsTblAutoLeftBase>().ResultTable; |
20608 | ············pm.Delete(l); |
20609 | ············pm.Save(); |
20610 | ············pm.UnloadCache(); |
20611 | ············decimal count; |
20612 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20613 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20614 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20615 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20616 | ········} |
20617 | ········catch (Exception) |
20618 | ········{ |
20619 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20620 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20621 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20622 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20623 | ········} |
20624 | ····} |
20625 | ····[Test] |
20626 | ····public void TestSaveReload() |
20627 | ····{ |
20628 | ········CreateObjects(); |
20629 | ········QueryOwn(); |
20630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20631 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20632 | ····} |
20633 | ····[Test] |
20634 | ····public void TestSaveReloadNull() |
20635 | ····{ |
20636 | ········CreateObjects(); |
20637 | ········QueryOwn(); |
20638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20639 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20640 | ········ownVar.RelField = null; |
20641 | ········pm.Save(); |
20642 | ········pm.UnloadCache(); |
20643 | ········QueryOwn(); |
20644 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20645 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20646 | ····} |
20647 | ····[Test] |
20648 | ····public void TestChangeKeyHolderLeft() |
20649 | ····{ |
20650 | ········CreateObjects(); |
20651 | ········QueryOwn(); |
20652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20654 | ········int x = ownVar.RelField.Dummy; |
20655 | ········ownVar.Dummy = 4711; |
20656 | ········pm.Save(); |
20657 | ········pm.UnloadCache(); |
20658 | ········QueryOwn(); |
20659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20660 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20662 | ····} |
20663 | ····[Test] |
20664 | ····public void TestChangeKeyHolderLeftNoTouch() |
20665 | ····{ |
20666 | ········CreateObjects(); |
20667 | ········QueryOwn(); |
20668 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20669 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20670 | ········ownVar.Dummy = 4711; |
20671 | ········pm.Save(); |
20672 | ········pm.UnloadCache(); |
20673 | ········QueryOwn(); |
20674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20675 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20676 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20677 | ····} |
20678 | ····void CreateObjects() |
20679 | ····{ |
20680 | ········pm.MakePersistent(ownVar); |
20681 | ········ownVar.AssignRelation(otherVar); |
20682 | ········pm.Save(); |
20683 | ········pm.UnloadCache(); |
20684 | ····} |
20685 | ····void QueryOwn() |
20686 | ····{ |
20687 | ········var q = new NDOQuery<CmpDir1OwnpabsTblAutoLeftBase>(pm); |
20688 | ········ownVar = q.ExecuteSingle(); |
20689 | ····} |
20690 | ····void QueryOther() |
20691 | ····{ |
20692 | ········var q = new NDOQuery<CmpDir1OwnpabsTblAutoRight>(pm); |
20693 | ········otherVar = q.ExecuteSingle(); |
20694 | ····} |
20695 | } |
20696 | |
20697 | |
20698 | [TestFixture] |
20699 | public class TestCmpBi11OwnpabsNoTblAuto : NDOTest |
20700 | { |
20701 | ····CmpBi11OwnpabsNoTblAutoLeftBase ownVar; |
20702 | ····CmpBi11OwnpabsNoTblAutoRight otherVar; |
20703 | ····PersistenceManager pm; |
20704 | ····[SetUp] |
20705 | ····public void Setup() |
20706 | ····{ |
20707 | ········pm = PmFactory.NewPersistenceManager(); |
20708 | ········ownVar = new CmpBi11OwnpabsNoTblAutoLeftDerived(); |
20709 | ········otherVar = new CmpBi11OwnpabsNoTblAutoRight(); |
20710 | ····} |
20711 | ····[TearDown] |
20712 | ····public void TearDown() |
20713 | ····{ |
20714 | ········try |
20715 | ········{ |
20716 | ············pm.UnloadCache(); |
20717 | ············var l = pm.Objects<CmpBi11OwnpabsNoTblAutoLeftBase>().ResultTable; |
20718 | ············pm.Delete(l); |
20719 | ············pm.Save(); |
20720 | ············pm.UnloadCache(); |
20721 | ············decimal count; |
20722 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20723 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20724 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20725 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20726 | ········} |
20727 | ········catch (Exception) |
20728 | ········{ |
20729 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20730 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20731 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20732 | ········} |
20733 | ····} |
20734 | ····[Test] |
20735 | ····public void TestSaveReload() |
20736 | ····{ |
20737 | ········CreateObjects(); |
20738 | ········QueryOwn(); |
20739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20740 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20741 | ····} |
20742 | ····[Test] |
20743 | ····public void TestSaveReloadNull() |
20744 | ····{ |
20745 | ········CreateObjects(); |
20746 | ········QueryOwn(); |
20747 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20748 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20749 | ········ownVar.RelField = null; |
20750 | ········pm.Save(); |
20751 | ········pm.UnloadCache(); |
20752 | ········QueryOwn(); |
20753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20754 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20755 | ····} |
20756 | ····[Test] |
20757 | ····public void TestChangeKeyHolderLeft() |
20758 | ····{ |
20759 | ········CreateObjects(); |
20760 | ········QueryOwn(); |
20761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20762 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20763 | ········int x = ownVar.RelField.Dummy; |
20764 | ········ownVar.Dummy = 4711; |
20765 | ········pm.Save(); |
20766 | ········pm.UnloadCache(); |
20767 | ········QueryOwn(); |
20768 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20769 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20770 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20771 | ····} |
20772 | ····[Test] |
20773 | ····public void TestChangeKeyHolderRight() |
20774 | ····{ |
20775 | ········CreateObjects(); |
20776 | ········QueryOther(); |
20777 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20778 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20779 | ········int x = otherVar.RelField.Dummy; |
20780 | ········otherVar.Dummy = 4711; |
20781 | ········pm.Save(); |
20782 | ········pm.UnloadCache(); |
20783 | ········QueryOther(); |
20784 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20785 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20786 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20787 | ····} |
20788 | ····[Test] |
20789 | ····public void TestChangeKeyHolderLeftNoTouch() |
20790 | ····{ |
20791 | ········CreateObjects(); |
20792 | ········QueryOwn(); |
20793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20794 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20795 | ········ownVar.Dummy = 4711; |
20796 | ········pm.Save(); |
20797 | ········pm.UnloadCache(); |
20798 | ········QueryOwn(); |
20799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20800 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20801 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20802 | ····} |
20803 | ····[Test] |
20804 | ····public void TestChangeKeyHolderRightNoTouch() |
20805 | ····{ |
20806 | ········CreateObjects(); |
20807 | ········QueryOther(); |
20808 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20809 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20810 | ········otherVar.Dummy = 4711; |
20811 | ········pm.Save(); |
20812 | ········pm.UnloadCache(); |
20813 | ········QueryOther(); |
20814 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20815 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20816 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20817 | ····} |
20818 | ····[Test] |
20819 | ····public void TestRelationHash() |
20820 | ····{ |
20821 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoLeftBase)); |
20822 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20823 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoRight)); |
20824 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20825 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20826 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20827 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoLeftDerived)); |
20828 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20829 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20830 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20831 | ····} |
20832 | ····void CreateObjects() |
20833 | ····{ |
20834 | ········pm.MakePersistent(ownVar); |
20835 | ········pm.Save(); |
20836 | ········ownVar.AssignRelation(otherVar); |
20837 | ········pm.Save(); |
20838 | ········pm.UnloadCache(); |
20839 | ····} |
20840 | ····void QueryOwn() |
20841 | ····{ |
20842 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblAutoLeftBase>(pm); |
20843 | ········ownVar = q.ExecuteSingle(); |
20844 | ····} |
20845 | ····void QueryOther() |
20846 | ····{ |
20847 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblAutoRight>(pm); |
20848 | ········otherVar = q.ExecuteSingle(); |
20849 | ····} |
20850 | } |
20851 | |
20852 | |
20853 | [TestFixture] |
20854 | public class TestCmpBi11OwnpabsTblAuto : NDOTest |
20855 | { |
20856 | ····CmpBi11OwnpabsTblAutoLeftBase ownVar; |
20857 | ····CmpBi11OwnpabsTblAutoRight otherVar; |
20858 | ····PersistenceManager pm; |
20859 | ····[SetUp] |
20860 | ····public void Setup() |
20861 | ····{ |
20862 | ········pm = PmFactory.NewPersistenceManager(); |
20863 | ········ownVar = new CmpBi11OwnpabsTblAutoLeftDerived(); |
20864 | ········otherVar = new CmpBi11OwnpabsTblAutoRight(); |
20865 | ····} |
20866 | ····[TearDown] |
20867 | ····public void TearDown() |
20868 | ····{ |
20869 | ········try |
20870 | ········{ |
20871 | ············pm.UnloadCache(); |
20872 | ············var l = pm.Objects<CmpBi11OwnpabsTblAutoLeftBase>().ResultTable; |
20873 | ············pm.Delete(l); |
20874 | ············pm.Save(); |
20875 | ············pm.UnloadCache(); |
20876 | ············decimal count; |
20877 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20878 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20879 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20880 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20881 | ········} |
20882 | ········catch (Exception) |
20883 | ········{ |
20884 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20885 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20886 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20887 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20888 | ········} |
20889 | ····} |
20890 | ····[Test] |
20891 | ····public void TestSaveReload() |
20892 | ····{ |
20893 | ········CreateObjects(); |
20894 | ········QueryOwn(); |
20895 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20896 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20897 | ····} |
20898 | ····[Test] |
20899 | ····public void TestSaveReloadNull() |
20900 | ····{ |
20901 | ········CreateObjects(); |
20902 | ········QueryOwn(); |
20903 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20904 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20905 | ········ownVar.RelField = null; |
20906 | ········pm.Save(); |
20907 | ········pm.UnloadCache(); |
20908 | ········QueryOwn(); |
20909 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20910 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20911 | ····} |
20912 | ····[Test] |
20913 | ····public void TestChangeKeyHolderLeft() |
20914 | ····{ |
20915 | ········CreateObjects(); |
20916 | ········QueryOwn(); |
20917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20918 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20919 | ········int x = ownVar.RelField.Dummy; |
20920 | ········ownVar.Dummy = 4711; |
20921 | ········pm.Save(); |
20922 | ········pm.UnloadCache(); |
20923 | ········QueryOwn(); |
20924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20925 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20926 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20927 | ····} |
20928 | ····[Test] |
20929 | ····public void TestChangeKeyHolderRight() |
20930 | ····{ |
20931 | ········CreateObjects(); |
20932 | ········QueryOther(); |
20933 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20934 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20935 | ········int x = otherVar.RelField.Dummy; |
20936 | ········otherVar.Dummy = 4711; |
20937 | ········pm.Save(); |
20938 | ········pm.UnloadCache(); |
20939 | ········QueryOther(); |
20940 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20941 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20942 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20943 | ····} |
20944 | ····[Test] |
20945 | ····public void TestChangeKeyHolderLeftNoTouch() |
20946 | ····{ |
20947 | ········CreateObjects(); |
20948 | ········QueryOwn(); |
20949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20950 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20951 | ········ownVar.Dummy = 4711; |
20952 | ········pm.Save(); |
20953 | ········pm.UnloadCache(); |
20954 | ········QueryOwn(); |
20955 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20956 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20957 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20958 | ····} |
20959 | ····[Test] |
20960 | ····public void TestChangeKeyHolderRightNoTouch() |
20961 | ····{ |
20962 | ········CreateObjects(); |
20963 | ········QueryOther(); |
20964 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20965 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20966 | ········otherVar.Dummy = 4711; |
20967 | ········pm.Save(); |
20968 | ········pm.UnloadCache(); |
20969 | ········QueryOther(); |
20970 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20971 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20972 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20973 | ····} |
20974 | ····[Test] |
20975 | ····public void TestRelationHash() |
20976 | ····{ |
20977 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoLeftBase)); |
20978 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20979 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoRight)); |
20980 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20981 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20982 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20983 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoLeftDerived)); |
20984 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20985 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20986 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20987 | ····} |
20988 | ····void CreateObjects() |
20989 | ····{ |
20990 | ········pm.MakePersistent(ownVar); |
20991 | ········ownVar.AssignRelation(otherVar); |
20992 | ········pm.Save(); |
20993 | ········pm.UnloadCache(); |
20994 | ····} |
20995 | ····void QueryOwn() |
20996 | ····{ |
20997 | ········var q = new NDOQuery<CmpBi11OwnpabsTblAutoLeftBase>(pm); |
20998 | ········ownVar = q.ExecuteSingle(); |
20999 | ····} |
21000 | ····void QueryOther() |
21001 | ····{ |
21002 | ········var q = new NDOQuery<CmpBi11OwnpabsTblAutoRight>(pm); |
21003 | ········otherVar = q.ExecuteSingle(); |
21004 | ····} |
21005 | } |
21006 | |
21007 | |
21008 | [TestFixture] |
21009 | public class TestCmpDirnOwnpabsNoTblAuto : NDOTest |
21010 | { |
21011 | ····CmpDirnOwnpabsNoTblAutoLeftBase ownVar; |
21012 | ····CmpDirnOwnpabsNoTblAutoRight otherVar; |
21013 | ····PersistenceManager pm; |
21014 | ····[SetUp] |
21015 | ····public void Setup() |
21016 | ····{ |
21017 | ········pm = PmFactory.NewPersistenceManager(); |
21018 | ········ownVar = new CmpDirnOwnpabsNoTblAutoLeftDerived(); |
21019 | ········otherVar = new CmpDirnOwnpabsNoTblAutoRight(); |
21020 | ····} |
21021 | ····[TearDown] |
21022 | ····public void TearDown() |
21023 | ····{ |
21024 | ········try |
21025 | ········{ |
21026 | ············pm.UnloadCache(); |
21027 | ············var l = pm.Objects<CmpDirnOwnpabsNoTblAutoLeftBase>().ResultTable; |
21028 | ············pm.Delete(l); |
21029 | ············pm.Save(); |
21030 | ············pm.UnloadCache(); |
21031 | ············decimal count; |
21032 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21033 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21034 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21035 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21036 | ········} |
21037 | ········catch (Exception) |
21038 | ········{ |
21039 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21040 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21041 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21042 | ········} |
21043 | ····} |
21044 | ····[Test] |
21045 | ····public void TestSaveReload() |
21046 | ····{ |
21047 | ········CreateObjects(); |
21048 | ········QueryOwn(); |
21049 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21050 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21051 | ····} |
21052 | ····[Test] |
21053 | ····public void TestSaveReloadNull() |
21054 | ····{ |
21055 | ········CreateObjects(); |
21056 | ········QueryOwn(); |
21057 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21058 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21059 | ········ownVar.RelField = new List<CmpDirnOwnpabsNoTblAutoRight>(); |
21060 | ········pm.Save(); |
21061 | ········pm.UnloadCache(); |
21062 | ········QueryOwn(); |
21063 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21064 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21065 | ····} |
21066 | ····[Test] |
21067 | ····public void TestSaveReloadRemove() |
21068 | ····{ |
21069 | ········CreateObjects(); |
21070 | ········QueryOwn(); |
21071 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21072 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21073 | ········ownVar.RemoveRelatedObject(); |
21074 | ········pm.Save(); |
21075 | ········pm.UnloadCache(); |
21076 | ········QueryOwn(); |
21077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21078 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21079 | ····} |
21080 | ····[Test] |
21081 | ····public void TestUpdateOrder() |
21082 | ····{ |
21083 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21084 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21085 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpabsNoTblAutoLeftDerived)})) |
21086 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpabsNoTblAutoRight)})), "Wrong order #2"); |
21087 | ········Debug.WriteLine("CmpDirnOwnpabsNoTblAutoLeftBase"); |
21088 | ····} |
21089 | ····void CreateObjects() |
21090 | ····{ |
21091 | ········pm.MakePersistent(ownVar); |
21092 | ········ownVar.AssignRelation(otherVar); |
21093 | ········pm.Save(); |
21094 | ········pm.UnloadCache(); |
21095 | ····} |
21096 | ····void QueryOwn() |
21097 | ····{ |
21098 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblAutoLeftBase>(pm); |
21099 | ········ownVar = q.ExecuteSingle(); |
21100 | ····} |
21101 | ····void QueryOther() |
21102 | ····{ |
21103 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblAutoRight>(pm); |
21104 | ········otherVar = q.ExecuteSingle(); |
21105 | ····} |
21106 | } |
21107 | |
21108 | |
21109 | [TestFixture] |
21110 | public class TestCmpDirnOwnpabsTblAuto : NDOTest |
21111 | { |
21112 | ····CmpDirnOwnpabsTblAutoLeftBase ownVar; |
21113 | ····CmpDirnOwnpabsTblAutoRight otherVar; |
21114 | ····PersistenceManager pm; |
21115 | ····[SetUp] |
21116 | ····public void Setup() |
21117 | ····{ |
21118 | ········pm = PmFactory.NewPersistenceManager(); |
21119 | ········ownVar = new CmpDirnOwnpabsTblAutoLeftDerived(); |
21120 | ········otherVar = new CmpDirnOwnpabsTblAutoRight(); |
21121 | ····} |
21122 | ····[TearDown] |
21123 | ····public void TearDown() |
21124 | ····{ |
21125 | ········try |
21126 | ········{ |
21127 | ············pm.UnloadCache(); |
21128 | ············var l = pm.Objects<CmpDirnOwnpabsTblAutoLeftBase>().ResultTable; |
21129 | ············pm.Delete(l); |
21130 | ············pm.Save(); |
21131 | ············pm.UnloadCache(); |
21132 | ············decimal count; |
21133 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21134 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21135 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21136 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21137 | ········} |
21138 | ········catch (Exception) |
21139 | ········{ |
21140 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21141 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21142 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21143 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21144 | ········} |
21145 | ····} |
21146 | ····[Test] |
21147 | ····public void TestSaveReload() |
21148 | ····{ |
21149 | ········CreateObjects(); |
21150 | ········QueryOwn(); |
21151 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21152 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21153 | ····} |
21154 | ····[Test] |
21155 | ····public void TestSaveReloadNull() |
21156 | ····{ |
21157 | ········CreateObjects(); |
21158 | ········QueryOwn(); |
21159 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21160 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21161 | ········ownVar.RelField = new List<CmpDirnOwnpabsTblAutoRight>(); |
21162 | ········pm.Save(); |
21163 | ········pm.UnloadCache(); |
21164 | ········QueryOwn(); |
21165 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21166 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21167 | ····} |
21168 | ····[Test] |
21169 | ····public void TestSaveReloadRemove() |
21170 | ····{ |
21171 | ········CreateObjects(); |
21172 | ········QueryOwn(); |
21173 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21174 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21175 | ········ownVar.RemoveRelatedObject(); |
21176 | ········pm.Save(); |
21177 | ········pm.UnloadCache(); |
21178 | ········QueryOwn(); |
21179 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21180 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21181 | ····} |
21182 | ····void CreateObjects() |
21183 | ····{ |
21184 | ········pm.MakePersistent(ownVar); |
21185 | ········ownVar.AssignRelation(otherVar); |
21186 | ········pm.Save(); |
21187 | ········pm.UnloadCache(); |
21188 | ····} |
21189 | ····void QueryOwn() |
21190 | ····{ |
21191 | ········var q = new NDOQuery<CmpDirnOwnpabsTblAutoLeftBase>(pm); |
21192 | ········ownVar = q.ExecuteSingle(); |
21193 | ····} |
21194 | ····void QueryOther() |
21195 | ····{ |
21196 | ········var q = new NDOQuery<CmpDirnOwnpabsTblAutoRight>(pm); |
21197 | ········otherVar = q.ExecuteSingle(); |
21198 | ····} |
21199 | } |
21200 | |
21201 | |
21202 | [TestFixture] |
21203 | public class TestCmpBin1OwnpabsNoTblAuto : NDOTest |
21204 | { |
21205 | ····CmpBin1OwnpabsNoTblAutoLeftBase ownVar; |
21206 | ····CmpBin1OwnpabsNoTblAutoRight otherVar; |
21207 | ····PersistenceManager pm; |
21208 | ····[SetUp] |
21209 | ····public void Setup() |
21210 | ····{ |
21211 | ········pm = PmFactory.NewPersistenceManager(); |
21212 | ········ownVar = new CmpBin1OwnpabsNoTblAutoLeftDerived(); |
21213 | ········otherVar = new CmpBin1OwnpabsNoTblAutoRight(); |
21214 | ····} |
21215 | ····[TearDown] |
21216 | ····public void TearDown() |
21217 | ····{ |
21218 | ········try |
21219 | ········{ |
21220 | ············pm.UnloadCache(); |
21221 | ············var l = pm.Objects<CmpBin1OwnpabsNoTblAutoLeftBase>().ResultTable; |
21222 | ············pm.Delete(l); |
21223 | ············pm.Save(); |
21224 | ············pm.UnloadCache(); |
21225 | ············decimal count; |
21226 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21227 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21228 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21229 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21230 | ········} |
21231 | ········catch (Exception) |
21232 | ········{ |
21233 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21234 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21235 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21236 | ········} |
21237 | ····} |
21238 | ····[Test] |
21239 | ····public void TestSaveReload() |
21240 | ····{ |
21241 | ········CreateObjects(); |
21242 | ········QueryOwn(); |
21243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21244 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21245 | ····} |
21246 | ····[Test] |
21247 | ····public void TestSaveReloadNull() |
21248 | ····{ |
21249 | ········CreateObjects(); |
21250 | ········QueryOwn(); |
21251 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21252 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21253 | ········ownVar.RelField = new List<CmpBin1OwnpabsNoTblAutoRight>(); |
21254 | ········pm.Save(); |
21255 | ········pm.UnloadCache(); |
21256 | ········QueryOwn(); |
21257 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21258 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21259 | ····} |
21260 | ····[Test] |
21261 | ····public void TestSaveReloadRemove() |
21262 | ····{ |
21263 | ········CreateObjects(); |
21264 | ········QueryOwn(); |
21265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21266 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21267 | ········ownVar.RemoveRelatedObject(); |
21268 | ········pm.Save(); |
21269 | ········pm.UnloadCache(); |
21270 | ········QueryOwn(); |
21271 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21272 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21273 | ····} |
21274 | ····[Test] |
21275 | ····public void TestChangeKeyHolderRight() |
21276 | ····{ |
21277 | ········CreateObjects(); |
21278 | ········QueryOther(); |
21279 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21280 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21281 | ········int x = otherVar.RelField.Dummy; |
21282 | ········otherVar.Dummy = 4711; |
21283 | ········pm.Save(); |
21284 | ········pm.UnloadCache(); |
21285 | ········QueryOther(); |
21286 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21287 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21288 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21289 | ····} |
21290 | ····[Test] |
21291 | ····public void TestChangeKeyHolderRightNoTouch() |
21292 | ····{ |
21293 | ········CreateObjects(); |
21294 | ········QueryOther(); |
21295 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21296 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21297 | ········otherVar.Dummy = 4711; |
21298 | ········pm.Save(); |
21299 | ········pm.UnloadCache(); |
21300 | ········QueryOther(); |
21301 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21302 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21303 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21304 | ····} |
21305 | ····[Test] |
21306 | ····public void TestUpdateOrder() |
21307 | ····{ |
21308 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21309 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21310 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpabsNoTblAutoLeftDerived)})) |
21311 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
21312 | ········Debug.WriteLine("CmpBin1OwnpabsNoTblAutoLeftBase"); |
21313 | ····} |
21314 | ····[Test] |
21315 | ····public void TestRelationHash() |
21316 | ····{ |
21317 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoLeftBase)); |
21318 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21319 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoRight)); |
21320 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21321 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21322 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21323 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoLeftDerived)); |
21324 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21325 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21326 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21327 | ····} |
21328 | ····void CreateObjects() |
21329 | ····{ |
21330 | ········pm.MakePersistent(ownVar); |
21331 | ········ownVar.AssignRelation(otherVar); |
21332 | ········pm.Save(); |
21333 | ········pm.UnloadCache(); |
21334 | ····} |
21335 | ····void QueryOwn() |
21336 | ····{ |
21337 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblAutoLeftBase>(pm); |
21338 | ········ownVar = q.ExecuteSingle(); |
21339 | ····} |
21340 | ····void QueryOther() |
21341 | ····{ |
21342 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblAutoRight>(pm); |
21343 | ········otherVar = q.ExecuteSingle(); |
21344 | ····} |
21345 | } |
21346 | |
21347 | |
21348 | [TestFixture] |
21349 | public class TestCmpBin1OwnpabsTblAuto : NDOTest |
21350 | { |
21351 | ····CmpBin1OwnpabsTblAutoLeftBase ownVar; |
21352 | ····CmpBin1OwnpabsTblAutoRight otherVar; |
21353 | ····PersistenceManager pm; |
21354 | ····[SetUp] |
21355 | ····public void Setup() |
21356 | ····{ |
21357 | ········pm = PmFactory.NewPersistenceManager(); |
21358 | ········ownVar = new CmpBin1OwnpabsTblAutoLeftDerived(); |
21359 | ········otherVar = new CmpBin1OwnpabsTblAutoRight(); |
21360 | ····} |
21361 | ····[TearDown] |
21362 | ····public void TearDown() |
21363 | ····{ |
21364 | ········try |
21365 | ········{ |
21366 | ············pm.UnloadCache(); |
21367 | ············var l = pm.Objects<CmpBin1OwnpabsTblAutoLeftBase>().ResultTable; |
21368 | ············pm.Delete(l); |
21369 | ············pm.Save(); |
21370 | ············pm.UnloadCache(); |
21371 | ············decimal count; |
21372 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21373 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21374 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21375 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21376 | ········} |
21377 | ········catch (Exception) |
21378 | ········{ |
21379 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21380 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21382 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21383 | ········} |
21384 | ····} |
21385 | ····[Test] |
21386 | ····public void TestSaveReload() |
21387 | ····{ |
21388 | ········CreateObjects(); |
21389 | ········QueryOwn(); |
21390 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21391 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21392 | ····} |
21393 | ····[Test] |
21394 | ····public void TestSaveReloadNull() |
21395 | ····{ |
21396 | ········CreateObjects(); |
21397 | ········QueryOwn(); |
21398 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21399 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21400 | ········ownVar.RelField = new List<CmpBin1OwnpabsTblAutoRight>(); |
21401 | ········pm.Save(); |
21402 | ········pm.UnloadCache(); |
21403 | ········QueryOwn(); |
21404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21405 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21406 | ····} |
21407 | ····[Test] |
21408 | ····public void TestSaveReloadRemove() |
21409 | ····{ |
21410 | ········CreateObjects(); |
21411 | ········QueryOwn(); |
21412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21413 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21414 | ········ownVar.RemoveRelatedObject(); |
21415 | ········pm.Save(); |
21416 | ········pm.UnloadCache(); |
21417 | ········QueryOwn(); |
21418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21419 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21420 | ····} |
21421 | ····[Test] |
21422 | ····public void TestChangeKeyHolderRight() |
21423 | ····{ |
21424 | ········CreateObjects(); |
21425 | ········QueryOther(); |
21426 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21427 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21428 | ········int x = otherVar.RelField.Dummy; |
21429 | ········otherVar.Dummy = 4711; |
21430 | ········pm.Save(); |
21431 | ········pm.UnloadCache(); |
21432 | ········QueryOther(); |
21433 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21434 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21435 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21436 | ····} |
21437 | ····[Test] |
21438 | ····public void TestChangeKeyHolderRightNoTouch() |
21439 | ····{ |
21440 | ········CreateObjects(); |
21441 | ········QueryOther(); |
21442 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21443 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21444 | ········otherVar.Dummy = 4711; |
21445 | ········pm.Save(); |
21446 | ········pm.UnloadCache(); |
21447 | ········QueryOther(); |
21448 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21449 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21450 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21451 | ····} |
21452 | ····[Test] |
21453 | ····public void TestRelationHash() |
21454 | ····{ |
21455 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoLeftBase)); |
21456 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21457 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoRight)); |
21458 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21459 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21460 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21461 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoLeftDerived)); |
21462 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21463 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21464 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21465 | ····} |
21466 | ····void CreateObjects() |
21467 | ····{ |
21468 | ········pm.MakePersistent(ownVar); |
21469 | ········ownVar.AssignRelation(otherVar); |
21470 | ········pm.Save(); |
21471 | ········pm.UnloadCache(); |
21472 | ····} |
21473 | ····void QueryOwn() |
21474 | ····{ |
21475 | ········var q = new NDOQuery<CmpBin1OwnpabsTblAutoLeftBase>(pm); |
21476 | ········ownVar = q.ExecuteSingle(); |
21477 | ····} |
21478 | ····void QueryOther() |
21479 | ····{ |
21480 | ········var q = new NDOQuery<CmpBin1OwnpabsTblAutoRight>(pm); |
21481 | ········otherVar = q.ExecuteSingle(); |
21482 | ····} |
21483 | } |
21484 | |
21485 | |
21486 | [TestFixture] |
21487 | public class TestCmpBi1nOwnpabsTblAuto : NDOTest |
21488 | { |
21489 | ····CmpBi1nOwnpabsTblAutoLeftBase ownVar; |
21490 | ····CmpBi1nOwnpabsTblAutoRight otherVar; |
21491 | ····PersistenceManager pm; |
21492 | ····[SetUp] |
21493 | ····public void Setup() |
21494 | ····{ |
21495 | ········pm = PmFactory.NewPersistenceManager(); |
21496 | ········ownVar = new CmpBi1nOwnpabsTblAutoLeftDerived(); |
21497 | ········otherVar = new CmpBi1nOwnpabsTblAutoRight(); |
21498 | ····} |
21499 | ····[TearDown] |
21500 | ····public void TearDown() |
21501 | ····{ |
21502 | ········try |
21503 | ········{ |
21504 | ············pm.UnloadCache(); |
21505 | ············var l = pm.Objects<CmpBi1nOwnpabsTblAutoLeftBase>().ResultTable; |
21506 | ············pm.Delete(l); |
21507 | ············pm.Save(); |
21508 | ············pm.UnloadCache(); |
21509 | ············decimal count; |
21510 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21511 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21512 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21513 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21514 | ········} |
21515 | ········catch (Exception) |
21516 | ········{ |
21517 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21518 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21519 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21520 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21521 | ········} |
21522 | ····} |
21523 | ····[Test] |
21524 | ····public void TestSaveReload() |
21525 | ····{ |
21526 | ········CreateObjects(); |
21527 | ········QueryOwn(); |
21528 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21529 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21530 | ····} |
21531 | ····[Test] |
21532 | ····public void TestSaveReloadNull() |
21533 | ····{ |
21534 | ········CreateObjects(); |
21535 | ········QueryOwn(); |
21536 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21537 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21538 | ········ownVar.RelField = null; |
21539 | ········pm.Save(); |
21540 | ········pm.UnloadCache(); |
21541 | ········QueryOwn(); |
21542 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21543 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21544 | ····} |
21545 | ····[Test] |
21546 | ····public void TestChangeKeyHolderLeft() |
21547 | ····{ |
21548 | ········CreateObjects(); |
21549 | ········QueryOwn(); |
21550 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21551 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21552 | ········int x = ownVar.RelField.Dummy; |
21553 | ········ownVar.Dummy = 4711; |
21554 | ········pm.Save(); |
21555 | ········pm.UnloadCache(); |
21556 | ········QueryOwn(); |
21557 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21558 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21559 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21560 | ····} |
21561 | ····[Test] |
21562 | ····public void TestChangeKeyHolderLeftNoTouch() |
21563 | ····{ |
21564 | ········CreateObjects(); |
21565 | ········QueryOwn(); |
21566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21567 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21568 | ········ownVar.Dummy = 4711; |
21569 | ········pm.Save(); |
21570 | ········pm.UnloadCache(); |
21571 | ········QueryOwn(); |
21572 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21573 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21574 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21575 | ····} |
21576 | ····[Test] |
21577 | ····public void TestRelationHash() |
21578 | ····{ |
21579 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoLeftBase)); |
21580 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21581 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoRight)); |
21582 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21583 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21584 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21585 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoLeftDerived)); |
21586 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21587 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21588 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21589 | ····} |
21590 | ····void CreateObjects() |
21591 | ····{ |
21592 | ········pm.MakePersistent(ownVar); |
21593 | ········ownVar.AssignRelation(otherVar); |
21594 | ········pm.Save(); |
21595 | ········pm.UnloadCache(); |
21596 | ····} |
21597 | ····void QueryOwn() |
21598 | ····{ |
21599 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblAutoLeftBase>(pm); |
21600 | ········ownVar = q.ExecuteSingle(); |
21601 | ····} |
21602 | ····void QueryOther() |
21603 | ····{ |
21604 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblAutoRight>(pm); |
21605 | ········otherVar = q.ExecuteSingle(); |
21606 | ····} |
21607 | } |
21608 | |
21609 | |
21610 | [TestFixture] |
21611 | public class TestCmpBinnOwnpabsTblAuto : NDOTest |
21612 | { |
21613 | ····CmpBinnOwnpabsTblAutoLeftBase ownVar; |
21614 | ····CmpBinnOwnpabsTblAutoRight otherVar; |
21615 | ····PersistenceManager pm; |
21616 | ····[SetUp] |
21617 | ····public void Setup() |
21618 | ····{ |
21619 | ········pm = PmFactory.NewPersistenceManager(); |
21620 | ········ownVar = new CmpBinnOwnpabsTblAutoLeftDerived(); |
21621 | ········otherVar = new CmpBinnOwnpabsTblAutoRight(); |
21622 | ····} |
21623 | ····[TearDown] |
21624 | ····public void TearDown() |
21625 | ····{ |
21626 | ········try |
21627 | ········{ |
21628 | ············pm.UnloadCache(); |
21629 | ············var l = pm.Objects<CmpBinnOwnpabsTblAutoLeftBase>().ResultTable; |
21630 | ············pm.Delete(l); |
21631 | ············pm.Save(); |
21632 | ············pm.UnloadCache(); |
21633 | ············decimal count; |
21634 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21636 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21637 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21638 | ········} |
21639 | ········catch (Exception) |
21640 | ········{ |
21641 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21642 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21644 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21645 | ········} |
21646 | ····} |
21647 | ····[Test] |
21648 | ····public void TestSaveReload() |
21649 | ····{ |
21650 | ········CreateObjects(); |
21651 | ········QueryOwn(); |
21652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21653 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21654 | ····} |
21655 | ····[Test] |
21656 | ····public void TestSaveReloadNull() |
21657 | ····{ |
21658 | ········CreateObjects(); |
21659 | ········QueryOwn(); |
21660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21661 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21662 | ········ownVar.RelField = new List<CmpBinnOwnpabsTblAutoRight>(); |
21663 | ········pm.Save(); |
21664 | ········pm.UnloadCache(); |
21665 | ········QueryOwn(); |
21666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21667 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21668 | ····} |
21669 | ····[Test] |
21670 | ····public void TestSaveReloadRemove() |
21671 | ····{ |
21672 | ········CreateObjects(); |
21673 | ········QueryOwn(); |
21674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21675 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21676 | ········ownVar.RemoveRelatedObject(); |
21677 | ········pm.Save(); |
21678 | ········pm.UnloadCache(); |
21679 | ········QueryOwn(); |
21680 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21681 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21682 | ····} |
21683 | ····[Test] |
21684 | ····public void TestRelationHash() |
21685 | ····{ |
21686 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoLeftBase)); |
21687 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21688 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoRight)); |
21689 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21690 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21691 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21692 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoLeftDerived)); |
21693 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21694 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21695 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21696 | ····} |
21697 | ····void CreateObjects() |
21698 | ····{ |
21699 | ········pm.MakePersistent(ownVar); |
21700 | ········ownVar.AssignRelation(otherVar); |
21701 | ········pm.Save(); |
21702 | ········pm.UnloadCache(); |
21703 | ····} |
21704 | ····void QueryOwn() |
21705 | ····{ |
21706 | ········var q = new NDOQuery<CmpBinnOwnpabsTblAutoLeftBase>(pm); |
21707 | ········ownVar = q.ExecuteSingle(); |
21708 | ····} |
21709 | ····void QueryOther() |
21710 | ····{ |
21711 | ········var q = new NDOQuery<CmpBinnOwnpabsTblAutoRight>(pm); |
21712 | ········otherVar = q.ExecuteSingle(); |
21713 | ····} |
21714 | } |
21715 | |
21716 | |
21717 | [TestFixture] |
21718 | public class TestAgrDir1OthpabsNoTblAuto : NDOTest |
21719 | { |
21720 | ····AgrDir1OthpabsNoTblAutoLeft ownVar; |
21721 | ····AgrDir1OthpabsNoTblAutoRightBase otherVar; |
21722 | ····PersistenceManager pm; |
21723 | ····[SetUp] |
21724 | ····public void Setup() |
21725 | ····{ |
21726 | ········pm = PmFactory.NewPersistenceManager(); |
21727 | ········ownVar = new AgrDir1OthpabsNoTblAutoLeft(); |
21728 | ········otherVar = new AgrDir1OthpabsNoTblAutoRightDerived(); |
21729 | ····} |
21730 | ····[TearDown] |
21731 | ····public void TearDown() |
21732 | ····{ |
21733 | ········try |
21734 | ········{ |
21735 | ············pm.UnloadCache(); |
21736 | ············var l = pm.Objects<AgrDir1OthpabsNoTblAutoLeft>().ResultTable; |
21737 | ············pm.Delete(l); |
21738 | ············pm.Save(); |
21739 | ············pm.UnloadCache(); |
21740 | ············var m = pm.Objects<AgrDir1OthpabsNoTblAutoRightBase>().ResultTable; |
21741 | ············pm.Delete(m); |
21742 | ············pm.Save(); |
21743 | ············pm.UnloadCache(); |
21744 | ············decimal count; |
21745 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21746 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21747 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21748 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21749 | ········} |
21750 | ········catch (Exception) |
21751 | ········{ |
21752 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21753 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21755 | ········} |
21756 | ····} |
21757 | ····[Test] |
21758 | ····public void TestSaveReload() |
21759 | ····{ |
21760 | ········CreateObjects(); |
21761 | ········QueryOwn(); |
21762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21763 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21764 | ····} |
21765 | ····[Test] |
21766 | ····public void TestSaveReloadNull() |
21767 | ····{ |
21768 | ········CreateObjects(); |
21769 | ········QueryOwn(); |
21770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21771 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21772 | ········ownVar.RelField = null; |
21773 | ········pm.Save(); |
21774 | ········pm.UnloadCache(); |
21775 | ········QueryOwn(); |
21776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21777 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21778 | ····} |
21779 | ····[Test] |
21780 | ····public void TestChangeKeyHolderLeft() |
21781 | ····{ |
21782 | ········CreateObjects(); |
21783 | ········QueryOwn(); |
21784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21785 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21786 | ········int x = ownVar.RelField.Dummy; |
21787 | ········ownVar.Dummy = 4711; |
21788 | ········pm.Save(); |
21789 | ········pm.UnloadCache(); |
21790 | ········QueryOwn(); |
21791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21792 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21793 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21794 | ····} |
21795 | ····[Test] |
21796 | ····public void TestChangeKeyHolderLeftNoTouch() |
21797 | ····{ |
21798 | ········CreateObjects(); |
21799 | ········QueryOwn(); |
21800 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21801 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21802 | ········ownVar.Dummy = 4711; |
21803 | ········pm.Save(); |
21804 | ········pm.UnloadCache(); |
21805 | ········QueryOwn(); |
21806 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21807 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21809 | ····} |
21810 | ····[Test] |
21811 | ····public void TestUpdateOrder() |
21812 | ····{ |
21813 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21814 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21815 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpabsNoTblAutoLeft)})) |
21816 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
21817 | ········Debug.WriteLine("AgrDir1OthpabsNoTblAutoLeft"); |
21818 | ····} |
21819 | ····void CreateObjects() |
21820 | ····{ |
21821 | ········pm.MakePersistent(ownVar); |
21822 | ········pm.Save(); |
21823 | ········pm.MakePersistent(otherVar); |
21824 | ········pm.Save(); |
21825 | ········ownVar.AssignRelation(otherVar); |
21826 | ········pm.Save(); |
21827 | ········pm.UnloadCache(); |
21828 | ····} |
21829 | ····void QueryOwn() |
21830 | ····{ |
21831 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblAutoLeft>(pm); |
21832 | ········ownVar = q.ExecuteSingle(); |
21833 | ····} |
21834 | ····void QueryOther() |
21835 | ····{ |
21836 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblAutoRightBase>(pm); |
21837 | ········otherVar = q.ExecuteSingle(); |
21838 | ····} |
21839 | } |
21840 | |
21841 | |
21842 | [TestFixture] |
21843 | public class TestAgrDir1OthpabsTblAuto : NDOTest |
21844 | { |
21845 | ····AgrDir1OthpabsTblAutoLeft ownVar; |
21846 | ····AgrDir1OthpabsTblAutoRightBase otherVar; |
21847 | ····PersistenceManager pm; |
21848 | ····[SetUp] |
21849 | ····public void Setup() |
21850 | ····{ |
21851 | ········pm = PmFactory.NewPersistenceManager(); |
21852 | ········ownVar = new AgrDir1OthpabsTblAutoLeft(); |
21853 | ········otherVar = new AgrDir1OthpabsTblAutoRightDerived(); |
21854 | ····} |
21855 | ····[TearDown] |
21856 | ····public void TearDown() |
21857 | ····{ |
21858 | ········try |
21859 | ········{ |
21860 | ············pm.UnloadCache(); |
21861 | ············var l = pm.Objects<AgrDir1OthpabsTblAutoLeft>().ResultTable; |
21862 | ············pm.Delete(l); |
21863 | ············pm.Save(); |
21864 | ············pm.UnloadCache(); |
21865 | ············var m = pm.Objects<AgrDir1OthpabsTblAutoRightBase>().ResultTable; |
21866 | ············pm.Delete(m); |
21867 | ············pm.Save(); |
21868 | ············pm.UnloadCache(); |
21869 | ············decimal count; |
21870 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21871 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21872 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21873 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21874 | ········} |
21875 | ········catch (Exception) |
21876 | ········{ |
21877 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21878 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21879 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21880 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21881 | ········} |
21882 | ····} |
21883 | ····[Test] |
21884 | ····public void TestSaveReload() |
21885 | ····{ |
21886 | ········CreateObjects(); |
21887 | ········QueryOwn(); |
21888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21889 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21890 | ····} |
21891 | ····[Test] |
21892 | ····public void TestSaveReloadNull() |
21893 | ····{ |
21894 | ········CreateObjects(); |
21895 | ········QueryOwn(); |
21896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21897 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21898 | ········ownVar.RelField = null; |
21899 | ········pm.Save(); |
21900 | ········pm.UnloadCache(); |
21901 | ········QueryOwn(); |
21902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21903 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21904 | ····} |
21905 | ····[Test] |
21906 | ····public void TestChangeKeyHolderLeft() |
21907 | ····{ |
21908 | ········CreateObjects(); |
21909 | ········QueryOwn(); |
21910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21911 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21912 | ········int x = ownVar.RelField.Dummy; |
21913 | ········ownVar.Dummy = 4711; |
21914 | ········pm.Save(); |
21915 | ········pm.UnloadCache(); |
21916 | ········QueryOwn(); |
21917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21918 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21919 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21920 | ····} |
21921 | ····[Test] |
21922 | ····public void TestChangeKeyHolderLeftNoTouch() |
21923 | ····{ |
21924 | ········CreateObjects(); |
21925 | ········QueryOwn(); |
21926 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21927 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21928 | ········ownVar.Dummy = 4711; |
21929 | ········pm.Save(); |
21930 | ········pm.UnloadCache(); |
21931 | ········QueryOwn(); |
21932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21933 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21934 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21935 | ····} |
21936 | ····void CreateObjects() |
21937 | ····{ |
21938 | ········pm.MakePersistent(ownVar); |
21939 | ········pm.MakePersistent(otherVar); |
21940 | ········ownVar.AssignRelation(otherVar); |
21941 | ········pm.Save(); |
21942 | ········pm.UnloadCache(); |
21943 | ····} |
21944 | ····void QueryOwn() |
21945 | ····{ |
21946 | ········var q = new NDOQuery<AgrDir1OthpabsTblAutoLeft>(pm); |
21947 | ········ownVar = q.ExecuteSingle(); |
21948 | ····} |
21949 | ····void QueryOther() |
21950 | ····{ |
21951 | ········var q = new NDOQuery<AgrDir1OthpabsTblAutoRightBase>(pm); |
21952 | ········otherVar = q.ExecuteSingle(); |
21953 | ····} |
21954 | } |
21955 | |
21956 | |
21957 | [TestFixture] |
21958 | public class TestAgrBi11OthpabsNoTblAuto : NDOTest |
21959 | { |
21960 | ····AgrBi11OthpabsNoTblAutoLeft ownVar; |
21961 | ····AgrBi11OthpabsNoTblAutoRightBase otherVar; |
21962 | ····PersistenceManager pm; |
21963 | ····[SetUp] |
21964 | ····public void Setup() |
21965 | ····{ |
21966 | ········pm = PmFactory.NewPersistenceManager(); |
21967 | ········ownVar = new AgrBi11OthpabsNoTblAutoLeft(); |
21968 | ········otherVar = new AgrBi11OthpabsNoTblAutoRightDerived(); |
21969 | ····} |
21970 | ····[TearDown] |
21971 | ····public void TearDown() |
21972 | ····{ |
21973 | ········try |
21974 | ········{ |
21975 | ············pm.UnloadCache(); |
21976 | ············var l = pm.Objects<AgrBi11OthpabsNoTblAutoLeft>().ResultTable; |
21977 | ············pm.Delete(l); |
21978 | ············pm.Save(); |
21979 | ············pm.UnloadCache(); |
21980 | ············var m = pm.Objects<AgrBi11OthpabsNoTblAutoRightBase>().ResultTable; |
21981 | ············pm.Delete(m); |
21982 | ············pm.Save(); |
21983 | ············pm.UnloadCache(); |
21984 | ············decimal count; |
21985 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21986 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21987 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21988 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21989 | ········} |
21990 | ········catch (Exception) |
21991 | ········{ |
21992 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21993 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21994 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21995 | ········} |
21996 | ····} |
21997 | ····[Test] |
21998 | ····public void TestSaveReload() |
21999 | ····{ |
22000 | ········CreateObjects(); |
22001 | ········QueryOwn(); |
22002 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22003 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22004 | ····} |
22005 | ····[Test] |
22006 | ····public void TestSaveReloadNull() |
22007 | ····{ |
22008 | ········CreateObjects(); |
22009 | ········QueryOwn(); |
22010 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22011 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22012 | ········ownVar.RelField = null; |
22013 | ········pm.Save(); |
22014 | ········pm.UnloadCache(); |
22015 | ········QueryOwn(); |
22016 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22017 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22018 | ····} |
22019 | ····[Test] |
22020 | ····public void TestChangeKeyHolderLeft() |
22021 | ····{ |
22022 | ········CreateObjects(); |
22023 | ········QueryOwn(); |
22024 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22025 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22026 | ········int x = ownVar.RelField.Dummy; |
22027 | ········ownVar.Dummy = 4711; |
22028 | ········pm.Save(); |
22029 | ········pm.UnloadCache(); |
22030 | ········QueryOwn(); |
22031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22032 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22033 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22034 | ····} |
22035 | ····[Test] |
22036 | ····public void TestChangeKeyHolderRight() |
22037 | ····{ |
22038 | ········CreateObjects(); |
22039 | ········QueryOther(); |
22040 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22041 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22042 | ········int x = otherVar.RelField.Dummy; |
22043 | ········otherVar.Dummy = 4711; |
22044 | ········pm.Save(); |
22045 | ········pm.UnloadCache(); |
22046 | ········QueryOther(); |
22047 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22048 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22049 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22050 | ····} |
22051 | ····[Test] |
22052 | ····public void TestChangeKeyHolderLeftNoTouch() |
22053 | ····{ |
22054 | ········CreateObjects(); |
22055 | ········QueryOwn(); |
22056 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22057 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22058 | ········ownVar.Dummy = 4711; |
22059 | ········pm.Save(); |
22060 | ········pm.UnloadCache(); |
22061 | ········QueryOwn(); |
22062 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22063 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22064 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22065 | ····} |
22066 | ····[Test] |
22067 | ····public void TestChangeKeyHolderRightNoTouch() |
22068 | ····{ |
22069 | ········CreateObjects(); |
22070 | ········QueryOther(); |
22071 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22072 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22073 | ········otherVar.Dummy = 4711; |
22074 | ········pm.Save(); |
22075 | ········pm.UnloadCache(); |
22076 | ········QueryOther(); |
22077 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22078 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22079 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22080 | ····} |
22081 | ····[Test] |
22082 | ····public void TestRelationHash() |
22083 | ····{ |
22084 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoLeft)); |
22085 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22086 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoRightBase)); |
22087 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22088 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22089 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22090 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoRightDerived)); |
22091 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22092 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22093 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22094 | ····} |
22095 | ····void CreateObjects() |
22096 | ····{ |
22097 | ········pm.MakePersistent(ownVar); |
22098 | ········pm.Save(); |
22099 | ········pm.MakePersistent(otherVar); |
22100 | ········pm.Save(); |
22101 | ········ownVar.AssignRelation(otherVar); |
22102 | ········pm.Save(); |
22103 | ········pm.UnloadCache(); |
22104 | ····} |
22105 | ····void QueryOwn() |
22106 | ····{ |
22107 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblAutoLeft>(pm); |
22108 | ········ownVar = q.ExecuteSingle(); |
22109 | ····} |
22110 | ····void QueryOther() |
22111 | ····{ |
22112 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblAutoRightBase>(pm); |
22113 | ········otherVar = q.ExecuteSingle(); |
22114 | ····} |
22115 | } |
22116 | |
22117 | |
22118 | [TestFixture] |
22119 | public class TestAgrBi11OthpabsTblAuto : NDOTest |
22120 | { |
22121 | ····AgrBi11OthpabsTblAutoLeft ownVar; |
22122 | ····AgrBi11OthpabsTblAutoRightBase otherVar; |
22123 | ····PersistenceManager pm; |
22124 | ····[SetUp] |
22125 | ····public void Setup() |
22126 | ····{ |
22127 | ········pm = PmFactory.NewPersistenceManager(); |
22128 | ········ownVar = new AgrBi11OthpabsTblAutoLeft(); |
22129 | ········otherVar = new AgrBi11OthpabsTblAutoRightDerived(); |
22130 | ····} |
22131 | ····[TearDown] |
22132 | ····public void TearDown() |
22133 | ····{ |
22134 | ········try |
22135 | ········{ |
22136 | ············pm.UnloadCache(); |
22137 | ············var l = pm.Objects<AgrBi11OthpabsTblAutoLeft>().ResultTable; |
22138 | ············pm.Delete(l); |
22139 | ············pm.Save(); |
22140 | ············pm.UnloadCache(); |
22141 | ············var m = pm.Objects<AgrBi11OthpabsTblAutoRightBase>().ResultTable; |
22142 | ············pm.Delete(m); |
22143 | ············pm.Save(); |
22144 | ············pm.UnloadCache(); |
22145 | ············decimal count; |
22146 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22147 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22148 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22150 | ········} |
22151 | ········catch (Exception) |
22152 | ········{ |
22153 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22154 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22155 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22156 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22157 | ········} |
22158 | ····} |
22159 | ····[Test] |
22160 | ····public void TestSaveReload() |
22161 | ····{ |
22162 | ········CreateObjects(); |
22163 | ········QueryOwn(); |
22164 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22165 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22166 | ····} |
22167 | ····[Test] |
22168 | ····public void TestSaveReloadNull() |
22169 | ····{ |
22170 | ········CreateObjects(); |
22171 | ········QueryOwn(); |
22172 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22174 | ········ownVar.RelField = null; |
22175 | ········pm.Save(); |
22176 | ········pm.UnloadCache(); |
22177 | ········QueryOwn(); |
22178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22179 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22180 | ····} |
22181 | ····[Test] |
22182 | ····public void TestChangeKeyHolderLeft() |
22183 | ····{ |
22184 | ········CreateObjects(); |
22185 | ········QueryOwn(); |
22186 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22187 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22188 | ········int x = ownVar.RelField.Dummy; |
22189 | ········ownVar.Dummy = 4711; |
22190 | ········pm.Save(); |
22191 | ········pm.UnloadCache(); |
22192 | ········QueryOwn(); |
22193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22194 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22195 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22196 | ····} |
22197 | ····[Test] |
22198 | ····public void TestChangeKeyHolderRight() |
22199 | ····{ |
22200 | ········CreateObjects(); |
22201 | ········QueryOther(); |
22202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22204 | ········int x = otherVar.RelField.Dummy; |
22205 | ········otherVar.Dummy = 4711; |
22206 | ········pm.Save(); |
22207 | ········pm.UnloadCache(); |
22208 | ········QueryOther(); |
22209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22212 | ····} |
22213 | ····[Test] |
22214 | ····public void TestChangeKeyHolderLeftNoTouch() |
22215 | ····{ |
22216 | ········CreateObjects(); |
22217 | ········QueryOwn(); |
22218 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22219 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22220 | ········ownVar.Dummy = 4711; |
22221 | ········pm.Save(); |
22222 | ········pm.UnloadCache(); |
22223 | ········QueryOwn(); |
22224 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22225 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22226 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22227 | ····} |
22228 | ····[Test] |
22229 | ····public void TestChangeKeyHolderRightNoTouch() |
22230 | ····{ |
22231 | ········CreateObjects(); |
22232 | ········QueryOther(); |
22233 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22234 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22235 | ········otherVar.Dummy = 4711; |
22236 | ········pm.Save(); |
22237 | ········pm.UnloadCache(); |
22238 | ········QueryOther(); |
22239 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22240 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22241 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22242 | ····} |
22243 | ····[Test] |
22244 | ····public void TestRelationHash() |
22245 | ····{ |
22246 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoLeft)); |
22247 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22248 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoRightBase)); |
22249 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22250 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22251 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22252 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoRightDerived)); |
22253 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22254 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22255 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22256 | ····} |
22257 | ····void CreateObjects() |
22258 | ····{ |
22259 | ········pm.MakePersistent(ownVar); |
22260 | ········pm.MakePersistent(otherVar); |
22261 | ········ownVar.AssignRelation(otherVar); |
22262 | ········pm.Save(); |
22263 | ········pm.UnloadCache(); |
22264 | ····} |
22265 | ····void QueryOwn() |
22266 | ····{ |
22267 | ········var q = new NDOQuery<AgrBi11OthpabsTblAutoLeft>(pm); |
22268 | ········ownVar = q.ExecuteSingle(); |
22269 | ····} |
22270 | ····void QueryOther() |
22271 | ····{ |
22272 | ········var q = new NDOQuery<AgrBi11OthpabsTblAutoRightBase>(pm); |
22273 | ········otherVar = q.ExecuteSingle(); |
22274 | ····} |
22275 | } |
22276 | |
22277 | |
22278 | [TestFixture] |
22279 | public class TestAgrDirnOthpabsTblAuto : NDOTest |
22280 | { |
22281 | ····AgrDirnOthpabsTblAutoLeft ownVar; |
22282 | ····AgrDirnOthpabsTblAutoRightBase otherVar; |
22283 | ····PersistenceManager pm; |
22284 | ····[SetUp] |
22285 | ····public void Setup() |
22286 | ····{ |
22287 | ········pm = PmFactory.NewPersistenceManager(); |
22288 | ········ownVar = new AgrDirnOthpabsTblAutoLeft(); |
22289 | ········otherVar = new AgrDirnOthpabsTblAutoRightDerived(); |
22290 | ····} |
22291 | ····[TearDown] |
22292 | ····public void TearDown() |
22293 | ····{ |
22294 | ········try |
22295 | ········{ |
22296 | ············pm.UnloadCache(); |
22297 | ············var l = pm.Objects<AgrDirnOthpabsTblAutoLeft>().ResultTable; |
22298 | ············pm.Delete(l); |
22299 | ············pm.Save(); |
22300 | ············pm.UnloadCache(); |
22301 | ············var m = pm.Objects<AgrDirnOthpabsTblAutoRightBase>().ResultTable; |
22302 | ············pm.Delete(m); |
22303 | ············pm.Save(); |
22304 | ············pm.UnloadCache(); |
22305 | ············decimal count; |
22306 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22307 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22308 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22309 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22310 | ········} |
22311 | ········catch (Exception) |
22312 | ········{ |
22313 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22314 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22315 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22316 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22317 | ········} |
22318 | ····} |
22319 | ····[Test] |
22320 | ····public void TestSaveReload() |
22321 | ····{ |
22322 | ········CreateObjects(); |
22323 | ········QueryOwn(); |
22324 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22325 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22326 | ····} |
22327 | ····[Test] |
22328 | ····public void TestSaveReloadNull() |
22329 | ····{ |
22330 | ········CreateObjects(); |
22331 | ········QueryOwn(); |
22332 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22333 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22334 | ········ownVar.RelField = new List<AgrDirnOthpabsTblAutoRightBase>(); |
22335 | ········pm.Save(); |
22336 | ········pm.UnloadCache(); |
22337 | ········QueryOwn(); |
22338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22339 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22340 | ····} |
22341 | ····[Test] |
22342 | ····public void TestSaveReloadRemove() |
22343 | ····{ |
22344 | ········CreateObjects(); |
22345 | ········QueryOwn(); |
22346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22347 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22348 | ········ownVar.RemoveRelatedObject(); |
22349 | ········pm.Save(); |
22350 | ········pm.UnloadCache(); |
22351 | ········QueryOwn(); |
22352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22353 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22354 | ····} |
22355 | ····void CreateObjects() |
22356 | ····{ |
22357 | ········pm.MakePersistent(ownVar); |
22358 | ········pm.MakePersistent(otherVar); |
22359 | ········ownVar.AssignRelation(otherVar); |
22360 | ········pm.Save(); |
22361 | ········pm.UnloadCache(); |
22362 | ····} |
22363 | ····void QueryOwn() |
22364 | ····{ |
22365 | ········var q = new NDOQuery<AgrDirnOthpabsTblAutoLeft>(pm); |
22366 | ········ownVar = q.ExecuteSingle(); |
22367 | ····} |
22368 | ····void QueryOther() |
22369 | ····{ |
22370 | ········var q = new NDOQuery<AgrDirnOthpabsTblAutoRightBase>(pm); |
22371 | ········otherVar = q.ExecuteSingle(); |
22372 | ····} |
22373 | } |
22374 | |
22375 | |
22376 | [TestFixture] |
22377 | public class TestAgrBin1OthpabsTblAuto : NDOTest |
22378 | { |
22379 | ····AgrBin1OthpabsTblAutoLeft ownVar; |
22380 | ····AgrBin1OthpabsTblAutoRightBase otherVar; |
22381 | ····PersistenceManager pm; |
22382 | ····[SetUp] |
22383 | ····public void Setup() |
22384 | ····{ |
22385 | ········pm = PmFactory.NewPersistenceManager(); |
22386 | ········ownVar = new AgrBin1OthpabsTblAutoLeft(); |
22387 | ········otherVar = new AgrBin1OthpabsTblAutoRightDerived(); |
22388 | ····} |
22389 | ····[TearDown] |
22390 | ····public void TearDown() |
22391 | ····{ |
22392 | ········try |
22393 | ········{ |
22394 | ············pm.UnloadCache(); |
22395 | ············var l = pm.Objects<AgrBin1OthpabsTblAutoLeft>().ResultTable; |
22396 | ············pm.Delete(l); |
22397 | ············pm.Save(); |
22398 | ············pm.UnloadCache(); |
22399 | ············var m = pm.Objects<AgrBin1OthpabsTblAutoRightBase>().ResultTable; |
22400 | ············pm.Delete(m); |
22401 | ············pm.Save(); |
22402 | ············pm.UnloadCache(); |
22403 | ············decimal count; |
22404 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22405 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22406 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22407 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22408 | ········} |
22409 | ········catch (Exception) |
22410 | ········{ |
22411 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22412 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22413 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22414 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22415 | ········} |
22416 | ····} |
22417 | ····[Test] |
22418 | ····public void TestSaveReload() |
22419 | ····{ |
22420 | ········CreateObjects(); |
22421 | ········QueryOwn(); |
22422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22424 | ····} |
22425 | ····[Test] |
22426 | ····public void TestSaveReloadNull() |
22427 | ····{ |
22428 | ········CreateObjects(); |
22429 | ········QueryOwn(); |
22430 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22431 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22432 | ········ownVar.RelField = new List<AgrBin1OthpabsTblAutoRightBase>(); |
22433 | ········pm.Save(); |
22434 | ········pm.UnloadCache(); |
22435 | ········QueryOwn(); |
22436 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22437 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22438 | ····} |
22439 | ····[Test] |
22440 | ····public void TestSaveReloadRemove() |
22441 | ····{ |
22442 | ········CreateObjects(); |
22443 | ········QueryOwn(); |
22444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22445 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22446 | ········ownVar.RemoveRelatedObject(); |
22447 | ········pm.Save(); |
22448 | ········pm.UnloadCache(); |
22449 | ········QueryOwn(); |
22450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22451 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22452 | ····} |
22453 | ····[Test] |
22454 | ····public void TestChangeKeyHolderRight() |
22455 | ····{ |
22456 | ········CreateObjects(); |
22457 | ········QueryOther(); |
22458 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22459 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22460 | ········int x = otherVar.RelField.Dummy; |
22461 | ········otherVar.Dummy = 4711; |
22462 | ········pm.Save(); |
22463 | ········pm.UnloadCache(); |
22464 | ········QueryOther(); |
22465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22468 | ····} |
22469 | ····[Test] |
22470 | ····public void TestChangeKeyHolderRightNoTouch() |
22471 | ····{ |
22472 | ········CreateObjects(); |
22473 | ········QueryOther(); |
22474 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22475 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22476 | ········otherVar.Dummy = 4711; |
22477 | ········pm.Save(); |
22478 | ········pm.UnloadCache(); |
22479 | ········QueryOther(); |
22480 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22481 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22482 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22483 | ····} |
22484 | ····[Test] |
22485 | ····public void TestRelationHash() |
22486 | ····{ |
22487 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoLeft)); |
22488 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22489 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoRightBase)); |
22490 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22491 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22492 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22493 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoRightDerived)); |
22494 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22495 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22496 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22497 | ····} |
22498 | ····void CreateObjects() |
22499 | ····{ |
22500 | ········pm.MakePersistent(ownVar); |
22501 | ········pm.MakePersistent(otherVar); |
22502 | ········ownVar.AssignRelation(otherVar); |
22503 | ········pm.Save(); |
22504 | ········pm.UnloadCache(); |
22505 | ····} |
22506 | ····void QueryOwn() |
22507 | ····{ |
22508 | ········var q = new NDOQuery<AgrBin1OthpabsTblAutoLeft>(pm); |
22509 | ········ownVar = q.ExecuteSingle(); |
22510 | ····} |
22511 | ····void QueryOther() |
22512 | ····{ |
22513 | ········var q = new NDOQuery<AgrBin1OthpabsTblAutoRightBase>(pm); |
22514 | ········otherVar = q.ExecuteSingle(); |
22515 | ····} |
22516 | } |
22517 | |
22518 | |
22519 | [TestFixture] |
22520 | public class TestAgrBi1nOthpabsNoTblAuto : NDOTest |
22521 | { |
22522 | ····AgrBi1nOthpabsNoTblAutoLeft ownVar; |
22523 | ····AgrBi1nOthpabsNoTblAutoRightBase otherVar; |
22524 | ····PersistenceManager pm; |
22525 | ····[SetUp] |
22526 | ····public void Setup() |
22527 | ····{ |
22528 | ········pm = PmFactory.NewPersistenceManager(); |
22529 | ········ownVar = new AgrBi1nOthpabsNoTblAutoLeft(); |
22530 | ········otherVar = new AgrBi1nOthpabsNoTblAutoRightDerived(); |
22531 | ····} |
22532 | ····[TearDown] |
22533 | ····public void TearDown() |
22534 | ····{ |
22535 | ········try |
22536 | ········{ |
22537 | ············pm.UnloadCache(); |
22538 | ············var l = pm.Objects<AgrBi1nOthpabsNoTblAutoLeft>().ResultTable; |
22539 | ············pm.Delete(l); |
22540 | ············pm.Save(); |
22541 | ············pm.UnloadCache(); |
22542 | ············var m = pm.Objects<AgrBi1nOthpabsNoTblAutoRightBase>().ResultTable; |
22543 | ············pm.Delete(m); |
22544 | ············pm.Save(); |
22545 | ············pm.UnloadCache(); |
22546 | ············decimal count; |
22547 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22548 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22549 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22550 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22551 | ········} |
22552 | ········catch (Exception) |
22553 | ········{ |
22554 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22555 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22557 | ········} |
22558 | ····} |
22559 | ····[Test] |
22560 | ····public void TestSaveReload() |
22561 | ····{ |
22562 | ········CreateObjects(); |
22563 | ········QueryOwn(); |
22564 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22566 | ····} |
22567 | ····[Test] |
22568 | ····public void TestSaveReloadNull() |
22569 | ····{ |
22570 | ········CreateObjects(); |
22571 | ········QueryOwn(); |
22572 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22573 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22574 | ········ownVar.RelField = null; |
22575 | ········pm.Save(); |
22576 | ········pm.UnloadCache(); |
22577 | ········QueryOwn(); |
22578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22579 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22580 | ····} |
22581 | ····[Test] |
22582 | ····public void TestChangeKeyHolderLeft() |
22583 | ····{ |
22584 | ········CreateObjects(); |
22585 | ········QueryOwn(); |
22586 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22587 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22588 | ········int x = ownVar.RelField.Dummy; |
22589 | ········ownVar.Dummy = 4711; |
22590 | ········pm.Save(); |
22591 | ········pm.UnloadCache(); |
22592 | ········QueryOwn(); |
22593 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22594 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22595 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22596 | ····} |
22597 | ····[Test] |
22598 | ····public void TestChangeKeyHolderLeftNoTouch() |
22599 | ····{ |
22600 | ········CreateObjects(); |
22601 | ········QueryOwn(); |
22602 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22603 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22604 | ········ownVar.Dummy = 4711; |
22605 | ········pm.Save(); |
22606 | ········pm.UnloadCache(); |
22607 | ········QueryOwn(); |
22608 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22609 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22610 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22611 | ····} |
22612 | ····[Test] |
22613 | ····public void TestUpdateOrder() |
22614 | ····{ |
22615 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
22616 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
22617 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpabsNoTblAutoLeft)})) |
22618 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
22619 | ········Debug.WriteLine("AgrBi1nOthpabsNoTblAutoLeft"); |
22620 | ····} |
22621 | ····[Test] |
22622 | ····public void TestRelationHash() |
22623 | ····{ |
22624 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoLeft)); |
22625 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22626 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoRightBase)); |
22627 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22628 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22629 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22630 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoRightDerived)); |
22631 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22632 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22633 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22634 | ····} |
22635 | ····void CreateObjects() |
22636 | ····{ |
22637 | ········pm.MakePersistent(ownVar); |
22638 | ········pm.Save(); |
22639 | ········pm.MakePersistent(otherVar); |
22640 | ········pm.Save(); |
22641 | ········ownVar.AssignRelation(otherVar); |
22642 | ········pm.Save(); |
22643 | ········pm.UnloadCache(); |
22644 | ····} |
22645 | ····void QueryOwn() |
22646 | ····{ |
22647 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblAutoLeft>(pm); |
22648 | ········ownVar = q.ExecuteSingle(); |
22649 | ····} |
22650 | ····void QueryOther() |
22651 | ····{ |
22652 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblAutoRightBase>(pm); |
22653 | ········otherVar = q.ExecuteSingle(); |
22654 | ····} |
22655 | } |
22656 | |
22657 | |
22658 | [TestFixture] |
22659 | public class TestAgrBi1nOthpabsTblAuto : NDOTest |
22660 | { |
22661 | ····AgrBi1nOthpabsTblAutoLeft ownVar; |
22662 | ····AgrBi1nOthpabsTblAutoRightBase otherVar; |
22663 | ····PersistenceManager pm; |
22664 | ····[SetUp] |
22665 | ····public void Setup() |
22666 | ····{ |
22667 | ········pm = PmFactory.NewPersistenceManager(); |
22668 | ········ownVar = new AgrBi1nOthpabsTblAutoLeft(); |
22669 | ········otherVar = new AgrBi1nOthpabsTblAutoRightDerived(); |
22670 | ····} |
22671 | ····[TearDown] |
22672 | ····public void TearDown() |
22673 | ····{ |
22674 | ········try |
22675 | ········{ |
22676 | ············pm.UnloadCache(); |
22677 | ············var l = pm.Objects<AgrBi1nOthpabsTblAutoLeft>().ResultTable; |
22678 | ············pm.Delete(l); |
22679 | ············pm.Save(); |
22680 | ············pm.UnloadCache(); |
22681 | ············var m = pm.Objects<AgrBi1nOthpabsTblAutoRightBase>().ResultTable; |
22682 | ············pm.Delete(m); |
22683 | ············pm.Save(); |
22684 | ············pm.UnloadCache(); |
22685 | ············decimal count; |
22686 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22687 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22688 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22689 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22690 | ········} |
22691 | ········catch (Exception) |
22692 | ········{ |
22693 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22694 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22695 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22696 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22697 | ········} |
22698 | ····} |
22699 | ····[Test] |
22700 | ····public void TestSaveReload() |
22701 | ····{ |
22702 | ········CreateObjects(); |
22703 | ········QueryOwn(); |
22704 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22705 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22706 | ····} |
22707 | ····[Test] |
22708 | ····public void TestSaveReloadNull() |
22709 | ····{ |
22710 | ········CreateObjects(); |
22711 | ········QueryOwn(); |
22712 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22713 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22714 | ········ownVar.RelField = null; |
22715 | ········pm.Save(); |
22716 | ········pm.UnloadCache(); |
22717 | ········QueryOwn(); |
22718 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22719 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22720 | ····} |
22721 | ····[Test] |
22722 | ····public void TestChangeKeyHolderLeft() |
22723 | ····{ |
22724 | ········CreateObjects(); |
22725 | ········QueryOwn(); |
22726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22727 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22728 | ········int x = ownVar.RelField.Dummy; |
22729 | ········ownVar.Dummy = 4711; |
22730 | ········pm.Save(); |
22731 | ········pm.UnloadCache(); |
22732 | ········QueryOwn(); |
22733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22734 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22735 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22736 | ····} |
22737 | ····[Test] |
22738 | ····public void TestChangeKeyHolderLeftNoTouch() |
22739 | ····{ |
22740 | ········CreateObjects(); |
22741 | ········QueryOwn(); |
22742 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22744 | ········ownVar.Dummy = 4711; |
22745 | ········pm.Save(); |
22746 | ········pm.UnloadCache(); |
22747 | ········QueryOwn(); |
22748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22749 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22750 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22751 | ····} |
22752 | ····[Test] |
22753 | ····public void TestRelationHash() |
22754 | ····{ |
22755 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoLeft)); |
22756 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22757 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoRightBase)); |
22758 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22759 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22760 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22761 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoRightDerived)); |
22762 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22763 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22764 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22765 | ····} |
22766 | ····void CreateObjects() |
22767 | ····{ |
22768 | ········pm.MakePersistent(ownVar); |
22769 | ········pm.MakePersistent(otherVar); |
22770 | ········ownVar.AssignRelation(otherVar); |
22771 | ········pm.Save(); |
22772 | ········pm.UnloadCache(); |
22773 | ····} |
22774 | ····void QueryOwn() |
22775 | ····{ |
22776 | ········var q = new NDOQuery<AgrBi1nOthpabsTblAutoLeft>(pm); |
22777 | ········ownVar = q.ExecuteSingle(); |
22778 | ····} |
22779 | ····void QueryOther() |
22780 | ····{ |
22781 | ········var q = new NDOQuery<AgrBi1nOthpabsTblAutoRightBase>(pm); |
22782 | ········otherVar = q.ExecuteSingle(); |
22783 | ····} |
22784 | } |
22785 | |
22786 | |
22787 | [TestFixture] |
22788 | public class TestAgrBinnOthpabsTblAuto : NDOTest |
22789 | { |
22790 | ····AgrBinnOthpabsTblAutoLeft ownVar; |
22791 | ····AgrBinnOthpabsTblAutoRightBase otherVar; |
22792 | ····PersistenceManager pm; |
22793 | ····[SetUp] |
22794 | ····public void Setup() |
22795 | ····{ |
22796 | ········pm = PmFactory.NewPersistenceManager(); |
22797 | ········ownVar = new AgrBinnOthpabsTblAutoLeft(); |
22798 | ········otherVar = new AgrBinnOthpabsTblAutoRightDerived(); |
22799 | ····} |
22800 | ····[TearDown] |
22801 | ····public void TearDown() |
22802 | ····{ |
22803 | ········try |
22804 | ········{ |
22805 | ············pm.UnloadCache(); |
22806 | ············var l = pm.Objects<AgrBinnOthpabsTblAutoLeft>().ResultTable; |
22807 | ············pm.Delete(l); |
22808 | ············pm.Save(); |
22809 | ············pm.UnloadCache(); |
22810 | ············var m = pm.Objects<AgrBinnOthpabsTblAutoRightBase>().ResultTable; |
22811 | ············pm.Delete(m); |
22812 | ············pm.Save(); |
22813 | ············pm.UnloadCache(); |
22814 | ············decimal count; |
22815 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22816 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22817 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22818 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22819 | ········} |
22820 | ········catch (Exception) |
22821 | ········{ |
22822 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22823 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22824 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22825 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22826 | ········} |
22827 | ····} |
22828 | ····[Test] |
22829 | ····public void TestSaveReload() |
22830 | ····{ |
22831 | ········CreateObjects(); |
22832 | ········QueryOwn(); |
22833 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22834 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22835 | ····} |
22836 | ····[Test] |
22837 | ····public void TestSaveReloadNull() |
22838 | ····{ |
22839 | ········CreateObjects(); |
22840 | ········QueryOwn(); |
22841 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22842 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22843 | ········ownVar.RelField = new List<AgrBinnOthpabsTblAutoRightBase>(); |
22844 | ········pm.Save(); |
22845 | ········pm.UnloadCache(); |
22846 | ········QueryOwn(); |
22847 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22848 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22849 | ····} |
22850 | ····[Test] |
22851 | ····public void TestSaveReloadRemove() |
22852 | ····{ |
22853 | ········CreateObjects(); |
22854 | ········QueryOwn(); |
22855 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22856 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22857 | ········ownVar.RemoveRelatedObject(); |
22858 | ········pm.Save(); |
22859 | ········pm.UnloadCache(); |
22860 | ········QueryOwn(); |
22861 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22862 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22863 | ····} |
22864 | ····[Test] |
22865 | ····public void TestRelationHash() |
22866 | ····{ |
22867 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoLeft)); |
22868 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22869 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoRightBase)); |
22870 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22871 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22872 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22873 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoRightDerived)); |
22874 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22875 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22876 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22877 | ····} |
22878 | ····void CreateObjects() |
22879 | ····{ |
22880 | ········pm.MakePersistent(ownVar); |
22881 | ········pm.MakePersistent(otherVar); |
22882 | ········ownVar.AssignRelation(otherVar); |
22883 | ········pm.Save(); |
22884 | ········pm.UnloadCache(); |
22885 | ····} |
22886 | ····void QueryOwn() |
22887 | ····{ |
22888 | ········var q = new NDOQuery<AgrBinnOthpabsTblAutoLeft>(pm); |
22889 | ········ownVar = q.ExecuteSingle(); |
22890 | ····} |
22891 | ····void QueryOther() |
22892 | ····{ |
22893 | ········var q = new NDOQuery<AgrBinnOthpabsTblAutoRightBase>(pm); |
22894 | ········otherVar = q.ExecuteSingle(); |
22895 | ····} |
22896 | } |
22897 | |
22898 | |
22899 | [TestFixture] |
22900 | public class TestCmpDir1OthpabsNoTblAuto : NDOTest |
22901 | { |
22902 | ····CmpDir1OthpabsNoTblAutoLeft ownVar; |
22903 | ····CmpDir1OthpabsNoTblAutoRightBase otherVar; |
22904 | ····PersistenceManager pm; |
22905 | ····[SetUp] |
22906 | ····public void Setup() |
22907 | ····{ |
22908 | ········pm = PmFactory.NewPersistenceManager(); |
22909 | ········ownVar = new CmpDir1OthpabsNoTblAutoLeft(); |
22910 | ········otherVar = new CmpDir1OthpabsNoTblAutoRightDerived(); |
22911 | ····} |
22912 | ····[TearDown] |
22913 | ····public void TearDown() |
22914 | ····{ |
22915 | ········try |
22916 | ········{ |
22917 | ············pm.UnloadCache(); |
22918 | ············var l = pm.Objects<CmpDir1OthpabsNoTblAutoLeft>().ResultTable; |
22919 | ············pm.Delete(l); |
22920 | ············pm.Save(); |
22921 | ············pm.UnloadCache(); |
22922 | ············decimal count; |
22923 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22924 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22925 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22926 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22927 | ········} |
22928 | ········catch (Exception) |
22929 | ········{ |
22930 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22931 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22932 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22933 | ········} |
22934 | ····} |
22935 | ····[Test] |
22936 | ····public void TestSaveReload() |
22937 | ····{ |
22938 | ········bool thrown = false; |
22939 | ········try |
22940 | ········{ |
22941 | ············CreateObjects(); |
22942 | ············QueryOwn(); |
22943 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22944 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22945 | ········} |
22946 | ········catch (NDOException) |
22947 | ········{ |
22948 | ············thrown = true; |
22949 | ········} |
22950 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
22951 | ····} |
22952 | ····[Test] |
22953 | ····public void TestSaveReloadNull() |
22954 | ····{ |
22955 | ········bool thrown = false; |
22956 | ········try |
22957 | ········{ |
22958 | ············CreateObjects(); |
22959 | ············QueryOwn(); |
22960 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22961 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22962 | ············ownVar.RelField = null; |
22963 | ············pm.Save(); |
22964 | ············pm.UnloadCache(); |
22965 | ············QueryOwn(); |
22966 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22967 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22968 | ········} |
22969 | ········catch (NDOException) |
22970 | ········{ |
22971 | ············thrown = true; |
22972 | ········} |
22973 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
22974 | ····} |
22975 | ····void CreateObjects() |
22976 | ····{ |
22977 | ········pm.MakePersistent(ownVar); |
22978 | ········pm.Save(); |
22979 | ········ownVar.AssignRelation(otherVar); |
22980 | ········pm.Save(); |
22981 | ········pm.UnloadCache(); |
22982 | ····} |
22983 | ····void QueryOwn() |
22984 | ····{ |
22985 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblAutoLeft>(pm); |
22986 | ········ownVar = q.ExecuteSingle(); |
22987 | ····} |
22988 | ····void QueryOther() |
22989 | ····{ |
22990 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblAutoRightBase>(pm); |
22991 | ········otherVar = q.ExecuteSingle(); |
22992 | ····} |
22993 | } |
22994 | |
22995 | |
22996 | [TestFixture] |
22997 | public class TestCmpDir1OthpabsTblAuto : NDOTest |
22998 | { |
22999 | ····CmpDir1OthpabsTblAutoLeft ownVar; |
23000 | ····CmpDir1OthpabsTblAutoRightBase otherVar; |
23001 | ····PersistenceManager pm; |
23002 | ····[SetUp] |
23003 | ····public void Setup() |
23004 | ····{ |
23005 | ········pm = PmFactory.NewPersistenceManager(); |
23006 | ········ownVar = new CmpDir1OthpabsTblAutoLeft(); |
23007 | ········otherVar = new CmpDir1OthpabsTblAutoRightDerived(); |
23008 | ····} |
23009 | ····[TearDown] |
23010 | ····public void TearDown() |
23011 | ····{ |
23012 | ········try |
23013 | ········{ |
23014 | ············pm.UnloadCache(); |
23015 | ············var l = pm.Objects<CmpDir1OthpabsTblAutoLeft>().ResultTable; |
23016 | ············pm.Delete(l); |
23017 | ············pm.Save(); |
23018 | ············pm.UnloadCache(); |
23019 | ············decimal count; |
23020 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23021 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23022 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23023 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23024 | ········} |
23025 | ········catch (Exception) |
23026 | ········{ |
23027 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23028 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23029 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23030 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23031 | ········} |
23032 | ····} |
23033 | ····[Test] |
23034 | ····public void TestSaveReload() |
23035 | ····{ |
23036 | ········CreateObjects(); |
23037 | ········QueryOwn(); |
23038 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23039 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23040 | ····} |
23041 | ····[Test] |
23042 | ····public void TestSaveReloadNull() |
23043 | ····{ |
23044 | ········CreateObjects(); |
23045 | ········QueryOwn(); |
23046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23047 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23048 | ········ownVar.RelField = null; |
23049 | ········pm.Save(); |
23050 | ········pm.UnloadCache(); |
23051 | ········QueryOwn(); |
23052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23053 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23054 | ····} |
23055 | ····[Test] |
23056 | ····public void TestChangeKeyHolderLeft() |
23057 | ····{ |
23058 | ········CreateObjects(); |
23059 | ········QueryOwn(); |
23060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23062 | ········int x = ownVar.RelField.Dummy; |
23063 | ········ownVar.Dummy = 4711; |
23064 | ········pm.Save(); |
23065 | ········pm.UnloadCache(); |
23066 | ········QueryOwn(); |
23067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23068 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23070 | ····} |
23071 | ····[Test] |
23072 | ····public void TestChangeKeyHolderLeftNoTouch() |
23073 | ····{ |
23074 | ········CreateObjects(); |
23075 | ········QueryOwn(); |
23076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23077 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23078 | ········ownVar.Dummy = 4711; |
23079 | ········pm.Save(); |
23080 | ········pm.UnloadCache(); |
23081 | ········QueryOwn(); |
23082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23083 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23084 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23085 | ····} |
23086 | ····void CreateObjects() |
23087 | ····{ |
23088 | ········pm.MakePersistent(ownVar); |
23089 | ········ownVar.AssignRelation(otherVar); |
23090 | ········pm.Save(); |
23091 | ········pm.UnloadCache(); |
23092 | ····} |
23093 | ····void QueryOwn() |
23094 | ····{ |
23095 | ········var q = new NDOQuery<CmpDir1OthpabsTblAutoLeft>(pm); |
23096 | ········ownVar = q.ExecuteSingle(); |
23097 | ····} |
23098 | ····void QueryOther() |
23099 | ····{ |
23100 | ········var q = new NDOQuery<CmpDir1OthpabsTblAutoRightBase>(pm); |
23101 | ········otherVar = q.ExecuteSingle(); |
23102 | ····} |
23103 | } |
23104 | |
23105 | |
23106 | [TestFixture] |
23107 | public class TestCmpBi11OthpabsNoTblAuto : NDOTest |
23108 | { |
23109 | ····CmpBi11OthpabsNoTblAutoLeft ownVar; |
23110 | ····CmpBi11OthpabsNoTblAutoRightBase otherVar; |
23111 | ····PersistenceManager pm; |
23112 | ····[SetUp] |
23113 | ····public void Setup() |
23114 | ····{ |
23115 | ········pm = PmFactory.NewPersistenceManager(); |
23116 | ········ownVar = new CmpBi11OthpabsNoTblAutoLeft(); |
23117 | ········otherVar = new CmpBi11OthpabsNoTblAutoRightDerived(); |
23118 | ····} |
23119 | ····[TearDown] |
23120 | ····public void TearDown() |
23121 | ····{ |
23122 | ········try |
23123 | ········{ |
23124 | ············pm.UnloadCache(); |
23125 | ············var l = pm.Objects<CmpBi11OthpabsNoTblAutoLeft>().ResultTable; |
23126 | ············pm.Delete(l); |
23127 | ············pm.Save(); |
23128 | ············pm.UnloadCache(); |
23129 | ············decimal count; |
23130 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23131 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23132 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23133 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23134 | ········} |
23135 | ········catch (Exception) |
23136 | ········{ |
23137 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23138 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23139 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23140 | ········} |
23141 | ····} |
23142 | ····[Test] |
23143 | ····public void TestSaveReload() |
23144 | ····{ |
23145 | ········bool thrown = false; |
23146 | ········try |
23147 | ········{ |
23148 | ············CreateObjects(); |
23149 | ············QueryOwn(); |
23150 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23151 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23152 | ········} |
23153 | ········catch (NDOException) |
23154 | ········{ |
23155 | ············thrown = true; |
23156 | ········} |
23157 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23158 | ····} |
23159 | ····[Test] |
23160 | ····public void TestSaveReloadNull() |
23161 | ····{ |
23162 | ········bool thrown = false; |
23163 | ········try |
23164 | ········{ |
23165 | ············CreateObjects(); |
23166 | ············QueryOwn(); |
23167 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23168 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23169 | ············ownVar.RelField = null; |
23170 | ············pm.Save(); |
23171 | ············pm.UnloadCache(); |
23172 | ············QueryOwn(); |
23173 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23174 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23175 | ········} |
23176 | ········catch (NDOException) |
23177 | ········{ |
23178 | ············thrown = true; |
23179 | ········} |
23180 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23181 | ····} |
23182 | ····[Test] |
23183 | ····public void TestRelationHash() |
23184 | ····{ |
23185 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoLeft)); |
23186 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23187 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoRightBase)); |
23188 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23189 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23190 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23191 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoRightDerived)); |
23192 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23193 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23194 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23195 | ····} |
23196 | ····void CreateObjects() |
23197 | ····{ |
23198 | ········pm.MakePersistent(ownVar); |
23199 | ········pm.Save(); |
23200 | ········ownVar.AssignRelation(otherVar); |
23201 | ········pm.Save(); |
23202 | ········pm.UnloadCache(); |
23203 | ····} |
23204 | ····void QueryOwn() |
23205 | ····{ |
23206 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblAutoLeft>(pm); |
23207 | ········ownVar = q.ExecuteSingle(); |
23208 | ····} |
23209 | ····void QueryOther() |
23210 | ····{ |
23211 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblAutoRightBase>(pm); |
23212 | ········otherVar = q.ExecuteSingle(); |
23213 | ····} |
23214 | } |
23215 | |
23216 | |
23217 | [TestFixture] |
23218 | public class TestCmpBi11OthpabsTblAuto : NDOTest |
23219 | { |
23220 | ····CmpBi11OthpabsTblAutoLeft ownVar; |
23221 | ····CmpBi11OthpabsTblAutoRightBase otherVar; |
23222 | ····PersistenceManager pm; |
23223 | ····[SetUp] |
23224 | ····public void Setup() |
23225 | ····{ |
23226 | ········pm = PmFactory.NewPersistenceManager(); |
23227 | ········ownVar = new CmpBi11OthpabsTblAutoLeft(); |
23228 | ········otherVar = new CmpBi11OthpabsTblAutoRightDerived(); |
23229 | ····} |
23230 | ····[TearDown] |
23231 | ····public void TearDown() |
23232 | ····{ |
23233 | ········try |
23234 | ········{ |
23235 | ············pm.UnloadCache(); |
23236 | ············var l = pm.Objects<CmpBi11OthpabsTblAutoLeft>().ResultTable; |
23237 | ············pm.Delete(l); |
23238 | ············pm.Save(); |
23239 | ············pm.UnloadCache(); |
23240 | ············decimal count; |
23241 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23242 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23243 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23245 | ········} |
23246 | ········catch (Exception) |
23247 | ········{ |
23248 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23249 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23250 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23251 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23252 | ········} |
23253 | ····} |
23254 | ····[Test] |
23255 | ····public void TestSaveReload() |
23256 | ····{ |
23257 | ········CreateObjects(); |
23258 | ········QueryOwn(); |
23259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23261 | ····} |
23262 | ····[Test] |
23263 | ····public void TestSaveReloadNull() |
23264 | ····{ |
23265 | ········CreateObjects(); |
23266 | ········QueryOwn(); |
23267 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23268 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23269 | ········ownVar.RelField = null; |
23270 | ········pm.Save(); |
23271 | ········pm.UnloadCache(); |
23272 | ········QueryOwn(); |
23273 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23274 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23275 | ····} |
23276 | ····[Test] |
23277 | ····public void TestChangeKeyHolderLeft() |
23278 | ····{ |
23279 | ········CreateObjects(); |
23280 | ········QueryOwn(); |
23281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23282 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23283 | ········int x = ownVar.RelField.Dummy; |
23284 | ········ownVar.Dummy = 4711; |
23285 | ········pm.Save(); |
23286 | ········pm.UnloadCache(); |
23287 | ········QueryOwn(); |
23288 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23289 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23290 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23291 | ····} |
23292 | ····[Test] |
23293 | ····public void TestChangeKeyHolderRight() |
23294 | ····{ |
23295 | ········CreateObjects(); |
23296 | ········QueryOther(); |
23297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23298 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23299 | ········int x = otherVar.RelField.Dummy; |
23300 | ········otherVar.Dummy = 4711; |
23301 | ········pm.Save(); |
23302 | ········pm.UnloadCache(); |
23303 | ········QueryOther(); |
23304 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23305 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23307 | ····} |
23308 | ····[Test] |
23309 | ····public void TestChangeKeyHolderLeftNoTouch() |
23310 | ····{ |
23311 | ········CreateObjects(); |
23312 | ········QueryOwn(); |
23313 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23315 | ········ownVar.Dummy = 4711; |
23316 | ········pm.Save(); |
23317 | ········pm.UnloadCache(); |
23318 | ········QueryOwn(); |
23319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23320 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23321 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23322 | ····} |
23323 | ····[Test] |
23324 | ····public void TestChangeKeyHolderRightNoTouch() |
23325 | ····{ |
23326 | ········CreateObjects(); |
23327 | ········QueryOther(); |
23328 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23329 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23330 | ········otherVar.Dummy = 4711; |
23331 | ········pm.Save(); |
23332 | ········pm.UnloadCache(); |
23333 | ········QueryOther(); |
23334 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23335 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23336 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23337 | ····} |
23338 | ····[Test] |
23339 | ····public void TestRelationHash() |
23340 | ····{ |
23341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoLeft)); |
23342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoRightBase)); |
23344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23347 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoRightDerived)); |
23348 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23349 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23350 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23351 | ····} |
23352 | ····void CreateObjects() |
23353 | ····{ |
23354 | ········pm.MakePersistent(ownVar); |
23355 | ········ownVar.AssignRelation(otherVar); |
23356 | ········pm.Save(); |
23357 | ········pm.UnloadCache(); |
23358 | ····} |
23359 | ····void QueryOwn() |
23360 | ····{ |
23361 | ········var q = new NDOQuery<CmpBi11OthpabsTblAutoLeft>(pm); |
23362 | ········ownVar = q.ExecuteSingle(); |
23363 | ····} |
23364 | ····void QueryOther() |
23365 | ····{ |
23366 | ········var q = new NDOQuery<CmpBi11OthpabsTblAutoRightBase>(pm); |
23367 | ········otherVar = q.ExecuteSingle(); |
23368 | ····} |
23369 | } |
23370 | |
23371 | |
23372 | [TestFixture] |
23373 | public class TestCmpDirnOthpabsTblAuto : NDOTest |
23374 | { |
23375 | ····CmpDirnOthpabsTblAutoLeft ownVar; |
23376 | ····CmpDirnOthpabsTblAutoRightBase otherVar; |
23377 | ····PersistenceManager pm; |
23378 | ····[SetUp] |
23379 | ····public void Setup() |
23380 | ····{ |
23381 | ········pm = PmFactory.NewPersistenceManager(); |
23382 | ········ownVar = new CmpDirnOthpabsTblAutoLeft(); |
23383 | ········otherVar = new CmpDirnOthpabsTblAutoRightDerived(); |
23384 | ····} |
23385 | ····[TearDown] |
23386 | ····public void TearDown() |
23387 | ····{ |
23388 | ········try |
23389 | ········{ |
23390 | ············pm.UnloadCache(); |
23391 | ············var l = pm.Objects<CmpDirnOthpabsTblAutoLeft>().ResultTable; |
23392 | ············pm.Delete(l); |
23393 | ············pm.Save(); |
23394 | ············pm.UnloadCache(); |
23395 | ············decimal count; |
23396 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23397 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23398 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23399 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23400 | ········} |
23401 | ········catch (Exception) |
23402 | ········{ |
23403 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23404 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23405 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23406 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23407 | ········} |
23408 | ····} |
23409 | ····[Test] |
23410 | ····public void TestSaveReload() |
23411 | ····{ |
23412 | ········CreateObjects(); |
23413 | ········QueryOwn(); |
23414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23415 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23416 | ····} |
23417 | ····[Test] |
23418 | ····public void TestSaveReloadNull() |
23419 | ····{ |
23420 | ········CreateObjects(); |
23421 | ········QueryOwn(); |
23422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23424 | ········ownVar.RelField = new List<CmpDirnOthpabsTblAutoRightBase>(); |
23425 | ········pm.Save(); |
23426 | ········pm.UnloadCache(); |
23427 | ········QueryOwn(); |
23428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23429 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23430 | ····} |
23431 | ····[Test] |
23432 | ····public void TestSaveReloadRemove() |
23433 | ····{ |
23434 | ········CreateObjects(); |
23435 | ········QueryOwn(); |
23436 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23437 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23438 | ········ownVar.RemoveRelatedObject(); |
23439 | ········pm.Save(); |
23440 | ········pm.UnloadCache(); |
23441 | ········QueryOwn(); |
23442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23443 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23444 | ····} |
23445 | ····void CreateObjects() |
23446 | ····{ |
23447 | ········pm.MakePersistent(ownVar); |
23448 | ········ownVar.AssignRelation(otherVar); |
23449 | ········pm.Save(); |
23450 | ········pm.UnloadCache(); |
23451 | ····} |
23452 | ····void QueryOwn() |
23453 | ····{ |
23454 | ········var q = new NDOQuery<CmpDirnOthpabsTblAutoLeft>(pm); |
23455 | ········ownVar = q.ExecuteSingle(); |
23456 | ····} |
23457 | ····void QueryOther() |
23458 | ····{ |
23459 | ········var q = new NDOQuery<CmpDirnOthpabsTblAutoRightBase>(pm); |
23460 | ········otherVar = q.ExecuteSingle(); |
23461 | ····} |
23462 | } |
23463 | |
23464 | |
23465 | [TestFixture] |
23466 | public class TestCmpBin1OthpabsTblAuto : NDOTest |
23467 | { |
23468 | ····CmpBin1OthpabsTblAutoLeft ownVar; |
23469 | ····CmpBin1OthpabsTblAutoRightBase otherVar; |
23470 | ····PersistenceManager pm; |
23471 | ····[SetUp] |
23472 | ····public void Setup() |
23473 | ····{ |
23474 | ········pm = PmFactory.NewPersistenceManager(); |
23475 | ········ownVar = new CmpBin1OthpabsTblAutoLeft(); |
23476 | ········otherVar = new CmpBin1OthpabsTblAutoRightDerived(); |
23477 | ····} |
23478 | ····[TearDown] |
23479 | ····public void TearDown() |
23480 | ····{ |
23481 | ········try |
23482 | ········{ |
23483 | ············pm.UnloadCache(); |
23484 | ············var l = pm.Objects<CmpBin1OthpabsTblAutoLeft>().ResultTable; |
23485 | ············pm.Delete(l); |
23486 | ············pm.Save(); |
23487 | ············pm.UnloadCache(); |
23488 | ············decimal count; |
23489 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23490 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23491 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23492 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23493 | ········} |
23494 | ········catch (Exception) |
23495 | ········{ |
23496 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23497 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23498 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23499 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23500 | ········} |
23501 | ····} |
23502 | ····[Test] |
23503 | ····public void TestSaveReload() |
23504 | ····{ |
23505 | ········CreateObjects(); |
23506 | ········QueryOwn(); |
23507 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23508 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23509 | ····} |
23510 | ····[Test] |
23511 | ····public void TestSaveReloadNull() |
23512 | ····{ |
23513 | ········CreateObjects(); |
23514 | ········QueryOwn(); |
23515 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23516 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23517 | ········ownVar.RelField = new List<CmpBin1OthpabsTblAutoRightBase>(); |
23518 | ········pm.Save(); |
23519 | ········pm.UnloadCache(); |
23520 | ········QueryOwn(); |
23521 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23522 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23523 | ····} |
23524 | ····[Test] |
23525 | ····public void TestSaveReloadRemove() |
23526 | ····{ |
23527 | ········CreateObjects(); |
23528 | ········QueryOwn(); |
23529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23530 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23531 | ········ownVar.RemoveRelatedObject(); |
23532 | ········pm.Save(); |
23533 | ········pm.UnloadCache(); |
23534 | ········QueryOwn(); |
23535 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23536 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23537 | ····} |
23538 | ····[Test] |
23539 | ····public void TestChangeKeyHolderRight() |
23540 | ····{ |
23541 | ········CreateObjects(); |
23542 | ········QueryOther(); |
23543 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23544 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23545 | ········int x = otherVar.RelField.Dummy; |
23546 | ········otherVar.Dummy = 4711; |
23547 | ········pm.Save(); |
23548 | ········pm.UnloadCache(); |
23549 | ········QueryOther(); |
23550 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23551 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23552 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23553 | ····} |
23554 | ····[Test] |
23555 | ····public void TestChangeKeyHolderRightNoTouch() |
23556 | ····{ |
23557 | ········CreateObjects(); |
23558 | ········QueryOther(); |
23559 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23560 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23561 | ········otherVar.Dummy = 4711; |
23562 | ········pm.Save(); |
23563 | ········pm.UnloadCache(); |
23564 | ········QueryOther(); |
23565 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23566 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23567 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23568 | ····} |
23569 | ····[Test] |
23570 | ····public void TestRelationHash() |
23571 | ····{ |
23572 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoLeft)); |
23573 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23574 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoRightBase)); |
23575 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23576 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23577 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23578 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoRightDerived)); |
23579 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23580 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23581 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23582 | ····} |
23583 | ····void CreateObjects() |
23584 | ····{ |
23585 | ········pm.MakePersistent(ownVar); |
23586 | ········ownVar.AssignRelation(otherVar); |
23587 | ········pm.Save(); |
23588 | ········pm.UnloadCache(); |
23589 | ····} |
23590 | ····void QueryOwn() |
23591 | ····{ |
23592 | ········var q = new NDOQuery<CmpBin1OthpabsTblAutoLeft>(pm); |
23593 | ········ownVar = q.ExecuteSingle(); |
23594 | ····} |
23595 | ····void QueryOther() |
23596 | ····{ |
23597 | ········var q = new NDOQuery<CmpBin1OthpabsTblAutoRightBase>(pm); |
23598 | ········otherVar = q.ExecuteSingle(); |
23599 | ····} |
23600 | } |
23601 | |
23602 | |
23603 | [TestFixture] |
23604 | public class TestCmpBi1nOthpabsNoTblAuto : NDOTest |
23605 | { |
23606 | ····CmpBi1nOthpabsNoTblAutoLeft ownVar; |
23607 | ····CmpBi1nOthpabsNoTblAutoRightBase otherVar; |
23608 | ····PersistenceManager pm; |
23609 | ····[SetUp] |
23610 | ····public void Setup() |
23611 | ····{ |
23612 | ········pm = PmFactory.NewPersistenceManager(); |
23613 | ········ownVar = new CmpBi1nOthpabsNoTblAutoLeft(); |
23614 | ········otherVar = new CmpBi1nOthpabsNoTblAutoRightDerived(); |
23615 | ····} |
23616 | ····[TearDown] |
23617 | ····public void TearDown() |
23618 | ····{ |
23619 | ········try |
23620 | ········{ |
23621 | ············pm.UnloadCache(); |
23622 | ············var l = pm.Objects<CmpBi1nOthpabsNoTblAutoLeft>().ResultTable; |
23623 | ············pm.Delete(l); |
23624 | ············pm.Save(); |
23625 | ············pm.UnloadCache(); |
23626 | ············decimal count; |
23627 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23628 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23629 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23630 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23631 | ········} |
23632 | ········catch (Exception) |
23633 | ········{ |
23634 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23635 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23636 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23637 | ········} |
23638 | ····} |
23639 | ····[Test] |
23640 | ····public void TestSaveReload() |
23641 | ····{ |
23642 | ········bool thrown = false; |
23643 | ········try |
23644 | ········{ |
23645 | ············CreateObjects(); |
23646 | ············QueryOwn(); |
23647 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23648 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23649 | ········} |
23650 | ········catch (NDOException) |
23651 | ········{ |
23652 | ············thrown = true; |
23653 | ········} |
23654 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23655 | ····} |
23656 | ····[Test] |
23657 | ····public void TestSaveReloadNull() |
23658 | ····{ |
23659 | ········bool thrown = false; |
23660 | ········try |
23661 | ········{ |
23662 | ············CreateObjects(); |
23663 | ············QueryOwn(); |
23664 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23665 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23666 | ············ownVar.RelField = null; |
23667 | ············pm.Save(); |
23668 | ············pm.UnloadCache(); |
23669 | ············QueryOwn(); |
23670 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23671 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23672 | ········} |
23673 | ········catch (NDOException) |
23674 | ········{ |
23675 | ············thrown = true; |
23676 | ········} |
23677 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23678 | ····} |
23679 | ····[Test] |
23680 | ····public void TestRelationHash() |
23681 | ····{ |
23682 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoLeft)); |
23683 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23684 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoRightBase)); |
23685 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23686 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23687 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23688 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoRightDerived)); |
23689 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23690 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23691 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23692 | ····} |
23693 | ····void CreateObjects() |
23694 | ····{ |
23695 | ········pm.MakePersistent(ownVar); |
23696 | ········pm.Save(); |
23697 | ········ownVar.AssignRelation(otherVar); |
23698 | ········pm.Save(); |
23699 | ········pm.UnloadCache(); |
23700 | ····} |
23701 | ····void QueryOwn() |
23702 | ····{ |
23703 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblAutoLeft>(pm); |
23704 | ········ownVar = q.ExecuteSingle(); |
23705 | ····} |
23706 | ····void QueryOther() |
23707 | ····{ |
23708 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblAutoRightBase>(pm); |
23709 | ········otherVar = q.ExecuteSingle(); |
23710 | ····} |
23711 | } |
23712 | |
23713 | |
23714 | [TestFixture] |
23715 | public class TestCmpBi1nOthpabsTblAuto : NDOTest |
23716 | { |
23717 | ····CmpBi1nOthpabsTblAutoLeft ownVar; |
23718 | ····CmpBi1nOthpabsTblAutoRightBase otherVar; |
23719 | ····PersistenceManager pm; |
23720 | ····[SetUp] |
23721 | ····public void Setup() |
23722 | ····{ |
23723 | ········pm = PmFactory.NewPersistenceManager(); |
23724 | ········ownVar = new CmpBi1nOthpabsTblAutoLeft(); |
23725 | ········otherVar = new CmpBi1nOthpabsTblAutoRightDerived(); |
23726 | ····} |
23727 | ····[TearDown] |
23728 | ····public void TearDown() |
23729 | ····{ |
23730 | ········try |
23731 | ········{ |
23732 | ············pm.UnloadCache(); |
23733 | ············var l = pm.Objects<CmpBi1nOthpabsTblAutoLeft>().ResultTable; |
23734 | ············pm.Delete(l); |
23735 | ············pm.Save(); |
23736 | ············pm.UnloadCache(); |
23737 | ············decimal count; |
23738 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23739 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23740 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23741 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23742 | ········} |
23743 | ········catch (Exception) |
23744 | ········{ |
23745 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23746 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23747 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23748 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23749 | ········} |
23750 | ····} |
23751 | ····[Test] |
23752 | ····public void TestSaveReload() |
23753 | ····{ |
23754 | ········CreateObjects(); |
23755 | ········QueryOwn(); |
23756 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23757 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23758 | ····} |
23759 | ····[Test] |
23760 | ····public void TestSaveReloadNull() |
23761 | ····{ |
23762 | ········CreateObjects(); |
23763 | ········QueryOwn(); |
23764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23765 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23766 | ········ownVar.RelField = null; |
23767 | ········pm.Save(); |
23768 | ········pm.UnloadCache(); |
23769 | ········QueryOwn(); |
23770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23771 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23772 | ····} |
23773 | ····[Test] |
23774 | ····public void TestChangeKeyHolderLeft() |
23775 | ····{ |
23776 | ········CreateObjects(); |
23777 | ········QueryOwn(); |
23778 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23779 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23780 | ········int x = ownVar.RelField.Dummy; |
23781 | ········ownVar.Dummy = 4711; |
23782 | ········pm.Save(); |
23783 | ········pm.UnloadCache(); |
23784 | ········QueryOwn(); |
23785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23786 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23787 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23788 | ····} |
23789 | ····[Test] |
23790 | ····public void TestChangeKeyHolderLeftNoTouch() |
23791 | ····{ |
23792 | ········CreateObjects(); |
23793 | ········QueryOwn(); |
23794 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23795 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23796 | ········ownVar.Dummy = 4711; |
23797 | ········pm.Save(); |
23798 | ········pm.UnloadCache(); |
23799 | ········QueryOwn(); |
23800 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23801 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23802 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23803 | ····} |
23804 | ····[Test] |
23805 | ····public void TestRelationHash() |
23806 | ····{ |
23807 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoLeft)); |
23808 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23809 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoRightBase)); |
23810 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23811 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23812 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23813 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoRightDerived)); |
23814 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23815 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23816 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23817 | ····} |
23818 | ····void CreateObjects() |
23819 | ····{ |
23820 | ········pm.MakePersistent(ownVar); |
23821 | ········ownVar.AssignRelation(otherVar); |
23822 | ········pm.Save(); |
23823 | ········pm.UnloadCache(); |
23824 | ····} |
23825 | ····void QueryOwn() |
23826 | ····{ |
23827 | ········var q = new NDOQuery<CmpBi1nOthpabsTblAutoLeft>(pm); |
23828 | ········ownVar = q.ExecuteSingle(); |
23829 | ····} |
23830 | ····void QueryOther() |
23831 | ····{ |
23832 | ········var q = new NDOQuery<CmpBi1nOthpabsTblAutoRightBase>(pm); |
23833 | ········otherVar = q.ExecuteSingle(); |
23834 | ····} |
23835 | } |
23836 | |
23837 | |
23838 | [TestFixture] |
23839 | public class TestCmpBinnOthpabsTblAuto : NDOTest |
23840 | { |
23841 | ····CmpBinnOthpabsTblAutoLeft ownVar; |
23842 | ····CmpBinnOthpabsTblAutoRightBase otherVar; |
23843 | ····PersistenceManager pm; |
23844 | ····[SetUp] |
23845 | ····public void Setup() |
23846 | ····{ |
23847 | ········pm = PmFactory.NewPersistenceManager(); |
23848 | ········ownVar = new CmpBinnOthpabsTblAutoLeft(); |
23849 | ········otherVar = new CmpBinnOthpabsTblAutoRightDerived(); |
23850 | ····} |
23851 | ····[TearDown] |
23852 | ····public void TearDown() |
23853 | ····{ |
23854 | ········try |
23855 | ········{ |
23856 | ············pm.UnloadCache(); |
23857 | ············var l = pm.Objects<CmpBinnOthpabsTblAutoLeft>().ResultTable; |
23858 | ············pm.Delete(l); |
23859 | ············pm.Save(); |
23860 | ············pm.UnloadCache(); |
23861 | ············decimal count; |
23862 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23863 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23864 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23866 | ········} |
23867 | ········catch (Exception) |
23868 | ········{ |
23869 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23870 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23871 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23872 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23873 | ········} |
23874 | ····} |
23875 | ····[Test] |
23876 | ····public void TestSaveReload() |
23877 | ····{ |
23878 | ········CreateObjects(); |
23879 | ········QueryOwn(); |
23880 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23881 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23882 | ····} |
23883 | ····[Test] |
23884 | ····public void TestSaveReloadNull() |
23885 | ····{ |
23886 | ········CreateObjects(); |
23887 | ········QueryOwn(); |
23888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23889 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23890 | ········ownVar.RelField = new List<CmpBinnOthpabsTblAutoRightBase>(); |
23891 | ········pm.Save(); |
23892 | ········pm.UnloadCache(); |
23893 | ········QueryOwn(); |
23894 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23895 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23896 | ····} |
23897 | ····[Test] |
23898 | ····public void TestSaveReloadRemove() |
23899 | ····{ |
23900 | ········CreateObjects(); |
23901 | ········QueryOwn(); |
23902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23903 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23904 | ········ownVar.RemoveRelatedObject(); |
23905 | ········pm.Save(); |
23906 | ········pm.UnloadCache(); |
23907 | ········QueryOwn(); |
23908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23909 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23910 | ····} |
23911 | ····[Test] |
23912 | ····public void TestRelationHash() |
23913 | ····{ |
23914 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoLeft)); |
23915 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23916 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoRightBase)); |
23917 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23918 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23919 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23920 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoRightDerived)); |
23921 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23922 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23923 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23924 | ····} |
23925 | ····void CreateObjects() |
23926 | ····{ |
23927 | ········pm.MakePersistent(ownVar); |
23928 | ········ownVar.AssignRelation(otherVar); |
23929 | ········pm.Save(); |
23930 | ········pm.UnloadCache(); |
23931 | ····} |
23932 | ····void QueryOwn() |
23933 | ····{ |
23934 | ········var q = new NDOQuery<CmpBinnOthpabsTblAutoLeft>(pm); |
23935 | ········ownVar = q.ExecuteSingle(); |
23936 | ····} |
23937 | ····void QueryOther() |
23938 | ····{ |
23939 | ········var q = new NDOQuery<CmpBinnOthpabsTblAutoRightBase>(pm); |
23940 | ········otherVar = q.ExecuteSingle(); |
23941 | ····} |
23942 | } |
23943 | |
23944 | |
23945 | [TestFixture] |
23946 | public class TestAgrDir1OwnpabsOthpabsNoTblAuto : NDOTest |
23947 | { |
23948 | ····AgrDir1OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
23949 | ····AgrDir1OwnpabsOthpabsNoTblAutoRightBase otherVar; |
23950 | ····PersistenceManager pm; |
23951 | ····[SetUp] |
23952 | ····public void Setup() |
23953 | ····{ |
23954 | ········pm = PmFactory.NewPersistenceManager(); |
23955 | ········ownVar = new AgrDir1OwnpabsOthpabsNoTblAutoLeftDerived(); |
23956 | ········otherVar = new AgrDir1OwnpabsOthpabsNoTblAutoRightDerived(); |
23957 | ····} |
23958 | ····[TearDown] |
23959 | ····public void TearDown() |
23960 | ····{ |
23961 | ········try |
23962 | ········{ |
23963 | ············pm.UnloadCache(); |
23964 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
23965 | ············pm.Delete(l); |
23966 | ············pm.Save(); |
23967 | ············pm.UnloadCache(); |
23968 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>().ResultTable; |
23969 | ············pm.Delete(m); |
23970 | ············pm.Save(); |
23971 | ············pm.UnloadCache(); |
23972 | ············decimal count; |
23973 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23974 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23975 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23976 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23977 | ········} |
23978 | ········catch (Exception) |
23979 | ········{ |
23980 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23981 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23982 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23983 | ········} |
23984 | ····} |
23985 | ····[Test] |
23986 | ····public void TestSaveReload() |
23987 | ····{ |
23988 | ········CreateObjects(); |
23989 | ········QueryOwn(); |
23990 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23991 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23992 | ····} |
23993 | ····[Test] |
23994 | ····public void TestSaveReloadNull() |
23995 | ····{ |
23996 | ········CreateObjects(); |
23997 | ········QueryOwn(); |
23998 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23999 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24000 | ········ownVar.RelField = null; |
24001 | ········pm.Save(); |
24002 | ········pm.UnloadCache(); |
24003 | ········QueryOwn(); |
24004 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24005 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24006 | ····} |
24007 | ····[Test] |
24008 | ····public void TestChangeKeyHolderLeft() |
24009 | ····{ |
24010 | ········CreateObjects(); |
24011 | ········QueryOwn(); |
24012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24013 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24014 | ········int x = ownVar.RelField.Dummy; |
24015 | ········ownVar.Dummy = 4711; |
24016 | ········pm.Save(); |
24017 | ········pm.UnloadCache(); |
24018 | ········QueryOwn(); |
24019 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24020 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24021 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24022 | ····} |
24023 | ····[Test] |
24024 | ····public void TestChangeKeyHolderLeftNoTouch() |
24025 | ····{ |
24026 | ········CreateObjects(); |
24027 | ········QueryOwn(); |
24028 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24029 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24030 | ········ownVar.Dummy = 4711; |
24031 | ········pm.Save(); |
24032 | ········pm.UnloadCache(); |
24033 | ········QueryOwn(); |
24034 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24035 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24036 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24037 | ····} |
24038 | ····[Test] |
24039 | ····public void TestUpdateOrder() |
24040 | ····{ |
24041 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
24042 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
24043 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsOthpabsNoTblAutoLeftDerived)})) |
24044 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsOthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
24045 | ········Debug.WriteLine("AgrDir1OwnpabsOthpabsNoTblAutoLeftBase"); |
24046 | ····} |
24047 | ····void CreateObjects() |
24048 | ····{ |
24049 | ········pm.MakePersistent(ownVar); |
24050 | ········pm.Save(); |
24051 | ········pm.MakePersistent(otherVar); |
24052 | ········pm.Save(); |
24053 | ········ownVar.AssignRelation(otherVar); |
24054 | ········pm.Save(); |
24055 | ········pm.UnloadCache(); |
24056 | ····} |
24057 | ····void QueryOwn() |
24058 | ····{ |
24059 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
24060 | ········ownVar = q.ExecuteSingle(); |
24061 | ····} |
24062 | ····void QueryOther() |
24063 | ····{ |
24064 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>(pm); |
24065 | ········otherVar = q.ExecuteSingle(); |
24066 | ····} |
24067 | } |
24068 | |
24069 | |
24070 | [TestFixture] |
24071 | public class TestAgrDir1OwnpabsOthpabsTblAuto : NDOTest |
24072 | { |
24073 | ····AgrDir1OwnpabsOthpabsTblAutoLeftBase ownVar; |
24074 | ····AgrDir1OwnpabsOthpabsTblAutoRightBase otherVar; |
24075 | ····PersistenceManager pm; |
24076 | ····[SetUp] |
24077 | ····public void Setup() |
24078 | ····{ |
24079 | ········pm = PmFactory.NewPersistenceManager(); |
24080 | ········ownVar = new AgrDir1OwnpabsOthpabsTblAutoLeftDerived(); |
24081 | ········otherVar = new AgrDir1OwnpabsOthpabsTblAutoRightDerived(); |
24082 | ····} |
24083 | ····[TearDown] |
24084 | ····public void TearDown() |
24085 | ····{ |
24086 | ········try |
24087 | ········{ |
24088 | ············pm.UnloadCache(); |
24089 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24090 | ············pm.Delete(l); |
24091 | ············pm.Save(); |
24092 | ············pm.UnloadCache(); |
24093 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24094 | ············pm.Delete(m); |
24095 | ············pm.Save(); |
24096 | ············pm.UnloadCache(); |
24097 | ············decimal count; |
24098 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24099 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24100 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24101 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24102 | ········} |
24103 | ········catch (Exception) |
24104 | ········{ |
24105 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24106 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24107 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24108 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24109 | ········} |
24110 | ····} |
24111 | ····[Test] |
24112 | ····public void TestSaveReload() |
24113 | ····{ |
24114 | ········CreateObjects(); |
24115 | ········QueryOwn(); |
24116 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24117 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24118 | ····} |
24119 | ····[Test] |
24120 | ····public void TestSaveReloadNull() |
24121 | ····{ |
24122 | ········CreateObjects(); |
24123 | ········QueryOwn(); |
24124 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24125 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24126 | ········ownVar.RelField = null; |
24127 | ········pm.Save(); |
24128 | ········pm.UnloadCache(); |
24129 | ········QueryOwn(); |
24130 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24131 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24132 | ····} |
24133 | ····[Test] |
24134 | ····public void TestChangeKeyHolderLeft() |
24135 | ····{ |
24136 | ········CreateObjects(); |
24137 | ········QueryOwn(); |
24138 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24139 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24140 | ········int x = ownVar.RelField.Dummy; |
24141 | ········ownVar.Dummy = 4711; |
24142 | ········pm.Save(); |
24143 | ········pm.UnloadCache(); |
24144 | ········QueryOwn(); |
24145 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24146 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24148 | ····} |
24149 | ····[Test] |
24150 | ····public void TestChangeKeyHolderLeftNoTouch() |
24151 | ····{ |
24152 | ········CreateObjects(); |
24153 | ········QueryOwn(); |
24154 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24155 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24156 | ········ownVar.Dummy = 4711; |
24157 | ········pm.Save(); |
24158 | ········pm.UnloadCache(); |
24159 | ········QueryOwn(); |
24160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24161 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24162 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24163 | ····} |
24164 | ····void CreateObjects() |
24165 | ····{ |
24166 | ········pm.MakePersistent(ownVar); |
24167 | ········pm.MakePersistent(otherVar); |
24168 | ········ownVar.AssignRelation(otherVar); |
24169 | ········pm.Save(); |
24170 | ········pm.UnloadCache(); |
24171 | ····} |
24172 | ····void QueryOwn() |
24173 | ····{ |
24174 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoLeftBase>(pm); |
24175 | ········ownVar = q.ExecuteSingle(); |
24176 | ····} |
24177 | ····void QueryOther() |
24178 | ····{ |
24179 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoRightBase>(pm); |
24180 | ········otherVar = q.ExecuteSingle(); |
24181 | ····} |
24182 | } |
24183 | |
24184 | |
24185 | [TestFixture] |
24186 | public class TestAgrBi11OwnpabsOthpabsNoTblAuto : NDOTest |
24187 | { |
24188 | ····AgrBi11OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
24189 | ····AgrBi11OwnpabsOthpabsNoTblAutoRightBase otherVar; |
24190 | ····PersistenceManager pm; |
24191 | ····[SetUp] |
24192 | ····public void Setup() |
24193 | ····{ |
24194 | ········pm = PmFactory.NewPersistenceManager(); |
24195 | ········ownVar = new AgrBi11OwnpabsOthpabsNoTblAutoLeftDerived(); |
24196 | ········otherVar = new AgrBi11OwnpabsOthpabsNoTblAutoRightDerived(); |
24197 | ····} |
24198 | ····[TearDown] |
24199 | ····public void TearDown() |
24200 | ····{ |
24201 | ········try |
24202 | ········{ |
24203 | ············pm.UnloadCache(); |
24204 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
24205 | ············pm.Delete(l); |
24206 | ············pm.Save(); |
24207 | ············pm.UnloadCache(); |
24208 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>().ResultTable; |
24209 | ············pm.Delete(m); |
24210 | ············pm.Save(); |
24211 | ············pm.UnloadCache(); |
24212 | ············decimal count; |
24213 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24214 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24215 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24216 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24217 | ········} |
24218 | ········catch (Exception) |
24219 | ········{ |
24220 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24221 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24222 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24223 | ········} |
24224 | ····} |
24225 | ····[Test] |
24226 | ····public void TestSaveReload() |
24227 | ····{ |
24228 | ········CreateObjects(); |
24229 | ········QueryOwn(); |
24230 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24231 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24232 | ····} |
24233 | ····[Test] |
24234 | ····public void TestSaveReloadNull() |
24235 | ····{ |
24236 | ········CreateObjects(); |
24237 | ········QueryOwn(); |
24238 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24239 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24240 | ········ownVar.RelField = null; |
24241 | ········pm.Save(); |
24242 | ········pm.UnloadCache(); |
24243 | ········QueryOwn(); |
24244 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24245 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24246 | ····} |
24247 | ····[Test] |
24248 | ····public void TestChangeKeyHolderLeft() |
24249 | ····{ |
24250 | ········CreateObjects(); |
24251 | ········QueryOwn(); |
24252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24254 | ········int x = ownVar.RelField.Dummy; |
24255 | ········ownVar.Dummy = 4711; |
24256 | ········pm.Save(); |
24257 | ········pm.UnloadCache(); |
24258 | ········QueryOwn(); |
24259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24260 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24262 | ····} |
24263 | ····[Test] |
24264 | ····public void TestChangeKeyHolderRight() |
24265 | ····{ |
24266 | ········CreateObjects(); |
24267 | ········QueryOther(); |
24268 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24269 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24270 | ········int x = otherVar.RelField.Dummy; |
24271 | ········otherVar.Dummy = 4711; |
24272 | ········pm.Save(); |
24273 | ········pm.UnloadCache(); |
24274 | ········QueryOther(); |
24275 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24276 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24277 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24278 | ····} |
24279 | ····[Test] |
24280 | ····public void TestChangeKeyHolderLeftNoTouch() |
24281 | ····{ |
24282 | ········CreateObjects(); |
24283 | ········QueryOwn(); |
24284 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24285 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24286 | ········ownVar.Dummy = 4711; |
24287 | ········pm.Save(); |
24288 | ········pm.UnloadCache(); |
24289 | ········QueryOwn(); |
24290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24291 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24292 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24293 | ····} |
24294 | ····[Test] |
24295 | ····public void TestChangeKeyHolderRightNoTouch() |
24296 | ····{ |
24297 | ········CreateObjects(); |
24298 | ········QueryOther(); |
24299 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24300 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24301 | ········otherVar.Dummy = 4711; |
24302 | ········pm.Save(); |
24303 | ········pm.UnloadCache(); |
24304 | ········QueryOther(); |
24305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24306 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24307 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24308 | ····} |
24309 | ····[Test] |
24310 | ····public void TestRelationHash() |
24311 | ····{ |
24312 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoLeftBase)); |
24313 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24314 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoRightBase)); |
24315 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24316 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24317 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24318 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoLeftDerived)); |
24319 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24320 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24321 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24322 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoRightDerived)); |
24323 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24324 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24325 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24326 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24327 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24328 | ····} |
24329 | ····void CreateObjects() |
24330 | ····{ |
24331 | ········pm.MakePersistent(ownVar); |
24332 | ········pm.Save(); |
24333 | ········pm.MakePersistent(otherVar); |
24334 | ········pm.Save(); |
24335 | ········pm.Save(); |
24336 | ········ownVar.AssignRelation(otherVar); |
24337 | ········pm.Save(); |
24338 | ········pm.UnloadCache(); |
24339 | ····} |
24340 | ····void QueryOwn() |
24341 | ····{ |
24342 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
24343 | ········ownVar = q.ExecuteSingle(); |
24344 | ····} |
24345 | ····void QueryOther() |
24346 | ····{ |
24347 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>(pm); |
24348 | ········otherVar = q.ExecuteSingle(); |
24349 | ····} |
24350 | } |
24351 | |
24352 | |
24353 | [TestFixture] |
24354 | public class TestAgrBi11OwnpabsOthpabsTblAuto : NDOTest |
24355 | { |
24356 | ····AgrBi11OwnpabsOthpabsTblAutoLeftBase ownVar; |
24357 | ····AgrBi11OwnpabsOthpabsTblAutoRightBase otherVar; |
24358 | ····PersistenceManager pm; |
24359 | ····[SetUp] |
24360 | ····public void Setup() |
24361 | ····{ |
24362 | ········pm = PmFactory.NewPersistenceManager(); |
24363 | ········ownVar = new AgrBi11OwnpabsOthpabsTblAutoLeftDerived(); |
24364 | ········otherVar = new AgrBi11OwnpabsOthpabsTblAutoRightDerived(); |
24365 | ····} |
24366 | ····[TearDown] |
24367 | ····public void TearDown() |
24368 | ····{ |
24369 | ········try |
24370 | ········{ |
24371 | ············pm.UnloadCache(); |
24372 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24373 | ············pm.Delete(l); |
24374 | ············pm.Save(); |
24375 | ············pm.UnloadCache(); |
24376 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24377 | ············pm.Delete(m); |
24378 | ············pm.Save(); |
24379 | ············pm.UnloadCache(); |
24380 | ············decimal count; |
24381 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24382 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24383 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24384 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24385 | ········} |
24386 | ········catch (Exception) |
24387 | ········{ |
24388 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24389 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24390 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24391 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24392 | ········} |
24393 | ····} |
24394 | ····[Test] |
24395 | ····public void TestSaveReload() |
24396 | ····{ |
24397 | ········CreateObjects(); |
24398 | ········QueryOwn(); |
24399 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24400 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24401 | ····} |
24402 | ····[Test] |
24403 | ····public void TestSaveReloadNull() |
24404 | ····{ |
24405 | ········CreateObjects(); |
24406 | ········QueryOwn(); |
24407 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24408 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24409 | ········ownVar.RelField = null; |
24410 | ········pm.Save(); |
24411 | ········pm.UnloadCache(); |
24412 | ········QueryOwn(); |
24413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24414 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24415 | ····} |
24416 | ····[Test] |
24417 | ····public void TestChangeKeyHolderLeft() |
24418 | ····{ |
24419 | ········CreateObjects(); |
24420 | ········QueryOwn(); |
24421 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24422 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24423 | ········int x = ownVar.RelField.Dummy; |
24424 | ········ownVar.Dummy = 4711; |
24425 | ········pm.Save(); |
24426 | ········pm.UnloadCache(); |
24427 | ········QueryOwn(); |
24428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24429 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24430 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24431 | ····} |
24432 | ····[Test] |
24433 | ····public void TestChangeKeyHolderRight() |
24434 | ····{ |
24435 | ········CreateObjects(); |
24436 | ········QueryOther(); |
24437 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24438 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24439 | ········int x = otherVar.RelField.Dummy; |
24440 | ········otherVar.Dummy = 4711; |
24441 | ········pm.Save(); |
24442 | ········pm.UnloadCache(); |
24443 | ········QueryOther(); |
24444 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24445 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24446 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24447 | ····} |
24448 | ····[Test] |
24449 | ····public void TestChangeKeyHolderLeftNoTouch() |
24450 | ····{ |
24451 | ········CreateObjects(); |
24452 | ········QueryOwn(); |
24453 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24454 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24455 | ········ownVar.Dummy = 4711; |
24456 | ········pm.Save(); |
24457 | ········pm.UnloadCache(); |
24458 | ········QueryOwn(); |
24459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24460 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24462 | ····} |
24463 | ····[Test] |
24464 | ····public void TestChangeKeyHolderRightNoTouch() |
24465 | ····{ |
24466 | ········CreateObjects(); |
24467 | ········QueryOther(); |
24468 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24469 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24470 | ········otherVar.Dummy = 4711; |
24471 | ········pm.Save(); |
24472 | ········pm.UnloadCache(); |
24473 | ········QueryOther(); |
24474 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24475 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24476 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24477 | ····} |
24478 | ····[Test] |
24479 | ····public void TestRelationHash() |
24480 | ····{ |
24481 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoLeftBase)); |
24482 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24483 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoRightBase)); |
24484 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24485 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24486 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24487 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoLeftDerived)); |
24488 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24489 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24490 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24491 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoRightDerived)); |
24492 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24493 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24494 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24495 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24496 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24497 | ····} |
24498 | ····void CreateObjects() |
24499 | ····{ |
24500 | ········pm.MakePersistent(ownVar); |
24501 | ········pm.MakePersistent(otherVar); |
24502 | ········pm.Save(); |
24503 | ········ownVar.AssignRelation(otherVar); |
24504 | ········pm.Save(); |
24505 | ········pm.UnloadCache(); |
24506 | ····} |
24507 | ····void QueryOwn() |
24508 | ····{ |
24509 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoLeftBase>(pm); |
24510 | ········ownVar = q.ExecuteSingle(); |
24511 | ····} |
24512 | ····void QueryOther() |
24513 | ····{ |
24514 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoRightBase>(pm); |
24515 | ········otherVar = q.ExecuteSingle(); |
24516 | ····} |
24517 | } |
24518 | |
24519 | |
24520 | [TestFixture] |
24521 | public class TestAgrDirnOwnpabsOthpabsTblAuto : NDOTest |
24522 | { |
24523 | ····AgrDirnOwnpabsOthpabsTblAutoLeftBase ownVar; |
24524 | ····AgrDirnOwnpabsOthpabsTblAutoRightBase otherVar; |
24525 | ····PersistenceManager pm; |
24526 | ····[SetUp] |
24527 | ····public void Setup() |
24528 | ····{ |
24529 | ········pm = PmFactory.NewPersistenceManager(); |
24530 | ········ownVar = new AgrDirnOwnpabsOthpabsTblAutoLeftDerived(); |
24531 | ········otherVar = new AgrDirnOwnpabsOthpabsTblAutoRightDerived(); |
24532 | ····} |
24533 | ····[TearDown] |
24534 | ····public void TearDown() |
24535 | ····{ |
24536 | ········try |
24537 | ········{ |
24538 | ············pm.UnloadCache(); |
24539 | ············var l = pm.Objects<AgrDirnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24540 | ············pm.Delete(l); |
24541 | ············pm.Save(); |
24542 | ············pm.UnloadCache(); |
24543 | ············var m = pm.Objects<AgrDirnOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24544 | ············pm.Delete(m); |
24545 | ············pm.Save(); |
24546 | ············pm.UnloadCache(); |
24547 | ············decimal count; |
24548 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24550 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24552 | ········} |
24553 | ········catch (Exception) |
24554 | ········{ |
24555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24559 | ········} |
24560 | ····} |
24561 | ····[Test] |
24562 | ····public void TestSaveReload() |
24563 | ····{ |
24564 | ········CreateObjects(); |
24565 | ········QueryOwn(); |
24566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24568 | ····} |
24569 | ····[Test] |
24570 | ····public void TestSaveReloadNull() |
24571 | ····{ |
24572 | ········CreateObjects(); |
24573 | ········QueryOwn(); |
24574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24576 | ········ownVar.RelField = new List<AgrDirnOwnpabsOthpabsTblAutoRightBase>(); |
24577 | ········pm.Save(); |
24578 | ········pm.UnloadCache(); |
24579 | ········QueryOwn(); |
24580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24582 | ····} |
24583 | ····[Test] |
24584 | ····public void TestSaveReloadRemove() |
24585 | ····{ |
24586 | ········CreateObjects(); |
24587 | ········QueryOwn(); |
24588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24590 | ········ownVar.RemoveRelatedObject(); |
24591 | ········pm.Save(); |
24592 | ········pm.UnloadCache(); |
24593 | ········QueryOwn(); |
24594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24596 | ····} |
24597 | ····void CreateObjects() |
24598 | ····{ |
24599 | ········pm.MakePersistent(ownVar); |
24600 | ········pm.MakePersistent(otherVar); |
24601 | ········ownVar.AssignRelation(otherVar); |
24602 | ········pm.Save(); |
24603 | ········pm.UnloadCache(); |
24604 | ····} |
24605 | ····void QueryOwn() |
24606 | ····{ |
24607 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoLeftBase>(pm); |
24608 | ········ownVar = q.ExecuteSingle(); |
24609 | ····} |
24610 | ····void QueryOther() |
24611 | ····{ |
24612 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoRightBase>(pm); |
24613 | ········otherVar = q.ExecuteSingle(); |
24614 | ····} |
24615 | } |
24616 | |
24617 | |
24618 | [TestFixture] |
24619 | public class TestAgrBin1OwnpabsOthpabsTblAuto : NDOTest |
24620 | { |
24621 | ····AgrBin1OwnpabsOthpabsTblAutoLeftBase ownVar; |
24622 | ····AgrBin1OwnpabsOthpabsTblAutoRightBase otherVar; |
24623 | ····PersistenceManager pm; |
24624 | ····[SetUp] |
24625 | ····public void Setup() |
24626 | ····{ |
24627 | ········pm = PmFactory.NewPersistenceManager(); |
24628 | ········ownVar = new AgrBin1OwnpabsOthpabsTblAutoLeftDerived(); |
24629 | ········otherVar = new AgrBin1OwnpabsOthpabsTblAutoRightDerived(); |
24630 | ····} |
24631 | ····[TearDown] |
24632 | ····public void TearDown() |
24633 | ····{ |
24634 | ········try |
24635 | ········{ |
24636 | ············pm.UnloadCache(); |
24637 | ············var l = pm.Objects<AgrBin1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24638 | ············pm.Delete(l); |
24639 | ············pm.Save(); |
24640 | ············pm.UnloadCache(); |
24641 | ············var m = pm.Objects<AgrBin1OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24642 | ············pm.Delete(m); |
24643 | ············pm.Save(); |
24644 | ············pm.UnloadCache(); |
24645 | ············decimal count; |
24646 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24647 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24648 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24649 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24650 | ········} |
24651 | ········catch (Exception) |
24652 | ········{ |
24653 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24654 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24655 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24656 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24657 | ········} |
24658 | ····} |
24659 | ····[Test] |
24660 | ····public void TestSaveReload() |
24661 | ····{ |
24662 | ········CreateObjects(); |
24663 | ········QueryOwn(); |
24664 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24665 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24666 | ····} |
24667 | ····[Test] |
24668 | ····public void TestSaveReloadNull() |
24669 | ····{ |
24670 | ········CreateObjects(); |
24671 | ········QueryOwn(); |
24672 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24673 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24674 | ········ownVar.RelField = new List<AgrBin1OwnpabsOthpabsTblAutoRightBase>(); |
24675 | ········pm.Save(); |
24676 | ········pm.UnloadCache(); |
24677 | ········QueryOwn(); |
24678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24679 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24680 | ····} |
24681 | ····[Test] |
24682 | ····public void TestSaveReloadRemove() |
24683 | ····{ |
24684 | ········CreateObjects(); |
24685 | ········QueryOwn(); |
24686 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24687 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24688 | ········ownVar.RemoveRelatedObject(); |
24689 | ········pm.Save(); |
24690 | ········pm.UnloadCache(); |
24691 | ········QueryOwn(); |
24692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24693 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24694 | ····} |
24695 | ····[Test] |
24696 | ····public void TestChangeKeyHolderRight() |
24697 | ····{ |
24698 | ········CreateObjects(); |
24699 | ········QueryOther(); |
24700 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24701 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24702 | ········int x = otherVar.RelField.Dummy; |
24703 | ········otherVar.Dummy = 4711; |
24704 | ········pm.Save(); |
24705 | ········pm.UnloadCache(); |
24706 | ········QueryOther(); |
24707 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24708 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24709 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24710 | ····} |
24711 | ····[Test] |
24712 | ····public void TestChangeKeyHolderRightNoTouch() |
24713 | ····{ |
24714 | ········CreateObjects(); |
24715 | ········QueryOther(); |
24716 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24717 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24718 | ········otherVar.Dummy = 4711; |
24719 | ········pm.Save(); |
24720 | ········pm.UnloadCache(); |
24721 | ········QueryOther(); |
24722 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24723 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24724 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24725 | ····} |
24726 | ····[Test] |
24727 | ····public void TestRelationHash() |
24728 | ····{ |
24729 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoLeftBase)); |
24730 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24731 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoRightBase)); |
24732 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24733 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24734 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24735 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoLeftDerived)); |
24736 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24737 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24738 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24739 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoRightDerived)); |
24740 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24741 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24742 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24743 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24744 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24745 | ····} |
24746 | ····void CreateObjects() |
24747 | ····{ |
24748 | ········pm.MakePersistent(ownVar); |
24749 | ········pm.MakePersistent(otherVar); |
24750 | ········pm.Save(); |
24751 | ········ownVar.AssignRelation(otherVar); |
24752 | ········pm.Save(); |
24753 | ········pm.UnloadCache(); |
24754 | ····} |
24755 | ····void QueryOwn() |
24756 | ····{ |
24757 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoLeftBase>(pm); |
24758 | ········ownVar = q.ExecuteSingle(); |
24759 | ····} |
24760 | ····void QueryOther() |
24761 | ····{ |
24762 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoRightBase>(pm); |
24763 | ········otherVar = q.ExecuteSingle(); |
24764 | ····} |
24765 | } |
24766 | |
24767 | |
24768 | [TestFixture] |
24769 | public class TestAgrBi1nOwnpabsOthpabsTblAuto : NDOTest |
24770 | { |
24771 | ····AgrBi1nOwnpabsOthpabsTblAutoLeftBase ownVar; |
24772 | ····AgrBi1nOwnpabsOthpabsTblAutoRightBase otherVar; |
24773 | ····PersistenceManager pm; |
24774 | ····[SetUp] |
24775 | ····public void Setup() |
24776 | ····{ |
24777 | ········pm = PmFactory.NewPersistenceManager(); |
24778 | ········ownVar = new AgrBi1nOwnpabsOthpabsTblAutoLeftDerived(); |
24779 | ········otherVar = new AgrBi1nOwnpabsOthpabsTblAutoRightDerived(); |
24780 | ····} |
24781 | ····[TearDown] |
24782 | ····public void TearDown() |
24783 | ····{ |
24784 | ········try |
24785 | ········{ |
24786 | ············pm.UnloadCache(); |
24787 | ············var l = pm.Objects<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24788 | ············pm.Delete(l); |
24789 | ············pm.Save(); |
24790 | ············pm.UnloadCache(); |
24791 | ············var m = pm.Objects<AgrBi1nOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24792 | ············pm.Delete(m); |
24793 | ············pm.Save(); |
24794 | ············pm.UnloadCache(); |
24795 | ············decimal count; |
24796 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24797 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24798 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24799 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24800 | ········} |
24801 | ········catch (Exception) |
24802 | ········{ |
24803 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24804 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24805 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24806 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24807 | ········} |
24808 | ····} |
24809 | ····[Test] |
24810 | ····public void TestSaveReload() |
24811 | ····{ |
24812 | ········CreateObjects(); |
24813 | ········QueryOwn(); |
24814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24815 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24816 | ····} |
24817 | ····[Test] |
24818 | ····public void TestSaveReloadNull() |
24819 | ····{ |
24820 | ········CreateObjects(); |
24821 | ········QueryOwn(); |
24822 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24823 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24824 | ········ownVar.RelField = null; |
24825 | ········pm.Save(); |
24826 | ········pm.UnloadCache(); |
24827 | ········QueryOwn(); |
24828 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24829 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24830 | ····} |
24831 | ····[Test] |
24832 | ····public void TestChangeKeyHolderLeft() |
24833 | ····{ |
24834 | ········CreateObjects(); |
24835 | ········QueryOwn(); |
24836 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24837 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24838 | ········int x = ownVar.RelField.Dummy; |
24839 | ········ownVar.Dummy = 4711; |
24840 | ········pm.Save(); |
24841 | ········pm.UnloadCache(); |
24842 | ········QueryOwn(); |
24843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24844 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24845 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24846 | ····} |
24847 | ····[Test] |
24848 | ····public void TestChangeKeyHolderLeftNoTouch() |
24849 | ····{ |
24850 | ········CreateObjects(); |
24851 | ········QueryOwn(); |
24852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24853 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24854 | ········ownVar.Dummy = 4711; |
24855 | ········pm.Save(); |
24856 | ········pm.UnloadCache(); |
24857 | ········QueryOwn(); |
24858 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24859 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24861 | ····} |
24862 | ····[Test] |
24863 | ····public void TestRelationHash() |
24864 | ····{ |
24865 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoLeftBase)); |
24866 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24867 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoRightBase)); |
24868 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24869 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24870 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24871 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoLeftDerived)); |
24872 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24873 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24874 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24875 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoRightDerived)); |
24876 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24877 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24878 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24879 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24880 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24881 | ····} |
24882 | ····void CreateObjects() |
24883 | ····{ |
24884 | ········pm.MakePersistent(ownVar); |
24885 | ········pm.MakePersistent(otherVar); |
24886 | ········ownVar.AssignRelation(otherVar); |
24887 | ········pm.Save(); |
24888 | ········pm.UnloadCache(); |
24889 | ····} |
24890 | ····void QueryOwn() |
24891 | ····{ |
24892 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>(pm); |
24893 | ········ownVar = q.ExecuteSingle(); |
24894 | ····} |
24895 | ····void QueryOther() |
24896 | ····{ |
24897 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoRightBase>(pm); |
24898 | ········otherVar = q.ExecuteSingle(); |
24899 | ····} |
24900 | } |
24901 | |
24902 | |
24903 | [TestFixture] |
24904 | public class TestAgrBinnOwnpabsOthpabsTblAuto : NDOTest |
24905 | { |
24906 | ····AgrBinnOwnpabsOthpabsTblAutoLeftBase ownVar; |
24907 | ····AgrBinnOwnpabsOthpabsTblAutoRightBase otherVar; |
24908 | ····PersistenceManager pm; |
24909 | ····[SetUp] |
24910 | ····public void Setup() |
24911 | ····{ |
24912 | ········pm = PmFactory.NewPersistenceManager(); |
24913 | ········ownVar = new AgrBinnOwnpabsOthpabsTblAutoLeftDerived(); |
24914 | ········otherVar = new AgrBinnOwnpabsOthpabsTblAutoRightDerived(); |
24915 | ····} |
24916 | ····[TearDown] |
24917 | ····public void TearDown() |
24918 | ····{ |
24919 | ········try |
24920 | ········{ |
24921 | ············pm.UnloadCache(); |
24922 | ············var l = pm.Objects<AgrBinnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24923 | ············pm.Delete(l); |
24924 | ············pm.Save(); |
24925 | ············pm.UnloadCache(); |
24926 | ············var m = pm.Objects<AgrBinnOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24927 | ············pm.Delete(m); |
24928 | ············pm.Save(); |
24929 | ············pm.UnloadCache(); |
24930 | ············decimal count; |
24931 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24932 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24933 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24934 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24935 | ········} |
24936 | ········catch (Exception) |
24937 | ········{ |
24938 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24939 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24940 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24941 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24942 | ········} |
24943 | ····} |
24944 | ····[Test] |
24945 | ····public void TestSaveReload() |
24946 | ····{ |
24947 | ········CreateObjects(); |
24948 | ········QueryOwn(); |
24949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24950 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24951 | ····} |
24952 | ····[Test] |
24953 | ····public void TestSaveReloadNull() |
24954 | ····{ |
24955 | ········CreateObjects(); |
24956 | ········QueryOwn(); |
24957 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24958 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24959 | ········ownVar.RelField = new List<AgrBinnOwnpabsOthpabsTblAutoRightBase>(); |
24960 | ········pm.Save(); |
24961 | ········pm.UnloadCache(); |
24962 | ········QueryOwn(); |
24963 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24964 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24965 | ····} |
24966 | ····[Test] |
24967 | ····public void TestSaveReloadRemove() |
24968 | ····{ |
24969 | ········CreateObjects(); |
24970 | ········QueryOwn(); |
24971 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24972 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24973 | ········ownVar.RemoveRelatedObject(); |
24974 | ········pm.Save(); |
24975 | ········pm.UnloadCache(); |
24976 | ········QueryOwn(); |
24977 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24978 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24979 | ····} |
24980 | ····[Test] |
24981 | ····public void TestRelationHash() |
24982 | ····{ |
24983 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoLeftBase)); |
24984 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24985 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoRightBase)); |
24986 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24987 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24988 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24989 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoLeftDerived)); |
24990 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24991 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24992 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24993 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoRightDerived)); |
24994 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24995 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24996 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24997 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24998 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24999 | ····} |
25000 | ····void CreateObjects() |
25001 | ····{ |
25002 | ········pm.MakePersistent(ownVar); |
25003 | ········pm.MakePersistent(otherVar); |
25004 | ········ownVar.AssignRelation(otherVar); |
25005 | ········pm.Save(); |
25006 | ········pm.UnloadCache(); |
25007 | ····} |
25008 | ····void QueryOwn() |
25009 | ····{ |
25010 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25011 | ········ownVar = q.ExecuteSingle(); |
25012 | ····} |
25013 | ····void QueryOther() |
25014 | ····{ |
25015 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoRightBase>(pm); |
25016 | ········otherVar = q.ExecuteSingle(); |
25017 | ····} |
25018 | } |
25019 | |
25020 | |
25021 | [TestFixture] |
25022 | public class TestCmpDir1OwnpabsOthpabsNoTblAuto : NDOTest |
25023 | { |
25024 | ····CmpDir1OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
25025 | ····CmpDir1OwnpabsOthpabsNoTblAutoRightBase otherVar; |
25026 | ····PersistenceManager pm; |
25027 | ····[SetUp] |
25028 | ····public void Setup() |
25029 | ····{ |
25030 | ········pm = PmFactory.NewPersistenceManager(); |
25031 | ········ownVar = new CmpDir1OwnpabsOthpabsNoTblAutoLeftDerived(); |
25032 | ········otherVar = new CmpDir1OwnpabsOthpabsNoTblAutoRightDerived(); |
25033 | ····} |
25034 | ····[TearDown] |
25035 | ····public void TearDown() |
25036 | ····{ |
25037 | ········try |
25038 | ········{ |
25039 | ············pm.UnloadCache(); |
25040 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
25041 | ············pm.Delete(l); |
25042 | ············pm.Save(); |
25043 | ············pm.UnloadCache(); |
25044 | ············decimal count; |
25045 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25046 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25047 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25048 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25049 | ········} |
25050 | ········catch (Exception) |
25051 | ········{ |
25052 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25053 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25054 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25055 | ········} |
25056 | ····} |
25057 | ····[Test] |
25058 | ····public void TestSaveReload() |
25059 | ····{ |
25060 | ········bool thrown = false; |
25061 | ········try |
25062 | ········{ |
25063 | ············CreateObjects(); |
25064 | ············QueryOwn(); |
25065 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25066 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25067 | ········} |
25068 | ········catch (NDOException) |
25069 | ········{ |
25070 | ············thrown = true; |
25071 | ········} |
25072 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25073 | ····} |
25074 | ····[Test] |
25075 | ····public void TestSaveReloadNull() |
25076 | ····{ |
25077 | ········bool thrown = false; |
25078 | ········try |
25079 | ········{ |
25080 | ············CreateObjects(); |
25081 | ············QueryOwn(); |
25082 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25083 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25084 | ············ownVar.RelField = null; |
25085 | ············pm.Save(); |
25086 | ············pm.UnloadCache(); |
25087 | ············QueryOwn(); |
25088 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25089 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25090 | ········} |
25091 | ········catch (NDOException) |
25092 | ········{ |
25093 | ············thrown = true; |
25094 | ········} |
25095 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25096 | ····} |
25097 | ····void CreateObjects() |
25098 | ····{ |
25099 | ········pm.MakePersistent(ownVar); |
25100 | ········pm.Save(); |
25101 | ········ownVar.AssignRelation(otherVar); |
25102 | ········pm.Save(); |
25103 | ········pm.UnloadCache(); |
25104 | ····} |
25105 | ····void QueryOwn() |
25106 | ····{ |
25107 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
25108 | ········ownVar = q.ExecuteSingle(); |
25109 | ····} |
25110 | ····void QueryOther() |
25111 | ····{ |
25112 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoRightBase>(pm); |
25113 | ········otherVar = q.ExecuteSingle(); |
25114 | ····} |
25115 | } |
25116 | |
25117 | |
25118 | [TestFixture] |
25119 | public class TestCmpDir1OwnpabsOthpabsTblAuto : NDOTest |
25120 | { |
25121 | ····CmpDir1OwnpabsOthpabsTblAutoLeftBase ownVar; |
25122 | ····CmpDir1OwnpabsOthpabsTblAutoRightBase otherVar; |
25123 | ····PersistenceManager pm; |
25124 | ····[SetUp] |
25125 | ····public void Setup() |
25126 | ····{ |
25127 | ········pm = PmFactory.NewPersistenceManager(); |
25128 | ········ownVar = new CmpDir1OwnpabsOthpabsTblAutoLeftDerived(); |
25129 | ········otherVar = new CmpDir1OwnpabsOthpabsTblAutoRightDerived(); |
25130 | ····} |
25131 | ····[TearDown] |
25132 | ····public void TearDown() |
25133 | ····{ |
25134 | ········try |
25135 | ········{ |
25136 | ············pm.UnloadCache(); |
25137 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25138 | ············pm.Delete(l); |
25139 | ············pm.Save(); |
25140 | ············pm.UnloadCache(); |
25141 | ············decimal count; |
25142 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25143 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25144 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25145 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25146 | ········} |
25147 | ········catch (Exception) |
25148 | ········{ |
25149 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25150 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25151 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25152 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25153 | ········} |
25154 | ····} |
25155 | ····[Test] |
25156 | ····public void TestSaveReload() |
25157 | ····{ |
25158 | ········CreateObjects(); |
25159 | ········QueryOwn(); |
25160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25161 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25162 | ····} |
25163 | ····[Test] |
25164 | ····public void TestSaveReloadNull() |
25165 | ····{ |
25166 | ········CreateObjects(); |
25167 | ········QueryOwn(); |
25168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25169 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25170 | ········ownVar.RelField = null; |
25171 | ········pm.Save(); |
25172 | ········pm.UnloadCache(); |
25173 | ········QueryOwn(); |
25174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25175 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25176 | ····} |
25177 | ····[Test] |
25178 | ····public void TestChangeKeyHolderLeft() |
25179 | ····{ |
25180 | ········CreateObjects(); |
25181 | ········QueryOwn(); |
25182 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25183 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25184 | ········int x = ownVar.RelField.Dummy; |
25185 | ········ownVar.Dummy = 4711; |
25186 | ········pm.Save(); |
25187 | ········pm.UnloadCache(); |
25188 | ········QueryOwn(); |
25189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25190 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25191 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25192 | ····} |
25193 | ····[Test] |
25194 | ····public void TestChangeKeyHolderLeftNoTouch() |
25195 | ····{ |
25196 | ········CreateObjects(); |
25197 | ········QueryOwn(); |
25198 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25199 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25200 | ········ownVar.Dummy = 4711; |
25201 | ········pm.Save(); |
25202 | ········pm.UnloadCache(); |
25203 | ········QueryOwn(); |
25204 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25205 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25207 | ····} |
25208 | ····void CreateObjects() |
25209 | ····{ |
25210 | ········pm.MakePersistent(ownVar); |
25211 | ········ownVar.AssignRelation(otherVar); |
25212 | ········pm.Save(); |
25213 | ········pm.UnloadCache(); |
25214 | ····} |
25215 | ····void QueryOwn() |
25216 | ····{ |
25217 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoLeftBase>(pm); |
25218 | ········ownVar = q.ExecuteSingle(); |
25219 | ····} |
25220 | ····void QueryOther() |
25221 | ····{ |
25222 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoRightBase>(pm); |
25223 | ········otherVar = q.ExecuteSingle(); |
25224 | ····} |
25225 | } |
25226 | |
25227 | |
25228 | [TestFixture] |
25229 | public class TestCmpBi11OwnpabsOthpabsNoTblAuto : NDOTest |
25230 | { |
25231 | ····CmpBi11OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
25232 | ····CmpBi11OwnpabsOthpabsNoTblAutoRightBase otherVar; |
25233 | ····PersistenceManager pm; |
25234 | ····[SetUp] |
25235 | ····public void Setup() |
25236 | ····{ |
25237 | ········pm = PmFactory.NewPersistenceManager(); |
25238 | ········ownVar = new CmpBi11OwnpabsOthpabsNoTblAutoLeftDerived(); |
25239 | ········otherVar = new CmpBi11OwnpabsOthpabsNoTblAutoRightDerived(); |
25240 | ····} |
25241 | ····[TearDown] |
25242 | ····public void TearDown() |
25243 | ····{ |
25244 | ········try |
25245 | ········{ |
25246 | ············pm.UnloadCache(); |
25247 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
25248 | ············pm.Delete(l); |
25249 | ············pm.Save(); |
25250 | ············pm.UnloadCache(); |
25251 | ············decimal count; |
25252 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25253 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25254 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25255 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25256 | ········} |
25257 | ········catch (Exception) |
25258 | ········{ |
25259 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25260 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25261 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25262 | ········} |
25263 | ····} |
25264 | ····[Test] |
25265 | ····public void TestSaveReload() |
25266 | ····{ |
25267 | ········bool thrown = false; |
25268 | ········try |
25269 | ········{ |
25270 | ············CreateObjects(); |
25271 | ············QueryOwn(); |
25272 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25273 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25274 | ········} |
25275 | ········catch (NDOException) |
25276 | ········{ |
25277 | ············thrown = true; |
25278 | ········} |
25279 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25280 | ····} |
25281 | ····[Test] |
25282 | ····public void TestSaveReloadNull() |
25283 | ····{ |
25284 | ········bool thrown = false; |
25285 | ········try |
25286 | ········{ |
25287 | ············CreateObjects(); |
25288 | ············QueryOwn(); |
25289 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25290 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25291 | ············ownVar.RelField = null; |
25292 | ············pm.Save(); |
25293 | ············pm.UnloadCache(); |
25294 | ············QueryOwn(); |
25295 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25296 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25297 | ········} |
25298 | ········catch (NDOException) |
25299 | ········{ |
25300 | ············thrown = true; |
25301 | ········} |
25302 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25303 | ····} |
25304 | ····[Test] |
25305 | ····public void TestRelationHash() |
25306 | ····{ |
25307 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoLeftBase)); |
25308 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25309 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoRightBase)); |
25310 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25311 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25312 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25313 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoLeftDerived)); |
25314 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25315 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25316 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25317 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoRightDerived)); |
25318 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25319 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25320 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25321 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25322 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25323 | ····} |
25324 | ····void CreateObjects() |
25325 | ····{ |
25326 | ········pm.MakePersistent(ownVar); |
25327 | ········pm.Save(); |
25328 | ········ownVar.AssignRelation(otherVar); |
25329 | ········pm.Save(); |
25330 | ········pm.UnloadCache(); |
25331 | ····} |
25332 | ····void QueryOwn() |
25333 | ····{ |
25334 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
25335 | ········ownVar = q.ExecuteSingle(); |
25336 | ····} |
25337 | ····void QueryOther() |
25338 | ····{ |
25339 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoRightBase>(pm); |
25340 | ········otherVar = q.ExecuteSingle(); |
25341 | ····} |
25342 | } |
25343 | |
25344 | |
25345 | [TestFixture] |
25346 | public class TestCmpBi11OwnpabsOthpabsTblAuto : NDOTest |
25347 | { |
25348 | ····CmpBi11OwnpabsOthpabsTblAutoLeftBase ownVar; |
25349 | ····CmpBi11OwnpabsOthpabsTblAutoRightBase otherVar; |
25350 | ····PersistenceManager pm; |
25351 | ····[SetUp] |
25352 | ····public void Setup() |
25353 | ····{ |
25354 | ········pm = PmFactory.NewPersistenceManager(); |
25355 | ········ownVar = new CmpBi11OwnpabsOthpabsTblAutoLeftDerived(); |
25356 | ········otherVar = new CmpBi11OwnpabsOthpabsTblAutoRightDerived(); |
25357 | ····} |
25358 | ····[TearDown] |
25359 | ····public void TearDown() |
25360 | ····{ |
25361 | ········try |
25362 | ········{ |
25363 | ············pm.UnloadCache(); |
25364 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25365 | ············pm.Delete(l); |
25366 | ············pm.Save(); |
25367 | ············pm.UnloadCache(); |
25368 | ············decimal count; |
25369 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25370 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25371 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25372 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25373 | ········} |
25374 | ········catch (Exception) |
25375 | ········{ |
25376 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25377 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25378 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25379 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25380 | ········} |
25381 | ····} |
25382 | ····[Test] |
25383 | ····public void TestSaveReload() |
25384 | ····{ |
25385 | ········CreateObjects(); |
25386 | ········QueryOwn(); |
25387 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25388 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25389 | ····} |
25390 | ····[Test] |
25391 | ····public void TestSaveReloadNull() |
25392 | ····{ |
25393 | ········CreateObjects(); |
25394 | ········QueryOwn(); |
25395 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25396 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25397 | ········ownVar.RelField = null; |
25398 | ········pm.Save(); |
25399 | ········pm.UnloadCache(); |
25400 | ········QueryOwn(); |
25401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25402 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25403 | ····} |
25404 | ····[Test] |
25405 | ····public void TestChangeKeyHolderLeft() |
25406 | ····{ |
25407 | ········CreateObjects(); |
25408 | ········QueryOwn(); |
25409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25410 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25411 | ········int x = ownVar.RelField.Dummy; |
25412 | ········ownVar.Dummy = 4711; |
25413 | ········pm.Save(); |
25414 | ········pm.UnloadCache(); |
25415 | ········QueryOwn(); |
25416 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25417 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25419 | ····} |
25420 | ····[Test] |
25421 | ····public void TestChangeKeyHolderRight() |
25422 | ····{ |
25423 | ········CreateObjects(); |
25424 | ········QueryOther(); |
25425 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25426 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25427 | ········int x = otherVar.RelField.Dummy; |
25428 | ········otherVar.Dummy = 4711; |
25429 | ········pm.Save(); |
25430 | ········pm.UnloadCache(); |
25431 | ········QueryOther(); |
25432 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25433 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25434 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25435 | ····} |
25436 | ····[Test] |
25437 | ····public void TestChangeKeyHolderLeftNoTouch() |
25438 | ····{ |
25439 | ········CreateObjects(); |
25440 | ········QueryOwn(); |
25441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25442 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25443 | ········ownVar.Dummy = 4711; |
25444 | ········pm.Save(); |
25445 | ········pm.UnloadCache(); |
25446 | ········QueryOwn(); |
25447 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25448 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25449 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25450 | ····} |
25451 | ····[Test] |
25452 | ····public void TestChangeKeyHolderRightNoTouch() |
25453 | ····{ |
25454 | ········CreateObjects(); |
25455 | ········QueryOther(); |
25456 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25457 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25458 | ········otherVar.Dummy = 4711; |
25459 | ········pm.Save(); |
25460 | ········pm.UnloadCache(); |
25461 | ········QueryOther(); |
25462 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25463 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25464 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25465 | ····} |
25466 | ····[Test] |
25467 | ····public void TestRelationHash() |
25468 | ····{ |
25469 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoLeftBase)); |
25470 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25471 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoRightBase)); |
25472 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25473 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25474 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25475 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoLeftDerived)); |
25476 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25477 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25478 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25479 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoRightDerived)); |
25480 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25481 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25482 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25483 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25484 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25485 | ····} |
25486 | ····void CreateObjects() |
25487 | ····{ |
25488 | ········pm.MakePersistent(ownVar); |
25489 | ········ownVar.AssignRelation(otherVar); |
25490 | ········pm.Save(); |
25491 | ········pm.UnloadCache(); |
25492 | ····} |
25493 | ····void QueryOwn() |
25494 | ····{ |
25495 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoLeftBase>(pm); |
25496 | ········ownVar = q.ExecuteSingle(); |
25497 | ····} |
25498 | ····void QueryOther() |
25499 | ····{ |
25500 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoRightBase>(pm); |
25501 | ········otherVar = q.ExecuteSingle(); |
25502 | ····} |
25503 | } |
25504 | |
25505 | |
25506 | [TestFixture] |
25507 | public class TestCmpDirnOwnpabsOthpabsTblAuto : NDOTest |
25508 | { |
25509 | ····CmpDirnOwnpabsOthpabsTblAutoLeftBase ownVar; |
25510 | ····CmpDirnOwnpabsOthpabsTblAutoRightBase otherVar; |
25511 | ····PersistenceManager pm; |
25512 | ····[SetUp] |
25513 | ····public void Setup() |
25514 | ····{ |
25515 | ········pm = PmFactory.NewPersistenceManager(); |
25516 | ········ownVar = new CmpDirnOwnpabsOthpabsTblAutoLeftDerived(); |
25517 | ········otherVar = new CmpDirnOwnpabsOthpabsTblAutoRightDerived(); |
25518 | ····} |
25519 | ····[TearDown] |
25520 | ····public void TearDown() |
25521 | ····{ |
25522 | ········try |
25523 | ········{ |
25524 | ············pm.UnloadCache(); |
25525 | ············var l = pm.Objects<CmpDirnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25526 | ············pm.Delete(l); |
25527 | ············pm.Save(); |
25528 | ············pm.UnloadCache(); |
25529 | ············decimal count; |
25530 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25532 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25533 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25534 | ········} |
25535 | ········catch (Exception) |
25536 | ········{ |
25537 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25538 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25539 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25540 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25541 | ········} |
25542 | ····} |
25543 | ····[Test] |
25544 | ····public void TestSaveReload() |
25545 | ····{ |
25546 | ········CreateObjects(); |
25547 | ········QueryOwn(); |
25548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25549 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25550 | ····} |
25551 | ····[Test] |
25552 | ····public void TestSaveReloadNull() |
25553 | ····{ |
25554 | ········CreateObjects(); |
25555 | ········QueryOwn(); |
25556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25557 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25558 | ········ownVar.RelField = new List<CmpDirnOwnpabsOthpabsTblAutoRightBase>(); |
25559 | ········pm.Save(); |
25560 | ········pm.UnloadCache(); |
25561 | ········QueryOwn(); |
25562 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25563 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25564 | ····} |
25565 | ····[Test] |
25566 | ····public void TestSaveReloadRemove() |
25567 | ····{ |
25568 | ········CreateObjects(); |
25569 | ········QueryOwn(); |
25570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25571 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25572 | ········ownVar.RemoveRelatedObject(); |
25573 | ········pm.Save(); |
25574 | ········pm.UnloadCache(); |
25575 | ········QueryOwn(); |
25576 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25577 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25578 | ····} |
25579 | ····void CreateObjects() |
25580 | ····{ |
25581 | ········pm.MakePersistent(ownVar); |
25582 | ········ownVar.AssignRelation(otherVar); |
25583 | ········pm.Save(); |
25584 | ········pm.UnloadCache(); |
25585 | ····} |
25586 | ····void QueryOwn() |
25587 | ····{ |
25588 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25589 | ········ownVar = q.ExecuteSingle(); |
25590 | ····} |
25591 | ····void QueryOther() |
25592 | ····{ |
25593 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoRightBase>(pm); |
25594 | ········otherVar = q.ExecuteSingle(); |
25595 | ····} |
25596 | } |
25597 | |
25598 | |
25599 | [TestFixture] |
25600 | public class TestCmpBin1OwnpabsOthpabsTblAuto : NDOTest |
25601 | { |
25602 | ····CmpBin1OwnpabsOthpabsTblAutoLeftBase ownVar; |
25603 | ····CmpBin1OwnpabsOthpabsTblAutoRightBase otherVar; |
25604 | ····PersistenceManager pm; |
25605 | ····[SetUp] |
25606 | ····public void Setup() |
25607 | ····{ |
25608 | ········pm = PmFactory.NewPersistenceManager(); |
25609 | ········ownVar = new CmpBin1OwnpabsOthpabsTblAutoLeftDerived(); |
25610 | ········otherVar = new CmpBin1OwnpabsOthpabsTblAutoRightDerived(); |
25611 | ····} |
25612 | ····[TearDown] |
25613 | ····public void TearDown() |
25614 | ····{ |
25615 | ········try |
25616 | ········{ |
25617 | ············pm.UnloadCache(); |
25618 | ············var l = pm.Objects<CmpBin1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25619 | ············pm.Delete(l); |
25620 | ············pm.Save(); |
25621 | ············pm.UnloadCache(); |
25622 | ············decimal count; |
25623 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25625 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25626 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25627 | ········} |
25628 | ········catch (Exception) |
25629 | ········{ |
25630 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25631 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25632 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25633 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25634 | ········} |
25635 | ····} |
25636 | ····[Test] |
25637 | ····public void TestSaveReload() |
25638 | ····{ |
25639 | ········CreateObjects(); |
25640 | ········QueryOwn(); |
25641 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25642 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25643 | ····} |
25644 | ····[Test] |
25645 | ····public void TestSaveReloadNull() |
25646 | ····{ |
25647 | ········CreateObjects(); |
25648 | ········QueryOwn(); |
25649 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25650 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25651 | ········ownVar.RelField = new List<CmpBin1OwnpabsOthpabsTblAutoRightBase>(); |
25652 | ········pm.Save(); |
25653 | ········pm.UnloadCache(); |
25654 | ········QueryOwn(); |
25655 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25656 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25657 | ····} |
25658 | ····[Test] |
25659 | ····public void TestSaveReloadRemove() |
25660 | ····{ |
25661 | ········CreateObjects(); |
25662 | ········QueryOwn(); |
25663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25664 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25665 | ········ownVar.RemoveRelatedObject(); |
25666 | ········pm.Save(); |
25667 | ········pm.UnloadCache(); |
25668 | ········QueryOwn(); |
25669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25670 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25671 | ····} |
25672 | ····[Test] |
25673 | ····public void TestChangeKeyHolderRight() |
25674 | ····{ |
25675 | ········CreateObjects(); |
25676 | ········QueryOther(); |
25677 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25678 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25679 | ········int x = otherVar.RelField.Dummy; |
25680 | ········otherVar.Dummy = 4711; |
25681 | ········pm.Save(); |
25682 | ········pm.UnloadCache(); |
25683 | ········QueryOther(); |
25684 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25685 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25686 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25687 | ····} |
25688 | ····[Test] |
25689 | ····public void TestChangeKeyHolderRightNoTouch() |
25690 | ····{ |
25691 | ········CreateObjects(); |
25692 | ········QueryOther(); |
25693 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25694 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25695 | ········otherVar.Dummy = 4711; |
25696 | ········pm.Save(); |
25697 | ········pm.UnloadCache(); |
25698 | ········QueryOther(); |
25699 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25700 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25701 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25702 | ····} |
25703 | ····[Test] |
25704 | ····public void TestRelationHash() |
25705 | ····{ |
25706 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoLeftBase)); |
25707 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25708 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoRightBase)); |
25709 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25710 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25711 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25712 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoLeftDerived)); |
25713 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25714 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25715 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25716 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoRightDerived)); |
25717 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25718 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25719 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25720 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25721 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25722 | ····} |
25723 | ····void CreateObjects() |
25724 | ····{ |
25725 | ········pm.MakePersistent(ownVar); |
25726 | ········ownVar.AssignRelation(otherVar); |
25727 | ········pm.Save(); |
25728 | ········pm.UnloadCache(); |
25729 | ····} |
25730 | ····void QueryOwn() |
25731 | ····{ |
25732 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoLeftBase>(pm); |
25733 | ········ownVar = q.ExecuteSingle(); |
25734 | ····} |
25735 | ····void QueryOther() |
25736 | ····{ |
25737 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoRightBase>(pm); |
25738 | ········otherVar = q.ExecuteSingle(); |
25739 | ····} |
25740 | } |
25741 | |
25742 | |
25743 | [TestFixture] |
25744 | public class TestCmpBi1nOwnpabsOthpabsTblAuto : NDOTest |
25745 | { |
25746 | ····CmpBi1nOwnpabsOthpabsTblAutoLeftBase ownVar; |
25747 | ····CmpBi1nOwnpabsOthpabsTblAutoRightBase otherVar; |
25748 | ····PersistenceManager pm; |
25749 | ····[SetUp] |
25750 | ····public void Setup() |
25751 | ····{ |
25752 | ········pm = PmFactory.NewPersistenceManager(); |
25753 | ········ownVar = new CmpBi1nOwnpabsOthpabsTblAutoLeftDerived(); |
25754 | ········otherVar = new CmpBi1nOwnpabsOthpabsTblAutoRightDerived(); |
25755 | ····} |
25756 | ····[TearDown] |
25757 | ····public void TearDown() |
25758 | ····{ |
25759 | ········try |
25760 | ········{ |
25761 | ············pm.UnloadCache(); |
25762 | ············var l = pm.Objects<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25763 | ············pm.Delete(l); |
25764 | ············pm.Save(); |
25765 | ············pm.UnloadCache(); |
25766 | ············decimal count; |
25767 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25768 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25769 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25770 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25771 | ········} |
25772 | ········catch (Exception) |
25773 | ········{ |
25774 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25775 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25776 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25777 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25778 | ········} |
25779 | ····} |
25780 | ····[Test] |
25781 | ····public void TestSaveReload() |
25782 | ····{ |
25783 | ········CreateObjects(); |
25784 | ········QueryOwn(); |
25785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25787 | ····} |
25788 | ····[Test] |
25789 | ····public void TestSaveReloadNull() |
25790 | ····{ |
25791 | ········CreateObjects(); |
25792 | ········QueryOwn(); |
25793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25794 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25795 | ········ownVar.RelField = null; |
25796 | ········pm.Save(); |
25797 | ········pm.UnloadCache(); |
25798 | ········QueryOwn(); |
25799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25800 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25801 | ····} |
25802 | ····[Test] |
25803 | ····public void TestChangeKeyHolderLeft() |
25804 | ····{ |
25805 | ········CreateObjects(); |
25806 | ········QueryOwn(); |
25807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25809 | ········int x = ownVar.RelField.Dummy; |
25810 | ········ownVar.Dummy = 4711; |
25811 | ········pm.Save(); |
25812 | ········pm.UnloadCache(); |
25813 | ········QueryOwn(); |
25814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25815 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25817 | ····} |
25818 | ····[Test] |
25819 | ····public void TestChangeKeyHolderLeftNoTouch() |
25820 | ····{ |
25821 | ········CreateObjects(); |
25822 | ········QueryOwn(); |
25823 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25824 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25825 | ········ownVar.Dummy = 4711; |
25826 | ········pm.Save(); |
25827 | ········pm.UnloadCache(); |
25828 | ········QueryOwn(); |
25829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25830 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25831 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25832 | ····} |
25833 | ····[Test] |
25834 | ····public void TestRelationHash() |
25835 | ····{ |
25836 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoLeftBase)); |
25837 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25838 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoRightBase)); |
25839 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25840 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25841 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25842 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoLeftDerived)); |
25843 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25844 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25845 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25846 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoRightDerived)); |
25847 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25848 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25849 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25850 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25851 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25852 | ····} |
25853 | ····void CreateObjects() |
25854 | ····{ |
25855 | ········pm.MakePersistent(ownVar); |
25856 | ········ownVar.AssignRelation(otherVar); |
25857 | ········pm.Save(); |
25858 | ········pm.UnloadCache(); |
25859 | ····} |
25860 | ····void QueryOwn() |
25861 | ····{ |
25862 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>(pm); |
25863 | ········ownVar = q.ExecuteSingle(); |
25864 | ····} |
25865 | ····void QueryOther() |
25866 | ····{ |
25867 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoRightBase>(pm); |
25868 | ········otherVar = q.ExecuteSingle(); |
25869 | ····} |
25870 | } |
25871 | |
25872 | |
25873 | [TestFixture] |
25874 | public class TestCmpBinnOwnpabsOthpabsTblAuto : NDOTest |
25875 | { |
25876 | ····CmpBinnOwnpabsOthpabsTblAutoLeftBase ownVar; |
25877 | ····CmpBinnOwnpabsOthpabsTblAutoRightBase otherVar; |
25878 | ····PersistenceManager pm; |
25879 | ····[SetUp] |
25880 | ····public void Setup() |
25881 | ····{ |
25882 | ········pm = PmFactory.NewPersistenceManager(); |
25883 | ········ownVar = new CmpBinnOwnpabsOthpabsTblAutoLeftDerived(); |
25884 | ········otherVar = new CmpBinnOwnpabsOthpabsTblAutoRightDerived(); |
25885 | ····} |
25886 | ····[TearDown] |
25887 | ····public void TearDown() |
25888 | ····{ |
25889 | ········try |
25890 | ········{ |
25891 | ············pm.UnloadCache(); |
25892 | ············var l = pm.Objects<CmpBinnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25893 | ············pm.Delete(l); |
25894 | ············pm.Save(); |
25895 | ············pm.UnloadCache(); |
25896 | ············decimal count; |
25897 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25898 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25899 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25901 | ········} |
25902 | ········catch (Exception) |
25903 | ········{ |
25904 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25905 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25906 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25907 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25908 | ········} |
25909 | ····} |
25910 | ····[Test] |
25911 | ····public void TestSaveReload() |
25912 | ····{ |
25913 | ········CreateObjects(); |
25914 | ········QueryOwn(); |
25915 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25916 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25917 | ····} |
25918 | ····[Test] |
25919 | ····public void TestSaveReloadNull() |
25920 | ····{ |
25921 | ········CreateObjects(); |
25922 | ········QueryOwn(); |
25923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25924 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25925 | ········ownVar.RelField = new List<CmpBinnOwnpabsOthpabsTblAutoRightBase>(); |
25926 | ········pm.Save(); |
25927 | ········pm.UnloadCache(); |
25928 | ········QueryOwn(); |
25929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25930 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25931 | ····} |
25932 | ····[Test] |
25933 | ····public void TestSaveReloadRemove() |
25934 | ····{ |
25935 | ········CreateObjects(); |
25936 | ········QueryOwn(); |
25937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25938 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25939 | ········ownVar.RemoveRelatedObject(); |
25940 | ········pm.Save(); |
25941 | ········pm.UnloadCache(); |
25942 | ········QueryOwn(); |
25943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25944 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25945 | ····} |
25946 | ····[Test] |
25947 | ····public void TestRelationHash() |
25948 | ····{ |
25949 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoLeftBase)); |
25950 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25951 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoRightBase)); |
25952 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25953 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25954 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25955 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoLeftDerived)); |
25956 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25957 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25958 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25959 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoRightDerived)); |
25960 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25961 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25962 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25963 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25964 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25965 | ····} |
25966 | ····void CreateObjects() |
25967 | ····{ |
25968 | ········pm.MakePersistent(ownVar); |
25969 | ········ownVar.AssignRelation(otherVar); |
25970 | ········pm.Save(); |
25971 | ········pm.UnloadCache(); |
25972 | ····} |
25973 | ····void QueryOwn() |
25974 | ····{ |
25975 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25976 | ········ownVar = q.ExecuteSingle(); |
25977 | ····} |
25978 | ····void QueryOther() |
25979 | ····{ |
25980 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoRightBase>(pm); |
25981 | ········otherVar = q.ExecuteSingle(); |
25982 | ····} |
25983 | } |
25984 | |
25985 | |
25986 | [TestFixture] |
25987 | public class TestAgrDir1OwnpabsNoTblGuid : NDOTest |
25988 | { |
25989 | ····AgrDir1OwnpabsNoTblGuidLeftBase ownVar; |
25990 | ····AgrDir1OwnpabsNoTblGuidRight otherVar; |
25991 | ····PersistenceManager pm; |
25992 | ····[SetUp] |
25993 | ····public void Setup() |
25994 | ····{ |
25995 | ········pm = PmFactory.NewPersistenceManager(); |
25996 | ········ownVar = new AgrDir1OwnpabsNoTblGuidLeftDerived(); |
25997 | ········otherVar = new AgrDir1OwnpabsNoTblGuidRight(); |
25998 | ····} |
25999 | ····[TearDown] |
26000 | ····public void TearDown() |
26001 | ····{ |
26002 | ········try |
26003 | ········{ |
26004 | ············pm.UnloadCache(); |
26005 | ············var l = pm.Objects<AgrDir1OwnpabsNoTblGuidLeftBase>().ResultTable; |
26006 | ············pm.Delete(l); |
26007 | ············pm.Save(); |
26008 | ············pm.UnloadCache(); |
26009 | ············var m = pm.Objects<AgrDir1OwnpabsNoTblGuidRight>().ResultTable; |
26010 | ············pm.Delete(m); |
26011 | ············pm.Save(); |
26012 | ············pm.UnloadCache(); |
26013 | ············decimal count; |
26014 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26015 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26016 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26017 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26018 | ········} |
26019 | ········catch (Exception) |
26020 | ········{ |
26021 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26022 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26023 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26024 | ········} |
26025 | ····} |
26026 | ····[Test] |
26027 | ····public void TestSaveReload() |
26028 | ····{ |
26029 | ········CreateObjects(); |
26030 | ········QueryOwn(); |
26031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26032 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26033 | ····} |
26034 | ····[Test] |
26035 | ····public void TestSaveReloadNull() |
26036 | ····{ |
26037 | ········CreateObjects(); |
26038 | ········QueryOwn(); |
26039 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26040 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26041 | ········ownVar.RelField = null; |
26042 | ········pm.Save(); |
26043 | ········pm.UnloadCache(); |
26044 | ········QueryOwn(); |
26045 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26046 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26047 | ····} |
26048 | ····[Test] |
26049 | ····public void TestChangeKeyHolderLeft() |
26050 | ····{ |
26051 | ········CreateObjects(); |
26052 | ········QueryOwn(); |
26053 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26054 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26055 | ········int x = ownVar.RelField.Dummy; |
26056 | ········ownVar.Dummy = 4711; |
26057 | ········pm.Save(); |
26058 | ········pm.UnloadCache(); |
26059 | ········QueryOwn(); |
26060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26061 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26062 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26063 | ····} |
26064 | ····[Test] |
26065 | ····public void TestChangeKeyHolderLeftNoTouch() |
26066 | ····{ |
26067 | ········CreateObjects(); |
26068 | ········QueryOwn(); |
26069 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26070 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26071 | ········ownVar.Dummy = 4711; |
26072 | ········pm.Save(); |
26073 | ········pm.UnloadCache(); |
26074 | ········QueryOwn(); |
26075 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26076 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26077 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26078 | ····} |
26079 | ····void CreateObjects() |
26080 | ····{ |
26081 | ········pm.MakePersistent(ownVar); |
26082 | ········pm.MakePersistent(otherVar); |
26083 | ········ownVar.AssignRelation(otherVar); |
26084 | ········pm.Save(); |
26085 | ········pm.UnloadCache(); |
26086 | ····} |
26087 | ····void QueryOwn() |
26088 | ····{ |
26089 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblGuidLeftBase>(pm); |
26090 | ········ownVar = q.ExecuteSingle(); |
26091 | ····} |
26092 | ····void QueryOther() |
26093 | ····{ |
26094 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblGuidRight>(pm); |
26095 | ········otherVar = q.ExecuteSingle(); |
26096 | ····} |
26097 | } |
26098 | |
26099 | |
26100 | [TestFixture] |
26101 | public class TestAgrDir1OwnpabsTblGuid : NDOTest |
26102 | { |
26103 | ····AgrDir1OwnpabsTblGuidLeftBase ownVar; |
26104 | ····AgrDir1OwnpabsTblGuidRight otherVar; |
26105 | ····PersistenceManager pm; |
26106 | ····[SetUp] |
26107 | ····public void Setup() |
26108 | ····{ |
26109 | ········pm = PmFactory.NewPersistenceManager(); |
26110 | ········ownVar = new AgrDir1OwnpabsTblGuidLeftDerived(); |
26111 | ········otherVar = new AgrDir1OwnpabsTblGuidRight(); |
26112 | ····} |
26113 | ····[TearDown] |
26114 | ····public void TearDown() |
26115 | ····{ |
26116 | ········try |
26117 | ········{ |
26118 | ············pm.UnloadCache(); |
26119 | ············var l = pm.Objects<AgrDir1OwnpabsTblGuidLeftBase>().ResultTable; |
26120 | ············pm.Delete(l); |
26121 | ············pm.Save(); |
26122 | ············pm.UnloadCache(); |
26123 | ············var m = pm.Objects<AgrDir1OwnpabsTblGuidRight>().ResultTable; |
26124 | ············pm.Delete(m); |
26125 | ············pm.Save(); |
26126 | ············pm.UnloadCache(); |
26127 | ············decimal count; |
26128 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26129 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26130 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26131 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26132 | ········} |
26133 | ········catch (Exception) |
26134 | ········{ |
26135 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26136 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26137 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26138 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26139 | ········} |
26140 | ····} |
26141 | ····[Test] |
26142 | ····public void TestSaveReload() |
26143 | ····{ |
26144 | ········CreateObjects(); |
26145 | ········QueryOwn(); |
26146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26148 | ····} |
26149 | ····[Test] |
26150 | ····public void TestSaveReloadNull() |
26151 | ····{ |
26152 | ········CreateObjects(); |
26153 | ········QueryOwn(); |
26154 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26155 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26156 | ········ownVar.RelField = null; |
26157 | ········pm.Save(); |
26158 | ········pm.UnloadCache(); |
26159 | ········QueryOwn(); |
26160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26161 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26162 | ····} |
26163 | ····[Test] |
26164 | ····public void TestChangeKeyHolderLeft() |
26165 | ····{ |
26166 | ········CreateObjects(); |
26167 | ········QueryOwn(); |
26168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26169 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26170 | ········int x = ownVar.RelField.Dummy; |
26171 | ········ownVar.Dummy = 4711; |
26172 | ········pm.Save(); |
26173 | ········pm.UnloadCache(); |
26174 | ········QueryOwn(); |
26175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26176 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26177 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26178 | ····} |
26179 | ····[Test] |
26180 | ····public void TestChangeKeyHolderLeftNoTouch() |
26181 | ····{ |
26182 | ········CreateObjects(); |
26183 | ········QueryOwn(); |
26184 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26185 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26186 | ········ownVar.Dummy = 4711; |
26187 | ········pm.Save(); |
26188 | ········pm.UnloadCache(); |
26189 | ········QueryOwn(); |
26190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26191 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26192 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26193 | ····} |
26194 | ····void CreateObjects() |
26195 | ····{ |
26196 | ········pm.MakePersistent(ownVar); |
26197 | ········pm.MakePersistent(otherVar); |
26198 | ········ownVar.AssignRelation(otherVar); |
26199 | ········pm.Save(); |
26200 | ········pm.UnloadCache(); |
26201 | ····} |
26202 | ····void QueryOwn() |
26203 | ····{ |
26204 | ········var q = new NDOQuery<AgrDir1OwnpabsTblGuidLeftBase>(pm); |
26205 | ········ownVar = q.ExecuteSingle(); |
26206 | ····} |
26207 | ····void QueryOther() |
26208 | ····{ |
26209 | ········var q = new NDOQuery<AgrDir1OwnpabsTblGuidRight>(pm); |
26210 | ········otherVar = q.ExecuteSingle(); |
26211 | ····} |
26212 | } |
26213 | |
26214 | |
26215 | [TestFixture] |
26216 | public class TestAgrBi11OwnpabsNoTblGuid : NDOTest |
26217 | { |
26218 | ····AgrBi11OwnpabsNoTblGuidLeftBase ownVar; |
26219 | ····AgrBi11OwnpabsNoTblGuidRight otherVar; |
26220 | ····PersistenceManager pm; |
26221 | ····[SetUp] |
26222 | ····public void Setup() |
26223 | ····{ |
26224 | ········pm = PmFactory.NewPersistenceManager(); |
26225 | ········ownVar = new AgrBi11OwnpabsNoTblGuidLeftDerived(); |
26226 | ········otherVar = new AgrBi11OwnpabsNoTblGuidRight(); |
26227 | ····} |
26228 | ····[TearDown] |
26229 | ····public void TearDown() |
26230 | ····{ |
26231 | ········try |
26232 | ········{ |
26233 | ············pm.UnloadCache(); |
26234 | ············var l = pm.Objects<AgrBi11OwnpabsNoTblGuidLeftBase>().ResultTable; |
26235 | ············pm.Delete(l); |
26236 | ············pm.Save(); |
26237 | ············pm.UnloadCache(); |
26238 | ············var m = pm.Objects<AgrBi11OwnpabsNoTblGuidRight>().ResultTable; |
26239 | ············pm.Delete(m); |
26240 | ············pm.Save(); |
26241 | ············pm.UnloadCache(); |
26242 | ············decimal count; |
26243 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26245 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26247 | ········} |
26248 | ········catch (Exception) |
26249 | ········{ |
26250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26253 | ········} |
26254 | ····} |
26255 | ····[Test] |
26256 | ····public void TestSaveReload() |
26257 | ····{ |
26258 | ········CreateObjects(); |
26259 | ········QueryOwn(); |
26260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26262 | ····} |
26263 | ····[Test] |
26264 | ····public void TestSaveReloadNull() |
26265 | ····{ |
26266 | ········CreateObjects(); |
26267 | ········QueryOwn(); |
26268 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26269 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26270 | ········ownVar.RelField = null; |
26271 | ········pm.Save(); |
26272 | ········pm.UnloadCache(); |
26273 | ········QueryOwn(); |
26274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26275 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26276 | ····} |
26277 | ····[Test] |
26278 | ····public void TestChangeKeyHolderLeft() |
26279 | ····{ |
26280 | ········CreateObjects(); |
26281 | ········QueryOwn(); |
26282 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26284 | ········int x = ownVar.RelField.Dummy; |
26285 | ········ownVar.Dummy = 4711; |
26286 | ········pm.Save(); |
26287 | ········pm.UnloadCache(); |
26288 | ········QueryOwn(); |
26289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26290 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26291 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26292 | ····} |
26293 | ····[Test] |
26294 | ····public void TestChangeKeyHolderRight() |
26295 | ····{ |
26296 | ········CreateObjects(); |
26297 | ········QueryOther(); |
26298 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26299 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26300 | ········int x = otherVar.RelField.Dummy; |
26301 | ········otherVar.Dummy = 4711; |
26302 | ········pm.Save(); |
26303 | ········pm.UnloadCache(); |
26304 | ········QueryOther(); |
26305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26306 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26307 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26308 | ····} |
26309 | ····[Test] |
26310 | ····public void TestChangeKeyHolderLeftNoTouch() |
26311 | ····{ |
26312 | ········CreateObjects(); |
26313 | ········QueryOwn(); |
26314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26315 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26316 | ········ownVar.Dummy = 4711; |
26317 | ········pm.Save(); |
26318 | ········pm.UnloadCache(); |
26319 | ········QueryOwn(); |
26320 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26321 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26322 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26323 | ····} |
26324 | ····[Test] |
26325 | ····public void TestChangeKeyHolderRightNoTouch() |
26326 | ····{ |
26327 | ········CreateObjects(); |
26328 | ········QueryOther(); |
26329 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26330 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26331 | ········otherVar.Dummy = 4711; |
26332 | ········pm.Save(); |
26333 | ········pm.UnloadCache(); |
26334 | ········QueryOther(); |
26335 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26336 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26337 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26338 | ····} |
26339 | ····[Test] |
26340 | ····public void TestRelationHash() |
26341 | ····{ |
26342 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidLeftBase)); |
26343 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26344 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidRight)); |
26345 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26346 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26347 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26348 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidLeftDerived)); |
26349 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26350 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26351 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26352 | ····} |
26353 | ····void CreateObjects() |
26354 | ····{ |
26355 | ········pm.MakePersistent(ownVar); |
26356 | ········pm.MakePersistent(otherVar); |
26357 | ········ownVar.AssignRelation(otherVar); |
26358 | ········pm.Save(); |
26359 | ········pm.UnloadCache(); |
26360 | ····} |
26361 | ····void QueryOwn() |
26362 | ····{ |
26363 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblGuidLeftBase>(pm); |
26364 | ········ownVar = q.ExecuteSingle(); |
26365 | ····} |
26366 | ····void QueryOther() |
26367 | ····{ |
26368 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblGuidRight>(pm); |
26369 | ········otherVar = q.ExecuteSingle(); |
26370 | ····} |
26371 | } |
26372 | |
26373 | |
26374 | [TestFixture] |
26375 | public class TestAgrBi11OwnpabsTblGuid : NDOTest |
26376 | { |
26377 | ····AgrBi11OwnpabsTblGuidLeftBase ownVar; |
26378 | ····AgrBi11OwnpabsTblGuidRight otherVar; |
26379 | ····PersistenceManager pm; |
26380 | ····[SetUp] |
26381 | ····public void Setup() |
26382 | ····{ |
26383 | ········pm = PmFactory.NewPersistenceManager(); |
26384 | ········ownVar = new AgrBi11OwnpabsTblGuidLeftDerived(); |
26385 | ········otherVar = new AgrBi11OwnpabsTblGuidRight(); |
26386 | ····} |
26387 | ····[TearDown] |
26388 | ····public void TearDown() |
26389 | ····{ |
26390 | ········try |
26391 | ········{ |
26392 | ············pm.UnloadCache(); |
26393 | ············var l = pm.Objects<AgrBi11OwnpabsTblGuidLeftBase>().ResultTable; |
26394 | ············pm.Delete(l); |
26395 | ············pm.Save(); |
26396 | ············pm.UnloadCache(); |
26397 | ············var m = pm.Objects<AgrBi11OwnpabsTblGuidRight>().ResultTable; |
26398 | ············pm.Delete(m); |
26399 | ············pm.Save(); |
26400 | ············pm.UnloadCache(); |
26401 | ············decimal count; |
26402 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26403 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26404 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26405 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26406 | ········} |
26407 | ········catch (Exception) |
26408 | ········{ |
26409 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26410 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26411 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26412 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26413 | ········} |
26414 | ····} |
26415 | ····[Test] |
26416 | ····public void TestSaveReload() |
26417 | ····{ |
26418 | ········CreateObjects(); |
26419 | ········QueryOwn(); |
26420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26422 | ····} |
26423 | ····[Test] |
26424 | ····public void TestSaveReloadNull() |
26425 | ····{ |
26426 | ········CreateObjects(); |
26427 | ········QueryOwn(); |
26428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26429 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26430 | ········ownVar.RelField = null; |
26431 | ········pm.Save(); |
26432 | ········pm.UnloadCache(); |
26433 | ········QueryOwn(); |
26434 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26435 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26436 | ····} |
26437 | ····[Test] |
26438 | ····public void TestChangeKeyHolderLeft() |
26439 | ····{ |
26440 | ········CreateObjects(); |
26441 | ········QueryOwn(); |
26442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26443 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26444 | ········int x = ownVar.RelField.Dummy; |
26445 | ········ownVar.Dummy = 4711; |
26446 | ········pm.Save(); |
26447 | ········pm.UnloadCache(); |
26448 | ········QueryOwn(); |
26449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26450 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26451 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26452 | ····} |
26453 | ····[Test] |
26454 | ····public void TestChangeKeyHolderRight() |
26455 | ····{ |
26456 | ········CreateObjects(); |
26457 | ········QueryOther(); |
26458 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26459 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26460 | ········int x = otherVar.RelField.Dummy; |
26461 | ········otherVar.Dummy = 4711; |
26462 | ········pm.Save(); |
26463 | ········pm.UnloadCache(); |
26464 | ········QueryOther(); |
26465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26468 | ····} |
26469 | ····[Test] |
26470 | ····public void TestChangeKeyHolderLeftNoTouch() |
26471 | ····{ |
26472 | ········CreateObjects(); |
26473 | ········QueryOwn(); |
26474 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26475 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26476 | ········ownVar.Dummy = 4711; |
26477 | ········pm.Save(); |
26478 | ········pm.UnloadCache(); |
26479 | ········QueryOwn(); |
26480 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26481 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26482 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26483 | ····} |
26484 | ····[Test] |
26485 | ····public void TestChangeKeyHolderRightNoTouch() |
26486 | ····{ |
26487 | ········CreateObjects(); |
26488 | ········QueryOther(); |
26489 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26490 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26491 | ········otherVar.Dummy = 4711; |
26492 | ········pm.Save(); |
26493 | ········pm.UnloadCache(); |
26494 | ········QueryOther(); |
26495 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26496 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26497 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26498 | ····} |
26499 | ····[Test] |
26500 | ····public void TestRelationHash() |
26501 | ····{ |
26502 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidLeftBase)); |
26503 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26504 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidRight)); |
26505 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26506 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26507 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26508 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidLeftDerived)); |
26509 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26510 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26511 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26512 | ····} |
26513 | ····void CreateObjects() |
26514 | ····{ |
26515 | ········pm.MakePersistent(ownVar); |
26516 | ········pm.MakePersistent(otherVar); |
26517 | ········ownVar.AssignRelation(otherVar); |
26518 | ········pm.Save(); |
26519 | ········pm.UnloadCache(); |
26520 | ····} |
26521 | ····void QueryOwn() |
26522 | ····{ |
26523 | ········var q = new NDOQuery<AgrBi11OwnpabsTblGuidLeftBase>(pm); |
26524 | ········ownVar = q.ExecuteSingle(); |
26525 | ····} |
26526 | ····void QueryOther() |
26527 | ····{ |
26528 | ········var q = new NDOQuery<AgrBi11OwnpabsTblGuidRight>(pm); |
26529 | ········otherVar = q.ExecuteSingle(); |
26530 | ····} |
26531 | } |
26532 | |
26533 | |
26534 | [TestFixture] |
26535 | public class TestAgrDirnOwnpabsNoTblGuid : NDOTest |
26536 | { |
26537 | ····AgrDirnOwnpabsNoTblGuidLeftBase ownVar; |
26538 | ····AgrDirnOwnpabsNoTblGuidRight otherVar; |
26539 | ····PersistenceManager pm; |
26540 | ····[SetUp] |
26541 | ····public void Setup() |
26542 | ····{ |
26543 | ········pm = PmFactory.NewPersistenceManager(); |
26544 | ········ownVar = new AgrDirnOwnpabsNoTblGuidLeftDerived(); |
26545 | ········otherVar = new AgrDirnOwnpabsNoTblGuidRight(); |
26546 | ····} |
26547 | ····[TearDown] |
26548 | ····public void TearDown() |
26549 | ····{ |
26550 | ········try |
26551 | ········{ |
26552 | ············pm.UnloadCache(); |
26553 | ············var l = pm.Objects<AgrDirnOwnpabsNoTblGuidLeftBase>().ResultTable; |
26554 | ············pm.Delete(l); |
26555 | ············pm.Save(); |
26556 | ············pm.UnloadCache(); |
26557 | ············var m = pm.Objects<AgrDirnOwnpabsNoTblGuidRight>().ResultTable; |
26558 | ············pm.Delete(m); |
26559 | ············pm.Save(); |
26560 | ············pm.UnloadCache(); |
26561 | ············decimal count; |
26562 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26563 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26564 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26565 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26566 | ········} |
26567 | ········catch (Exception) |
26568 | ········{ |
26569 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26570 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26571 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26572 | ········} |
26573 | ····} |
26574 | ····[Test] |
26575 | ····public void TestSaveReload() |
26576 | ····{ |
26577 | ········CreateObjects(); |
26578 | ········QueryOwn(); |
26579 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26580 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26581 | ····} |
26582 | ····[Test] |
26583 | ····public void TestSaveReloadNull() |
26584 | ····{ |
26585 | ········CreateObjects(); |
26586 | ········QueryOwn(); |
26587 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26588 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26589 | ········ownVar.RelField = new List<AgrDirnOwnpabsNoTblGuidRight>(); |
26590 | ········pm.Save(); |
26591 | ········pm.UnloadCache(); |
26592 | ········QueryOwn(); |
26593 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26594 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26595 | ····} |
26596 | ····[Test] |
26597 | ····public void TestSaveReloadRemove() |
26598 | ····{ |
26599 | ········CreateObjects(); |
26600 | ········QueryOwn(); |
26601 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26602 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26603 | ········ownVar.RemoveRelatedObject(); |
26604 | ········pm.Save(); |
26605 | ········pm.UnloadCache(); |
26606 | ········QueryOwn(); |
26607 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26608 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26609 | ····} |
26610 | ····void CreateObjects() |
26611 | ····{ |
26612 | ········pm.MakePersistent(ownVar); |
26613 | ········pm.MakePersistent(otherVar); |
26614 | ········ownVar.AssignRelation(otherVar); |
26615 | ········pm.Save(); |
26616 | ········pm.UnloadCache(); |
26617 | ····} |
26618 | ····void QueryOwn() |
26619 | ····{ |
26620 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblGuidLeftBase>(pm); |
26621 | ········ownVar = q.ExecuteSingle(); |
26622 | ····} |
26623 | ····void QueryOther() |
26624 | ····{ |
26625 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblGuidRight>(pm); |
26626 | ········otherVar = q.ExecuteSingle(); |
26627 | ····} |
26628 | } |
26629 | |
26630 | |
26631 | [TestFixture] |
26632 | public class TestAgrDirnOwnpabsTblGuid : NDOTest |
26633 | { |
26634 | ····AgrDirnOwnpabsTblGuidLeftBase ownVar; |
26635 | ····AgrDirnOwnpabsTblGuidRight otherVar; |
26636 | ····PersistenceManager pm; |
26637 | ····[SetUp] |
26638 | ····public void Setup() |
26639 | ····{ |
26640 | ········pm = PmFactory.NewPersistenceManager(); |
26641 | ········ownVar = new AgrDirnOwnpabsTblGuidLeftDerived(); |
26642 | ········otherVar = new AgrDirnOwnpabsTblGuidRight(); |
26643 | ····} |
26644 | ····[TearDown] |
26645 | ····public void TearDown() |
26646 | ····{ |
26647 | ········try |
26648 | ········{ |
26649 | ············pm.UnloadCache(); |
26650 | ············var l = pm.Objects<AgrDirnOwnpabsTblGuidLeftBase>().ResultTable; |
26651 | ············pm.Delete(l); |
26652 | ············pm.Save(); |
26653 | ············pm.UnloadCache(); |
26654 | ············var m = pm.Objects<AgrDirnOwnpabsTblGuidRight>().ResultTable; |
26655 | ············pm.Delete(m); |
26656 | ············pm.Save(); |
26657 | ············pm.UnloadCache(); |
26658 | ············decimal count; |
26659 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26660 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26661 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26662 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26663 | ········} |
26664 | ········catch (Exception) |
26665 | ········{ |
26666 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26667 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26668 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26669 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26670 | ········} |
26671 | ····} |
26672 | ····[Test] |
26673 | ····public void TestSaveReload() |
26674 | ····{ |
26675 | ········CreateObjects(); |
26676 | ········QueryOwn(); |
26677 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26678 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26679 | ····} |
26680 | ····[Test] |
26681 | ····public void TestSaveReloadNull() |
26682 | ····{ |
26683 | ········CreateObjects(); |
26684 | ········QueryOwn(); |
26685 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26686 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26687 | ········ownVar.RelField = new List<AgrDirnOwnpabsTblGuidRight>(); |
26688 | ········pm.Save(); |
26689 | ········pm.UnloadCache(); |
26690 | ········QueryOwn(); |
26691 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26692 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26693 | ····} |
26694 | ····[Test] |
26695 | ····public void TestSaveReloadRemove() |
26696 | ····{ |
26697 | ········CreateObjects(); |
26698 | ········QueryOwn(); |
26699 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26700 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26701 | ········ownVar.RemoveRelatedObject(); |
26702 | ········pm.Save(); |
26703 | ········pm.UnloadCache(); |
26704 | ········QueryOwn(); |
26705 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26706 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26707 | ····} |
26708 | ····void CreateObjects() |
26709 | ····{ |
26710 | ········pm.MakePersistent(ownVar); |
26711 | ········pm.MakePersistent(otherVar); |
26712 | ········ownVar.AssignRelation(otherVar); |
26713 | ········pm.Save(); |
26714 | ········pm.UnloadCache(); |
26715 | ····} |
26716 | ····void QueryOwn() |
26717 | ····{ |
26718 | ········var q = new NDOQuery<AgrDirnOwnpabsTblGuidLeftBase>(pm); |
26719 | ········ownVar = q.ExecuteSingle(); |
26720 | ····} |
26721 | ····void QueryOther() |
26722 | ····{ |
26723 | ········var q = new NDOQuery<AgrDirnOwnpabsTblGuidRight>(pm); |
26724 | ········otherVar = q.ExecuteSingle(); |
26725 | ····} |
26726 | } |
26727 | |
26728 | |
26729 | [TestFixture] |
26730 | public class TestAgrBin1OwnpabsNoTblGuid : NDOTest |
26731 | { |
26732 | ····AgrBin1OwnpabsNoTblGuidLeftBase ownVar; |
26733 | ····AgrBin1OwnpabsNoTblGuidRight otherVar; |
26734 | ····PersistenceManager pm; |
26735 | ····[SetUp] |
26736 | ····public void Setup() |
26737 | ····{ |
26738 | ········pm = PmFactory.NewPersistenceManager(); |
26739 | ········ownVar = new AgrBin1OwnpabsNoTblGuidLeftDerived(); |
26740 | ········otherVar = new AgrBin1OwnpabsNoTblGuidRight(); |
26741 | ····} |
26742 | ····[TearDown] |
26743 | ····public void TearDown() |
26744 | ····{ |
26745 | ········try |
26746 | ········{ |
26747 | ············pm.UnloadCache(); |
26748 | ············var l = pm.Objects<AgrBin1OwnpabsNoTblGuidLeftBase>().ResultTable; |
26749 | ············pm.Delete(l); |
26750 | ············pm.Save(); |
26751 | ············pm.UnloadCache(); |
26752 | ············var m = pm.Objects<AgrBin1OwnpabsNoTblGuidRight>().ResultTable; |
26753 | ············pm.Delete(m); |
26754 | ············pm.Save(); |
26755 | ············pm.UnloadCache(); |
26756 | ············decimal count; |
26757 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26758 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26759 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26761 | ········} |
26762 | ········catch (Exception) |
26763 | ········{ |
26764 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26765 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26766 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26767 | ········} |
26768 | ····} |
26769 | ····[Test] |
26770 | ····public void TestSaveReload() |
26771 | ····{ |
26772 | ········CreateObjects(); |
26773 | ········QueryOwn(); |
26774 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26775 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26776 | ····} |
26777 | ····[Test] |
26778 | ····public void TestSaveReloadNull() |
26779 | ····{ |
26780 | ········CreateObjects(); |
26781 | ········QueryOwn(); |
26782 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26783 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26784 | ········ownVar.RelField = new List<AgrBin1OwnpabsNoTblGuidRight>(); |
26785 | ········pm.Save(); |
26786 | ········pm.UnloadCache(); |
26787 | ········QueryOwn(); |
26788 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26789 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26790 | ····} |
26791 | ····[Test] |
26792 | ····public void TestSaveReloadRemove() |
26793 | ····{ |
26794 | ········CreateObjects(); |
26795 | ········QueryOwn(); |
26796 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26797 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26798 | ········ownVar.RemoveRelatedObject(); |
26799 | ········pm.Save(); |
26800 | ········pm.UnloadCache(); |
26801 | ········QueryOwn(); |
26802 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26803 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26804 | ····} |
26805 | ····[Test] |
26806 | ····public void TestChangeKeyHolderRight() |
26807 | ····{ |
26808 | ········CreateObjects(); |
26809 | ········QueryOther(); |
26810 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26811 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26812 | ········int x = otherVar.RelField.Dummy; |
26813 | ········otherVar.Dummy = 4711; |
26814 | ········pm.Save(); |
26815 | ········pm.UnloadCache(); |
26816 | ········QueryOther(); |
26817 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26818 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26819 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26820 | ····} |
26821 | ····[Test] |
26822 | ····public void TestChangeKeyHolderRightNoTouch() |
26823 | ····{ |
26824 | ········CreateObjects(); |
26825 | ········QueryOther(); |
26826 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26827 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26828 | ········otherVar.Dummy = 4711; |
26829 | ········pm.Save(); |
26830 | ········pm.UnloadCache(); |
26831 | ········QueryOther(); |
26832 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26833 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26834 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26835 | ····} |
26836 | ····[Test] |
26837 | ····public void TestRelationHash() |
26838 | ····{ |
26839 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidLeftBase)); |
26840 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26841 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidRight)); |
26842 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26843 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26844 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26845 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidLeftDerived)); |
26846 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26847 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26848 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26849 | ····} |
26850 | ····void CreateObjects() |
26851 | ····{ |
26852 | ········pm.MakePersistent(ownVar); |
26853 | ········pm.MakePersistent(otherVar); |
26854 | ········ownVar.AssignRelation(otherVar); |
26855 | ········pm.Save(); |
26856 | ········pm.UnloadCache(); |
26857 | ····} |
26858 | ····void QueryOwn() |
26859 | ····{ |
26860 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblGuidLeftBase>(pm); |
26861 | ········ownVar = q.ExecuteSingle(); |
26862 | ····} |
26863 | ····void QueryOther() |
26864 | ····{ |
26865 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblGuidRight>(pm); |
26866 | ········otherVar = q.ExecuteSingle(); |
26867 | ····} |
26868 | } |
26869 | |
26870 | |
26871 | [TestFixture] |
26872 | public class TestAgrBin1OwnpabsTblGuid : NDOTest |
26873 | { |
26874 | ····AgrBin1OwnpabsTblGuidLeftBase ownVar; |
26875 | ····AgrBin1OwnpabsTblGuidRight otherVar; |
26876 | ····PersistenceManager pm; |
26877 | ····[SetUp] |
26878 | ····public void Setup() |
26879 | ····{ |
26880 | ········pm = PmFactory.NewPersistenceManager(); |
26881 | ········ownVar = new AgrBin1OwnpabsTblGuidLeftDerived(); |
26882 | ········otherVar = new AgrBin1OwnpabsTblGuidRight(); |
26883 | ····} |
26884 | ····[TearDown] |
26885 | ····public void TearDown() |
26886 | ····{ |
26887 | ········try |
26888 | ········{ |
26889 | ············pm.UnloadCache(); |
26890 | ············var l = pm.Objects<AgrBin1OwnpabsTblGuidLeftBase>().ResultTable; |
26891 | ············pm.Delete(l); |
26892 | ············pm.Save(); |
26893 | ············pm.UnloadCache(); |
26894 | ············var m = pm.Objects<AgrBin1OwnpabsTblGuidRight>().ResultTable; |
26895 | ············pm.Delete(m); |
26896 | ············pm.Save(); |
26897 | ············pm.UnloadCache(); |
26898 | ············decimal count; |
26899 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26901 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26902 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26903 | ········} |
26904 | ········catch (Exception) |
26905 | ········{ |
26906 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26907 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26909 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26910 | ········} |
26911 | ····} |
26912 | ····[Test] |
26913 | ····public void TestSaveReload() |
26914 | ····{ |
26915 | ········CreateObjects(); |
26916 | ········QueryOwn(); |
26917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26918 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26919 | ····} |
26920 | ····[Test] |
26921 | ····public void TestSaveReloadNull() |
26922 | ····{ |
26923 | ········CreateObjects(); |
26924 | ········QueryOwn(); |
26925 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26926 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26927 | ········ownVar.RelField = new List<AgrBin1OwnpabsTblGuidRight>(); |
26928 | ········pm.Save(); |
26929 | ········pm.UnloadCache(); |
26930 | ········QueryOwn(); |
26931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26932 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26933 | ····} |
26934 | ····[Test] |
26935 | ····public void TestSaveReloadRemove() |
26936 | ····{ |
26937 | ········CreateObjects(); |
26938 | ········QueryOwn(); |
26939 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26940 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26941 | ········ownVar.RemoveRelatedObject(); |
26942 | ········pm.Save(); |
26943 | ········pm.UnloadCache(); |
26944 | ········QueryOwn(); |
26945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26946 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26947 | ····} |
26948 | ····[Test] |
26949 | ····public void TestChangeKeyHolderRight() |
26950 | ····{ |
26951 | ········CreateObjects(); |
26952 | ········QueryOther(); |
26953 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26954 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26955 | ········int x = otherVar.RelField.Dummy; |
26956 | ········otherVar.Dummy = 4711; |
26957 | ········pm.Save(); |
26958 | ········pm.UnloadCache(); |
26959 | ········QueryOther(); |
26960 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26961 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26962 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26963 | ····} |
26964 | ····[Test] |
26965 | ····public void TestChangeKeyHolderRightNoTouch() |
26966 | ····{ |
26967 | ········CreateObjects(); |
26968 | ········QueryOther(); |
26969 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26970 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26971 | ········otherVar.Dummy = 4711; |
26972 | ········pm.Save(); |
26973 | ········pm.UnloadCache(); |
26974 | ········QueryOther(); |
26975 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26976 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26977 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26978 | ····} |
26979 | ····[Test] |
26980 | ····public void TestRelationHash() |
26981 | ····{ |
26982 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidLeftBase)); |
26983 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26984 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidRight)); |
26985 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26986 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26987 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26988 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidLeftDerived)); |
26989 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26990 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26991 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26992 | ····} |
26993 | ····void CreateObjects() |
26994 | ····{ |
26995 | ········pm.MakePersistent(ownVar); |
26996 | ········pm.MakePersistent(otherVar); |
26997 | ········ownVar.AssignRelation(otherVar); |
26998 | ········pm.Save(); |
26999 | ········pm.UnloadCache(); |
27000 | ····} |
27001 | ····void QueryOwn() |
27002 | ····{ |
27003 | ········var q = new NDOQuery<AgrBin1OwnpabsTblGuidLeftBase>(pm); |
27004 | ········ownVar = q.ExecuteSingle(); |
27005 | ····} |
27006 | ····void QueryOther() |
27007 | ····{ |
27008 | ········var q = new NDOQuery<AgrBin1OwnpabsTblGuidRight>(pm); |
27009 | ········otherVar = q.ExecuteSingle(); |
27010 | ····} |
27011 | } |
27012 | |
27013 | |
27014 | [TestFixture] |
27015 | public class TestAgrBi1nOwnpabsTblGuid : NDOTest |
27016 | { |
27017 | ····AgrBi1nOwnpabsTblGuidLeftBase ownVar; |
27018 | ····AgrBi1nOwnpabsTblGuidRight otherVar; |
27019 | ····PersistenceManager pm; |
27020 | ····[SetUp] |
27021 | ····public void Setup() |
27022 | ····{ |
27023 | ········pm = PmFactory.NewPersistenceManager(); |
27024 | ········ownVar = new AgrBi1nOwnpabsTblGuidLeftDerived(); |
27025 | ········otherVar = new AgrBi1nOwnpabsTblGuidRight(); |
27026 | ····} |
27027 | ····[TearDown] |
27028 | ····public void TearDown() |
27029 | ····{ |
27030 | ········try |
27031 | ········{ |
27032 | ············pm.UnloadCache(); |
27033 | ············var l = pm.Objects<AgrBi1nOwnpabsTblGuidLeftBase>().ResultTable; |
27034 | ············pm.Delete(l); |
27035 | ············pm.Save(); |
27036 | ············pm.UnloadCache(); |
27037 | ············var m = pm.Objects<AgrBi1nOwnpabsTblGuidRight>().ResultTable; |
27038 | ············pm.Delete(m); |
27039 | ············pm.Save(); |
27040 | ············pm.UnloadCache(); |
27041 | ············decimal count; |
27042 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27044 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27045 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27046 | ········} |
27047 | ········catch (Exception) |
27048 | ········{ |
27049 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27050 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27051 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27052 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27053 | ········} |
27054 | ····} |
27055 | ····[Test] |
27056 | ····public void TestSaveReload() |
27057 | ····{ |
27058 | ········CreateObjects(); |
27059 | ········QueryOwn(); |
27060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27062 | ····} |
27063 | ····[Test] |
27064 | ····public void TestSaveReloadNull() |
27065 | ····{ |
27066 | ········CreateObjects(); |
27067 | ········QueryOwn(); |
27068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27070 | ········ownVar.RelField = null; |
27071 | ········pm.Save(); |
27072 | ········pm.UnloadCache(); |
27073 | ········QueryOwn(); |
27074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27075 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27076 | ····} |
27077 | ····[Test] |
27078 | ····public void TestChangeKeyHolderLeft() |
27079 | ····{ |
27080 | ········CreateObjects(); |
27081 | ········QueryOwn(); |
27082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27083 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27084 | ········int x = ownVar.RelField.Dummy; |
27085 | ········ownVar.Dummy = 4711; |
27086 | ········pm.Save(); |
27087 | ········pm.UnloadCache(); |
27088 | ········QueryOwn(); |
27089 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27090 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27091 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27092 | ····} |
27093 | ····[Test] |
27094 | ····public void TestChangeKeyHolderLeftNoTouch() |
27095 | ····{ |
27096 | ········CreateObjects(); |
27097 | ········QueryOwn(); |
27098 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27099 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27100 | ········ownVar.Dummy = 4711; |
27101 | ········pm.Save(); |
27102 | ········pm.UnloadCache(); |
27103 | ········QueryOwn(); |
27104 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27105 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27106 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27107 | ····} |
27108 | ····[Test] |
27109 | ····public void TestRelationHash() |
27110 | ····{ |
27111 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidLeftBase)); |
27112 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27113 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidRight)); |
27114 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27115 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27116 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27117 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidLeftDerived)); |
27118 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27119 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27120 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27121 | ····} |
27122 | ····void CreateObjects() |
27123 | ····{ |
27124 | ········pm.MakePersistent(ownVar); |
27125 | ········pm.MakePersistent(otherVar); |
27126 | ········ownVar.AssignRelation(otherVar); |
27127 | ········pm.Save(); |
27128 | ········pm.UnloadCache(); |
27129 | ····} |
27130 | ····void QueryOwn() |
27131 | ····{ |
27132 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblGuidLeftBase>(pm); |
27133 | ········ownVar = q.ExecuteSingle(); |
27134 | ····} |
27135 | ····void QueryOther() |
27136 | ····{ |
27137 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblGuidRight>(pm); |
27138 | ········otherVar = q.ExecuteSingle(); |
27139 | ····} |
27140 | } |
27141 | |
27142 | |
27143 | [TestFixture] |
27144 | public class TestAgrBinnOwnpabsTblGuid : NDOTest |
27145 | { |
27146 | ····AgrBinnOwnpabsTblGuidLeftBase ownVar; |
27147 | ····AgrBinnOwnpabsTblGuidRight otherVar; |
27148 | ····PersistenceManager pm; |
27149 | ····[SetUp] |
27150 | ····public void Setup() |
27151 | ····{ |
27152 | ········pm = PmFactory.NewPersistenceManager(); |
27153 | ········ownVar = new AgrBinnOwnpabsTblGuidLeftDerived(); |
27154 | ········otherVar = new AgrBinnOwnpabsTblGuidRight(); |
27155 | ····} |
27156 | ····[TearDown] |
27157 | ····public void TearDown() |
27158 | ····{ |
27159 | ········try |
27160 | ········{ |
27161 | ············pm.UnloadCache(); |
27162 | ············var l = pm.Objects<AgrBinnOwnpabsTblGuidLeftBase>().ResultTable; |
27163 | ············pm.Delete(l); |
27164 | ············pm.Save(); |
27165 | ············pm.UnloadCache(); |
27166 | ············var m = pm.Objects<AgrBinnOwnpabsTblGuidRight>().ResultTable; |
27167 | ············pm.Delete(m); |
27168 | ············pm.Save(); |
27169 | ············pm.UnloadCache(); |
27170 | ············decimal count; |
27171 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27172 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27173 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27174 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27175 | ········} |
27176 | ········catch (Exception) |
27177 | ········{ |
27178 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27179 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27180 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27181 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27182 | ········} |
27183 | ····} |
27184 | ····[Test] |
27185 | ····public void TestSaveReload() |
27186 | ····{ |
27187 | ········CreateObjects(); |
27188 | ········QueryOwn(); |
27189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27190 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27191 | ····} |
27192 | ····[Test] |
27193 | ····public void TestSaveReloadNull() |
27194 | ····{ |
27195 | ········CreateObjects(); |
27196 | ········QueryOwn(); |
27197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27198 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27199 | ········ownVar.RelField = new List<AgrBinnOwnpabsTblGuidRight>(); |
27200 | ········pm.Save(); |
27201 | ········pm.UnloadCache(); |
27202 | ········QueryOwn(); |
27203 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27204 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27205 | ····} |
27206 | ····[Test] |
27207 | ····public void TestSaveReloadRemove() |
27208 | ····{ |
27209 | ········CreateObjects(); |
27210 | ········QueryOwn(); |
27211 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27212 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27213 | ········ownVar.RemoveRelatedObject(); |
27214 | ········pm.Save(); |
27215 | ········pm.UnloadCache(); |
27216 | ········QueryOwn(); |
27217 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27218 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27219 | ····} |
27220 | ····[Test] |
27221 | ····public void TestRelationHash() |
27222 | ····{ |
27223 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidLeftBase)); |
27224 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27225 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidRight)); |
27226 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27227 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27228 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27229 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidLeftDerived)); |
27230 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27231 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27232 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27233 | ····} |
27234 | ····void CreateObjects() |
27235 | ····{ |
27236 | ········pm.MakePersistent(ownVar); |
27237 | ········pm.MakePersistent(otherVar); |
27238 | ········ownVar.AssignRelation(otherVar); |
27239 | ········pm.Save(); |
27240 | ········pm.UnloadCache(); |
27241 | ····} |
27242 | ····void QueryOwn() |
27243 | ····{ |
27244 | ········var q = new NDOQuery<AgrBinnOwnpabsTblGuidLeftBase>(pm); |
27245 | ········ownVar = q.ExecuteSingle(); |
27246 | ····} |
27247 | ····void QueryOther() |
27248 | ····{ |
27249 | ········var q = new NDOQuery<AgrBinnOwnpabsTblGuidRight>(pm); |
27250 | ········otherVar = q.ExecuteSingle(); |
27251 | ····} |
27252 | } |
27253 | |
27254 | |
27255 | [TestFixture] |
27256 | public class TestCmpDir1OwnpabsNoTblGuid : NDOTest |
27257 | { |
27258 | ····CmpDir1OwnpabsNoTblGuidLeftBase ownVar; |
27259 | ····CmpDir1OwnpabsNoTblGuidRight otherVar; |
27260 | ····PersistenceManager pm; |
27261 | ····[SetUp] |
27262 | ····public void Setup() |
27263 | ····{ |
27264 | ········pm = PmFactory.NewPersistenceManager(); |
27265 | ········ownVar = new CmpDir1OwnpabsNoTblGuidLeftDerived(); |
27266 | ········otherVar = new CmpDir1OwnpabsNoTblGuidRight(); |
27267 | ····} |
27268 | ····[TearDown] |
27269 | ····public void TearDown() |
27270 | ····{ |
27271 | ········try |
27272 | ········{ |
27273 | ············pm.UnloadCache(); |
27274 | ············var l = pm.Objects<CmpDir1OwnpabsNoTblGuidLeftBase>().ResultTable; |
27275 | ············pm.Delete(l); |
27276 | ············pm.Save(); |
27277 | ············pm.UnloadCache(); |
27278 | ············decimal count; |
27279 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27280 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27281 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27282 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27283 | ········} |
27284 | ········catch (Exception) |
27285 | ········{ |
27286 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27287 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27288 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27289 | ········} |
27290 | ····} |
27291 | ····[Test] |
27292 | ····public void TestSaveReload() |
27293 | ····{ |
27294 | ········CreateObjects(); |
27295 | ········QueryOwn(); |
27296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27297 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27298 | ····} |
27299 | ····[Test] |
27300 | ····public void TestSaveReloadNull() |
27301 | ····{ |
27302 | ········CreateObjects(); |
27303 | ········QueryOwn(); |
27304 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27305 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27306 | ········ownVar.RelField = null; |
27307 | ········pm.Save(); |
27308 | ········pm.UnloadCache(); |
27309 | ········QueryOwn(); |
27310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27311 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27312 | ····} |
27313 | ····[Test] |
27314 | ····public void TestChangeKeyHolderLeft() |
27315 | ····{ |
27316 | ········CreateObjects(); |
27317 | ········QueryOwn(); |
27318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27319 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27320 | ········int x = ownVar.RelField.Dummy; |
27321 | ········ownVar.Dummy = 4711; |
27322 | ········pm.Save(); |
27323 | ········pm.UnloadCache(); |
27324 | ········QueryOwn(); |
27325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27326 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27327 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27328 | ····} |
27329 | ····[Test] |
27330 | ····public void TestChangeKeyHolderLeftNoTouch() |
27331 | ····{ |
27332 | ········CreateObjects(); |
27333 | ········QueryOwn(); |
27334 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27335 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27336 | ········ownVar.Dummy = 4711; |
27337 | ········pm.Save(); |
27338 | ········pm.UnloadCache(); |
27339 | ········QueryOwn(); |
27340 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27341 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27342 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27343 | ····} |
27344 | ····void CreateObjects() |
27345 | ····{ |
27346 | ········pm.MakePersistent(ownVar); |
27347 | ········ownVar.AssignRelation(otherVar); |
27348 | ········pm.Save(); |
27349 | ········pm.UnloadCache(); |
27350 | ····} |
27351 | ····void QueryOwn() |
27352 | ····{ |
27353 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblGuidLeftBase>(pm); |
27354 | ········ownVar = q.ExecuteSingle(); |
27355 | ····} |
27356 | ····void QueryOther() |
27357 | ····{ |
27358 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblGuidRight>(pm); |
27359 | ········otherVar = q.ExecuteSingle(); |
27360 | ····} |
27361 | } |
27362 | |
27363 | |
27364 | [TestFixture] |
27365 | public class TestCmpDir1OwnpabsTblGuid : NDOTest |
27366 | { |
27367 | ····CmpDir1OwnpabsTblGuidLeftBase ownVar; |
27368 | ····CmpDir1OwnpabsTblGuidRight otherVar; |
27369 | ····PersistenceManager pm; |
27370 | ····[SetUp] |
27371 | ····public void Setup() |
27372 | ····{ |
27373 | ········pm = PmFactory.NewPersistenceManager(); |
27374 | ········ownVar = new CmpDir1OwnpabsTblGuidLeftDerived(); |
27375 | ········otherVar = new CmpDir1OwnpabsTblGuidRight(); |
27376 | ····} |
27377 | ····[TearDown] |
27378 | ····public void TearDown() |
27379 | ····{ |
27380 | ········try |
27381 | ········{ |
27382 | ············pm.UnloadCache(); |
27383 | ············var l = pm.Objects<CmpDir1OwnpabsTblGuidLeftBase>().ResultTable; |
27384 | ············pm.Delete(l); |
27385 | ············pm.Save(); |
27386 | ············pm.UnloadCache(); |
27387 | ············decimal count; |
27388 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27389 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27390 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27391 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27392 | ········} |
27393 | ········catch (Exception) |
27394 | ········{ |
27395 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27396 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27397 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27398 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27399 | ········} |
27400 | ····} |
27401 | ····[Test] |
27402 | ····public void TestSaveReload() |
27403 | ····{ |
27404 | ········CreateObjects(); |
27405 | ········QueryOwn(); |
27406 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27407 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27408 | ····} |
27409 | ····[Test] |
27410 | ····public void TestSaveReloadNull() |
27411 | ····{ |
27412 | ········CreateObjects(); |
27413 | ········QueryOwn(); |
27414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27415 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27416 | ········ownVar.RelField = null; |
27417 | ········pm.Save(); |
27418 | ········pm.UnloadCache(); |
27419 | ········QueryOwn(); |
27420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27421 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27422 | ····} |
27423 | ····[Test] |
27424 | ····public void TestChangeKeyHolderLeft() |
27425 | ····{ |
27426 | ········CreateObjects(); |
27427 | ········QueryOwn(); |
27428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27429 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27430 | ········int x = ownVar.RelField.Dummy; |
27431 | ········ownVar.Dummy = 4711; |
27432 | ········pm.Save(); |
27433 | ········pm.UnloadCache(); |
27434 | ········QueryOwn(); |
27435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27436 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27437 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27438 | ····} |
27439 | ····[Test] |
27440 | ····public void TestChangeKeyHolderLeftNoTouch() |
27441 | ····{ |
27442 | ········CreateObjects(); |
27443 | ········QueryOwn(); |
27444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27445 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27446 | ········ownVar.Dummy = 4711; |
27447 | ········pm.Save(); |
27448 | ········pm.UnloadCache(); |
27449 | ········QueryOwn(); |
27450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27451 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27452 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27453 | ····} |
27454 | ····void CreateObjects() |
27455 | ····{ |
27456 | ········pm.MakePersistent(ownVar); |
27457 | ········ownVar.AssignRelation(otherVar); |
27458 | ········pm.Save(); |
27459 | ········pm.UnloadCache(); |
27460 | ····} |
27461 | ····void QueryOwn() |
27462 | ····{ |
27463 | ········var q = new NDOQuery<CmpDir1OwnpabsTblGuidLeftBase>(pm); |
27464 | ········ownVar = q.ExecuteSingle(); |
27465 | ····} |
27466 | ····void QueryOther() |
27467 | ····{ |
27468 | ········var q = new NDOQuery<CmpDir1OwnpabsTblGuidRight>(pm); |
27469 | ········otherVar = q.ExecuteSingle(); |
27470 | ····} |
27471 | } |
27472 | |
27473 | |
27474 | [TestFixture] |
27475 | public class TestCmpBi11OwnpabsNoTblGuid : NDOTest |
27476 | { |
27477 | ····CmpBi11OwnpabsNoTblGuidLeftBase ownVar; |
27478 | ····CmpBi11OwnpabsNoTblGuidRight otherVar; |
27479 | ····PersistenceManager pm; |
27480 | ····[SetUp] |
27481 | ····public void Setup() |
27482 | ····{ |
27483 | ········pm = PmFactory.NewPersistenceManager(); |
27484 | ········ownVar = new CmpBi11OwnpabsNoTblGuidLeftDerived(); |
27485 | ········otherVar = new CmpBi11OwnpabsNoTblGuidRight(); |
27486 | ····} |
27487 | ····[TearDown] |
27488 | ····public void TearDown() |
27489 | ····{ |
27490 | ········try |
27491 | ········{ |
27492 | ············pm.UnloadCache(); |
27493 | ············var l = pm.Objects<CmpBi11OwnpabsNoTblGuidLeftBase>().ResultTable; |
27494 | ············pm.Delete(l); |
27495 | ············pm.Save(); |
27496 | ············pm.UnloadCache(); |
27497 | ············decimal count; |
27498 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27499 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27500 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27501 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27502 | ········} |
27503 | ········catch (Exception) |
27504 | ········{ |
27505 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27506 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27507 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27508 | ········} |
27509 | ····} |
27510 | ····[Test] |
27511 | ····public void TestSaveReload() |
27512 | ····{ |
27513 | ········CreateObjects(); |
27514 | ········QueryOwn(); |
27515 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27516 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27517 | ····} |
27518 | ····[Test] |
27519 | ····public void TestSaveReloadNull() |
27520 | ····{ |
27521 | ········CreateObjects(); |
27522 | ········QueryOwn(); |
27523 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27524 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27525 | ········ownVar.RelField = null; |
27526 | ········pm.Save(); |
27527 | ········pm.UnloadCache(); |
27528 | ········QueryOwn(); |
27529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27530 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27531 | ····} |
27532 | ····[Test] |
27533 | ····public void TestChangeKeyHolderLeft() |
27534 | ····{ |
27535 | ········CreateObjects(); |
27536 | ········QueryOwn(); |
27537 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27538 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27539 | ········int x = ownVar.RelField.Dummy; |
27540 | ········ownVar.Dummy = 4711; |
27541 | ········pm.Save(); |
27542 | ········pm.UnloadCache(); |
27543 | ········QueryOwn(); |
27544 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27545 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27546 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27547 | ····} |
27548 | ····[Test] |
27549 | ····public void TestChangeKeyHolderRight() |
27550 | ····{ |
27551 | ········CreateObjects(); |
27552 | ········QueryOther(); |
27553 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27554 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27555 | ········int x = otherVar.RelField.Dummy; |
27556 | ········otherVar.Dummy = 4711; |
27557 | ········pm.Save(); |
27558 | ········pm.UnloadCache(); |
27559 | ········QueryOther(); |
27560 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27561 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27562 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27563 | ····} |
27564 | ····[Test] |
27565 | ····public void TestChangeKeyHolderLeftNoTouch() |
27566 | ····{ |
27567 | ········CreateObjects(); |
27568 | ········QueryOwn(); |
27569 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27570 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27571 | ········ownVar.Dummy = 4711; |
27572 | ········pm.Save(); |
27573 | ········pm.UnloadCache(); |
27574 | ········QueryOwn(); |
27575 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27576 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27577 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27578 | ····} |
27579 | ····[Test] |
27580 | ····public void TestChangeKeyHolderRightNoTouch() |
27581 | ····{ |
27582 | ········CreateObjects(); |
27583 | ········QueryOther(); |
27584 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27585 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27586 | ········otherVar.Dummy = 4711; |
27587 | ········pm.Save(); |
27588 | ········pm.UnloadCache(); |
27589 | ········QueryOther(); |
27590 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27591 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27592 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27593 | ····} |
27594 | ····[Test] |
27595 | ····public void TestRelationHash() |
27596 | ····{ |
27597 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidLeftBase)); |
27598 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27599 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidRight)); |
27600 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27601 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27602 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27603 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidLeftDerived)); |
27604 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27605 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27606 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27607 | ····} |
27608 | ····void CreateObjects() |
27609 | ····{ |
27610 | ········pm.MakePersistent(ownVar); |
27611 | ········ownVar.AssignRelation(otherVar); |
27612 | ········pm.Save(); |
27613 | ········pm.UnloadCache(); |
27614 | ····} |
27615 | ····void QueryOwn() |
27616 | ····{ |
27617 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblGuidLeftBase>(pm); |
27618 | ········ownVar = q.ExecuteSingle(); |
27619 | ····} |
27620 | ····void QueryOther() |
27621 | ····{ |
27622 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblGuidRight>(pm); |
27623 | ········otherVar = q.ExecuteSingle(); |
27624 | ····} |
27625 | } |
27626 | |
27627 | |
27628 | [TestFixture] |
27629 | public class TestCmpBi11OwnpabsTblGuid : NDOTest |
27630 | { |
27631 | ····CmpBi11OwnpabsTblGuidLeftBase ownVar; |
27632 | ····CmpBi11OwnpabsTblGuidRight otherVar; |
27633 | ····PersistenceManager pm; |
27634 | ····[SetUp] |
27635 | ····public void Setup() |
27636 | ····{ |
27637 | ········pm = PmFactory.NewPersistenceManager(); |
27638 | ········ownVar = new CmpBi11OwnpabsTblGuidLeftDerived(); |
27639 | ········otherVar = new CmpBi11OwnpabsTblGuidRight(); |
27640 | ····} |
27641 | ····[TearDown] |
27642 | ····public void TearDown() |
27643 | ····{ |
27644 | ········try |
27645 | ········{ |
27646 | ············pm.UnloadCache(); |
27647 | ············var l = pm.Objects<CmpBi11OwnpabsTblGuidLeftBase>().ResultTable; |
27648 | ············pm.Delete(l); |
27649 | ············pm.Save(); |
27650 | ············pm.UnloadCache(); |
27651 | ············decimal count; |
27652 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27653 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27654 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27655 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27656 | ········} |
27657 | ········catch (Exception) |
27658 | ········{ |
27659 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27660 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27661 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27662 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27663 | ········} |
27664 | ····} |
27665 | ····[Test] |
27666 | ····public void TestSaveReload() |
27667 | ····{ |
27668 | ········CreateObjects(); |
27669 | ········QueryOwn(); |
27670 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27671 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27672 | ····} |
27673 | ····[Test] |
27674 | ····public void TestSaveReloadNull() |
27675 | ····{ |
27676 | ········CreateObjects(); |
27677 | ········QueryOwn(); |
27678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27679 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27680 | ········ownVar.RelField = null; |
27681 | ········pm.Save(); |
27682 | ········pm.UnloadCache(); |
27683 | ········QueryOwn(); |
27684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27685 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27686 | ····} |
27687 | ····[Test] |
27688 | ····public void TestChangeKeyHolderLeft() |
27689 | ····{ |
27690 | ········CreateObjects(); |
27691 | ········QueryOwn(); |
27692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27693 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27694 | ········int x = ownVar.RelField.Dummy; |
27695 | ········ownVar.Dummy = 4711; |
27696 | ········pm.Save(); |
27697 | ········pm.UnloadCache(); |
27698 | ········QueryOwn(); |
27699 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27700 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27701 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27702 | ····} |
27703 | ····[Test] |
27704 | ····public void TestChangeKeyHolderRight() |
27705 | ····{ |
27706 | ········CreateObjects(); |
27707 | ········QueryOther(); |
27708 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27709 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27710 | ········int x = otherVar.RelField.Dummy; |
27711 | ········otherVar.Dummy = 4711; |
27712 | ········pm.Save(); |
27713 | ········pm.UnloadCache(); |
27714 | ········QueryOther(); |
27715 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27716 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27717 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27718 | ····} |
27719 | ····[Test] |
27720 | ····public void TestChangeKeyHolderLeftNoTouch() |
27721 | ····{ |
27722 | ········CreateObjects(); |
27723 | ········QueryOwn(); |
27724 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27725 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27726 | ········ownVar.Dummy = 4711; |
27727 | ········pm.Save(); |
27728 | ········pm.UnloadCache(); |
27729 | ········QueryOwn(); |
27730 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27731 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27732 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27733 | ····} |
27734 | ····[Test] |
27735 | ····public void TestChangeKeyHolderRightNoTouch() |
27736 | ····{ |
27737 | ········CreateObjects(); |
27738 | ········QueryOther(); |
27739 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27740 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27741 | ········otherVar.Dummy = 4711; |
27742 | ········pm.Save(); |
27743 | ········pm.UnloadCache(); |
27744 | ········QueryOther(); |
27745 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27746 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27747 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27748 | ····} |
27749 | ····[Test] |
27750 | ····public void TestRelationHash() |
27751 | ····{ |
27752 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidLeftBase)); |
27753 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27754 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidRight)); |
27755 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27756 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27757 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27758 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidLeftDerived)); |
27759 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27760 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27761 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27762 | ····} |
27763 | ····void CreateObjects() |
27764 | ····{ |
27765 | ········pm.MakePersistent(ownVar); |
27766 | ········ownVar.AssignRelation(otherVar); |
27767 | ········pm.Save(); |
27768 | ········pm.UnloadCache(); |
27769 | ····} |
27770 | ····void QueryOwn() |
27771 | ····{ |
27772 | ········var q = new NDOQuery<CmpBi11OwnpabsTblGuidLeftBase>(pm); |
27773 | ········ownVar = q.ExecuteSingle(); |
27774 | ····} |
27775 | ····void QueryOther() |
27776 | ····{ |
27777 | ········var q = new NDOQuery<CmpBi11OwnpabsTblGuidRight>(pm); |
27778 | ········otherVar = q.ExecuteSingle(); |
27779 | ····} |
27780 | } |
27781 | |
27782 | |
27783 | [TestFixture] |
27784 | public class TestCmpDirnOwnpabsNoTblGuid : NDOTest |
27785 | { |
27786 | ····CmpDirnOwnpabsNoTblGuidLeftBase ownVar; |
27787 | ····CmpDirnOwnpabsNoTblGuidRight otherVar; |
27788 | ····PersistenceManager pm; |
27789 | ····[SetUp] |
27790 | ····public void Setup() |
27791 | ····{ |
27792 | ········pm = PmFactory.NewPersistenceManager(); |
27793 | ········ownVar = new CmpDirnOwnpabsNoTblGuidLeftDerived(); |
27794 | ········otherVar = new CmpDirnOwnpabsNoTblGuidRight(); |
27795 | ····} |
27796 | ····[TearDown] |
27797 | ····public void TearDown() |
27798 | ····{ |
27799 | ········try |
27800 | ········{ |
27801 | ············pm.UnloadCache(); |
27802 | ············var l = pm.Objects<CmpDirnOwnpabsNoTblGuidLeftBase>().ResultTable; |
27803 | ············pm.Delete(l); |
27804 | ············pm.Save(); |
27805 | ············pm.UnloadCache(); |
27806 | ············decimal count; |
27807 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27808 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27809 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27810 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27811 | ········} |
27812 | ········catch (Exception) |
27813 | ········{ |
27814 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27815 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27816 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27817 | ········} |
27818 | ····} |
27819 | ····[Test] |
27820 | ····public void TestSaveReload() |
27821 | ····{ |
27822 | ········CreateObjects(); |
27823 | ········QueryOwn(); |
27824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27825 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27826 | ····} |
27827 | ····[Test] |
27828 | ····public void TestSaveReloadNull() |
27829 | ····{ |
27830 | ········CreateObjects(); |
27831 | ········QueryOwn(); |
27832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27833 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27834 | ········ownVar.RelField = new List<CmpDirnOwnpabsNoTblGuidRight>(); |
27835 | ········pm.Save(); |
27836 | ········pm.UnloadCache(); |
27837 | ········QueryOwn(); |
27838 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27839 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27840 | ····} |
27841 | ····[Test] |
27842 | ····public void TestSaveReloadRemove() |
27843 | ····{ |
27844 | ········CreateObjects(); |
27845 | ········QueryOwn(); |
27846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27847 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27848 | ········ownVar.RemoveRelatedObject(); |
27849 | ········pm.Save(); |
27850 | ········pm.UnloadCache(); |
27851 | ········QueryOwn(); |
27852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27853 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27854 | ····} |
27855 | ····void CreateObjects() |
27856 | ····{ |
27857 | ········pm.MakePersistent(ownVar); |
27858 | ········ownVar.AssignRelation(otherVar); |
27859 | ········pm.Save(); |
27860 | ········pm.UnloadCache(); |
27861 | ····} |
27862 | ····void QueryOwn() |
27863 | ····{ |
27864 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblGuidLeftBase>(pm); |
27865 | ········ownVar = q.ExecuteSingle(); |
27866 | ····} |
27867 | ····void QueryOther() |
27868 | ····{ |
27869 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblGuidRight>(pm); |
27870 | ········otherVar = q.ExecuteSingle(); |
27871 | ····} |
27872 | } |
27873 | |
27874 | |
27875 | [TestFixture] |
27876 | public class TestCmpDirnOwnpabsTblGuid : NDOTest |
27877 | { |
27878 | ····CmpDirnOwnpabsTblGuidLeftBase ownVar; |
27879 | ····CmpDirnOwnpabsTblGuidRight otherVar; |
27880 | ····PersistenceManager pm; |
27881 | ····[SetUp] |
27882 | ····public void Setup() |
27883 | ····{ |
27884 | ········pm = PmFactory.NewPersistenceManager(); |
27885 | ········ownVar = new CmpDirnOwnpabsTblGuidLeftDerived(); |
27886 | ········otherVar = new CmpDirnOwnpabsTblGuidRight(); |
27887 | ····} |
27888 | ····[TearDown] |
27889 | ····public void TearDown() |
27890 | ····{ |
27891 | ········try |
27892 | ········{ |
27893 | ············pm.UnloadCache(); |
27894 | ············var l = pm.Objects<CmpDirnOwnpabsTblGuidLeftBase>().ResultTable; |
27895 | ············pm.Delete(l); |
27896 | ············pm.Save(); |
27897 | ············pm.UnloadCache(); |
27898 | ············decimal count; |
27899 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27901 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27902 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27903 | ········} |
27904 | ········catch (Exception) |
27905 | ········{ |
27906 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27907 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27909 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27910 | ········} |
27911 | ····} |
27912 | ····[Test] |
27913 | ····public void TestSaveReload() |
27914 | ····{ |
27915 | ········CreateObjects(); |
27916 | ········QueryOwn(); |
27917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27918 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27919 | ····} |
27920 | ····[Test] |
27921 | ····public void TestSaveReloadNull() |
27922 | ····{ |
27923 | ········CreateObjects(); |
27924 | ········QueryOwn(); |
27925 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27926 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27927 | ········ownVar.RelField = new List<CmpDirnOwnpabsTblGuidRight>(); |
27928 | ········pm.Save(); |
27929 | ········pm.UnloadCache(); |
27930 | ········QueryOwn(); |
27931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27932 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27933 | ····} |
27934 | ····[Test] |
27935 | ····public void TestSaveReloadRemove() |
27936 | ····{ |
27937 | ········CreateObjects(); |
27938 | ········QueryOwn(); |
27939 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27940 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27941 | ········ownVar.RemoveRelatedObject(); |
27942 | ········pm.Save(); |
27943 | ········pm.UnloadCache(); |
27944 | ········QueryOwn(); |
27945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27946 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27947 | ····} |
27948 | ····void CreateObjects() |
27949 | ····{ |
27950 | ········pm.MakePersistent(ownVar); |
27951 | ········ownVar.AssignRelation(otherVar); |
27952 | ········pm.Save(); |
27953 | ········pm.UnloadCache(); |
27954 | ····} |
27955 | ····void QueryOwn() |
27956 | ····{ |
27957 | ········var q = new NDOQuery<CmpDirnOwnpabsTblGuidLeftBase>(pm); |
27958 | ········ownVar = q.ExecuteSingle(); |
27959 | ····} |
27960 | ····void QueryOther() |
27961 | ····{ |
27962 | ········var q = new NDOQuery<CmpDirnOwnpabsTblGuidRight>(pm); |
27963 | ········otherVar = q.ExecuteSingle(); |
27964 | ····} |
27965 | } |
27966 | |
27967 | |
27968 | [TestFixture] |
27969 | public class TestCmpBin1OwnpabsNoTblGuid : NDOTest |
27970 | { |
27971 | ····CmpBin1OwnpabsNoTblGuidLeftBase ownVar; |
27972 | ····CmpBin1OwnpabsNoTblGuidRight otherVar; |
27973 | ····PersistenceManager pm; |
27974 | ····[SetUp] |
27975 | ····public void Setup() |
27976 | ····{ |
27977 | ········pm = PmFactory.NewPersistenceManager(); |
27978 | ········ownVar = new CmpBin1OwnpabsNoTblGuidLeftDerived(); |
27979 | ········otherVar = new CmpBin1OwnpabsNoTblGuidRight(); |
27980 | ····} |
27981 | ····[TearDown] |
27982 | ····public void TearDown() |
27983 | ····{ |
27984 | ········try |
27985 | ········{ |
27986 | ············pm.UnloadCache(); |
27987 | ············var l = pm.Objects<CmpBin1OwnpabsNoTblGuidLeftBase>().ResultTable; |
27988 | ············pm.Delete(l); |
27989 | ············pm.Save(); |
27990 | ············pm.UnloadCache(); |
27991 | ············decimal count; |
27992 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27993 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27994 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27995 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27996 | ········} |
27997 | ········catch (Exception) |
27998 | ········{ |
27999 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28000 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28001 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28002 | ········} |
28003 | ····} |
28004 | ····[Test] |
28005 | ····public void TestSaveReload() |
28006 | ····{ |
28007 | ········CreateObjects(); |
28008 | ········QueryOwn(); |
28009 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28010 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28011 | ····} |
28012 | ····[Test] |
28013 | ····public void TestSaveReloadNull() |
28014 | ····{ |
28015 | ········CreateObjects(); |
28016 | ········QueryOwn(); |
28017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28018 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28019 | ········ownVar.RelField = new List<CmpBin1OwnpabsNoTblGuidRight>(); |
28020 | ········pm.Save(); |
28021 | ········pm.UnloadCache(); |
28022 | ········QueryOwn(); |
28023 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28024 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28025 | ····} |
28026 | ····[Test] |
28027 | ····public void TestSaveReloadRemove() |
28028 | ····{ |
28029 | ········CreateObjects(); |
28030 | ········QueryOwn(); |
28031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28032 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28033 | ········ownVar.RemoveRelatedObject(); |
28034 | ········pm.Save(); |
28035 | ········pm.UnloadCache(); |
28036 | ········QueryOwn(); |
28037 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28038 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28039 | ····} |
28040 | ····[Test] |
28041 | ····public void TestChangeKeyHolderRight() |
28042 | ····{ |
28043 | ········CreateObjects(); |
28044 | ········QueryOther(); |
28045 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28046 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28047 | ········int x = otherVar.RelField.Dummy; |
28048 | ········otherVar.Dummy = 4711; |
28049 | ········pm.Save(); |
28050 | ········pm.UnloadCache(); |
28051 | ········QueryOther(); |
28052 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28053 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28054 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28055 | ····} |
28056 | ····[Test] |
28057 | ····public void TestChangeKeyHolderRightNoTouch() |
28058 | ····{ |
28059 | ········CreateObjects(); |
28060 | ········QueryOther(); |
28061 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28062 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28063 | ········otherVar.Dummy = 4711; |
28064 | ········pm.Save(); |
28065 | ········pm.UnloadCache(); |
28066 | ········QueryOther(); |
28067 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28068 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28069 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28070 | ····} |
28071 | ····[Test] |
28072 | ····public void TestRelationHash() |
28073 | ····{ |
28074 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidLeftBase)); |
28075 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28076 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidRight)); |
28077 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28078 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28079 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28080 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidLeftDerived)); |
28081 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28082 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28083 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28084 | ····} |
28085 | ····void CreateObjects() |
28086 | ····{ |
28087 | ········pm.MakePersistent(ownVar); |
28088 | ········ownVar.AssignRelation(otherVar); |
28089 | ········pm.Save(); |
28090 | ········pm.UnloadCache(); |
28091 | ····} |
28092 | ····void QueryOwn() |
28093 | ····{ |
28094 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblGuidLeftBase>(pm); |
28095 | ········ownVar = q.ExecuteSingle(); |
28096 | ····} |
28097 | ····void QueryOther() |
28098 | ····{ |
28099 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblGuidRight>(pm); |
28100 | ········otherVar = q.ExecuteSingle(); |
28101 | ····} |
28102 | } |
28103 | |
28104 | |
28105 | [TestFixture] |
28106 | public class TestCmpBin1OwnpabsTblGuid : NDOTest |
28107 | { |
28108 | ····CmpBin1OwnpabsTblGuidLeftBase ownVar; |
28109 | ····CmpBin1OwnpabsTblGuidRight otherVar; |
28110 | ····PersistenceManager pm; |
28111 | ····[SetUp] |
28112 | ····public void Setup() |
28113 | ····{ |
28114 | ········pm = PmFactory.NewPersistenceManager(); |
28115 | ········ownVar = new CmpBin1OwnpabsTblGuidLeftDerived(); |
28116 | ········otherVar = new CmpBin1OwnpabsTblGuidRight(); |
28117 | ····} |
28118 | ····[TearDown] |
28119 | ····public void TearDown() |
28120 | ····{ |
28121 | ········try |
28122 | ········{ |
28123 | ············pm.UnloadCache(); |
28124 | ············var l = pm.Objects<CmpBin1OwnpabsTblGuidLeftBase>().ResultTable; |
28125 | ············pm.Delete(l); |
28126 | ············pm.Save(); |
28127 | ············pm.UnloadCache(); |
28128 | ············decimal count; |
28129 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28130 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28131 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28132 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28133 | ········} |
28134 | ········catch (Exception) |
28135 | ········{ |
28136 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28137 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28138 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28139 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28140 | ········} |
28141 | ····} |
28142 | ····[Test] |
28143 | ····public void TestSaveReload() |
28144 | ····{ |
28145 | ········CreateObjects(); |
28146 | ········QueryOwn(); |
28147 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28148 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28149 | ····} |
28150 | ····[Test] |
28151 | ····public void TestSaveReloadNull() |
28152 | ····{ |
28153 | ········CreateObjects(); |
28154 | ········QueryOwn(); |
28155 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28156 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28157 | ········ownVar.RelField = new List<CmpBin1OwnpabsTblGuidRight>(); |
28158 | ········pm.Save(); |
28159 | ········pm.UnloadCache(); |
28160 | ········QueryOwn(); |
28161 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28162 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28163 | ····} |
28164 | ····[Test] |
28165 | ····public void TestSaveReloadRemove() |
28166 | ····{ |
28167 | ········CreateObjects(); |
28168 | ········QueryOwn(); |
28169 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28170 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28171 | ········ownVar.RemoveRelatedObject(); |
28172 | ········pm.Save(); |
28173 | ········pm.UnloadCache(); |
28174 | ········QueryOwn(); |
28175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28176 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28177 | ····} |
28178 | ····[Test] |
28179 | ····public void TestChangeKeyHolderRight() |
28180 | ····{ |
28181 | ········CreateObjects(); |
28182 | ········QueryOther(); |
28183 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28184 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28185 | ········int x = otherVar.RelField.Dummy; |
28186 | ········otherVar.Dummy = 4711; |
28187 | ········pm.Save(); |
28188 | ········pm.UnloadCache(); |
28189 | ········QueryOther(); |
28190 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28191 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28192 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28193 | ····} |
28194 | ····[Test] |
28195 | ····public void TestChangeKeyHolderRightNoTouch() |
28196 | ····{ |
28197 | ········CreateObjects(); |
28198 | ········QueryOther(); |
28199 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28200 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28201 | ········otherVar.Dummy = 4711; |
28202 | ········pm.Save(); |
28203 | ········pm.UnloadCache(); |
28204 | ········QueryOther(); |
28205 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28206 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28207 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28208 | ····} |
28209 | ····[Test] |
28210 | ····public void TestRelationHash() |
28211 | ····{ |
28212 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidLeftBase)); |
28213 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28214 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidRight)); |
28215 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28216 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28217 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28218 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidLeftDerived)); |
28219 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28220 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28221 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28222 | ····} |
28223 | ····void CreateObjects() |
28224 | ····{ |
28225 | ········pm.MakePersistent(ownVar); |
28226 | ········ownVar.AssignRelation(otherVar); |
28227 | ········pm.Save(); |
28228 | ········pm.UnloadCache(); |
28229 | ····} |
28230 | ····void QueryOwn() |
28231 | ····{ |
28232 | ········var q = new NDOQuery<CmpBin1OwnpabsTblGuidLeftBase>(pm); |
28233 | ········ownVar = q.ExecuteSingle(); |
28234 | ····} |
28235 | ····void QueryOther() |
28236 | ····{ |
28237 | ········var q = new NDOQuery<CmpBin1OwnpabsTblGuidRight>(pm); |
28238 | ········otherVar = q.ExecuteSingle(); |
28239 | ····} |
28240 | } |
28241 | |
28242 | |
28243 | [TestFixture] |
28244 | public class TestCmpBi1nOwnpabsTblGuid : NDOTest |
28245 | { |
28246 | ····CmpBi1nOwnpabsTblGuidLeftBase ownVar; |
28247 | ····CmpBi1nOwnpabsTblGuidRight otherVar; |
28248 | ····PersistenceManager pm; |
28249 | ····[SetUp] |
28250 | ····public void Setup() |
28251 | ····{ |
28252 | ········pm = PmFactory.NewPersistenceManager(); |
28253 | ········ownVar = new CmpBi1nOwnpabsTblGuidLeftDerived(); |
28254 | ········otherVar = new CmpBi1nOwnpabsTblGuidRight(); |
28255 | ····} |
28256 | ····[TearDown] |
28257 | ····public void TearDown() |
28258 | ····{ |
28259 | ········try |
28260 | ········{ |
28261 | ············pm.UnloadCache(); |
28262 | ············var l = pm.Objects<CmpBi1nOwnpabsTblGuidLeftBase>().ResultTable; |
28263 | ············pm.Delete(l); |
28264 | ············pm.Save(); |
28265 | ············pm.UnloadCache(); |
28266 | ············decimal count; |
28267 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28268 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28269 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28270 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28271 | ········} |
28272 | ········catch (Exception) |
28273 | ········{ |
28274 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28275 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28276 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28277 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28278 | ········} |
28279 | ····} |
28280 | ····[Test] |
28281 | ····public void TestSaveReload() |
28282 | ····{ |
28283 | ········CreateObjects(); |
28284 | ········QueryOwn(); |
28285 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28286 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28287 | ····} |
28288 | ····[Test] |
28289 | ····public void TestSaveReloadNull() |
28290 | ····{ |
28291 | ········CreateObjects(); |
28292 | ········QueryOwn(); |
28293 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28294 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28295 | ········ownVar.RelField = null; |
28296 | ········pm.Save(); |
28297 | ········pm.UnloadCache(); |
28298 | ········QueryOwn(); |
28299 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28300 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28301 | ····} |
28302 | ····[Test] |
28303 | ····public void TestChangeKeyHolderLeft() |
28304 | ····{ |
28305 | ········CreateObjects(); |
28306 | ········QueryOwn(); |
28307 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28308 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28309 | ········int x = ownVar.RelField.Dummy; |
28310 | ········ownVar.Dummy = 4711; |
28311 | ········pm.Save(); |
28312 | ········pm.UnloadCache(); |
28313 | ········QueryOwn(); |
28314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28315 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28316 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28317 | ····} |
28318 | ····[Test] |
28319 | ····public void TestChangeKeyHolderLeftNoTouch() |
28320 | ····{ |
28321 | ········CreateObjects(); |
28322 | ········QueryOwn(); |
28323 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28324 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28325 | ········ownVar.Dummy = 4711; |
28326 | ········pm.Save(); |
28327 | ········pm.UnloadCache(); |
28328 | ········QueryOwn(); |
28329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28330 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28332 | ····} |
28333 | ····[Test] |
28334 | ····public void TestRelationHash() |
28335 | ····{ |
28336 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidLeftBase)); |
28337 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28338 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidRight)); |
28339 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28340 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28341 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28342 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidLeftDerived)); |
28343 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28344 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28345 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28346 | ····} |
28347 | ····void CreateObjects() |
28348 | ····{ |
28349 | ········pm.MakePersistent(ownVar); |
28350 | ········ownVar.AssignRelation(otherVar); |
28351 | ········pm.Save(); |
28352 | ········pm.UnloadCache(); |
28353 | ····} |
28354 | ····void QueryOwn() |
28355 | ····{ |
28356 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblGuidLeftBase>(pm); |
28357 | ········ownVar = q.ExecuteSingle(); |
28358 | ····} |
28359 | ····void QueryOther() |
28360 | ····{ |
28361 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblGuidRight>(pm); |
28362 | ········otherVar = q.ExecuteSingle(); |
28363 | ····} |
28364 | } |
28365 | |
28366 | |
28367 | [TestFixture] |
28368 | public class TestCmpBinnOwnpabsTblGuid : NDOTest |
28369 | { |
28370 | ····CmpBinnOwnpabsTblGuidLeftBase ownVar; |
28371 | ····CmpBinnOwnpabsTblGuidRight otherVar; |
28372 | ····PersistenceManager pm; |
28373 | ····[SetUp] |
28374 | ····public void Setup() |
28375 | ····{ |
28376 | ········pm = PmFactory.NewPersistenceManager(); |
28377 | ········ownVar = new CmpBinnOwnpabsTblGuidLeftDerived(); |
28378 | ········otherVar = new CmpBinnOwnpabsTblGuidRight(); |
28379 | ····} |
28380 | ····[TearDown] |
28381 | ····public void TearDown() |
28382 | ····{ |
28383 | ········try |
28384 | ········{ |
28385 | ············pm.UnloadCache(); |
28386 | ············var l = pm.Objects<CmpBinnOwnpabsTblGuidLeftBase>().ResultTable; |
28387 | ············pm.Delete(l); |
28388 | ············pm.Save(); |
28389 | ············pm.UnloadCache(); |
28390 | ············decimal count; |
28391 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28392 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28393 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28394 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28395 | ········} |
28396 | ········catch (Exception) |
28397 | ········{ |
28398 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28399 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28400 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28401 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28402 | ········} |
28403 | ····} |
28404 | ····[Test] |
28405 | ····public void TestSaveReload() |
28406 | ····{ |
28407 | ········CreateObjects(); |
28408 | ········QueryOwn(); |
28409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28410 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28411 | ····} |
28412 | ····[Test] |
28413 | ····public void TestSaveReloadNull() |
28414 | ····{ |
28415 | ········CreateObjects(); |
28416 | ········QueryOwn(); |
28417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28418 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28419 | ········ownVar.RelField = new List<CmpBinnOwnpabsTblGuidRight>(); |
28420 | ········pm.Save(); |
28421 | ········pm.UnloadCache(); |
28422 | ········QueryOwn(); |
28423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28424 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28425 | ····} |
28426 | ····[Test] |
28427 | ····public void TestSaveReloadRemove() |
28428 | ····{ |
28429 | ········CreateObjects(); |
28430 | ········QueryOwn(); |
28431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28432 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28433 | ········ownVar.RemoveRelatedObject(); |
28434 | ········pm.Save(); |
28435 | ········pm.UnloadCache(); |
28436 | ········QueryOwn(); |
28437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28438 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28439 | ····} |
28440 | ····[Test] |
28441 | ····public void TestRelationHash() |
28442 | ····{ |
28443 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidLeftBase)); |
28444 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28445 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidRight)); |
28446 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28447 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28448 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28449 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidLeftDerived)); |
28450 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28451 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28452 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28453 | ····} |
28454 | ····void CreateObjects() |
28455 | ····{ |
28456 | ········pm.MakePersistent(ownVar); |
28457 | ········ownVar.AssignRelation(otherVar); |
28458 | ········pm.Save(); |
28459 | ········pm.UnloadCache(); |
28460 | ····} |
28461 | ····void QueryOwn() |
28462 | ····{ |
28463 | ········var q = new NDOQuery<CmpBinnOwnpabsTblGuidLeftBase>(pm); |
28464 | ········ownVar = q.ExecuteSingle(); |
28465 | ····} |
28466 | ····void QueryOther() |
28467 | ····{ |
28468 | ········var q = new NDOQuery<CmpBinnOwnpabsTblGuidRight>(pm); |
28469 | ········otherVar = q.ExecuteSingle(); |
28470 | ····} |
28471 | } |
28472 | |
28473 | |
28474 | [TestFixture] |
28475 | public class TestAgrDir1OthpabsNoTblGuid : NDOTest |
28476 | { |
28477 | ····AgrDir1OthpabsNoTblGuidLeft ownVar; |
28478 | ····AgrDir1OthpabsNoTblGuidRightBase otherVar; |
28479 | ····PersistenceManager pm; |
28480 | ····[SetUp] |
28481 | ····public void Setup() |
28482 | ····{ |
28483 | ········pm = PmFactory.NewPersistenceManager(); |
28484 | ········ownVar = new AgrDir1OthpabsNoTblGuidLeft(); |
28485 | ········otherVar = new AgrDir1OthpabsNoTblGuidRightDerived(); |
28486 | ····} |
28487 | ····[TearDown] |
28488 | ····public void TearDown() |
28489 | ····{ |
28490 | ········try |
28491 | ········{ |
28492 | ············pm.UnloadCache(); |
28493 | ············var l = pm.Objects<AgrDir1OthpabsNoTblGuidLeft>().ResultTable; |
28494 | ············pm.Delete(l); |
28495 | ············pm.Save(); |
28496 | ············pm.UnloadCache(); |
28497 | ············var m = pm.Objects<AgrDir1OthpabsNoTblGuidRightBase>().ResultTable; |
28498 | ············pm.Delete(m); |
28499 | ············pm.Save(); |
28500 | ············pm.UnloadCache(); |
28501 | ············decimal count; |
28502 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28503 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28504 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28505 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28506 | ········} |
28507 | ········catch (Exception) |
28508 | ········{ |
28509 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28510 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28511 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28512 | ········} |
28513 | ····} |
28514 | ····[Test] |
28515 | ····public void TestSaveReload() |
28516 | ····{ |
28517 | ········CreateObjects(); |
28518 | ········QueryOwn(); |
28519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28520 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28521 | ····} |
28522 | ····[Test] |
28523 | ····public void TestSaveReloadNull() |
28524 | ····{ |
28525 | ········CreateObjects(); |
28526 | ········QueryOwn(); |
28527 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28528 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28529 | ········ownVar.RelField = null; |
28530 | ········pm.Save(); |
28531 | ········pm.UnloadCache(); |
28532 | ········QueryOwn(); |
28533 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28534 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28535 | ····} |
28536 | ····[Test] |
28537 | ····public void TestChangeKeyHolderLeft() |
28538 | ····{ |
28539 | ········CreateObjects(); |
28540 | ········QueryOwn(); |
28541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28542 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28543 | ········int x = ownVar.RelField.Dummy; |
28544 | ········ownVar.Dummy = 4711; |
28545 | ········pm.Save(); |
28546 | ········pm.UnloadCache(); |
28547 | ········QueryOwn(); |
28548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28549 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28550 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28551 | ····} |
28552 | ····[Test] |
28553 | ····public void TestChangeKeyHolderLeftNoTouch() |
28554 | ····{ |
28555 | ········CreateObjects(); |
28556 | ········QueryOwn(); |
28557 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28558 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28559 | ········ownVar.Dummy = 4711; |
28560 | ········pm.Save(); |
28561 | ········pm.UnloadCache(); |
28562 | ········QueryOwn(); |
28563 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28564 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28566 | ····} |
28567 | ····void CreateObjects() |
28568 | ····{ |
28569 | ········pm.MakePersistent(ownVar); |
28570 | ········pm.MakePersistent(otherVar); |
28571 | ········ownVar.AssignRelation(otherVar); |
28572 | ········pm.Save(); |
28573 | ········pm.UnloadCache(); |
28574 | ····} |
28575 | ····void QueryOwn() |
28576 | ····{ |
28577 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblGuidLeft>(pm); |
28578 | ········ownVar = q.ExecuteSingle(); |
28579 | ····} |
28580 | ····void QueryOther() |
28581 | ····{ |
28582 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblGuidRightBase>(pm); |
28583 | ········otherVar = q.ExecuteSingle(); |
28584 | ····} |
28585 | } |
28586 | |
28587 | |
28588 | [TestFixture] |
28589 | public class TestAgrDir1OthpabsTblGuid : NDOTest |
28590 | { |
28591 | ····AgrDir1OthpabsTblGuidLeft ownVar; |
28592 | ····AgrDir1OthpabsTblGuidRightBase otherVar; |
28593 | ····PersistenceManager pm; |
28594 | ····[SetUp] |
28595 | ····public void Setup() |
28596 | ····{ |
28597 | ········pm = PmFactory.NewPersistenceManager(); |
28598 | ········ownVar = new AgrDir1OthpabsTblGuidLeft(); |
28599 | ········otherVar = new AgrDir1OthpabsTblGuidRightDerived(); |
28600 | ····} |
28601 | ····[TearDown] |
28602 | ····public void TearDown() |
28603 | ····{ |
28604 | ········try |
28605 | ········{ |
28606 | ············pm.UnloadCache(); |
28607 | ············var l = pm.Objects<AgrDir1OthpabsTblGuidLeft>().ResultTable; |
28608 | ············pm.Delete(l); |
28609 | ············pm.Save(); |
28610 | ············pm.UnloadCache(); |
28611 | ············var m = pm.Objects<AgrDir1OthpabsTblGuidRightBase>().ResultTable; |
28612 | ············pm.Delete(m); |
28613 | ············pm.Save(); |
28614 | ············pm.UnloadCache(); |
28615 | ············decimal count; |
28616 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28617 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28618 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28619 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28620 | ········} |
28621 | ········catch (Exception) |
28622 | ········{ |
28623 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28624 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28625 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28626 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28627 | ········} |
28628 | ····} |
28629 | ····[Test] |
28630 | ····public void TestSaveReload() |
28631 | ····{ |
28632 | ········CreateObjects(); |
28633 | ········QueryOwn(); |
28634 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28635 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28636 | ····} |
28637 | ····[Test] |
28638 | ····public void TestSaveReloadNull() |
28639 | ····{ |
28640 | ········CreateObjects(); |
28641 | ········QueryOwn(); |
28642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28643 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28644 | ········ownVar.RelField = null; |
28645 | ········pm.Save(); |
28646 | ········pm.UnloadCache(); |
28647 | ········QueryOwn(); |
28648 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28649 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28650 | ····} |
28651 | ····[Test] |
28652 | ····public void TestChangeKeyHolderLeft() |
28653 | ····{ |
28654 | ········CreateObjects(); |
28655 | ········QueryOwn(); |
28656 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28657 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28658 | ········int x = ownVar.RelField.Dummy; |
28659 | ········ownVar.Dummy = 4711; |
28660 | ········pm.Save(); |
28661 | ········pm.UnloadCache(); |
28662 | ········QueryOwn(); |
28663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28664 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28665 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28666 | ····} |
28667 | ····[Test] |
28668 | ····public void TestChangeKeyHolderLeftNoTouch() |
28669 | ····{ |
28670 | ········CreateObjects(); |
28671 | ········QueryOwn(); |
28672 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28673 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28674 | ········ownVar.Dummy = 4711; |
28675 | ········pm.Save(); |
28676 | ········pm.UnloadCache(); |
28677 | ········QueryOwn(); |
28678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28679 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28680 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28681 | ····} |
28682 | ····void CreateObjects() |
28683 | ····{ |
28684 | ········pm.MakePersistent(ownVar); |
28685 | ········pm.MakePersistent(otherVar); |
28686 | ········ownVar.AssignRelation(otherVar); |
28687 | ········pm.Save(); |
28688 | ········pm.UnloadCache(); |
28689 | ····} |
28690 | ····void QueryOwn() |
28691 | ····{ |
28692 | ········var q = new NDOQuery<AgrDir1OthpabsTblGuidLeft>(pm); |
28693 | ········ownVar = q.ExecuteSingle(); |
28694 | ····} |
28695 | ····void QueryOther() |
28696 | ····{ |
28697 | ········var q = new NDOQuery<AgrDir1OthpabsTblGuidRightBase>(pm); |
28698 | ········otherVar = q.ExecuteSingle(); |
28699 | ····} |
28700 | } |
28701 | |
28702 | |
28703 | [TestFixture] |
28704 | public class TestAgrBi11OthpabsNoTblGuid : NDOTest |
28705 | { |
28706 | ····AgrBi11OthpabsNoTblGuidLeft ownVar; |
28707 | ····AgrBi11OthpabsNoTblGuidRightBase otherVar; |
28708 | ····PersistenceManager pm; |
28709 | ····[SetUp] |
28710 | ····public void Setup() |
28711 | ····{ |
28712 | ········pm = PmFactory.NewPersistenceManager(); |
28713 | ········ownVar = new AgrBi11OthpabsNoTblGuidLeft(); |
28714 | ········otherVar = new AgrBi11OthpabsNoTblGuidRightDerived(); |
28715 | ····} |
28716 | ····[TearDown] |
28717 | ····public void TearDown() |
28718 | ····{ |
28719 | ········try |
28720 | ········{ |
28721 | ············pm.UnloadCache(); |
28722 | ············var l = pm.Objects<AgrBi11OthpabsNoTblGuidLeft>().ResultTable; |
28723 | ············pm.Delete(l); |
28724 | ············pm.Save(); |
28725 | ············pm.UnloadCache(); |
28726 | ············var m = pm.Objects<AgrBi11OthpabsNoTblGuidRightBase>().ResultTable; |
28727 | ············pm.Delete(m); |
28728 | ············pm.Save(); |
28729 | ············pm.UnloadCache(); |
28730 | ············decimal count; |
28731 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28732 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28733 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28734 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28735 | ········} |
28736 | ········catch (Exception) |
28737 | ········{ |
28738 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28739 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28740 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28741 | ········} |
28742 | ····} |
28743 | ····[Test] |
28744 | ····public void TestSaveReload() |
28745 | ····{ |
28746 | ········CreateObjects(); |
28747 | ········QueryOwn(); |
28748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28749 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28750 | ····} |
28751 | ····[Test] |
28752 | ····public void TestSaveReloadNull() |
28753 | ····{ |
28754 | ········CreateObjects(); |
28755 | ········QueryOwn(); |
28756 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28757 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28758 | ········ownVar.RelField = null; |
28759 | ········pm.Save(); |
28760 | ········pm.UnloadCache(); |
28761 | ········QueryOwn(); |
28762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28763 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28764 | ····} |
28765 | ····[Test] |
28766 | ····public void TestChangeKeyHolderLeft() |
28767 | ····{ |
28768 | ········CreateObjects(); |
28769 | ········QueryOwn(); |
28770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28771 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28772 | ········int x = ownVar.RelField.Dummy; |
28773 | ········ownVar.Dummy = 4711; |
28774 | ········pm.Save(); |
28775 | ········pm.UnloadCache(); |
28776 | ········QueryOwn(); |
28777 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28778 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28779 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28780 | ····} |
28781 | ····[Test] |
28782 | ····public void TestChangeKeyHolderRight() |
28783 | ····{ |
28784 | ········CreateObjects(); |
28785 | ········QueryOther(); |
28786 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28787 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28788 | ········int x = otherVar.RelField.Dummy; |
28789 | ········otherVar.Dummy = 4711; |
28790 | ········pm.Save(); |
28791 | ········pm.UnloadCache(); |
28792 | ········QueryOther(); |
28793 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28794 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28795 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28796 | ····} |
28797 | ····[Test] |
28798 | ····public void TestChangeKeyHolderLeftNoTouch() |
28799 | ····{ |
28800 | ········CreateObjects(); |
28801 | ········QueryOwn(); |
28802 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28803 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28804 | ········ownVar.Dummy = 4711; |
28805 | ········pm.Save(); |
28806 | ········pm.UnloadCache(); |
28807 | ········QueryOwn(); |
28808 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28809 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28810 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28811 | ····} |
28812 | ····[Test] |
28813 | ····public void TestChangeKeyHolderRightNoTouch() |
28814 | ····{ |
28815 | ········CreateObjects(); |
28816 | ········QueryOther(); |
28817 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28818 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28819 | ········otherVar.Dummy = 4711; |
28820 | ········pm.Save(); |
28821 | ········pm.UnloadCache(); |
28822 | ········QueryOther(); |
28823 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28824 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28825 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28826 | ····} |
28827 | ····[Test] |
28828 | ····public void TestRelationHash() |
28829 | ····{ |
28830 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidLeft)); |
28831 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28832 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidRightBase)); |
28833 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28834 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28835 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28836 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidRightDerived)); |
28837 | ········Relation relderRight = clderRight.FindRelation("relField"); |
28838 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
28839 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
28840 | ····} |
28841 | ····void CreateObjects() |
28842 | ····{ |
28843 | ········pm.MakePersistent(ownVar); |
28844 | ········pm.MakePersistent(otherVar); |
28845 | ········ownVar.AssignRelation(otherVar); |
28846 | ········pm.Save(); |
28847 | ········pm.UnloadCache(); |
28848 | ····} |
28849 | ····void QueryOwn() |
28850 | ····{ |
28851 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblGuidLeft>(pm); |
28852 | ········ownVar = q.ExecuteSingle(); |
28853 | ····} |
28854 | ····void QueryOther() |
28855 | ····{ |
28856 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblGuidRightBase>(pm); |
28857 | ········otherVar = q.ExecuteSingle(); |
28858 | ····} |
28859 | } |
28860 | |
28861 | |
28862 | [TestFixture] |
28863 | public class TestAgrBi11OthpabsTblGuid : NDOTest |
28864 | { |
28865 | ····AgrBi11OthpabsTblGuidLeft ownVar; |
28866 | ····AgrBi11OthpabsTblGuidRightBase otherVar; |
28867 | ····PersistenceManager pm; |
28868 | ····[SetUp] |
28869 | ····public void Setup() |
28870 | ····{ |
28871 | ········pm = PmFactory.NewPersistenceManager(); |
28872 | ········ownVar = new AgrBi11OthpabsTblGuidLeft(); |
28873 | ········otherVar = new AgrBi11OthpabsTblGuidRightDerived(); |
28874 | ····} |
28875 | ····[TearDown] |
28876 | ····public void TearDown() |
28877 | ····{ |
28878 | ········try |
28879 | ········{ |
28880 | ············pm.UnloadCache(); |
28881 | ············var l = pm.Objects<AgrBi11OthpabsTblGuidLeft>().ResultTable; |
28882 | ············pm.Delete(l); |
28883 | ············pm.Save(); |
28884 | ············pm.UnloadCache(); |
28885 | ············var m = pm.Objects<AgrBi11OthpabsTblGuidRightBase>().ResultTable; |
28886 | ············pm.Delete(m); |
28887 | ············pm.Save(); |
28888 | ············pm.UnloadCache(); |
28889 | ············decimal count; |
28890 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28891 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28892 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28893 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28894 | ········} |
28895 | ········catch (Exception) |
28896 | ········{ |
28897 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28898 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28899 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28900 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28901 | ········} |
28902 | ····} |
28903 | ····[Test] |
28904 | ····public void TestSaveReload() |
28905 | ····{ |
28906 | ········CreateObjects(); |
28907 | ········QueryOwn(); |
28908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28910 | ····} |
28911 | ····[Test] |
28912 | ····public void TestSaveReloadNull() |
28913 | ····{ |
28914 | ········CreateObjects(); |
28915 | ········QueryOwn(); |
28916 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28917 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28918 | ········ownVar.RelField = null; |
28919 | ········pm.Save(); |
28920 | ········pm.UnloadCache(); |
28921 | ········QueryOwn(); |
28922 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28923 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28924 | ····} |
28925 | ····[Test] |
28926 | ····public void TestChangeKeyHolderLeft() |
28927 | ····{ |
28928 | ········CreateObjects(); |
28929 | ········QueryOwn(); |
28930 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28931 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28932 | ········int x = ownVar.RelField.Dummy; |
28933 | ········ownVar.Dummy = 4711; |
28934 | ········pm.Save(); |
28935 | ········pm.UnloadCache(); |
28936 | ········QueryOwn(); |
28937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28938 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28939 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28940 | ····} |
28941 | ····[Test] |
28942 | ····public void TestChangeKeyHolderRight() |
28943 | ····{ |
28944 | ········CreateObjects(); |
28945 | ········QueryOther(); |
28946 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28947 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28948 | ········int x = otherVar.RelField.Dummy; |
28949 | ········otherVar.Dummy = 4711; |
28950 | ········pm.Save(); |
28951 | ········pm.UnloadCache(); |
28952 | ········QueryOther(); |
28953 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28954 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28955 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28956 | ····} |
28957 | ····[Test] |
28958 | ····public void TestChangeKeyHolderLeftNoTouch() |
28959 | ····{ |
28960 | ········CreateObjects(); |
28961 | ········QueryOwn(); |
28962 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28963 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28964 | ········ownVar.Dummy = 4711; |
28965 | ········pm.Save(); |
28966 | ········pm.UnloadCache(); |
28967 | ········QueryOwn(); |
28968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28969 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28970 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28971 | ····} |
28972 | ····[Test] |
28973 | ····public void TestChangeKeyHolderRightNoTouch() |
28974 | ····{ |
28975 | ········CreateObjects(); |
28976 | ········QueryOther(); |
28977 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28978 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28979 | ········otherVar.Dummy = 4711; |
28980 | ········pm.Save(); |
28981 | ········pm.UnloadCache(); |
28982 | ········QueryOther(); |
28983 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28984 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28985 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28986 | ····} |
28987 | ····[Test] |
28988 | ····public void TestRelationHash() |
28989 | ····{ |
28990 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidLeft)); |
28991 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28992 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidRightBase)); |
28993 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28994 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28995 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28996 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidRightDerived)); |
28997 | ········Relation relderRight = clderRight.FindRelation("relField"); |
28998 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
28999 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29000 | ····} |
29001 | ····void CreateObjects() |
29002 | ····{ |
29003 | ········pm.MakePersistent(ownVar); |
29004 | ········pm.MakePersistent(otherVar); |
29005 | ········ownVar.AssignRelation(otherVar); |
29006 | ········pm.Save(); |
29007 | ········pm.UnloadCache(); |
29008 | ····} |
29009 | ····void QueryOwn() |
29010 | ····{ |
29011 | ········var q = new NDOQuery<AgrBi11OthpabsTblGuidLeft>(pm); |
29012 | ········ownVar = q.ExecuteSingle(); |
29013 | ····} |
29014 | ····void QueryOther() |
29015 | ····{ |
29016 | ········var q = new NDOQuery<AgrBi11OthpabsTblGuidRightBase>(pm); |
29017 | ········otherVar = q.ExecuteSingle(); |
29018 | ····} |
29019 | } |
29020 | |
29021 | |
29022 | [TestFixture] |
29023 | public class TestAgrDirnOthpabsTblGuid : NDOTest |
29024 | { |
29025 | ····AgrDirnOthpabsTblGuidLeft ownVar; |
29026 | ····AgrDirnOthpabsTblGuidRightBase otherVar; |
29027 | ····PersistenceManager pm; |
29028 | ····[SetUp] |
29029 | ····public void Setup() |
29030 | ····{ |
29031 | ········pm = PmFactory.NewPersistenceManager(); |
29032 | ········ownVar = new AgrDirnOthpabsTblGuidLeft(); |
29033 | ········otherVar = new AgrDirnOthpabsTblGuidRightDerived(); |
29034 | ····} |
29035 | ····[TearDown] |
29036 | ····public void TearDown() |
29037 | ····{ |
29038 | ········try |
29039 | ········{ |
29040 | ············pm.UnloadCache(); |
29041 | ············var l = pm.Objects<AgrDirnOthpabsTblGuidLeft>().ResultTable; |
29042 | ············pm.Delete(l); |
29043 | ············pm.Save(); |
29044 | ············pm.UnloadCache(); |
29045 | ············var m = pm.Objects<AgrDirnOthpabsTblGuidRightBase>().ResultTable; |
29046 | ············pm.Delete(m); |
29047 | ············pm.Save(); |
29048 | ············pm.UnloadCache(); |
29049 | ············decimal count; |
29050 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29051 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29052 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29053 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29054 | ········} |
29055 | ········catch (Exception) |
29056 | ········{ |
29057 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29058 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29059 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29060 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29061 | ········} |
29062 | ····} |
29063 | ····[Test] |
29064 | ····public void TestSaveReload() |
29065 | ····{ |
29066 | ········CreateObjects(); |
29067 | ········QueryOwn(); |
29068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29069 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29070 | ····} |
29071 | ····[Test] |
29072 | ····public void TestSaveReloadNull() |
29073 | ····{ |
29074 | ········CreateObjects(); |
29075 | ········QueryOwn(); |
29076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29077 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29078 | ········ownVar.RelField = new List<AgrDirnOthpabsTblGuidRightBase>(); |
29079 | ········pm.Save(); |
29080 | ········pm.UnloadCache(); |
29081 | ········QueryOwn(); |
29082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29083 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29084 | ····} |
29085 | ····[Test] |
29086 | ····public void TestSaveReloadRemove() |
29087 | ····{ |
29088 | ········CreateObjects(); |
29089 | ········QueryOwn(); |
29090 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29091 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29092 | ········ownVar.RemoveRelatedObject(); |
29093 | ········pm.Save(); |
29094 | ········pm.UnloadCache(); |
29095 | ········QueryOwn(); |
29096 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29097 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29098 | ····} |
29099 | ····void CreateObjects() |
29100 | ····{ |
29101 | ········pm.MakePersistent(ownVar); |
29102 | ········pm.MakePersistent(otherVar); |
29103 | ········ownVar.AssignRelation(otherVar); |
29104 | ········pm.Save(); |
29105 | ········pm.UnloadCache(); |
29106 | ····} |
29107 | ····void QueryOwn() |
29108 | ····{ |
29109 | ········var q = new NDOQuery<AgrDirnOthpabsTblGuidLeft>(pm); |
29110 | ········ownVar = q.ExecuteSingle(); |
29111 | ····} |
29112 | ····void QueryOther() |
29113 | ····{ |
29114 | ········var q = new NDOQuery<AgrDirnOthpabsTblGuidRightBase>(pm); |
29115 | ········otherVar = q.ExecuteSingle(); |
29116 | ····} |
29117 | } |
29118 | |
29119 | |
29120 | [TestFixture] |
29121 | public class TestAgrBin1OthpabsTblGuid : NDOTest |
29122 | { |
29123 | ····AgrBin1OthpabsTblGuidLeft ownVar; |
29124 | ····AgrBin1OthpabsTblGuidRightBase otherVar; |
29125 | ····PersistenceManager pm; |
29126 | ····[SetUp] |
29127 | ····public void Setup() |
29128 | ····{ |
29129 | ········pm = PmFactory.NewPersistenceManager(); |
29130 | ········ownVar = new AgrBin1OthpabsTblGuidLeft(); |
29131 | ········otherVar = new AgrBin1OthpabsTblGuidRightDerived(); |
29132 | ····} |
29133 | ····[TearDown] |
29134 | ····public void TearDown() |
29135 | ····{ |
29136 | ········try |
29137 | ········{ |
29138 | ············pm.UnloadCache(); |
29139 | ············var l = pm.Objects<AgrBin1OthpabsTblGuidLeft>().ResultTable; |
29140 | ············pm.Delete(l); |
29141 | ············pm.Save(); |
29142 | ············pm.UnloadCache(); |
29143 | ············var m = pm.Objects<AgrBin1OthpabsTblGuidRightBase>().ResultTable; |
29144 | ············pm.Delete(m); |
29145 | ············pm.Save(); |
29146 | ············pm.UnloadCache(); |
29147 | ············decimal count; |
29148 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29150 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29151 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29152 | ········} |
29153 | ········catch (Exception) |
29154 | ········{ |
29155 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29156 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29158 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29159 | ········} |
29160 | ····} |
29161 | ····[Test] |
29162 | ····public void TestSaveReload() |
29163 | ····{ |
29164 | ········CreateObjects(); |
29165 | ········QueryOwn(); |
29166 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29167 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29168 | ····} |
29169 | ····[Test] |
29170 | ····public void TestSaveReloadNull() |
29171 | ····{ |
29172 | ········CreateObjects(); |
29173 | ········QueryOwn(); |
29174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29175 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29176 | ········ownVar.RelField = new List<AgrBin1OthpabsTblGuidRightBase>(); |
29177 | ········pm.Save(); |
29178 | ········pm.UnloadCache(); |
29179 | ········QueryOwn(); |
29180 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29181 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29182 | ····} |
29183 | ····[Test] |
29184 | ····public void TestSaveReloadRemove() |
29185 | ····{ |
29186 | ········CreateObjects(); |
29187 | ········QueryOwn(); |
29188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29189 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29190 | ········ownVar.RemoveRelatedObject(); |
29191 | ········pm.Save(); |
29192 | ········pm.UnloadCache(); |
29193 | ········QueryOwn(); |
29194 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29195 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29196 | ····} |
29197 | ····[Test] |
29198 | ····public void TestChangeKeyHolderRight() |
29199 | ····{ |
29200 | ········CreateObjects(); |
29201 | ········QueryOther(); |
29202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29204 | ········int x = otherVar.RelField.Dummy; |
29205 | ········otherVar.Dummy = 4711; |
29206 | ········pm.Save(); |
29207 | ········pm.UnloadCache(); |
29208 | ········QueryOther(); |
29209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29212 | ····} |
29213 | ····[Test] |
29214 | ····public void TestChangeKeyHolderRightNoTouch() |
29215 | ····{ |
29216 | ········CreateObjects(); |
29217 | ········QueryOther(); |
29218 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29219 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29220 | ········otherVar.Dummy = 4711; |
29221 | ········pm.Save(); |
29222 | ········pm.UnloadCache(); |
29223 | ········QueryOther(); |
29224 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29225 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29226 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29227 | ····} |
29228 | ····[Test] |
29229 | ····public void TestRelationHash() |
29230 | ····{ |
29231 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidLeft)); |
29232 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29233 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidRightBase)); |
29234 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29235 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29236 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29237 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidRightDerived)); |
29238 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29239 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29240 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29241 | ····} |
29242 | ····void CreateObjects() |
29243 | ····{ |
29244 | ········pm.MakePersistent(ownVar); |
29245 | ········pm.MakePersistent(otherVar); |
29246 | ········ownVar.AssignRelation(otherVar); |
29247 | ········pm.Save(); |
29248 | ········pm.UnloadCache(); |
29249 | ····} |
29250 | ····void QueryOwn() |
29251 | ····{ |
29252 | ········var q = new NDOQuery<AgrBin1OthpabsTblGuidLeft>(pm); |
29253 | ········ownVar = q.ExecuteSingle(); |
29254 | ····} |
29255 | ····void QueryOther() |
29256 | ····{ |
29257 | ········var q = new NDOQuery<AgrBin1OthpabsTblGuidRightBase>(pm); |
29258 | ········otherVar = q.ExecuteSingle(); |
29259 | ····} |
29260 | } |
29261 | |
29262 | |
29263 | [TestFixture] |
29264 | public class TestAgrBi1nOthpabsNoTblGuid : NDOTest |
29265 | { |
29266 | ····AgrBi1nOthpabsNoTblGuidLeft ownVar; |
29267 | ····AgrBi1nOthpabsNoTblGuidRightBase otherVar; |
29268 | ····PersistenceManager pm; |
29269 | ····[SetUp] |
29270 | ····public void Setup() |
29271 | ····{ |
29272 | ········pm = PmFactory.NewPersistenceManager(); |
29273 | ········ownVar = new AgrBi1nOthpabsNoTblGuidLeft(); |
29274 | ········otherVar = new AgrBi1nOthpabsNoTblGuidRightDerived(); |
29275 | ····} |
29276 | ····[TearDown] |
29277 | ····public void TearDown() |
29278 | ····{ |
29279 | ········try |
29280 | ········{ |
29281 | ············pm.UnloadCache(); |
29282 | ············var l = pm.Objects<AgrBi1nOthpabsNoTblGuidLeft>().ResultTable; |
29283 | ············pm.Delete(l); |
29284 | ············pm.Save(); |
29285 | ············pm.UnloadCache(); |
29286 | ············var m = pm.Objects<AgrBi1nOthpabsNoTblGuidRightBase>().ResultTable; |
29287 | ············pm.Delete(m); |
29288 | ············pm.Save(); |
29289 | ············pm.UnloadCache(); |
29290 | ············decimal count; |
29291 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29292 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29293 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29294 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29295 | ········} |
29296 | ········catch (Exception) |
29297 | ········{ |
29298 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29299 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29300 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29301 | ········} |
29302 | ····} |
29303 | ····[Test] |
29304 | ····public void TestSaveReload() |
29305 | ····{ |
29306 | ········CreateObjects(); |
29307 | ········QueryOwn(); |
29308 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29309 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29310 | ····} |
29311 | ····[Test] |
29312 | ····public void TestSaveReloadNull() |
29313 | ····{ |
29314 | ········CreateObjects(); |
29315 | ········QueryOwn(); |
29316 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29317 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29318 | ········ownVar.RelField = null; |
29319 | ········pm.Save(); |
29320 | ········pm.UnloadCache(); |
29321 | ········QueryOwn(); |
29322 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29323 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29324 | ····} |
29325 | ····[Test] |
29326 | ····public void TestChangeKeyHolderLeft() |
29327 | ····{ |
29328 | ········CreateObjects(); |
29329 | ········QueryOwn(); |
29330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29332 | ········int x = ownVar.RelField.Dummy; |
29333 | ········ownVar.Dummy = 4711; |
29334 | ········pm.Save(); |
29335 | ········pm.UnloadCache(); |
29336 | ········QueryOwn(); |
29337 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29338 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29340 | ····} |
29341 | ····[Test] |
29342 | ····public void TestChangeKeyHolderLeftNoTouch() |
29343 | ····{ |
29344 | ········CreateObjects(); |
29345 | ········QueryOwn(); |
29346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29347 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29348 | ········ownVar.Dummy = 4711; |
29349 | ········pm.Save(); |
29350 | ········pm.UnloadCache(); |
29351 | ········QueryOwn(); |
29352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29353 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29354 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29355 | ····} |
29356 | ····[Test] |
29357 | ····public void TestRelationHash() |
29358 | ····{ |
29359 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidLeft)); |
29360 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29361 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidRightBase)); |
29362 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29363 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29364 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29365 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidRightDerived)); |
29366 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29367 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29368 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29369 | ····} |
29370 | ····void CreateObjects() |
29371 | ····{ |
29372 | ········pm.MakePersistent(ownVar); |
29373 | ········pm.MakePersistent(otherVar); |
29374 | ········ownVar.AssignRelation(otherVar); |
29375 | ········pm.Save(); |
29376 | ········pm.UnloadCache(); |
29377 | ····} |
29378 | ····void QueryOwn() |
29379 | ····{ |
29380 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblGuidLeft>(pm); |
29381 | ········ownVar = q.ExecuteSingle(); |
29382 | ····} |
29383 | ····void QueryOther() |
29384 | ····{ |
29385 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblGuidRightBase>(pm); |
29386 | ········otherVar = q.ExecuteSingle(); |
29387 | ····} |
29388 | } |
29389 | |
29390 | |
29391 | [TestFixture] |
29392 | public class TestAgrBi1nOthpabsTblGuid : NDOTest |
29393 | { |
29394 | ····AgrBi1nOthpabsTblGuidLeft ownVar; |
29395 | ····AgrBi1nOthpabsTblGuidRightBase otherVar; |
29396 | ····PersistenceManager pm; |
29397 | ····[SetUp] |
29398 | ····public void Setup() |
29399 | ····{ |
29400 | ········pm = PmFactory.NewPersistenceManager(); |
29401 | ········ownVar = new AgrBi1nOthpabsTblGuidLeft(); |
29402 | ········otherVar = new AgrBi1nOthpabsTblGuidRightDerived(); |
29403 | ····} |
29404 | ····[TearDown] |
29405 | ····public void TearDown() |
29406 | ····{ |
29407 | ········try |
29408 | ········{ |
29409 | ············pm.UnloadCache(); |
29410 | ············var l = pm.Objects<AgrBi1nOthpabsTblGuidLeft>().ResultTable; |
29411 | ············pm.Delete(l); |
29412 | ············pm.Save(); |
29413 | ············pm.UnloadCache(); |
29414 | ············var m = pm.Objects<AgrBi1nOthpabsTblGuidRightBase>().ResultTable; |
29415 | ············pm.Delete(m); |
29416 | ············pm.Save(); |
29417 | ············pm.UnloadCache(); |
29418 | ············decimal count; |
29419 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29420 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29421 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29422 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29423 | ········} |
29424 | ········catch (Exception) |
29425 | ········{ |
29426 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29427 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29428 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29429 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29430 | ········} |
29431 | ····} |
29432 | ····[Test] |
29433 | ····public void TestSaveReload() |
29434 | ····{ |
29435 | ········CreateObjects(); |
29436 | ········QueryOwn(); |
29437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29438 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29439 | ····} |
29440 | ····[Test] |
29441 | ····public void TestSaveReloadNull() |
29442 | ····{ |
29443 | ········CreateObjects(); |
29444 | ········QueryOwn(); |
29445 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29447 | ········ownVar.RelField = null; |
29448 | ········pm.Save(); |
29449 | ········pm.UnloadCache(); |
29450 | ········QueryOwn(); |
29451 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29452 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29453 | ····} |
29454 | ····[Test] |
29455 | ····public void TestChangeKeyHolderLeft() |
29456 | ····{ |
29457 | ········CreateObjects(); |
29458 | ········QueryOwn(); |
29459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29460 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29461 | ········int x = ownVar.RelField.Dummy; |
29462 | ········ownVar.Dummy = 4711; |
29463 | ········pm.Save(); |
29464 | ········pm.UnloadCache(); |
29465 | ········QueryOwn(); |
29466 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29467 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29468 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29469 | ····} |
29470 | ····[Test] |
29471 | ····public void TestChangeKeyHolderLeftNoTouch() |
29472 | ····{ |
29473 | ········CreateObjects(); |
29474 | ········QueryOwn(); |
29475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29476 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29477 | ········ownVar.Dummy = 4711; |
29478 | ········pm.Save(); |
29479 | ········pm.UnloadCache(); |
29480 | ········QueryOwn(); |
29481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29482 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29483 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29484 | ····} |
29485 | ····[Test] |
29486 | ····public void TestRelationHash() |
29487 | ····{ |
29488 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidLeft)); |
29489 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29490 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidRightBase)); |
29491 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29492 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29493 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29494 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidRightDerived)); |
29495 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29496 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29497 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29498 | ····} |
29499 | ····void CreateObjects() |
29500 | ····{ |
29501 | ········pm.MakePersistent(ownVar); |
29502 | ········pm.MakePersistent(otherVar); |
29503 | ········ownVar.AssignRelation(otherVar); |
29504 | ········pm.Save(); |
29505 | ········pm.UnloadCache(); |
29506 | ····} |
29507 | ····void QueryOwn() |
29508 | ····{ |
29509 | ········var q = new NDOQuery<AgrBi1nOthpabsTblGuidLeft>(pm); |
29510 | ········ownVar = q.ExecuteSingle(); |
29511 | ····} |
29512 | ····void QueryOther() |
29513 | ····{ |
29514 | ········var q = new NDOQuery<AgrBi1nOthpabsTblGuidRightBase>(pm); |
29515 | ········otherVar = q.ExecuteSingle(); |
29516 | ····} |
29517 | } |
29518 | |
29519 | |
29520 | [TestFixture] |
29521 | public class TestAgrBinnOthpabsTblGuid : NDOTest |
29522 | { |
29523 | ····AgrBinnOthpabsTblGuidLeft ownVar; |
29524 | ····AgrBinnOthpabsTblGuidRightBase otherVar; |
29525 | ····PersistenceManager pm; |
29526 | ····[SetUp] |
29527 | ····public void Setup() |
29528 | ····{ |
29529 | ········pm = PmFactory.NewPersistenceManager(); |
29530 | ········ownVar = new AgrBinnOthpabsTblGuidLeft(); |
29531 | ········otherVar = new AgrBinnOthpabsTblGuidRightDerived(); |
29532 | ····} |
29533 | ····[TearDown] |
29534 | ····public void TearDown() |
29535 | ····{ |
29536 | ········try |
29537 | ········{ |
29538 | ············pm.UnloadCache(); |
29539 | ············var l = pm.Objects<AgrBinnOthpabsTblGuidLeft>().ResultTable; |
29540 | ············pm.Delete(l); |
29541 | ············pm.Save(); |
29542 | ············pm.UnloadCache(); |
29543 | ············var m = pm.Objects<AgrBinnOthpabsTblGuidRightBase>().ResultTable; |
29544 | ············pm.Delete(m); |
29545 | ············pm.Save(); |
29546 | ············pm.UnloadCache(); |
29547 | ············decimal count; |
29548 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29550 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29552 | ········} |
29553 | ········catch (Exception) |
29554 | ········{ |
29555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29559 | ········} |
29560 | ····} |
29561 | ····[Test] |
29562 | ····public void TestSaveReload() |
29563 | ····{ |
29564 | ········CreateObjects(); |
29565 | ········QueryOwn(); |
29566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29568 | ····} |
29569 | ····[Test] |
29570 | ····public void TestSaveReloadNull() |
29571 | ····{ |
29572 | ········CreateObjects(); |
29573 | ········QueryOwn(); |
29574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29576 | ········ownVar.RelField = new List<AgrBinnOthpabsTblGuidRightBase>(); |
29577 | ········pm.Save(); |
29578 | ········pm.UnloadCache(); |
29579 | ········QueryOwn(); |
29580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29582 | ····} |
29583 | ····[Test] |
29584 | ····public void TestSaveReloadRemove() |
29585 | ····{ |
29586 | ········CreateObjects(); |
29587 | ········QueryOwn(); |
29588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29590 | ········ownVar.RemoveRelatedObject(); |
29591 | ········pm.Save(); |
29592 | ········pm.UnloadCache(); |
29593 | ········QueryOwn(); |
29594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29596 | ····} |
29597 | ····[Test] |
29598 | ····public void TestRelationHash() |
29599 | ····{ |
29600 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidLeft)); |
29601 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29602 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidRightBase)); |
29603 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29604 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29605 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29606 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidRightDerived)); |
29607 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29608 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29609 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29610 | ····} |
29611 | ····void CreateObjects() |
29612 | ····{ |
29613 | ········pm.MakePersistent(ownVar); |
29614 | ········pm.MakePersistent(otherVar); |
29615 | ········ownVar.AssignRelation(otherVar); |
29616 | ········pm.Save(); |
29617 | ········pm.UnloadCache(); |
29618 | ····} |
29619 | ····void QueryOwn() |
29620 | ····{ |
29621 | ········var q = new NDOQuery<AgrBinnOthpabsTblGuidLeft>(pm); |
29622 | ········ownVar = q.ExecuteSingle(); |
29623 | ····} |
29624 | ····void QueryOther() |
29625 | ····{ |
29626 | ········var q = new NDOQuery<AgrBinnOthpabsTblGuidRightBase>(pm); |
29627 | ········otherVar = q.ExecuteSingle(); |
29628 | ····} |
29629 | } |
29630 | |
29631 | |
29632 | [TestFixture] |
29633 | public class TestCmpDir1OthpabsNoTblGuid : NDOTest |
29634 | { |
29635 | ····CmpDir1OthpabsNoTblGuidLeft ownVar; |
29636 | ····CmpDir1OthpabsNoTblGuidRightBase otherVar; |
29637 | ····PersistenceManager pm; |
29638 | ····[SetUp] |
29639 | ····public void Setup() |
29640 | ····{ |
29641 | ········pm = PmFactory.NewPersistenceManager(); |
29642 | ········ownVar = new CmpDir1OthpabsNoTblGuidLeft(); |
29643 | ········otherVar = new CmpDir1OthpabsNoTblGuidRightDerived(); |
29644 | ····} |
29645 | ····[TearDown] |
29646 | ····public void TearDown() |
29647 | ····{ |
29648 | ········try |
29649 | ········{ |
29650 | ············pm.UnloadCache(); |
29651 | ············var l = pm.Objects<CmpDir1OthpabsNoTblGuidLeft>().ResultTable; |
29652 | ············pm.Delete(l); |
29653 | ············pm.Save(); |
29654 | ············pm.UnloadCache(); |
29655 | ············decimal count; |
29656 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29657 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29658 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29659 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29660 | ········} |
29661 | ········catch (Exception) |
29662 | ········{ |
29663 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29664 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29665 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29666 | ········} |
29667 | ····} |
29668 | ····[Test] |
29669 | ····public void TestSaveReload() |
29670 | ····{ |
29671 | ········CreateObjects(); |
29672 | ········QueryOwn(); |
29673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29674 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29675 | ····} |
29676 | ····[Test] |
29677 | ····public void TestSaveReloadNull() |
29678 | ····{ |
29679 | ········CreateObjects(); |
29680 | ········QueryOwn(); |
29681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29682 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29683 | ········ownVar.RelField = null; |
29684 | ········pm.Save(); |
29685 | ········pm.UnloadCache(); |
29686 | ········QueryOwn(); |
29687 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29688 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29689 | ····} |
29690 | ····[Test] |
29691 | ····public void TestChangeKeyHolderLeft() |
29692 | ····{ |
29693 | ········CreateObjects(); |
29694 | ········QueryOwn(); |
29695 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29696 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29697 | ········int x = ownVar.RelField.Dummy; |
29698 | ········ownVar.Dummy = 4711; |
29699 | ········pm.Save(); |
29700 | ········pm.UnloadCache(); |
29701 | ········QueryOwn(); |
29702 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29703 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29704 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29705 | ····} |
29706 | ····[Test] |
29707 | ····public void TestChangeKeyHolderLeftNoTouch() |
29708 | ····{ |
29709 | ········CreateObjects(); |
29710 | ········QueryOwn(); |
29711 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29712 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29713 | ········ownVar.Dummy = 4711; |
29714 | ········pm.Save(); |
29715 | ········pm.UnloadCache(); |
29716 | ········QueryOwn(); |
29717 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29718 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29719 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29720 | ····} |
29721 | ····void CreateObjects() |
29722 | ····{ |
29723 | ········pm.MakePersistent(ownVar); |
29724 | ········ownVar.AssignRelation(otherVar); |
29725 | ········pm.Save(); |
29726 | ········pm.UnloadCache(); |
29727 | ····} |
29728 | ····void QueryOwn() |
29729 | ····{ |
29730 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblGuidLeft>(pm); |
29731 | ········ownVar = q.ExecuteSingle(); |
29732 | ····} |
29733 | ····void QueryOther() |
29734 | ····{ |
29735 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblGuidRightBase>(pm); |
29736 | ········otherVar = q.ExecuteSingle(); |
29737 | ····} |
29738 | } |
29739 | |
29740 | |
29741 | [TestFixture] |
29742 | public class TestCmpDir1OthpabsTblGuid : NDOTest |
29743 | { |
29744 | ····CmpDir1OthpabsTblGuidLeft ownVar; |
29745 | ····CmpDir1OthpabsTblGuidRightBase otherVar; |
29746 | ····PersistenceManager pm; |
29747 | ····[SetUp] |
29748 | ····public void Setup() |
29749 | ····{ |
29750 | ········pm = PmFactory.NewPersistenceManager(); |
29751 | ········ownVar = new CmpDir1OthpabsTblGuidLeft(); |
29752 | ········otherVar = new CmpDir1OthpabsTblGuidRightDerived(); |
29753 | ····} |
29754 | ····[TearDown] |
29755 | ····public void TearDown() |
29756 | ····{ |
29757 | ········try |
29758 | ········{ |
29759 | ············pm.UnloadCache(); |
29760 | ············var l = pm.Objects<CmpDir1OthpabsTblGuidLeft>().ResultTable; |
29761 | ············pm.Delete(l); |
29762 | ············pm.Save(); |
29763 | ············pm.UnloadCache(); |
29764 | ············decimal count; |
29765 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29766 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29767 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29768 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29769 | ········} |
29770 | ········catch (Exception) |
29771 | ········{ |
29772 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29773 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29774 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29775 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29776 | ········} |
29777 | ····} |
29778 | ····[Test] |
29779 | ····public void TestSaveReload() |
29780 | ····{ |
29781 | ········CreateObjects(); |
29782 | ········QueryOwn(); |
29783 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29784 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29785 | ····} |
29786 | ····[Test] |
29787 | ····public void TestSaveReloadNull() |
29788 | ····{ |
29789 | ········CreateObjects(); |
29790 | ········QueryOwn(); |
29791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29792 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29793 | ········ownVar.RelField = null; |
29794 | ········pm.Save(); |
29795 | ········pm.UnloadCache(); |
29796 | ········QueryOwn(); |
29797 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29798 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29799 | ····} |
29800 | ····[Test] |
29801 | ····public void TestChangeKeyHolderLeft() |
29802 | ····{ |
29803 | ········CreateObjects(); |
29804 | ········QueryOwn(); |
29805 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29806 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29807 | ········int x = ownVar.RelField.Dummy; |
29808 | ········ownVar.Dummy = 4711; |
29809 | ········pm.Save(); |
29810 | ········pm.UnloadCache(); |
29811 | ········QueryOwn(); |
29812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29813 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29814 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29815 | ····} |
29816 | ····[Test] |
29817 | ····public void TestChangeKeyHolderLeftNoTouch() |
29818 | ····{ |
29819 | ········CreateObjects(); |
29820 | ········QueryOwn(); |
29821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29823 | ········ownVar.Dummy = 4711; |
29824 | ········pm.Save(); |
29825 | ········pm.UnloadCache(); |
29826 | ········QueryOwn(); |
29827 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29828 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29829 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29830 | ····} |
29831 | ····void CreateObjects() |
29832 | ····{ |
29833 | ········pm.MakePersistent(ownVar); |
29834 | ········ownVar.AssignRelation(otherVar); |
29835 | ········pm.Save(); |
29836 | ········pm.UnloadCache(); |
29837 | ····} |
29838 | ····void QueryOwn() |
29839 | ····{ |
29840 | ········var q = new NDOQuery<CmpDir1OthpabsTblGuidLeft>(pm); |
29841 | ········ownVar = q.ExecuteSingle(); |
29842 | ····} |
29843 | ····void QueryOther() |
29844 | ····{ |
29845 | ········var q = new NDOQuery<CmpDir1OthpabsTblGuidRightBase>(pm); |
29846 | ········otherVar = q.ExecuteSingle(); |
29847 | ····} |
29848 | } |
29849 | |
29850 | |
29851 | [TestFixture] |
29852 | public class TestCmpBi11OthpabsNoTblGuid : NDOTest |
29853 | { |
29854 | ····CmpBi11OthpabsNoTblGuidLeft ownVar; |
29855 | ····CmpBi11OthpabsNoTblGuidRightBase otherVar; |
29856 | ····PersistenceManager pm; |
29857 | ····[SetUp] |
29858 | ····public void Setup() |
29859 | ····{ |
29860 | ········pm = PmFactory.NewPersistenceManager(); |
29861 | ········ownVar = new CmpBi11OthpabsNoTblGuidLeft(); |
29862 | ········otherVar = new CmpBi11OthpabsNoTblGuidRightDerived(); |
29863 | ····} |
29864 | ····[TearDown] |
29865 | ····public void TearDown() |
29866 | ····{ |
29867 | ········try |
29868 | ········{ |
29869 | ············pm.UnloadCache(); |
29870 | ············var l = pm.Objects<CmpBi11OthpabsNoTblGuidLeft>().ResultTable; |
29871 | ············pm.Delete(l); |
29872 | ············pm.Save(); |
29873 | ············pm.UnloadCache(); |
29874 | ············decimal count; |
29875 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29876 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29877 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29878 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29879 | ········} |
29880 | ········catch (Exception) |
29881 | ········{ |
29882 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29883 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29884 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29885 | ········} |
29886 | ····} |
29887 | ····[Test] |
29888 | ····public void TestSaveReload() |
29889 | ····{ |
29890 | ········CreateObjects(); |
29891 | ········QueryOwn(); |
29892 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29893 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29894 | ····} |
29895 | ····[Test] |
29896 | ····public void TestSaveReloadNull() |
29897 | ····{ |
29898 | ········CreateObjects(); |
29899 | ········QueryOwn(); |
29900 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29901 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29902 | ········ownVar.RelField = null; |
29903 | ········pm.Save(); |
29904 | ········pm.UnloadCache(); |
29905 | ········QueryOwn(); |
29906 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29907 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29908 | ····} |
29909 | ····[Test] |
29910 | ····public void TestChangeKeyHolderLeft() |
29911 | ····{ |
29912 | ········CreateObjects(); |
29913 | ········QueryOwn(); |
29914 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29915 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29916 | ········int x = ownVar.RelField.Dummy; |
29917 | ········ownVar.Dummy = 4711; |
29918 | ········pm.Save(); |
29919 | ········pm.UnloadCache(); |
29920 | ········QueryOwn(); |
29921 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29922 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29923 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29924 | ····} |
29925 | ····[Test] |
29926 | ····public void TestChangeKeyHolderRight() |
29927 | ····{ |
29928 | ········CreateObjects(); |
29929 | ········QueryOther(); |
29930 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29931 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29932 | ········int x = otherVar.RelField.Dummy; |
29933 | ········otherVar.Dummy = 4711; |
29934 | ········pm.Save(); |
29935 | ········pm.UnloadCache(); |
29936 | ········QueryOther(); |
29937 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29938 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29939 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29940 | ····} |
29941 | ····[Test] |
29942 | ····public void TestChangeKeyHolderLeftNoTouch() |
29943 | ····{ |
29944 | ········CreateObjects(); |
29945 | ········QueryOwn(); |
29946 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29947 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29948 | ········ownVar.Dummy = 4711; |
29949 | ········pm.Save(); |
29950 | ········pm.UnloadCache(); |
29951 | ········QueryOwn(); |
29952 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29953 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29954 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29955 | ····} |
29956 | ····[Test] |
29957 | ····public void TestChangeKeyHolderRightNoTouch() |
29958 | ····{ |
29959 | ········CreateObjects(); |
29960 | ········QueryOther(); |
29961 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29962 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29963 | ········otherVar.Dummy = 4711; |
29964 | ········pm.Save(); |
29965 | ········pm.UnloadCache(); |
29966 | ········QueryOther(); |
29967 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29968 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29969 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29970 | ····} |
29971 | ····[Test] |
29972 | ····public void TestRelationHash() |
29973 | ····{ |
29974 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidLeft)); |
29975 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29976 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidRightBase)); |
29977 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29978 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29979 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29980 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidRightDerived)); |
29981 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29982 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29983 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29984 | ····} |
29985 | ····void CreateObjects() |
29986 | ····{ |
29987 | ········pm.MakePersistent(ownVar); |
29988 | ········ownVar.AssignRelation(otherVar); |
29989 | ········pm.Save(); |
29990 | ········pm.UnloadCache(); |
29991 | ····} |
29992 | ····void QueryOwn() |
29993 | ····{ |
29994 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblGuidLeft>(pm); |
29995 | ········ownVar = q.ExecuteSingle(); |
29996 | ····} |
29997 | ····void QueryOther() |
29998 | ····{ |
29999 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblGuidRightBase>(pm); |
30000 | ········otherVar = q.ExecuteSingle(); |
30001 | ····} |
30002 | } |
30003 | |
30004 | |
30005 | [TestFixture] |
30006 | public class TestCmpBi11OthpabsTblGuid : NDOTest |
30007 | { |
30008 | ····CmpBi11OthpabsTblGuidLeft ownVar; |
30009 | ····CmpBi11OthpabsTblGuidRightBase otherVar; |
30010 | ····PersistenceManager pm; |
30011 | ····[SetUp] |
30012 | ····public void Setup() |
30013 | ····{ |
30014 | ········pm = PmFactory.NewPersistenceManager(); |
30015 | ········ownVar = new CmpBi11OthpabsTblGuidLeft(); |
30016 | ········otherVar = new CmpBi11OthpabsTblGuidRightDerived(); |
30017 | ····} |
30018 | ····[TearDown] |
30019 | ····public void TearDown() |
30020 | ····{ |
30021 | ········try |
30022 | ········{ |
30023 | ············pm.UnloadCache(); |
30024 | ············var l = pm.Objects<CmpBi11OthpabsTblGuidLeft>().ResultTable; |
30025 | ············pm.Delete(l); |
30026 | ············pm.Save(); |
30027 | ············pm.UnloadCache(); |
30028 | ············decimal count; |
30029 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30030 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30031 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30032 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30033 | ········} |
30034 | ········catch (Exception) |
30035 | ········{ |
30036 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30037 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30038 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30039 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30040 | ········} |
30041 | ····} |
30042 | ····[Test] |
30043 | ····public void TestSaveReload() |
30044 | ····{ |
30045 | ········CreateObjects(); |
30046 | ········QueryOwn(); |
30047 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30048 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30049 | ····} |
30050 | ····[Test] |
30051 | ····public void TestSaveReloadNull() |
30052 | ····{ |
30053 | ········CreateObjects(); |
30054 | ········QueryOwn(); |
30055 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30056 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30057 | ········ownVar.RelField = null; |
30058 | ········pm.Save(); |
30059 | ········pm.UnloadCache(); |
30060 | ········QueryOwn(); |
30061 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30062 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30063 | ····} |
30064 | ····[Test] |
30065 | ····public void TestChangeKeyHolderLeft() |
30066 | ····{ |
30067 | ········CreateObjects(); |
30068 | ········QueryOwn(); |
30069 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30070 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30071 | ········int x = ownVar.RelField.Dummy; |
30072 | ········ownVar.Dummy = 4711; |
30073 | ········pm.Save(); |
30074 | ········pm.UnloadCache(); |
30075 | ········QueryOwn(); |
30076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30077 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30078 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30079 | ····} |
30080 | ····[Test] |
30081 | ····public void TestChangeKeyHolderRight() |
30082 | ····{ |
30083 | ········CreateObjects(); |
30084 | ········QueryOther(); |
30085 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30086 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30087 | ········int x = otherVar.RelField.Dummy; |
30088 | ········otherVar.Dummy = 4711; |
30089 | ········pm.Save(); |
30090 | ········pm.UnloadCache(); |
30091 | ········QueryOther(); |
30092 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30093 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30094 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30095 | ····} |
30096 | ····[Test] |
30097 | ····public void TestChangeKeyHolderLeftNoTouch() |
30098 | ····{ |
30099 | ········CreateObjects(); |
30100 | ········QueryOwn(); |
30101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30102 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30103 | ········ownVar.Dummy = 4711; |
30104 | ········pm.Save(); |
30105 | ········pm.UnloadCache(); |
30106 | ········QueryOwn(); |
30107 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30108 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30109 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30110 | ····} |
30111 | ····[Test] |
30112 | ····public void TestChangeKeyHolderRightNoTouch() |
30113 | ····{ |
30114 | ········CreateObjects(); |
30115 | ········QueryOther(); |
30116 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30117 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30118 | ········otherVar.Dummy = 4711; |
30119 | ········pm.Save(); |
30120 | ········pm.UnloadCache(); |
30121 | ········QueryOther(); |
30122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30125 | ····} |
30126 | ····[Test] |
30127 | ····public void TestRelationHash() |
30128 | ····{ |
30129 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidLeft)); |
30130 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30131 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidRightBase)); |
30132 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30133 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30134 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30135 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidRightDerived)); |
30136 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30137 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30138 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30139 | ····} |
30140 | ····void CreateObjects() |
30141 | ····{ |
30142 | ········pm.MakePersistent(ownVar); |
30143 | ········ownVar.AssignRelation(otherVar); |
30144 | ········pm.Save(); |
30145 | ········pm.UnloadCache(); |
30146 | ····} |
30147 | ····void QueryOwn() |
30148 | ····{ |
30149 | ········var q = new NDOQuery<CmpBi11OthpabsTblGuidLeft>(pm); |
30150 | ········ownVar = q.ExecuteSingle(); |
30151 | ····} |
30152 | ····void QueryOther() |
30153 | ····{ |
30154 | ········var q = new NDOQuery<CmpBi11OthpabsTblGuidRightBase>(pm); |
30155 | ········otherVar = q.ExecuteSingle(); |
30156 | ····} |
30157 | } |
30158 | |
30159 | |
30160 | [TestFixture] |
30161 | public class TestCmpDirnOthpabsTblGuid : NDOTest |
30162 | { |
30163 | ····CmpDirnOthpabsTblGuidLeft ownVar; |
30164 | ····CmpDirnOthpabsTblGuidRightBase otherVar; |
30165 | ····PersistenceManager pm; |
30166 | ····[SetUp] |
30167 | ····public void Setup() |
30168 | ····{ |
30169 | ········pm = PmFactory.NewPersistenceManager(); |
30170 | ········ownVar = new CmpDirnOthpabsTblGuidLeft(); |
30171 | ········otherVar = new CmpDirnOthpabsTblGuidRightDerived(); |
30172 | ····} |
30173 | ····[TearDown] |
30174 | ····public void TearDown() |
30175 | ····{ |
30176 | ········try |
30177 | ········{ |
30178 | ············pm.UnloadCache(); |
30179 | ············var l = pm.Objects<CmpDirnOthpabsTblGuidLeft>().ResultTable; |
30180 | ············pm.Delete(l); |
30181 | ············pm.Save(); |
30182 | ············pm.UnloadCache(); |
30183 | ············decimal count; |
30184 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30185 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30186 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30187 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30188 | ········} |
30189 | ········catch (Exception) |
30190 | ········{ |
30191 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30192 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30193 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30194 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30195 | ········} |
30196 | ····} |
30197 | ····[Test] |
30198 | ····public void TestSaveReload() |
30199 | ····{ |
30200 | ········CreateObjects(); |
30201 | ········QueryOwn(); |
30202 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30203 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30204 | ····} |
30205 | ····[Test] |
30206 | ····public void TestSaveReloadNull() |
30207 | ····{ |
30208 | ········CreateObjects(); |
30209 | ········QueryOwn(); |
30210 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30211 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30212 | ········ownVar.RelField = new List<CmpDirnOthpabsTblGuidRightBase>(); |
30213 | ········pm.Save(); |
30214 | ········pm.UnloadCache(); |
30215 | ········QueryOwn(); |
30216 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30217 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30218 | ····} |
30219 | ····[Test] |
30220 | ····public void TestSaveReloadRemove() |
30221 | ····{ |
30222 | ········CreateObjects(); |
30223 | ········QueryOwn(); |
30224 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30225 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30226 | ········ownVar.RemoveRelatedObject(); |
30227 | ········pm.Save(); |
30228 | ········pm.UnloadCache(); |
30229 | ········QueryOwn(); |
30230 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30231 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30232 | ····} |
30233 | ····void CreateObjects() |
30234 | ····{ |
30235 | ········pm.MakePersistent(ownVar); |
30236 | ········ownVar.AssignRelation(otherVar); |
30237 | ········pm.Save(); |
30238 | ········pm.UnloadCache(); |
30239 | ····} |
30240 | ····void QueryOwn() |
30241 | ····{ |
30242 | ········var q = new NDOQuery<CmpDirnOthpabsTblGuidLeft>(pm); |
30243 | ········ownVar = q.ExecuteSingle(); |
30244 | ····} |
30245 | ····void QueryOther() |
30246 | ····{ |
30247 | ········var q = new NDOQuery<CmpDirnOthpabsTblGuidRightBase>(pm); |
30248 | ········otherVar = q.ExecuteSingle(); |
30249 | ····} |
30250 | } |
30251 | |
30252 | |
30253 | [TestFixture] |
30254 | public class TestCmpBin1OthpabsTblGuid : NDOTest |
30255 | { |
30256 | ····CmpBin1OthpabsTblGuidLeft ownVar; |
30257 | ····CmpBin1OthpabsTblGuidRightBase otherVar; |
30258 | ····PersistenceManager pm; |
30259 | ····[SetUp] |
30260 | ····public void Setup() |
30261 | ····{ |
30262 | ········pm = PmFactory.NewPersistenceManager(); |
30263 | ········ownVar = new CmpBin1OthpabsTblGuidLeft(); |
30264 | ········otherVar = new CmpBin1OthpabsTblGuidRightDerived(); |
30265 | ····} |
30266 | ····[TearDown] |
30267 | ····public void TearDown() |
30268 | ····{ |
30269 | ········try |
30270 | ········{ |
30271 | ············pm.UnloadCache(); |
30272 | ············var l = pm.Objects<CmpBin1OthpabsTblGuidLeft>().ResultTable; |
30273 | ············pm.Delete(l); |
30274 | ············pm.Save(); |
30275 | ············pm.UnloadCache(); |
30276 | ············decimal count; |
30277 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30278 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30279 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30280 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30281 | ········} |
30282 | ········catch (Exception) |
30283 | ········{ |
30284 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30285 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30286 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30287 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30288 | ········} |
30289 | ····} |
30290 | ····[Test] |
30291 | ····public void TestSaveReload() |
30292 | ····{ |
30293 | ········CreateObjects(); |
30294 | ········QueryOwn(); |
30295 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30296 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30297 | ····} |
30298 | ····[Test] |
30299 | ····public void TestSaveReloadNull() |
30300 | ····{ |
30301 | ········CreateObjects(); |
30302 | ········QueryOwn(); |
30303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30304 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30305 | ········ownVar.RelField = new List<CmpBin1OthpabsTblGuidRightBase>(); |
30306 | ········pm.Save(); |
30307 | ········pm.UnloadCache(); |
30308 | ········QueryOwn(); |
30309 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30310 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30311 | ····} |
30312 | ····[Test] |
30313 | ····public void TestSaveReloadRemove() |
30314 | ····{ |
30315 | ········CreateObjects(); |
30316 | ········QueryOwn(); |
30317 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30318 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30319 | ········ownVar.RemoveRelatedObject(); |
30320 | ········pm.Save(); |
30321 | ········pm.UnloadCache(); |
30322 | ········QueryOwn(); |
30323 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30324 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30325 | ····} |
30326 | ····[Test] |
30327 | ····public void TestChangeKeyHolderRight() |
30328 | ····{ |
30329 | ········CreateObjects(); |
30330 | ········QueryOther(); |
30331 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30332 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30333 | ········int x = otherVar.RelField.Dummy; |
30334 | ········otherVar.Dummy = 4711; |
30335 | ········pm.Save(); |
30336 | ········pm.UnloadCache(); |
30337 | ········QueryOther(); |
30338 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30339 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30340 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30341 | ····} |
30342 | ····[Test] |
30343 | ····public void TestChangeKeyHolderRightNoTouch() |
30344 | ····{ |
30345 | ········CreateObjects(); |
30346 | ········QueryOther(); |
30347 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30348 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30349 | ········otherVar.Dummy = 4711; |
30350 | ········pm.Save(); |
30351 | ········pm.UnloadCache(); |
30352 | ········QueryOther(); |
30353 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30354 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30355 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30356 | ····} |
30357 | ····[Test] |
30358 | ····public void TestRelationHash() |
30359 | ····{ |
30360 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidLeft)); |
30361 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30362 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidRightBase)); |
30363 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30364 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30365 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30366 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidRightDerived)); |
30367 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30368 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30369 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30370 | ····} |
30371 | ····void CreateObjects() |
30372 | ····{ |
30373 | ········pm.MakePersistent(ownVar); |
30374 | ········ownVar.AssignRelation(otherVar); |
30375 | ········pm.Save(); |
30376 | ········pm.UnloadCache(); |
30377 | ····} |
30378 | ····void QueryOwn() |
30379 | ····{ |
30380 | ········var q = new NDOQuery<CmpBin1OthpabsTblGuidLeft>(pm); |
30381 | ········ownVar = q.ExecuteSingle(); |
30382 | ····} |
30383 | ····void QueryOther() |
30384 | ····{ |
30385 | ········var q = new NDOQuery<CmpBin1OthpabsTblGuidRightBase>(pm); |
30386 | ········otherVar = q.ExecuteSingle(); |
30387 | ····} |
30388 | } |
30389 | |
30390 | |
30391 | [TestFixture] |
30392 | public class TestCmpBi1nOthpabsNoTblGuid : NDOTest |
30393 | { |
30394 | ····CmpBi1nOthpabsNoTblGuidLeft ownVar; |
30395 | ····CmpBi1nOthpabsNoTblGuidRightBase otherVar; |
30396 | ····PersistenceManager pm; |
30397 | ····[SetUp] |
30398 | ····public void Setup() |
30399 | ····{ |
30400 | ········pm = PmFactory.NewPersistenceManager(); |
30401 | ········ownVar = new CmpBi1nOthpabsNoTblGuidLeft(); |
30402 | ········otherVar = new CmpBi1nOthpabsNoTblGuidRightDerived(); |
30403 | ····} |
30404 | ····[TearDown] |
30405 | ····public void TearDown() |
30406 | ····{ |
30407 | ········try |
30408 | ········{ |
30409 | ············pm.UnloadCache(); |
30410 | ············var l = pm.Objects<CmpBi1nOthpabsNoTblGuidLeft>().ResultTable; |
30411 | ············pm.Delete(l); |
30412 | ············pm.Save(); |
30413 | ············pm.UnloadCache(); |
30414 | ············decimal count; |
30415 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30416 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30417 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30418 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30419 | ········} |
30420 | ········catch (Exception) |
30421 | ········{ |
30422 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30423 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30424 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30425 | ········} |
30426 | ····} |
30427 | ····[Test] |
30428 | ····public void TestSaveReload() |
30429 | ····{ |
30430 | ········CreateObjects(); |
30431 | ········QueryOwn(); |
30432 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30433 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30434 | ····} |
30435 | ····[Test] |
30436 | ····public void TestSaveReloadNull() |
30437 | ····{ |
30438 | ········CreateObjects(); |
30439 | ········QueryOwn(); |
30440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30441 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30442 | ········ownVar.RelField = null; |
30443 | ········pm.Save(); |
30444 | ········pm.UnloadCache(); |
30445 | ········QueryOwn(); |
30446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30447 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30448 | ····} |
30449 | ····[Test] |
30450 | ····public void TestChangeKeyHolderLeft() |
30451 | ····{ |
30452 | ········CreateObjects(); |
30453 | ········QueryOwn(); |
30454 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30455 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30456 | ········int x = ownVar.RelField.Dummy; |
30457 | ········ownVar.Dummy = 4711; |
30458 | ········pm.Save(); |
30459 | ········pm.UnloadCache(); |
30460 | ········QueryOwn(); |
30461 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30462 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30463 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30464 | ····} |
30465 | ····[Test] |
30466 | ····public void TestChangeKeyHolderLeftNoTouch() |
30467 | ····{ |
30468 | ········CreateObjects(); |
30469 | ········QueryOwn(); |
30470 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30471 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30472 | ········ownVar.Dummy = 4711; |
30473 | ········pm.Save(); |
30474 | ········pm.UnloadCache(); |
30475 | ········QueryOwn(); |
30476 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30477 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30478 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30479 | ····} |
30480 | ····[Test] |
30481 | ····public void TestRelationHash() |
30482 | ····{ |
30483 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidLeft)); |
30484 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30485 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidRightBase)); |
30486 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30487 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30488 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30489 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidRightDerived)); |
30490 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30491 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30492 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30493 | ····} |
30494 | ····void CreateObjects() |
30495 | ····{ |
30496 | ········pm.MakePersistent(ownVar); |
30497 | ········ownVar.AssignRelation(otherVar); |
30498 | ········pm.Save(); |
30499 | ········pm.UnloadCache(); |
30500 | ····} |
30501 | ····void QueryOwn() |
30502 | ····{ |
30503 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblGuidLeft>(pm); |
30504 | ········ownVar = q.ExecuteSingle(); |
30505 | ····} |
30506 | ····void QueryOther() |
30507 | ····{ |
30508 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblGuidRightBase>(pm); |
30509 | ········otherVar = q.ExecuteSingle(); |
30510 | ····} |
30511 | } |
30512 | |
30513 | |
30514 | [TestFixture] |
30515 | public class TestCmpBi1nOthpabsTblGuid : NDOTest |
30516 | { |
30517 | ····CmpBi1nOthpabsTblGuidLeft ownVar; |
30518 | ····CmpBi1nOthpabsTblGuidRightBase otherVar; |
30519 | ····PersistenceManager pm; |
30520 | ····[SetUp] |
30521 | ····public void Setup() |
30522 | ····{ |
30523 | ········pm = PmFactory.NewPersistenceManager(); |
30524 | ········ownVar = new CmpBi1nOthpabsTblGuidLeft(); |
30525 | ········otherVar = new CmpBi1nOthpabsTblGuidRightDerived(); |
30526 | ····} |
30527 | ····[TearDown] |
30528 | ····public void TearDown() |
30529 | ····{ |
30530 | ········try |
30531 | ········{ |
30532 | ············pm.UnloadCache(); |
30533 | ············var l = pm.Objects<CmpBi1nOthpabsTblGuidLeft>().ResultTable; |
30534 | ············pm.Delete(l); |
30535 | ············pm.Save(); |
30536 | ············pm.UnloadCache(); |
30537 | ············decimal count; |
30538 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30539 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30540 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30541 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30542 | ········} |
30543 | ········catch (Exception) |
30544 | ········{ |
30545 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30546 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30547 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30548 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30549 | ········} |
30550 | ····} |
30551 | ····[Test] |
30552 | ····public void TestSaveReload() |
30553 | ····{ |
30554 | ········CreateObjects(); |
30555 | ········QueryOwn(); |
30556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30557 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30558 | ····} |
30559 | ····[Test] |
30560 | ····public void TestSaveReloadNull() |
30561 | ····{ |
30562 | ········CreateObjects(); |
30563 | ········QueryOwn(); |
30564 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30566 | ········ownVar.RelField = null; |
30567 | ········pm.Save(); |
30568 | ········pm.UnloadCache(); |
30569 | ········QueryOwn(); |
30570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30571 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30572 | ····} |
30573 | ····[Test] |
30574 | ····public void TestChangeKeyHolderLeft() |
30575 | ····{ |
30576 | ········CreateObjects(); |
30577 | ········QueryOwn(); |
30578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30579 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30580 | ········int x = ownVar.RelField.Dummy; |
30581 | ········ownVar.Dummy = 4711; |
30582 | ········pm.Save(); |
30583 | ········pm.UnloadCache(); |
30584 | ········QueryOwn(); |
30585 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30586 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30587 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30588 | ····} |
30589 | ····[Test] |
30590 | ····public void TestChangeKeyHolderLeftNoTouch() |
30591 | ····{ |
30592 | ········CreateObjects(); |
30593 | ········QueryOwn(); |
30594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30595 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30596 | ········ownVar.Dummy = 4711; |
30597 | ········pm.Save(); |
30598 | ········pm.UnloadCache(); |
30599 | ········QueryOwn(); |
30600 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30601 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30602 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30603 | ····} |
30604 | ····[Test] |
30605 | ····public void TestRelationHash() |
30606 | ····{ |
30607 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidLeft)); |
30608 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30609 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidRightBase)); |
30610 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30611 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30612 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30613 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidRightDerived)); |
30614 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30615 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30616 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30617 | ····} |
30618 | ····void CreateObjects() |
30619 | ····{ |
30620 | ········pm.MakePersistent(ownVar); |
30621 | ········ownVar.AssignRelation(otherVar); |
30622 | ········pm.Save(); |
30623 | ········pm.UnloadCache(); |
30624 | ····} |
30625 | ····void QueryOwn() |
30626 | ····{ |
30627 | ········var q = new NDOQuery<CmpBi1nOthpabsTblGuidLeft>(pm); |
30628 | ········ownVar = q.ExecuteSingle(); |
30629 | ····} |
30630 | ····void QueryOther() |
30631 | ····{ |
30632 | ········var q = new NDOQuery<CmpBi1nOthpabsTblGuidRightBase>(pm); |
30633 | ········otherVar = q.ExecuteSingle(); |
30634 | ····} |
30635 | } |
30636 | |
30637 | |
30638 | [TestFixture] |
30639 | public class TestCmpBinnOthpabsTblGuid : NDOTest |
30640 | { |
30641 | ····CmpBinnOthpabsTblGuidLeft ownVar; |
30642 | ····CmpBinnOthpabsTblGuidRightBase otherVar; |
30643 | ····PersistenceManager pm; |
30644 | ····[SetUp] |
30645 | ····public void Setup() |
30646 | ····{ |
30647 | ········pm = PmFactory.NewPersistenceManager(); |
30648 | ········ownVar = new CmpBinnOthpabsTblGuidLeft(); |
30649 | ········otherVar = new CmpBinnOthpabsTblGuidRightDerived(); |
30650 | ····} |
30651 | ····[TearDown] |
30652 | ····public void TearDown() |
30653 | ····{ |
30654 | ········try |
30655 | ········{ |
30656 | ············pm.UnloadCache(); |
30657 | ············var l = pm.Objects<CmpBinnOthpabsTblGuidLeft>().ResultTable; |
30658 | ············pm.Delete(l); |
30659 | ············pm.Save(); |
30660 | ············pm.UnloadCache(); |
30661 | ············decimal count; |
30662 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30663 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30664 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30665 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30666 | ········} |
30667 | ········catch (Exception) |
30668 | ········{ |
30669 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30670 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30671 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30672 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30673 | ········} |
30674 | ····} |
30675 | ····[Test] |
30676 | ····public void TestSaveReload() |
30677 | ····{ |
30678 | ········CreateObjects(); |
30679 | ········QueryOwn(); |
30680 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30681 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30682 | ····} |
30683 | ····[Test] |
30684 | ····public void TestSaveReloadNull() |
30685 | ····{ |
30686 | ········CreateObjects(); |
30687 | ········QueryOwn(); |
30688 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30689 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30690 | ········ownVar.RelField = new List<CmpBinnOthpabsTblGuidRightBase>(); |
30691 | ········pm.Save(); |
30692 | ········pm.UnloadCache(); |
30693 | ········QueryOwn(); |
30694 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30695 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30696 | ····} |
30697 | ····[Test] |
30698 | ····public void TestSaveReloadRemove() |
30699 | ····{ |
30700 | ········CreateObjects(); |
30701 | ········QueryOwn(); |
30702 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30703 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30704 | ········ownVar.RemoveRelatedObject(); |
30705 | ········pm.Save(); |
30706 | ········pm.UnloadCache(); |
30707 | ········QueryOwn(); |
30708 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30709 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30710 | ····} |
30711 | ····[Test] |
30712 | ····public void TestRelationHash() |
30713 | ····{ |
30714 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidLeft)); |
30715 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30716 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidRightBase)); |
30717 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30718 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30719 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30720 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidRightDerived)); |
30721 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30722 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30723 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30724 | ····} |
30725 | ····void CreateObjects() |
30726 | ····{ |
30727 | ········pm.MakePersistent(ownVar); |
30728 | ········ownVar.AssignRelation(otherVar); |
30729 | ········pm.Save(); |
30730 | ········pm.UnloadCache(); |
30731 | ····} |
30732 | ····void QueryOwn() |
30733 | ····{ |
30734 | ········var q = new NDOQuery<CmpBinnOthpabsTblGuidLeft>(pm); |
30735 | ········ownVar = q.ExecuteSingle(); |
30736 | ····} |
30737 | ····void QueryOther() |
30738 | ····{ |
30739 | ········var q = new NDOQuery<CmpBinnOthpabsTblGuidRightBase>(pm); |
30740 | ········otherVar = q.ExecuteSingle(); |
30741 | ····} |
30742 | } |
30743 | |
30744 | |
30745 | [TestFixture] |
30746 | public class TestAgrDir1OwnpabsOthpabsNoTblGuid : NDOTest |
30747 | { |
30748 | ····AgrDir1OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
30749 | ····AgrDir1OwnpabsOthpabsNoTblGuidRightBase otherVar; |
30750 | ····PersistenceManager pm; |
30751 | ····[SetUp] |
30752 | ····public void Setup() |
30753 | ····{ |
30754 | ········pm = PmFactory.NewPersistenceManager(); |
30755 | ········ownVar = new AgrDir1OwnpabsOthpabsNoTblGuidLeftDerived(); |
30756 | ········otherVar = new AgrDir1OwnpabsOthpabsNoTblGuidRightDerived(); |
30757 | ····} |
30758 | ····[TearDown] |
30759 | ····public void TearDown() |
30760 | ····{ |
30761 | ········try |
30762 | ········{ |
30763 | ············pm.UnloadCache(); |
30764 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
30765 | ············pm.Delete(l); |
30766 | ············pm.Save(); |
30767 | ············pm.UnloadCache(); |
30768 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>().ResultTable; |
30769 | ············pm.Delete(m); |
30770 | ············pm.Save(); |
30771 | ············pm.UnloadCache(); |
30772 | ············decimal count; |
30773 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30774 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30775 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30776 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30777 | ········} |
30778 | ········catch (Exception) |
30779 | ········{ |
30780 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30781 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30782 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30783 | ········} |
30784 | ····} |
30785 | ····[Test] |
30786 | ····public void TestSaveReload() |
30787 | ····{ |
30788 | ········CreateObjects(); |
30789 | ········QueryOwn(); |
30790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30791 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30792 | ····} |
30793 | ····[Test] |
30794 | ····public void TestSaveReloadNull() |
30795 | ····{ |
30796 | ········CreateObjects(); |
30797 | ········QueryOwn(); |
30798 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30799 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30800 | ········ownVar.RelField = null; |
30801 | ········pm.Save(); |
30802 | ········pm.UnloadCache(); |
30803 | ········QueryOwn(); |
30804 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30805 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30806 | ····} |
30807 | ····[Test] |
30808 | ····public void TestChangeKeyHolderLeft() |
30809 | ····{ |
30810 | ········CreateObjects(); |
30811 | ········QueryOwn(); |
30812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30813 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30814 | ········int x = ownVar.RelField.Dummy; |
30815 | ········ownVar.Dummy = 4711; |
30816 | ········pm.Save(); |
30817 | ········pm.UnloadCache(); |
30818 | ········QueryOwn(); |
30819 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30820 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30821 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30822 | ····} |
30823 | ····[Test] |
30824 | ····public void TestChangeKeyHolderLeftNoTouch() |
30825 | ····{ |
30826 | ········CreateObjects(); |
30827 | ········QueryOwn(); |
30828 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30829 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30830 | ········ownVar.Dummy = 4711; |
30831 | ········pm.Save(); |
30832 | ········pm.UnloadCache(); |
30833 | ········QueryOwn(); |
30834 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30835 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30836 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30837 | ····} |
30838 | ····void CreateObjects() |
30839 | ····{ |
30840 | ········pm.MakePersistent(ownVar); |
30841 | ········pm.MakePersistent(otherVar); |
30842 | ········ownVar.AssignRelation(otherVar); |
30843 | ········pm.Save(); |
30844 | ········pm.UnloadCache(); |
30845 | ····} |
30846 | ····void QueryOwn() |
30847 | ····{ |
30848 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
30849 | ········ownVar = q.ExecuteSingle(); |
30850 | ····} |
30851 | ····void QueryOther() |
30852 | ····{ |
30853 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>(pm); |
30854 | ········otherVar = q.ExecuteSingle(); |
30855 | ····} |
30856 | } |
30857 | |
30858 | |
30859 | [TestFixture] |
30860 | public class TestAgrDir1OwnpabsOthpabsTblGuid : NDOTest |
30861 | { |
30862 | ····AgrDir1OwnpabsOthpabsTblGuidLeftBase ownVar; |
30863 | ····AgrDir1OwnpabsOthpabsTblGuidRightBase otherVar; |
30864 | ····PersistenceManager pm; |
30865 | ····[SetUp] |
30866 | ····public void Setup() |
30867 | ····{ |
30868 | ········pm = PmFactory.NewPersistenceManager(); |
30869 | ········ownVar = new AgrDir1OwnpabsOthpabsTblGuidLeftDerived(); |
30870 | ········otherVar = new AgrDir1OwnpabsOthpabsTblGuidRightDerived(); |
30871 | ····} |
30872 | ····[TearDown] |
30873 | ····public void TearDown() |
30874 | ····{ |
30875 | ········try |
30876 | ········{ |
30877 | ············pm.UnloadCache(); |
30878 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
30879 | ············pm.Delete(l); |
30880 | ············pm.Save(); |
30881 | ············pm.UnloadCache(); |
30882 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
30883 | ············pm.Delete(m); |
30884 | ············pm.Save(); |
30885 | ············pm.UnloadCache(); |
30886 | ············decimal count; |
30887 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30888 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30889 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30890 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30891 | ········} |
30892 | ········catch (Exception) |
30893 | ········{ |
30894 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30895 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30896 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30897 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30898 | ········} |
30899 | ····} |
30900 | ····[Test] |
30901 | ····public void TestSaveReload() |
30902 | ····{ |
30903 | ········CreateObjects(); |
30904 | ········QueryOwn(); |
30905 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30906 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30907 | ····} |
30908 | ····[Test] |
30909 | ····public void TestSaveReloadNull() |
30910 | ····{ |
30911 | ········CreateObjects(); |
30912 | ········QueryOwn(); |
30913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30915 | ········ownVar.RelField = null; |
30916 | ········pm.Save(); |
30917 | ········pm.UnloadCache(); |
30918 | ········QueryOwn(); |
30919 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30920 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30921 | ····} |
30922 | ····[Test] |
30923 | ····public void TestChangeKeyHolderLeft() |
30924 | ····{ |
30925 | ········CreateObjects(); |
30926 | ········QueryOwn(); |
30927 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30928 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30929 | ········int x = ownVar.RelField.Dummy; |
30930 | ········ownVar.Dummy = 4711; |
30931 | ········pm.Save(); |
30932 | ········pm.UnloadCache(); |
30933 | ········QueryOwn(); |
30934 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30935 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30936 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30937 | ····} |
30938 | ····[Test] |
30939 | ····public void TestChangeKeyHolderLeftNoTouch() |
30940 | ····{ |
30941 | ········CreateObjects(); |
30942 | ········QueryOwn(); |
30943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30945 | ········ownVar.Dummy = 4711; |
30946 | ········pm.Save(); |
30947 | ········pm.UnloadCache(); |
30948 | ········QueryOwn(); |
30949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30950 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30951 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30952 | ····} |
30953 | ····void CreateObjects() |
30954 | ····{ |
30955 | ········pm.MakePersistent(ownVar); |
30956 | ········pm.MakePersistent(otherVar); |
30957 | ········ownVar.AssignRelation(otherVar); |
30958 | ········pm.Save(); |
30959 | ········pm.UnloadCache(); |
30960 | ····} |
30961 | ····void QueryOwn() |
30962 | ····{ |
30963 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidLeftBase>(pm); |
30964 | ········ownVar = q.ExecuteSingle(); |
30965 | ····} |
30966 | ····void QueryOther() |
30967 | ····{ |
30968 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidRightBase>(pm); |
30969 | ········otherVar = q.ExecuteSingle(); |
30970 | ····} |
30971 | } |
30972 | |
30973 | |
30974 | [TestFixture] |
30975 | public class TestAgrBi11OwnpabsOthpabsNoTblGuid : NDOTest |
30976 | { |
30977 | ····AgrBi11OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
30978 | ····AgrBi11OwnpabsOthpabsNoTblGuidRightBase otherVar; |
30979 | ····PersistenceManager pm; |
30980 | ····[SetUp] |
30981 | ····public void Setup() |
30982 | ····{ |
30983 | ········pm = PmFactory.NewPersistenceManager(); |
30984 | ········ownVar = new AgrBi11OwnpabsOthpabsNoTblGuidLeftDerived(); |
30985 | ········otherVar = new AgrBi11OwnpabsOthpabsNoTblGuidRightDerived(); |
30986 | ····} |
30987 | ····[TearDown] |
30988 | ····public void TearDown() |
30989 | ····{ |
30990 | ········try |
30991 | ········{ |
30992 | ············pm.UnloadCache(); |
30993 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
30994 | ············pm.Delete(l); |
30995 | ············pm.Save(); |
30996 | ············pm.UnloadCache(); |
30997 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>().ResultTable; |
30998 | ············pm.Delete(m); |
30999 | ············pm.Save(); |
31000 | ············pm.UnloadCache(); |
31001 | ············decimal count; |
31002 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31003 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31004 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31005 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31006 | ········} |
31007 | ········catch (Exception) |
31008 | ········{ |
31009 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31010 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31011 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31012 | ········} |
31013 | ····} |
31014 | ····[Test] |
31015 | ····public void TestSaveReload() |
31016 | ····{ |
31017 | ········CreateObjects(); |
31018 | ········QueryOwn(); |
31019 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31020 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31021 | ····} |
31022 | ····[Test] |
31023 | ····public void TestSaveReloadNull() |
31024 | ····{ |
31025 | ········CreateObjects(); |
31026 | ········QueryOwn(); |
31027 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31028 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31029 | ········ownVar.RelField = null; |
31030 | ········pm.Save(); |
31031 | ········pm.UnloadCache(); |
31032 | ········QueryOwn(); |
31033 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31034 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31035 | ····} |
31036 | ····[Test] |
31037 | ····public void TestChangeKeyHolderLeft() |
31038 | ····{ |
31039 | ········CreateObjects(); |
31040 | ········QueryOwn(); |
31041 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31042 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31043 | ········int x = ownVar.RelField.Dummy; |
31044 | ········ownVar.Dummy = 4711; |
31045 | ········pm.Save(); |
31046 | ········pm.UnloadCache(); |
31047 | ········QueryOwn(); |
31048 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31049 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31050 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31051 | ····} |
31052 | ····[Test] |
31053 | ····public void TestChangeKeyHolderRight() |
31054 | ····{ |
31055 | ········CreateObjects(); |
31056 | ········QueryOther(); |
31057 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31058 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31059 | ········int x = otherVar.RelField.Dummy; |
31060 | ········otherVar.Dummy = 4711; |
31061 | ········pm.Save(); |
31062 | ········pm.UnloadCache(); |
31063 | ········QueryOther(); |
31064 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31065 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31066 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31067 | ····} |
31068 | ····[Test] |
31069 | ····public void TestChangeKeyHolderLeftNoTouch() |
31070 | ····{ |
31071 | ········CreateObjects(); |
31072 | ········QueryOwn(); |
31073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31074 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31075 | ········ownVar.Dummy = 4711; |
31076 | ········pm.Save(); |
31077 | ········pm.UnloadCache(); |
31078 | ········QueryOwn(); |
31079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31080 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31081 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31082 | ····} |
31083 | ····[Test] |
31084 | ····public void TestChangeKeyHolderRightNoTouch() |
31085 | ····{ |
31086 | ········CreateObjects(); |
31087 | ········QueryOther(); |
31088 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31089 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31090 | ········otherVar.Dummy = 4711; |
31091 | ········pm.Save(); |
31092 | ········pm.UnloadCache(); |
31093 | ········QueryOther(); |
31094 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31095 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31096 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31097 | ····} |
31098 | ····[Test] |
31099 | ····public void TestRelationHash() |
31100 | ····{ |
31101 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidLeftBase)); |
31102 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31103 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidRightBase)); |
31104 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31105 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31106 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31107 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidLeftDerived)); |
31108 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31109 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31110 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31111 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidRightDerived)); |
31112 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31113 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31114 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31115 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31116 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31117 | ····} |
31118 | ····void CreateObjects() |
31119 | ····{ |
31120 | ········pm.MakePersistent(ownVar); |
31121 | ········pm.MakePersistent(otherVar); |
31122 | ········ownVar.AssignRelation(otherVar); |
31123 | ········pm.Save(); |
31124 | ········pm.UnloadCache(); |
31125 | ····} |
31126 | ····void QueryOwn() |
31127 | ····{ |
31128 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
31129 | ········ownVar = q.ExecuteSingle(); |
31130 | ····} |
31131 | ····void QueryOther() |
31132 | ····{ |
31133 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>(pm); |
31134 | ········otherVar = q.ExecuteSingle(); |
31135 | ····} |
31136 | } |
31137 | |
31138 | |
31139 | [TestFixture] |
31140 | public class TestAgrBi11OwnpabsOthpabsTblGuid : NDOTest |
31141 | { |
31142 | ····AgrBi11OwnpabsOthpabsTblGuidLeftBase ownVar; |
31143 | ····AgrBi11OwnpabsOthpabsTblGuidRightBase otherVar; |
31144 | ····PersistenceManager pm; |
31145 | ····[SetUp] |
31146 | ····public void Setup() |
31147 | ····{ |
31148 | ········pm = PmFactory.NewPersistenceManager(); |
31149 | ········ownVar = new AgrBi11OwnpabsOthpabsTblGuidLeftDerived(); |
31150 | ········otherVar = new AgrBi11OwnpabsOthpabsTblGuidRightDerived(); |
31151 | ····} |
31152 | ····[TearDown] |
31153 | ····public void TearDown() |
31154 | ····{ |
31155 | ········try |
31156 | ········{ |
31157 | ············pm.UnloadCache(); |
31158 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31159 | ············pm.Delete(l); |
31160 | ············pm.Save(); |
31161 | ············pm.UnloadCache(); |
31162 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31163 | ············pm.Delete(m); |
31164 | ············pm.Save(); |
31165 | ············pm.UnloadCache(); |
31166 | ············decimal count; |
31167 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31168 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31169 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31170 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31171 | ········} |
31172 | ········catch (Exception) |
31173 | ········{ |
31174 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31175 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31176 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31177 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31178 | ········} |
31179 | ····} |
31180 | ····[Test] |
31181 | ····public void TestSaveReload() |
31182 | ····{ |
31183 | ········CreateObjects(); |
31184 | ········QueryOwn(); |
31185 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31186 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31187 | ····} |
31188 | ····[Test] |
31189 | ····public void TestSaveReloadNull() |
31190 | ····{ |
31191 | ········CreateObjects(); |
31192 | ········QueryOwn(); |
31193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31194 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31195 | ········ownVar.RelField = null; |
31196 | ········pm.Save(); |
31197 | ········pm.UnloadCache(); |
31198 | ········QueryOwn(); |
31199 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31200 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31201 | ····} |
31202 | ····[Test] |
31203 | ····public void TestChangeKeyHolderLeft() |
31204 | ····{ |
31205 | ········CreateObjects(); |
31206 | ········QueryOwn(); |
31207 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31208 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31209 | ········int x = ownVar.RelField.Dummy; |
31210 | ········ownVar.Dummy = 4711; |
31211 | ········pm.Save(); |
31212 | ········pm.UnloadCache(); |
31213 | ········QueryOwn(); |
31214 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31215 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31216 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31217 | ····} |
31218 | ····[Test] |
31219 | ····public void TestChangeKeyHolderRight() |
31220 | ····{ |
31221 | ········CreateObjects(); |
31222 | ········QueryOther(); |
31223 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31224 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31225 | ········int x = otherVar.RelField.Dummy; |
31226 | ········otherVar.Dummy = 4711; |
31227 | ········pm.Save(); |
31228 | ········pm.UnloadCache(); |
31229 | ········QueryOther(); |
31230 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31231 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31232 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31233 | ····} |
31234 | ····[Test] |
31235 | ····public void TestChangeKeyHolderLeftNoTouch() |
31236 | ····{ |
31237 | ········CreateObjects(); |
31238 | ········QueryOwn(); |
31239 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31240 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31241 | ········ownVar.Dummy = 4711; |
31242 | ········pm.Save(); |
31243 | ········pm.UnloadCache(); |
31244 | ········QueryOwn(); |
31245 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31246 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31247 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31248 | ····} |
31249 | ····[Test] |
31250 | ····public void TestChangeKeyHolderRightNoTouch() |
31251 | ····{ |
31252 | ········CreateObjects(); |
31253 | ········QueryOther(); |
31254 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31255 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31256 | ········otherVar.Dummy = 4711; |
31257 | ········pm.Save(); |
31258 | ········pm.UnloadCache(); |
31259 | ········QueryOther(); |
31260 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31261 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31262 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31263 | ····} |
31264 | ····[Test] |
31265 | ····public void TestRelationHash() |
31266 | ····{ |
31267 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidLeftBase)); |
31268 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31269 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidRightBase)); |
31270 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31271 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31272 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31273 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidLeftDerived)); |
31274 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31275 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31276 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31277 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidRightDerived)); |
31278 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31279 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31280 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31281 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31282 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31283 | ····} |
31284 | ····void CreateObjects() |
31285 | ····{ |
31286 | ········pm.MakePersistent(ownVar); |
31287 | ········pm.MakePersistent(otherVar); |
31288 | ········ownVar.AssignRelation(otherVar); |
31289 | ········pm.Save(); |
31290 | ········pm.UnloadCache(); |
31291 | ····} |
31292 | ····void QueryOwn() |
31293 | ····{ |
31294 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidLeftBase>(pm); |
31295 | ········ownVar = q.ExecuteSingle(); |
31296 | ····} |
31297 | ····void QueryOther() |
31298 | ····{ |
31299 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidRightBase>(pm); |
31300 | ········otherVar = q.ExecuteSingle(); |
31301 | ····} |
31302 | } |
31303 | |
31304 | |
31305 | [TestFixture] |
31306 | public class TestAgrDirnOwnpabsOthpabsTblGuid : NDOTest |
31307 | { |
31308 | ····AgrDirnOwnpabsOthpabsTblGuidLeftBase ownVar; |
31309 | ····AgrDirnOwnpabsOthpabsTblGuidRightBase otherVar; |
31310 | ····PersistenceManager pm; |
31311 | ····[SetUp] |
31312 | ····public void Setup() |
31313 | ····{ |
31314 | ········pm = PmFactory.NewPersistenceManager(); |
31315 | ········ownVar = new AgrDirnOwnpabsOthpabsTblGuidLeftDerived(); |
31316 | ········otherVar = new AgrDirnOwnpabsOthpabsTblGuidRightDerived(); |
31317 | ····} |
31318 | ····[TearDown] |
31319 | ····public void TearDown() |
31320 | ····{ |
31321 | ········try |
31322 | ········{ |
31323 | ············pm.UnloadCache(); |
31324 | ············var l = pm.Objects<AgrDirnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31325 | ············pm.Delete(l); |
31326 | ············pm.Save(); |
31327 | ············pm.UnloadCache(); |
31328 | ············var m = pm.Objects<AgrDirnOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31329 | ············pm.Delete(m); |
31330 | ············pm.Save(); |
31331 | ············pm.UnloadCache(); |
31332 | ············decimal count; |
31333 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31334 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31335 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31336 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31337 | ········} |
31338 | ········catch (Exception) |
31339 | ········{ |
31340 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31341 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31342 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31343 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31344 | ········} |
31345 | ····} |
31346 | ····[Test] |
31347 | ····public void TestSaveReload() |
31348 | ····{ |
31349 | ········CreateObjects(); |
31350 | ········QueryOwn(); |
31351 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31352 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31353 | ····} |
31354 | ····[Test] |
31355 | ····public void TestSaveReloadNull() |
31356 | ····{ |
31357 | ········CreateObjects(); |
31358 | ········QueryOwn(); |
31359 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31360 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31361 | ········ownVar.RelField = new List<AgrDirnOwnpabsOthpabsTblGuidRightBase>(); |
31362 | ········pm.Save(); |
31363 | ········pm.UnloadCache(); |
31364 | ········QueryOwn(); |
31365 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31366 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31367 | ····} |
31368 | ····[Test] |
31369 | ····public void TestSaveReloadRemove() |
31370 | ····{ |
31371 | ········CreateObjects(); |
31372 | ········QueryOwn(); |
31373 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31374 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31375 | ········ownVar.RemoveRelatedObject(); |
31376 | ········pm.Save(); |
31377 | ········pm.UnloadCache(); |
31378 | ········QueryOwn(); |
31379 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31380 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31381 | ····} |
31382 | ····void CreateObjects() |
31383 | ····{ |
31384 | ········pm.MakePersistent(ownVar); |
31385 | ········pm.MakePersistent(otherVar); |
31386 | ········ownVar.AssignRelation(otherVar); |
31387 | ········pm.Save(); |
31388 | ········pm.UnloadCache(); |
31389 | ····} |
31390 | ····void QueryOwn() |
31391 | ····{ |
31392 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidLeftBase>(pm); |
31393 | ········ownVar = q.ExecuteSingle(); |
31394 | ····} |
31395 | ····void QueryOther() |
31396 | ····{ |
31397 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidRightBase>(pm); |
31398 | ········otherVar = q.ExecuteSingle(); |
31399 | ····} |
31400 | } |
31401 | |
31402 | |
31403 | [TestFixture] |
31404 | public class TestAgrBin1OwnpabsOthpabsTblGuid : NDOTest |
31405 | { |
31406 | ····AgrBin1OwnpabsOthpabsTblGuidLeftBase ownVar; |
31407 | ····AgrBin1OwnpabsOthpabsTblGuidRightBase otherVar; |
31408 | ····PersistenceManager pm; |
31409 | ····[SetUp] |
31410 | ····public void Setup() |
31411 | ····{ |
31412 | ········pm = PmFactory.NewPersistenceManager(); |
31413 | ········ownVar = new AgrBin1OwnpabsOthpabsTblGuidLeftDerived(); |
31414 | ········otherVar = new AgrBin1OwnpabsOthpabsTblGuidRightDerived(); |
31415 | ····} |
31416 | ····[TearDown] |
31417 | ····public void TearDown() |
31418 | ····{ |
31419 | ········try |
31420 | ········{ |
31421 | ············pm.UnloadCache(); |
31422 | ············var l = pm.Objects<AgrBin1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31423 | ············pm.Delete(l); |
31424 | ············pm.Save(); |
31425 | ············pm.UnloadCache(); |
31426 | ············var m = pm.Objects<AgrBin1OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31427 | ············pm.Delete(m); |
31428 | ············pm.Save(); |
31429 | ············pm.UnloadCache(); |
31430 | ············decimal count; |
31431 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31432 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31433 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31434 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31435 | ········} |
31436 | ········catch (Exception) |
31437 | ········{ |
31438 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31439 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31440 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31441 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31442 | ········} |
31443 | ····} |
31444 | ····[Test] |
31445 | ····public void TestSaveReload() |
31446 | ····{ |
31447 | ········CreateObjects(); |
31448 | ········QueryOwn(); |
31449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31450 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31451 | ····} |
31452 | ····[Test] |
31453 | ····public void TestSaveReloadNull() |
31454 | ····{ |
31455 | ········CreateObjects(); |
31456 | ········QueryOwn(); |
31457 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31458 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31459 | ········ownVar.RelField = new List<AgrBin1OwnpabsOthpabsTblGuidRightBase>(); |
31460 | ········pm.Save(); |
31461 | ········pm.UnloadCache(); |
31462 | ········QueryOwn(); |
31463 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31464 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31465 | ····} |
31466 | ····[Test] |
31467 | ····public void TestSaveReloadRemove() |
31468 | ····{ |
31469 | ········CreateObjects(); |
31470 | ········QueryOwn(); |
31471 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31472 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31473 | ········ownVar.RemoveRelatedObject(); |
31474 | ········pm.Save(); |
31475 | ········pm.UnloadCache(); |
31476 | ········QueryOwn(); |
31477 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31478 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31479 | ····} |
31480 | ····[Test] |
31481 | ····public void TestChangeKeyHolderRight() |
31482 | ····{ |
31483 | ········CreateObjects(); |
31484 | ········QueryOther(); |
31485 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31486 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31487 | ········int x = otherVar.RelField.Dummy; |
31488 | ········otherVar.Dummy = 4711; |
31489 | ········pm.Save(); |
31490 | ········pm.UnloadCache(); |
31491 | ········QueryOther(); |
31492 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31493 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31494 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31495 | ····} |
31496 | ····[Test] |
31497 | ····public void TestChangeKeyHolderRightNoTouch() |
31498 | ····{ |
31499 | ········CreateObjects(); |
31500 | ········QueryOther(); |
31501 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31502 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31503 | ········otherVar.Dummy = 4711; |
31504 | ········pm.Save(); |
31505 | ········pm.UnloadCache(); |
31506 | ········QueryOther(); |
31507 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31508 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31509 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31510 | ····} |
31511 | ····[Test] |
31512 | ····public void TestRelationHash() |
31513 | ····{ |
31514 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidLeftBase)); |
31515 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31516 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidRightBase)); |
31517 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31518 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31519 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31520 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidLeftDerived)); |
31521 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31522 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31523 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31524 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidRightDerived)); |
31525 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31526 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31527 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31528 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31529 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31530 | ····} |
31531 | ····void CreateObjects() |
31532 | ····{ |
31533 | ········pm.MakePersistent(ownVar); |
31534 | ········pm.MakePersistent(otherVar); |
31535 | ········ownVar.AssignRelation(otherVar); |
31536 | ········pm.Save(); |
31537 | ········pm.UnloadCache(); |
31538 | ····} |
31539 | ····void QueryOwn() |
31540 | ····{ |
31541 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidLeftBase>(pm); |
31542 | ········ownVar = q.ExecuteSingle(); |
31543 | ····} |
31544 | ····void QueryOther() |
31545 | ····{ |
31546 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidRightBase>(pm); |
31547 | ········otherVar = q.ExecuteSingle(); |
31548 | ····} |
31549 | } |
31550 | |
31551 | |
31552 | [TestFixture] |
31553 | public class TestAgrBi1nOwnpabsOthpabsTblGuid : NDOTest |
31554 | { |
31555 | ····AgrBi1nOwnpabsOthpabsTblGuidLeftBase ownVar; |
31556 | ····AgrBi1nOwnpabsOthpabsTblGuidRightBase otherVar; |
31557 | ····PersistenceManager pm; |
31558 | ····[SetUp] |
31559 | ····public void Setup() |
31560 | ····{ |
31561 | ········pm = PmFactory.NewPersistenceManager(); |
31562 | ········ownVar = new AgrBi1nOwnpabsOthpabsTblGuidLeftDerived(); |
31563 | ········otherVar = new AgrBi1nOwnpabsOthpabsTblGuidRightDerived(); |
31564 | ····} |
31565 | ····[TearDown] |
31566 | ····public void TearDown() |
31567 | ····{ |
31568 | ········try |
31569 | ········{ |
31570 | ············pm.UnloadCache(); |
31571 | ············var l = pm.Objects<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31572 | ············pm.Delete(l); |
31573 | ············pm.Save(); |
31574 | ············pm.UnloadCache(); |
31575 | ············var m = pm.Objects<AgrBi1nOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31576 | ············pm.Delete(m); |
31577 | ············pm.Save(); |
31578 | ············pm.UnloadCache(); |
31579 | ············decimal count; |
31580 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31581 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31582 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31583 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31584 | ········} |
31585 | ········catch (Exception) |
31586 | ········{ |
31587 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31588 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31589 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31590 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31591 | ········} |
31592 | ····} |
31593 | ····[Test] |
31594 | ····public void TestSaveReload() |
31595 | ····{ |
31596 | ········CreateObjects(); |
31597 | ········QueryOwn(); |
31598 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31599 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31600 | ····} |
31601 | ····[Test] |
31602 | ····public void TestSaveReloadNull() |
31603 | ····{ |
31604 | ········CreateObjects(); |
31605 | ········QueryOwn(); |
31606 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31607 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31608 | ········ownVar.RelField = null; |
31609 | ········pm.Save(); |
31610 | ········pm.UnloadCache(); |
31611 | ········QueryOwn(); |
31612 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31613 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31614 | ····} |
31615 | ····[Test] |
31616 | ····public void TestChangeKeyHolderLeft() |
31617 | ····{ |
31618 | ········CreateObjects(); |
31619 | ········QueryOwn(); |
31620 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31621 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31622 | ········int x = ownVar.RelField.Dummy; |
31623 | ········ownVar.Dummy = 4711; |
31624 | ········pm.Save(); |
31625 | ········pm.UnloadCache(); |
31626 | ········QueryOwn(); |
31627 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31628 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31629 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31630 | ····} |
31631 | ····[Test] |
31632 | ····public void TestChangeKeyHolderLeftNoTouch() |
31633 | ····{ |
31634 | ········CreateObjects(); |
31635 | ········QueryOwn(); |
31636 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31637 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31638 | ········ownVar.Dummy = 4711; |
31639 | ········pm.Save(); |
31640 | ········pm.UnloadCache(); |
31641 | ········QueryOwn(); |
31642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31643 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31644 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31645 | ····} |
31646 | ····[Test] |
31647 | ····public void TestRelationHash() |
31648 | ····{ |
31649 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidLeftBase)); |
31650 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31651 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidRightBase)); |
31652 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31653 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31654 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31655 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidLeftDerived)); |
31656 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31657 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31658 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31659 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidRightDerived)); |
31660 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31661 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31662 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31663 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31664 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31665 | ····} |
31666 | ····void CreateObjects() |
31667 | ····{ |
31668 | ········pm.MakePersistent(ownVar); |
31669 | ········pm.MakePersistent(otherVar); |
31670 | ········ownVar.AssignRelation(otherVar); |
31671 | ········pm.Save(); |
31672 | ········pm.UnloadCache(); |
31673 | ····} |
31674 | ····void QueryOwn() |
31675 | ····{ |
31676 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>(pm); |
31677 | ········ownVar = q.ExecuteSingle(); |
31678 | ····} |
31679 | ····void QueryOther() |
31680 | ····{ |
31681 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidRightBase>(pm); |
31682 | ········otherVar = q.ExecuteSingle(); |
31683 | ····} |
31684 | } |
31685 | |
31686 | |
31687 | [TestFixture] |
31688 | public class TestAgrBinnOwnpabsOthpabsTblGuid : NDOTest |
31689 | { |
31690 | ····AgrBinnOwnpabsOthpabsTblGuidLeftBase ownVar; |
31691 | ····AgrBinnOwnpabsOthpabsTblGuidRightBase otherVar; |
31692 | ····PersistenceManager pm; |
31693 | ····[SetUp] |
31694 | ····public void Setup() |
31695 | ····{ |
31696 | ········pm = PmFactory.NewPersistenceManager(); |
31697 | ········ownVar = new AgrBinnOwnpabsOthpabsTblGuidLeftDerived(); |
31698 | ········otherVar = new AgrBinnOwnpabsOthpabsTblGuidRightDerived(); |
31699 | ····} |
31700 | ····[TearDown] |
31701 | ····public void TearDown() |
31702 | ····{ |
31703 | ········try |
31704 | ········{ |
31705 | ············pm.UnloadCache(); |
31706 | ············var l = pm.Objects<AgrBinnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31707 | ············pm.Delete(l); |
31708 | ············pm.Save(); |
31709 | ············pm.UnloadCache(); |
31710 | ············var m = pm.Objects<AgrBinnOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31711 | ············pm.Delete(m); |
31712 | ············pm.Save(); |
31713 | ············pm.UnloadCache(); |
31714 | ············decimal count; |
31715 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31716 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31717 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31718 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31719 | ········} |
31720 | ········catch (Exception) |
31721 | ········{ |
31722 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31723 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31724 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31725 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31726 | ········} |
31727 | ····} |
31728 | ····[Test] |
31729 | ····public void TestSaveReload() |
31730 | ····{ |
31731 | ········CreateObjects(); |
31732 | ········QueryOwn(); |
31733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31734 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31735 | ····} |
31736 | ····[Test] |
31737 | ····public void TestSaveReloadNull() |
31738 | ····{ |
31739 | ········CreateObjects(); |
31740 | ········QueryOwn(); |
31741 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31742 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31743 | ········ownVar.RelField = new List<AgrBinnOwnpabsOthpabsTblGuidRightBase>(); |
31744 | ········pm.Save(); |
31745 | ········pm.UnloadCache(); |
31746 | ········QueryOwn(); |
31747 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31748 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31749 | ····} |
31750 | ····[Test] |
31751 | ····public void TestSaveReloadRemove() |
31752 | ····{ |
31753 | ········CreateObjects(); |
31754 | ········QueryOwn(); |
31755 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31756 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31757 | ········ownVar.RemoveRelatedObject(); |
31758 | ········pm.Save(); |
31759 | ········pm.UnloadCache(); |
31760 | ········QueryOwn(); |
31761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31762 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31763 | ····} |
31764 | ····[Test] |
31765 | ····public void TestRelationHash() |
31766 | ····{ |
31767 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidLeftBase)); |
31768 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31769 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidRightBase)); |
31770 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31771 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31772 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31773 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidLeftDerived)); |
31774 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31775 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31776 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31777 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidRightDerived)); |
31778 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31779 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31780 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31781 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31782 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31783 | ····} |
31784 | ····void CreateObjects() |
31785 | ····{ |
31786 | ········pm.MakePersistent(ownVar); |
31787 | ········pm.MakePersistent(otherVar); |
31788 | ········ownVar.AssignRelation(otherVar); |
31789 | ········pm.Save(); |
31790 | ········pm.UnloadCache(); |
31791 | ····} |
31792 | ····void QueryOwn() |
31793 | ····{ |
31794 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidLeftBase>(pm); |
31795 | ········ownVar = q.ExecuteSingle(); |
31796 | ····} |
31797 | ····void QueryOther() |
31798 | ····{ |
31799 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidRightBase>(pm); |
31800 | ········otherVar = q.ExecuteSingle(); |
31801 | ····} |
31802 | } |
31803 | |
31804 | |
31805 | [TestFixture] |
31806 | public class TestCmpDir1OwnpabsOthpabsNoTblGuid : NDOTest |
31807 | { |
31808 | ····CmpDir1OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
31809 | ····CmpDir1OwnpabsOthpabsNoTblGuidRightBase otherVar; |
31810 | ····PersistenceManager pm; |
31811 | ····[SetUp] |
31812 | ····public void Setup() |
31813 | ····{ |
31814 | ········pm = PmFactory.NewPersistenceManager(); |
31815 | ········ownVar = new CmpDir1OwnpabsOthpabsNoTblGuidLeftDerived(); |
31816 | ········otherVar = new CmpDir1OwnpabsOthpabsNoTblGuidRightDerived(); |
31817 | ····} |
31818 | ····[TearDown] |
31819 | ····public void TearDown() |
31820 | ····{ |
31821 | ········try |
31822 | ········{ |
31823 | ············pm.UnloadCache(); |
31824 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
31825 | ············pm.Delete(l); |
31826 | ············pm.Save(); |
31827 | ············pm.UnloadCache(); |
31828 | ············decimal count; |
31829 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31830 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31831 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31832 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31833 | ········} |
31834 | ········catch (Exception) |
31835 | ········{ |
31836 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31837 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31838 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31839 | ········} |
31840 | ····} |
31841 | ····[Test] |
31842 | ····public void TestSaveReload() |
31843 | ····{ |
31844 | ········CreateObjects(); |
31845 | ········QueryOwn(); |
31846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31847 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31848 | ····} |
31849 | ····[Test] |
31850 | ····public void TestSaveReloadNull() |
31851 | ····{ |
31852 | ········CreateObjects(); |
31853 | ········QueryOwn(); |
31854 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31855 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31856 | ········ownVar.RelField = null; |
31857 | ········pm.Save(); |
31858 | ········pm.UnloadCache(); |
31859 | ········QueryOwn(); |
31860 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31861 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31862 | ····} |
31863 | ····[Test] |
31864 | ····public void TestChangeKeyHolderLeft() |
31865 | ····{ |
31866 | ········CreateObjects(); |
31867 | ········QueryOwn(); |
31868 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31869 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31870 | ········int x = ownVar.RelField.Dummy; |
31871 | ········ownVar.Dummy = 4711; |
31872 | ········pm.Save(); |
31873 | ········pm.UnloadCache(); |
31874 | ········QueryOwn(); |
31875 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31876 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31877 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31878 | ····} |
31879 | ····[Test] |
31880 | ····public void TestChangeKeyHolderLeftNoTouch() |
31881 | ····{ |
31882 | ········CreateObjects(); |
31883 | ········QueryOwn(); |
31884 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31885 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31886 | ········ownVar.Dummy = 4711; |
31887 | ········pm.Save(); |
31888 | ········pm.UnloadCache(); |
31889 | ········QueryOwn(); |
31890 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31891 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31892 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31893 | ····} |
31894 | ····void CreateObjects() |
31895 | ····{ |
31896 | ········pm.MakePersistent(ownVar); |
31897 | ········ownVar.AssignRelation(otherVar); |
31898 | ········pm.Save(); |
31899 | ········pm.UnloadCache(); |
31900 | ····} |
31901 | ····void QueryOwn() |
31902 | ····{ |
31903 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
31904 | ········ownVar = q.ExecuteSingle(); |
31905 | ····} |
31906 | ····void QueryOther() |
31907 | ····{ |
31908 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidRightBase>(pm); |
31909 | ········otherVar = q.ExecuteSingle(); |
31910 | ····} |
31911 | } |
31912 | |
31913 | |
31914 | [TestFixture] |
31915 | public class TestCmpDir1OwnpabsOthpabsTblGuid : NDOTest |
31916 | { |
31917 | ····CmpDir1OwnpabsOthpabsTblGuidLeftBase ownVar; |
31918 | ····CmpDir1OwnpabsOthpabsTblGuidRightBase otherVar; |
31919 | ····PersistenceManager pm; |
31920 | ····[SetUp] |
31921 | ····public void Setup() |
31922 | ····{ |
31923 | ········pm = PmFactory.NewPersistenceManager(); |
31924 | ········ownVar = new CmpDir1OwnpabsOthpabsTblGuidLeftDerived(); |
31925 | ········otherVar = new CmpDir1OwnpabsOthpabsTblGuidRightDerived(); |
31926 | ····} |
31927 | ····[TearDown] |
31928 | ····public void TearDown() |
31929 | ····{ |
31930 | ········try |
31931 | ········{ |
31932 | ············pm.UnloadCache(); |
31933 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31934 | ············pm.Delete(l); |
31935 | ············pm.Save(); |
31936 | ············pm.UnloadCache(); |
31937 | ············decimal count; |
31938 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31939 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31940 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31941 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31942 | ········} |
31943 | ········catch (Exception) |
31944 | ········{ |
31945 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31946 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31947 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31948 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31949 | ········} |
31950 | ····} |
31951 | ····[Test] |
31952 | ····public void TestSaveReload() |
31953 | ····{ |
31954 | ········CreateObjects(); |
31955 | ········QueryOwn(); |
31956 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31957 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31958 | ····} |
31959 | ····[Test] |
31960 | ····public void TestSaveReloadNull() |
31961 | ····{ |
31962 | ········CreateObjects(); |
31963 | ········QueryOwn(); |
31964 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31965 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31966 | ········ownVar.RelField = null; |
31967 | ········pm.Save(); |
31968 | ········pm.UnloadCache(); |
31969 | ········QueryOwn(); |
31970 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31971 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31972 | ····} |
31973 | ····[Test] |
31974 | ····public void TestChangeKeyHolderLeft() |
31975 | ····{ |
31976 | ········CreateObjects(); |
31977 | ········QueryOwn(); |
31978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31979 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31980 | ········int x = ownVar.RelField.Dummy; |
31981 | ········ownVar.Dummy = 4711; |
31982 | ········pm.Save(); |
31983 | ········pm.UnloadCache(); |
31984 | ········QueryOwn(); |
31985 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31986 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31987 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31988 | ····} |
31989 | ····[Test] |
31990 | ····public void TestChangeKeyHolderLeftNoTouch() |
31991 | ····{ |
31992 | ········CreateObjects(); |
31993 | ········QueryOwn(); |
31994 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31995 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31996 | ········ownVar.Dummy = 4711; |
31997 | ········pm.Save(); |
31998 | ········pm.UnloadCache(); |
31999 | ········QueryOwn(); |
32000 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32001 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32002 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32003 | ····} |
32004 | ····void CreateObjects() |
32005 | ····{ |
32006 | ········pm.MakePersistent(ownVar); |
32007 | ········ownVar.AssignRelation(otherVar); |
32008 | ········pm.Save(); |
32009 | ········pm.UnloadCache(); |
32010 | ····} |
32011 | ····void QueryOwn() |
32012 | ····{ |
32013 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidLeftBase>(pm); |
32014 | ········ownVar = q.ExecuteSingle(); |
32015 | ····} |
32016 | ····void QueryOther() |
32017 | ····{ |
32018 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidRightBase>(pm); |
32019 | ········otherVar = q.ExecuteSingle(); |
32020 | ····} |
32021 | } |
32022 | |
32023 | |
32024 | [TestFixture] |
32025 | public class TestCmpBi11OwnpabsOthpabsNoTblGuid : NDOTest |
32026 | { |
32027 | ····CmpBi11OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
32028 | ····CmpBi11OwnpabsOthpabsNoTblGuidRightBase otherVar; |
32029 | ····PersistenceManager pm; |
32030 | ····[SetUp] |
32031 | ····public void Setup() |
32032 | ····{ |
32033 | ········pm = PmFactory.NewPersistenceManager(); |
32034 | ········ownVar = new CmpBi11OwnpabsOthpabsNoTblGuidLeftDerived(); |
32035 | ········otherVar = new CmpBi11OwnpabsOthpabsNoTblGuidRightDerived(); |
32036 | ····} |
32037 | ····[TearDown] |
32038 | ····public void TearDown() |
32039 | ····{ |
32040 | ········try |
32041 | ········{ |
32042 | ············pm.UnloadCache(); |
32043 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
32044 | ············pm.Delete(l); |
32045 | ············pm.Save(); |
32046 | ············pm.UnloadCache(); |
32047 | ············decimal count; |
32048 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32049 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32050 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32051 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32052 | ········} |
32053 | ········catch (Exception) |
32054 | ········{ |
32055 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32056 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32057 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32058 | ········} |
32059 | ····} |
32060 | ····[Test] |
32061 | ····public void TestSaveReload() |
32062 | ····{ |
32063 | ········CreateObjects(); |
32064 | ········QueryOwn(); |
32065 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32066 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32067 | ····} |
32068 | ····[Test] |
32069 | ····public void TestSaveReloadNull() |
32070 | ····{ |
32071 | ········CreateObjects(); |
32072 | ········QueryOwn(); |
32073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32074 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32075 | ········ownVar.RelField = null; |
32076 | ········pm.Save(); |
32077 | ········pm.UnloadCache(); |
32078 | ········QueryOwn(); |
32079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32080 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32081 | ····} |
32082 | ····[Test] |
32083 | ····public void TestChangeKeyHolderLeft() |
32084 | ····{ |
32085 | ········CreateObjects(); |
32086 | ········QueryOwn(); |
32087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32088 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32089 | ········int x = ownVar.RelField.Dummy; |
32090 | ········ownVar.Dummy = 4711; |
32091 | ········pm.Save(); |
32092 | ········pm.UnloadCache(); |
32093 | ········QueryOwn(); |
32094 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32095 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32096 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32097 | ····} |
32098 | ····[Test] |
32099 | ····public void TestChangeKeyHolderRight() |
32100 | ····{ |
32101 | ········CreateObjects(); |
32102 | ········QueryOther(); |
32103 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32104 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32105 | ········int x = otherVar.RelField.Dummy; |
32106 | ········otherVar.Dummy = 4711; |
32107 | ········pm.Save(); |
32108 | ········pm.UnloadCache(); |
32109 | ········QueryOther(); |
32110 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32111 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32112 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32113 | ····} |
32114 | ····[Test] |
32115 | ····public void TestChangeKeyHolderLeftNoTouch() |
32116 | ····{ |
32117 | ········CreateObjects(); |
32118 | ········QueryOwn(); |
32119 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32120 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32121 | ········ownVar.Dummy = 4711; |
32122 | ········pm.Save(); |
32123 | ········pm.UnloadCache(); |
32124 | ········QueryOwn(); |
32125 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32126 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32127 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32128 | ····} |
32129 | ····[Test] |
32130 | ····public void TestChangeKeyHolderRightNoTouch() |
32131 | ····{ |
32132 | ········CreateObjects(); |
32133 | ········QueryOther(); |
32134 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32135 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32136 | ········otherVar.Dummy = 4711; |
32137 | ········pm.Save(); |
32138 | ········pm.UnloadCache(); |
32139 | ········QueryOther(); |
32140 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32141 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32142 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32143 | ····} |
32144 | ····[Test] |
32145 | ····public void TestRelationHash() |
32146 | ····{ |
32147 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidLeftBase)); |
32148 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32149 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidRightBase)); |
32150 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32151 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32152 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32153 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidLeftDerived)); |
32154 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32155 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32156 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32157 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidRightDerived)); |
32158 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32159 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32160 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32161 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32162 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32163 | ····} |
32164 | ····void CreateObjects() |
32165 | ····{ |
32166 | ········pm.MakePersistent(ownVar); |
32167 | ········ownVar.AssignRelation(otherVar); |
32168 | ········pm.Save(); |
32169 | ········pm.UnloadCache(); |
32170 | ····} |
32171 | ····void QueryOwn() |
32172 | ····{ |
32173 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
32174 | ········ownVar = q.ExecuteSingle(); |
32175 | ····} |
32176 | ····void QueryOther() |
32177 | ····{ |
32178 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidRightBase>(pm); |
32179 | ········otherVar = q.ExecuteSingle(); |
32180 | ····} |
32181 | } |
32182 | |
32183 | |
32184 | [TestFixture] |
32185 | public class TestCmpBi11OwnpabsOthpabsTblGuid : NDOTest |
32186 | { |
32187 | ····CmpBi11OwnpabsOthpabsTblGuidLeftBase ownVar; |
32188 | ····CmpBi11OwnpabsOthpabsTblGuidRightBase otherVar; |
32189 | ····PersistenceManager pm; |
32190 | ····[SetUp] |
32191 | ····public void Setup() |
32192 | ····{ |
32193 | ········pm = PmFactory.NewPersistenceManager(); |
32194 | ········ownVar = new CmpBi11OwnpabsOthpabsTblGuidLeftDerived(); |
32195 | ········otherVar = new CmpBi11OwnpabsOthpabsTblGuidRightDerived(); |
32196 | ····} |
32197 | ····[TearDown] |
32198 | ····public void TearDown() |
32199 | ····{ |
32200 | ········try |
32201 | ········{ |
32202 | ············pm.UnloadCache(); |
32203 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32204 | ············pm.Delete(l); |
32205 | ············pm.Save(); |
32206 | ············pm.UnloadCache(); |
32207 | ············decimal count; |
32208 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32209 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32210 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32211 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32212 | ········} |
32213 | ········catch (Exception) |
32214 | ········{ |
32215 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32216 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32218 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32219 | ········} |
32220 | ····} |
32221 | ····[Test] |
32222 | ····public void TestSaveReload() |
32223 | ····{ |
32224 | ········CreateObjects(); |
32225 | ········QueryOwn(); |
32226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32227 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32228 | ····} |
32229 | ····[Test] |
32230 | ····public void TestSaveReloadNull() |
32231 | ····{ |
32232 | ········CreateObjects(); |
32233 | ········QueryOwn(); |
32234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32235 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32236 | ········ownVar.RelField = null; |
32237 | ········pm.Save(); |
32238 | ········pm.UnloadCache(); |
32239 | ········QueryOwn(); |
32240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32241 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32242 | ····} |
32243 | ····[Test] |
32244 | ····public void TestChangeKeyHolderLeft() |
32245 | ····{ |
32246 | ········CreateObjects(); |
32247 | ········QueryOwn(); |
32248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32249 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32250 | ········int x = ownVar.RelField.Dummy; |
32251 | ········ownVar.Dummy = 4711; |
32252 | ········pm.Save(); |
32253 | ········pm.UnloadCache(); |
32254 | ········QueryOwn(); |
32255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32256 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32257 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32258 | ····} |
32259 | ····[Test] |
32260 | ····public void TestChangeKeyHolderRight() |
32261 | ····{ |
32262 | ········CreateObjects(); |
32263 | ········QueryOther(); |
32264 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32265 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32266 | ········int x = otherVar.RelField.Dummy; |
32267 | ········otherVar.Dummy = 4711; |
32268 | ········pm.Save(); |
32269 | ········pm.UnloadCache(); |
32270 | ········QueryOther(); |
32271 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32272 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32273 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32274 | ····} |
32275 | ····[Test] |
32276 | ····public void TestChangeKeyHolderLeftNoTouch() |
32277 | ····{ |
32278 | ········CreateObjects(); |
32279 | ········QueryOwn(); |
32280 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32281 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32282 | ········ownVar.Dummy = 4711; |
32283 | ········pm.Save(); |
32284 | ········pm.UnloadCache(); |
32285 | ········QueryOwn(); |
32286 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32287 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32288 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32289 | ····} |
32290 | ····[Test] |
32291 | ····public void TestChangeKeyHolderRightNoTouch() |
32292 | ····{ |
32293 | ········CreateObjects(); |
32294 | ········QueryOther(); |
32295 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32296 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32297 | ········otherVar.Dummy = 4711; |
32298 | ········pm.Save(); |
32299 | ········pm.UnloadCache(); |
32300 | ········QueryOther(); |
32301 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32302 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32303 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32304 | ····} |
32305 | ····[Test] |
32306 | ····public void TestRelationHash() |
32307 | ····{ |
32308 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidLeftBase)); |
32309 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32310 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidRightBase)); |
32311 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32312 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32313 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32314 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidLeftDerived)); |
32315 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32316 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32317 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32318 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidRightDerived)); |
32319 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32320 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32321 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32322 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32323 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32324 | ····} |
32325 | ····void CreateObjects() |
32326 | ····{ |
32327 | ········pm.MakePersistent(ownVar); |
32328 | ········ownVar.AssignRelation(otherVar); |
32329 | ········pm.Save(); |
32330 | ········pm.UnloadCache(); |
32331 | ····} |
32332 | ····void QueryOwn() |
32333 | ····{ |
32334 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidLeftBase>(pm); |
32335 | ········ownVar = q.ExecuteSingle(); |
32336 | ····} |
32337 | ····void QueryOther() |
32338 | ····{ |
32339 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidRightBase>(pm); |
32340 | ········otherVar = q.ExecuteSingle(); |
32341 | ····} |
32342 | } |
32343 | |
32344 | |
32345 | [TestFixture] |
32346 | public class TestCmpDirnOwnpabsOthpabsTblGuid : NDOTest |
32347 | { |
32348 | ····CmpDirnOwnpabsOthpabsTblGuidLeftBase ownVar; |
32349 | ····CmpDirnOwnpabsOthpabsTblGuidRightBase otherVar; |
32350 | ····PersistenceManager pm; |
32351 | ····[SetUp] |
32352 | ····public void Setup() |
32353 | ····{ |
32354 | ········pm = PmFactory.NewPersistenceManager(); |
32355 | ········ownVar = new CmpDirnOwnpabsOthpabsTblGuidLeftDerived(); |
32356 | ········otherVar = new CmpDirnOwnpabsOthpabsTblGuidRightDerived(); |
32357 | ····} |
32358 | ····[TearDown] |
32359 | ····public void TearDown() |
32360 | ····{ |
32361 | ········try |
32362 | ········{ |
32363 | ············pm.UnloadCache(); |
32364 | ············var l = pm.Objects<CmpDirnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32365 | ············pm.Delete(l); |
32366 | ············pm.Save(); |
32367 | ············pm.UnloadCache(); |
32368 | ············decimal count; |
32369 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32370 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32371 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32372 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32373 | ········} |
32374 | ········catch (Exception) |
32375 | ········{ |
32376 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32377 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32378 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32379 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32380 | ········} |
32381 | ····} |
32382 | ····[Test] |
32383 | ····public void TestSaveReload() |
32384 | ····{ |
32385 | ········CreateObjects(); |
32386 | ········QueryOwn(); |
32387 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32388 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32389 | ····} |
32390 | ····[Test] |
32391 | ····public void TestSaveReloadNull() |
32392 | ····{ |
32393 | ········CreateObjects(); |
32394 | ········QueryOwn(); |
32395 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32396 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32397 | ········ownVar.RelField = new List<CmpDirnOwnpabsOthpabsTblGuidRightBase>(); |
32398 | ········pm.Save(); |
32399 | ········pm.UnloadCache(); |
32400 | ········QueryOwn(); |
32401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32402 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32403 | ····} |
32404 | ····[Test] |
32405 | ····public void TestSaveReloadRemove() |
32406 | ····{ |
32407 | ········CreateObjects(); |
32408 | ········QueryOwn(); |
32409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32410 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32411 | ········ownVar.RemoveRelatedObject(); |
32412 | ········pm.Save(); |
32413 | ········pm.UnloadCache(); |
32414 | ········QueryOwn(); |
32415 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32416 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32417 | ····} |
32418 | ····void CreateObjects() |
32419 | ····{ |
32420 | ········pm.MakePersistent(ownVar); |
32421 | ········ownVar.AssignRelation(otherVar); |
32422 | ········pm.Save(); |
32423 | ········pm.UnloadCache(); |
32424 | ····} |
32425 | ····void QueryOwn() |
32426 | ····{ |
32427 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidLeftBase>(pm); |
32428 | ········ownVar = q.ExecuteSingle(); |
32429 | ····} |
32430 | ····void QueryOther() |
32431 | ····{ |
32432 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidRightBase>(pm); |
32433 | ········otherVar = q.ExecuteSingle(); |
32434 | ····} |
32435 | } |
32436 | |
32437 | |
32438 | [TestFixture] |
32439 | public class TestCmpBin1OwnpabsOthpabsTblGuid : NDOTest |
32440 | { |
32441 | ····CmpBin1OwnpabsOthpabsTblGuidLeftBase ownVar; |
32442 | ····CmpBin1OwnpabsOthpabsTblGuidRightBase otherVar; |
32443 | ····PersistenceManager pm; |
32444 | ····[SetUp] |
32445 | ····public void Setup() |
32446 | ····{ |
32447 | ········pm = PmFactory.NewPersistenceManager(); |
32448 | ········ownVar = new CmpBin1OwnpabsOthpabsTblGuidLeftDerived(); |
32449 | ········otherVar = new CmpBin1OwnpabsOthpabsTblGuidRightDerived(); |
32450 | ····} |
32451 | ····[TearDown] |
32452 | ····public void TearDown() |
32453 | ····{ |
32454 | ········try |
32455 | ········{ |
32456 | ············pm.UnloadCache(); |
32457 | ············var l = pm.Objects<CmpBin1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32458 | ············pm.Delete(l); |
32459 | ············pm.Save(); |
32460 | ············pm.UnloadCache(); |
32461 | ············decimal count; |
32462 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32463 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32464 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32465 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32466 | ········} |
32467 | ········catch (Exception) |
32468 | ········{ |
32469 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32470 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32471 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32472 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32473 | ········} |
32474 | ····} |
32475 | ····[Test] |
32476 | ····public void TestSaveReload() |
32477 | ····{ |
32478 | ········CreateObjects(); |
32479 | ········QueryOwn(); |
32480 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32481 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32482 | ····} |
32483 | ····[Test] |
32484 | ····public void TestSaveReloadNull() |
32485 | ····{ |
32486 | ········CreateObjects(); |
32487 | ········QueryOwn(); |
32488 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32489 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32490 | ········ownVar.RelField = new List<CmpBin1OwnpabsOthpabsTblGuidRightBase>(); |
32491 | ········pm.Save(); |
32492 | ········pm.UnloadCache(); |
32493 | ········QueryOwn(); |
32494 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32495 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32496 | ····} |
32497 | ····[Test] |
32498 | ····public void TestSaveReloadRemove() |
32499 | ····{ |
32500 | ········CreateObjects(); |
32501 | ········QueryOwn(); |
32502 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32503 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32504 | ········ownVar.RemoveRelatedObject(); |
32505 | ········pm.Save(); |
32506 | ········pm.UnloadCache(); |
32507 | ········QueryOwn(); |
32508 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32509 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32510 | ····} |
32511 | ····[Test] |
32512 | ····public void TestChangeKeyHolderRight() |
32513 | ····{ |
32514 | ········CreateObjects(); |
32515 | ········QueryOther(); |
32516 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32517 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32518 | ········int x = otherVar.RelField.Dummy; |
32519 | ········otherVar.Dummy = 4711; |
32520 | ········pm.Save(); |
32521 | ········pm.UnloadCache(); |
32522 | ········QueryOther(); |
32523 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32524 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32525 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32526 | ····} |
32527 | ····[Test] |
32528 | ····public void TestChangeKeyHolderRightNoTouch() |
32529 | ····{ |
32530 | ········CreateObjects(); |
32531 | ········QueryOther(); |
32532 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32533 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32534 | ········otherVar.Dummy = 4711; |
32535 | ········pm.Save(); |
32536 | ········pm.UnloadCache(); |
32537 | ········QueryOther(); |
32538 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32539 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32540 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32541 | ····} |
32542 | ····[Test] |
32543 | ····public void TestRelationHash() |
32544 | ····{ |
32545 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidLeftBase)); |
32546 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32547 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidRightBase)); |
32548 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32549 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32550 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32551 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidLeftDerived)); |
32552 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32553 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32554 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32555 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidRightDerived)); |
32556 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32557 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32558 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32559 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32560 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32561 | ····} |
32562 | ····void CreateObjects() |
32563 | ····{ |
32564 | ········pm.MakePersistent(ownVar); |
32565 | ········ownVar.AssignRelation(otherVar); |
32566 | ········pm.Save(); |
32567 | ········pm.UnloadCache(); |
32568 | ····} |
32569 | ····void QueryOwn() |
32570 | ····{ |
32571 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidLeftBase>(pm); |
32572 | ········ownVar = q.ExecuteSingle(); |
32573 | ····} |
32574 | ····void QueryOther() |
32575 | ····{ |
32576 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidRightBase>(pm); |
32577 | ········otherVar = q.ExecuteSingle(); |
32578 | ····} |
32579 | } |
32580 | |
32581 | |
32582 | [TestFixture] |
32583 | public class TestCmpBi1nOwnpabsOthpabsTblGuid : NDOTest |
32584 | { |
32585 | ····CmpBi1nOwnpabsOthpabsTblGuidLeftBase ownVar; |
32586 | ····CmpBi1nOwnpabsOthpabsTblGuidRightBase otherVar; |
32587 | ····PersistenceManager pm; |
32588 | ····[SetUp] |
32589 | ····public void Setup() |
32590 | ····{ |
32591 | ········pm = PmFactory.NewPersistenceManager(); |
32592 | ········ownVar = new CmpBi1nOwnpabsOthpabsTblGuidLeftDerived(); |
32593 | ········otherVar = new CmpBi1nOwnpabsOthpabsTblGuidRightDerived(); |
32594 | ····} |
32595 | ····[TearDown] |
32596 | ····public void TearDown() |
32597 | ····{ |
32598 | ········try |
32599 | ········{ |
32600 | ············pm.UnloadCache(); |
32601 | ············var l = pm.Objects<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32602 | ············pm.Delete(l); |
32603 | ············pm.Save(); |
32604 | ············pm.UnloadCache(); |
32605 | ············decimal count; |
32606 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32607 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32608 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32609 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32610 | ········} |
32611 | ········catch (Exception) |
32612 | ········{ |
32613 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32614 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32615 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32616 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32617 | ········} |
32618 | ····} |
32619 | ····[Test] |
32620 | ····public void TestSaveReload() |
32621 | ····{ |
32622 | ········CreateObjects(); |
32623 | ········QueryOwn(); |
32624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32625 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32626 | ····} |
32627 | ····[Test] |
32628 | ····public void TestSaveReloadNull() |
32629 | ····{ |
32630 | ········CreateObjects(); |
32631 | ········QueryOwn(); |
32632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32633 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32634 | ········ownVar.RelField = null; |
32635 | ········pm.Save(); |
32636 | ········pm.UnloadCache(); |
32637 | ········QueryOwn(); |
32638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32639 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32640 | ····} |
32641 | ····[Test] |
32642 | ····public void TestChangeKeyHolderLeft() |
32643 | ····{ |
32644 | ········CreateObjects(); |
32645 | ········QueryOwn(); |
32646 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32647 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32648 | ········int x = ownVar.RelField.Dummy; |
32649 | ········ownVar.Dummy = 4711; |
32650 | ········pm.Save(); |
32651 | ········pm.UnloadCache(); |
32652 | ········QueryOwn(); |
32653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32654 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32655 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32656 | ····} |
32657 | ····[Test] |
32658 | ····public void TestChangeKeyHolderLeftNoTouch() |
32659 | ····{ |
32660 | ········CreateObjects(); |
32661 | ········QueryOwn(); |
32662 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32663 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32664 | ········ownVar.Dummy = 4711; |
32665 | ········pm.Save(); |
32666 | ········pm.UnloadCache(); |
32667 | ········QueryOwn(); |
32668 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32669 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32670 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32671 | ····} |
32672 | ····[Test] |
32673 | ····public void TestRelationHash() |
32674 | ····{ |
32675 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidLeftBase)); |
32676 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32677 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidRightBase)); |
32678 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32679 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32680 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32681 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidLeftDerived)); |
32682 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32683 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32684 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32685 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidRightDerived)); |
32686 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32687 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32688 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32689 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32690 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32691 | ····} |
32692 | ····void CreateObjects() |
32693 | ····{ |
32694 | ········pm.MakePersistent(ownVar); |
32695 | ········ownVar.AssignRelation(otherVar); |
32696 | ········pm.Save(); |
32697 | ········pm.UnloadCache(); |
32698 | ····} |
32699 | ····void QueryOwn() |
32700 | ····{ |
32701 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>(pm); |
32702 | ········ownVar = q.ExecuteSingle(); |
32703 | ····} |
32704 | ····void QueryOther() |
32705 | ····{ |
32706 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidRightBase>(pm); |
32707 | ········otherVar = q.ExecuteSingle(); |
32708 | ····} |
32709 | } |
32710 | |
32711 | |
32712 | [TestFixture] |
32713 | public class TestCmpBinnOwnpabsOthpabsTblGuid : NDOTest |
32714 | { |
32715 | ····CmpBinnOwnpabsOthpabsTblGuidLeftBase ownVar; |
32716 | ····CmpBinnOwnpabsOthpabsTblGuidRightBase otherVar; |
32717 | ····PersistenceManager pm; |
32718 | ····[SetUp] |
32719 | ····public void Setup() |
32720 | ····{ |
32721 | ········pm = PmFactory.NewPersistenceManager(); |
32722 | ········ownVar = new CmpBinnOwnpabsOthpabsTblGuidLeftDerived(); |
32723 | ········otherVar = new CmpBinnOwnpabsOthpabsTblGuidRightDerived(); |
32724 | ····} |
32725 | ····[TearDown] |
32726 | ····public void TearDown() |
32727 | ····{ |
32728 | ········try |
32729 | ········{ |
32730 | ············pm.UnloadCache(); |
32731 | ············var l = pm.Objects<CmpBinnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32732 | ············pm.Delete(l); |
32733 | ············pm.Save(); |
32734 | ············pm.UnloadCache(); |
32735 | ············decimal count; |
32736 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32737 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32738 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32739 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32740 | ········} |
32741 | ········catch (Exception) |
32742 | ········{ |
32743 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32744 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32745 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32746 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32747 | ········} |
32748 | ····} |
32749 | ····[Test] |
32750 | ····public void TestSaveReload() |
32751 | ····{ |
32752 | ········CreateObjects(); |
32753 | ········QueryOwn(); |
32754 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32755 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32756 | ····} |
32757 | ····[Test] |
32758 | ····public void TestSaveReloadNull() |
32759 | ····{ |
32760 | ········CreateObjects(); |
32761 | ········QueryOwn(); |
32762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32763 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32764 | ········ownVar.RelField = new List<CmpBinnOwnpabsOthpabsTblGuidRightBase>(); |
32765 | ········pm.Save(); |
32766 | ········pm.UnloadCache(); |
32767 | ········QueryOwn(); |
32768 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32769 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32770 | ····} |
32771 | ····[Test] |
32772 | ····public void TestSaveReloadRemove() |
32773 | ····{ |
32774 | ········CreateObjects(); |
32775 | ········QueryOwn(); |
32776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32777 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32778 | ········ownVar.RemoveRelatedObject(); |
32779 | ········pm.Save(); |
32780 | ········pm.UnloadCache(); |
32781 | ········QueryOwn(); |
32782 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32783 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32784 | ····} |
32785 | ····[Test] |
32786 | ····public void TestRelationHash() |
32787 | ····{ |
32788 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidLeftBase)); |
32789 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32790 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidRightBase)); |
32791 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32792 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32793 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32794 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidLeftDerived)); |
32795 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32796 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32797 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32798 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidRightDerived)); |
32799 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32800 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32801 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32802 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32803 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32804 | ····} |
32805 | ····void CreateObjects() |
32806 | ····{ |
32807 | ········pm.MakePersistent(ownVar); |
32808 | ········ownVar.AssignRelation(otherVar); |
32809 | ········pm.Save(); |
32810 | ········pm.UnloadCache(); |
32811 | ····} |
32812 | ····void QueryOwn() |
32813 | ····{ |
32814 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidLeftBase>(pm); |
32815 | ········ownVar = q.ExecuteSingle(); |
32816 | ····} |
32817 | ····void QueryOther() |
32818 | ····{ |
32819 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidRightBase>(pm); |
32820 | ········otherVar = q.ExecuteSingle(); |
32821 | ····} |
32822 | } |
32823 | |
32824 | |
32825 | |
32826 | } |
32827 |
New Commit (36bb808)
1 | // |
2 | // Copyright (c) 2002-2016 Mirko Matytschak |
3 | // (www.netdataobjects.de) |
4 | // |
5 | // Author: Mirko Matytschak |
6 | // |
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
8 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation |
9 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the |
10 | // Software, and to permit persons to whom the Software is furnished to do so, subject to the following |
11 | // conditions: |
12 | |
13 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions |
14 | // of the Software. |
15 | // |
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED |
17 | // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
19 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. |
21 | |
22 | |
23 | using System; |
24 | using System.Linq; |
25 | using System.Reflection; |
26 | using System.Diagnostics; |
27 | using System.Collections; |
28 | using System.Collections.Generic; |
29 | using NDO; |
30 | using NDO.Mapping; |
31 | using NDO.Query; |
32 | using NUnit.Framework; |
33 | using RelationTestClasses; |
34 | using NdoUnitTests; |
35 | |
36 | namespace RelationUnitTests |
37 | { |
38 | |
39 | public class PmFactory |
40 | { |
41 | ····static PersistenceManager pm; |
42 | ····public static PersistenceManager NewPersistenceManager() |
43 | ····{ |
44 | ········if (pm == null) |
45 | ········{ |
46 | pm = new PersistenceManager( @"C:\Projekte\NDO5\UnitTestGenerator\UnitTests\bin\Debug\NDOMapping. xml") ; |
47 | ········} |
48 | ········else |
49 | ········{ |
50 | ············pm.UnloadCache(); |
51 | ········} |
52 | ········return pm; |
53 | ····} |
54 | } |
55 | |
56 | |
57 | [TestFixture] |
58 | public class TestAgrDir1NoTblAuto : NDOTest |
59 | { |
60 | ····AgrDir1NoTblAutoLeft ownVar; |
61 | ····AgrDir1NoTblAutoRight otherVar; |
62 | ····PersistenceManager pm; |
63 | ····[SetUp] |
64 | ····public void Setup() |
65 | ····{ |
66 | ········pm = PmFactory.NewPersistenceManager(); |
67 | ········ownVar = new AgrDir1NoTblAutoLeft(); |
68 | ········otherVar = new AgrDir1NoTblAutoRight(); |
69 | ····} |
70 | ····[TearDown] |
71 | ····public void TearDown() |
72 | ····{ |
73 | ········try |
74 | ········{ |
75 | ············pm.UnloadCache(); |
76 | ············var l = pm.Objects<AgrDir1NoTblAutoLeft>().ResultTable; |
77 | ············pm.Delete(l); |
78 | ············pm.Save(); |
79 | ············pm.UnloadCache(); |
80 | ············var m = pm.Objects<AgrDir1NoTblAutoRight>().ResultTable; |
81 | ············pm.Delete(m); |
82 | ············pm.Save(); |
83 | ············pm.UnloadCache(); |
84 | ············decimal count; |
85 | ············count = (decimal) new NDOQuery<AgrDir1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
86 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
87 | ············count = (decimal) new NDOQuery<AgrDir1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
88 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
89 | ········} |
90 | ········catch (Exception) |
91 | ········{ |
92 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
93 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
94 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
95 | ········} |
96 | ····} |
97 | ····[Test] |
98 | ····public void TestSaveReload() |
99 | ····{ |
100 | ········CreateObjects(); |
101 | ········QueryOwn(); |
102 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
104 | ····} |
105 | ····[Test] |
106 | ····public void TestSaveReloadNull() |
107 | ····{ |
108 | ········CreateObjects(); |
109 | ········QueryOwn(); |
110 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
111 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
112 | ········ownVar.RelField = null; |
113 | ········pm.Save(); |
114 | ········pm.UnloadCache(); |
115 | ········QueryOwn(); |
116 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
117 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
118 | ····} |
119 | ····[Test] |
120 | ····public void TestChangeKeyHolderLeft() |
121 | ····{ |
122 | ········CreateObjects(); |
123 | ········QueryOwn(); |
124 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
125 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
126 | ········int x = ownVar.RelField.Dummy; |
127 | ········ownVar.Dummy = 4711; |
128 | ········pm.Save(); |
129 | ········pm.UnloadCache(); |
130 | ········QueryOwn(); |
131 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
132 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
133 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
134 | ····} |
135 | ····[Test] |
136 | ····public void TestChangeKeyHolderLeftNoTouch() |
137 | ····{ |
138 | ········CreateObjects(); |
139 | ········QueryOwn(); |
140 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
141 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
142 | ········ownVar.Dummy = 4711; |
143 | ········pm.Save(); |
144 | ········pm.UnloadCache(); |
145 | ········QueryOwn(); |
146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
147 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
148 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
149 | ····} |
150 | ····[Test] |
151 | ····public void TestUpdateOrder() |
152 | ····{ |
153 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
154 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
155 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1NoTblAutoLeft)})) |
156 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1NoTblAutoRight)})), "Wrong order #1"); |
157 | ········Debug.WriteLine("AgrDir1NoTblAutoLeft"); |
158 | ····} |
159 | ····void CreateObjects() |
160 | ····{ |
161 | ········pm.MakePersistent(ownVar); |
162 | ········pm.MakePersistent(otherVar); |
163 | ········ownVar.AssignRelation(otherVar); |
164 | ········pm.Save(); |
165 | ········pm.UnloadCache(); |
166 | ····} |
167 | ····void QueryOwn() |
168 | ····{ |
169 | ········var q = new NDOQuery<AgrDir1NoTblAutoLeft>(pm); |
170 | ········ownVar = q.ExecuteSingle(); |
171 | ····} |
172 | ····void QueryOther() |
173 | ····{ |
174 | ········var q = new NDOQuery<AgrDir1NoTblAutoRight>(pm); |
175 | ········otherVar = q.ExecuteSingle(); |
176 | ····} |
177 | } |
178 | |
179 | |
180 | [TestFixture] |
181 | public class TestAgrDir1TblAuto : NDOTest |
182 | { |
183 | ····AgrDir1TblAutoLeft ownVar; |
184 | ····AgrDir1TblAutoRight otherVar; |
185 | ····PersistenceManager pm; |
186 | ····[SetUp] |
187 | ····public void Setup() |
188 | ····{ |
189 | ········pm = PmFactory.NewPersistenceManager(); |
190 | ········ownVar = new AgrDir1TblAutoLeft(); |
191 | ········otherVar = new AgrDir1TblAutoRight(); |
192 | ····} |
193 | ····[TearDown] |
194 | ····public void TearDown() |
195 | ····{ |
196 | ········try |
197 | ········{ |
198 | ············pm.UnloadCache(); |
199 | ············var l = pm.Objects<AgrDir1TblAutoLeft>().ResultTable; |
200 | ············pm.Delete(l); |
201 | ············pm.Save(); |
202 | ············pm.UnloadCache(); |
203 | ············var m = pm.Objects<AgrDir1TblAutoRight>().ResultTable; |
204 | ············pm.Delete(m); |
205 | ············pm.Save(); |
206 | ············pm.UnloadCache(); |
207 | ············decimal count; |
208 | ············count = (decimal) new NDOQuery<AgrDir1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
209 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
210 | ············count = (decimal) new NDOQuery<AgrDir1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
211 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
212 | ········} |
213 | ········catch (Exception) |
214 | ········{ |
215 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
216 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
218 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
219 | ········} |
220 | ····} |
221 | ····[Test] |
222 | ····public void TestSaveReload() |
223 | ····{ |
224 | ········CreateObjects(); |
225 | ········QueryOwn(); |
226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
227 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
228 | ····} |
229 | ····[Test] |
230 | ····public void TestSaveReloadNull() |
231 | ····{ |
232 | ········CreateObjects(); |
233 | ········QueryOwn(); |
234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
235 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
236 | ········ownVar.RelField = null; |
237 | ········pm.Save(); |
238 | ········pm.UnloadCache(); |
239 | ········QueryOwn(); |
240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
241 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
242 | ····} |
243 | ····[Test] |
244 | ····public void TestChangeKeyHolderLeft() |
245 | ····{ |
246 | ········CreateObjects(); |
247 | ········QueryOwn(); |
248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
249 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
250 | ········int x = ownVar.RelField.Dummy; |
251 | ········ownVar.Dummy = 4711; |
252 | ········pm.Save(); |
253 | ········pm.UnloadCache(); |
254 | ········QueryOwn(); |
255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
256 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
257 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
258 | ····} |
259 | ····[Test] |
260 | ····public void TestChangeKeyHolderLeftNoTouch() |
261 | ····{ |
262 | ········CreateObjects(); |
263 | ········QueryOwn(); |
264 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
265 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
266 | ········ownVar.Dummy = 4711; |
267 | ········pm.Save(); |
268 | ········pm.UnloadCache(); |
269 | ········QueryOwn(); |
270 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
271 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
272 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
273 | ····} |
274 | ····void CreateObjects() |
275 | ····{ |
276 | ········pm.MakePersistent(ownVar); |
277 | ········pm.MakePersistent(otherVar); |
278 | ········ownVar.AssignRelation(otherVar); |
279 | ········pm.Save(); |
280 | ········pm.UnloadCache(); |
281 | ····} |
282 | ····void QueryOwn() |
283 | ····{ |
284 | ········var q = new NDOQuery<AgrDir1TblAutoLeft>(pm); |
285 | ········ownVar = q.ExecuteSingle(); |
286 | ····} |
287 | ····void QueryOther() |
288 | ····{ |
289 | ········var q = new NDOQuery<AgrDir1TblAutoRight>(pm); |
290 | ········otherVar = q.ExecuteSingle(); |
291 | ····} |
292 | } |
293 | |
294 | |
295 | [TestFixture] |
296 | public class TestAgrBi11NoTblAuto : NDOTest |
297 | { |
298 | ····AgrBi11NoTblAutoLeft ownVar; |
299 | ····AgrBi11NoTblAutoRight otherVar; |
300 | ····PersistenceManager pm; |
301 | ····[SetUp] |
302 | ····public void Setup() |
303 | ····{ |
304 | ········pm = PmFactory.NewPersistenceManager(); |
305 | ········ownVar = new AgrBi11NoTblAutoLeft(); |
306 | ········otherVar = new AgrBi11NoTblAutoRight(); |
307 | ····} |
308 | ····[TearDown] |
309 | ····public void TearDown() |
310 | ····{ |
311 | ········try |
312 | ········{ |
313 | ············pm.UnloadCache(); |
314 | ············var l = pm.Objects<AgrBi11NoTblAutoLeft>().ResultTable; |
315 | ············pm.Delete(l); |
316 | ············pm.Save(); |
317 | ············pm.UnloadCache(); |
318 | ············var m = pm.Objects<AgrBi11NoTblAutoRight>().ResultTable; |
319 | ············pm.Delete(m); |
320 | ············pm.Save(); |
321 | ············pm.UnloadCache(); |
322 | ············decimal count; |
323 | ············count = (decimal) new NDOQuery<AgrBi11NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
324 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
325 | ············count = (decimal) new NDOQuery<AgrBi11NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
326 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
327 | ········} |
328 | ········catch (Exception) |
329 | ········{ |
330 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
331 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
332 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
333 | ········} |
334 | ····} |
335 | ····[Test] |
336 | ····public void TestSaveReload() |
337 | ····{ |
338 | ········CreateObjects(); |
339 | ········QueryOwn(); |
340 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
341 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
342 | ····} |
343 | ····[Test] |
344 | ····public void TestSaveReloadNull() |
345 | ····{ |
346 | ········CreateObjects(); |
347 | ········QueryOwn(); |
348 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
349 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
350 | ········ownVar.RelField = null; |
351 | ········pm.Save(); |
352 | ········pm.UnloadCache(); |
353 | ········QueryOwn(); |
354 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
355 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
356 | ····} |
357 | ····[Test] |
358 | ····public void TestChangeKeyHolderLeft() |
359 | ····{ |
360 | ········CreateObjects(); |
361 | ········QueryOwn(); |
362 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
363 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
364 | ········int x = ownVar.RelField.Dummy; |
365 | ········ownVar.Dummy = 4711; |
366 | ········pm.Save(); |
367 | ········pm.UnloadCache(); |
368 | ········QueryOwn(); |
369 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
370 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
371 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
372 | ····} |
373 | ····[Test] |
374 | ····public void TestChangeKeyHolderRight() |
375 | ····{ |
376 | ········CreateObjects(); |
377 | ········QueryOther(); |
378 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
379 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
380 | ········int x = otherVar.RelField.Dummy; |
381 | ········otherVar.Dummy = 4711; |
382 | ········pm.Save(); |
383 | ········pm.UnloadCache(); |
384 | ········QueryOther(); |
385 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
386 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
387 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
388 | ····} |
389 | ····[Test] |
390 | ····public void TestChangeKeyHolderLeftNoTouch() |
391 | ····{ |
392 | ········CreateObjects(); |
393 | ········QueryOwn(); |
394 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
395 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
396 | ········ownVar.Dummy = 4711; |
397 | ········pm.Save(); |
398 | ········pm.UnloadCache(); |
399 | ········QueryOwn(); |
400 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
401 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
402 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
403 | ····} |
404 | ····[Test] |
405 | ····public void TestChangeKeyHolderRightNoTouch() |
406 | ····{ |
407 | ········CreateObjects(); |
408 | ········QueryOther(); |
409 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
410 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
411 | ········otherVar.Dummy = 4711; |
412 | ········pm.Save(); |
413 | ········pm.UnloadCache(); |
414 | ········QueryOther(); |
415 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
416 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
417 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
418 | ····} |
419 | ····[Test] |
420 | ····public void TestRelationHash() |
421 | ····{ |
422 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblAutoLeft)); |
423 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
424 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblAutoRight)); |
425 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
426 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
427 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
428 | ····} |
429 | ····void CreateObjects() |
430 | ····{ |
431 | ········pm.MakePersistent(ownVar); |
432 | ········pm.MakePersistent(otherVar); |
433 | ········ownVar.AssignRelation(otherVar); |
434 | ········pm.Save(); |
435 | ········pm.UnloadCache(); |
436 | ····} |
437 | ····void QueryOwn() |
438 | ····{ |
439 | ········var q = new NDOQuery<AgrBi11NoTblAutoLeft>(pm); |
440 | ········ownVar = q.ExecuteSingle(); |
441 | ····} |
442 | ····void QueryOther() |
443 | ····{ |
444 | ········var q = new NDOQuery<AgrBi11NoTblAutoRight>(pm); |
445 | ········otherVar = q.ExecuteSingle(); |
446 | ····} |
447 | } |
448 | |
449 | |
450 | [TestFixture] |
451 | public class TestAgrBi11TblAuto : NDOTest |
452 | { |
453 | ····AgrBi11TblAutoLeft ownVar; |
454 | ····AgrBi11TblAutoRight otherVar; |
455 | ····PersistenceManager pm; |
456 | ····[SetUp] |
457 | ····public void Setup() |
458 | ····{ |
459 | ········pm = PmFactory.NewPersistenceManager(); |
460 | ········ownVar = new AgrBi11TblAutoLeft(); |
461 | ········otherVar = new AgrBi11TblAutoRight(); |
462 | ····} |
463 | ····[TearDown] |
464 | ····public void TearDown() |
465 | ····{ |
466 | ········try |
467 | ········{ |
468 | ············pm.UnloadCache(); |
469 | ············var l = pm.Objects<AgrBi11TblAutoLeft>().ResultTable; |
470 | ············pm.Delete(l); |
471 | ············pm.Save(); |
472 | ············pm.UnloadCache(); |
473 | ············var m = pm.Objects<AgrBi11TblAutoRight>().ResultTable; |
474 | ············pm.Delete(m); |
475 | ············pm.Save(); |
476 | ············pm.UnloadCache(); |
477 | ············decimal count; |
478 | ············count = (decimal) new NDOQuery<AgrBi11TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
479 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
480 | ············count = (decimal) new NDOQuery<AgrBi11TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
481 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
482 | ········} |
483 | ········catch (Exception) |
484 | ········{ |
485 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
486 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
487 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
488 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
489 | ········} |
490 | ····} |
491 | ····[Test] |
492 | ····public void TestSaveReload() |
493 | ····{ |
494 | ········CreateObjects(); |
495 | ········QueryOwn(); |
496 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
497 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
498 | ····} |
499 | ····[Test] |
500 | ····public void TestSaveReloadNull() |
501 | ····{ |
502 | ········CreateObjects(); |
503 | ········QueryOwn(); |
504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
505 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
506 | ········ownVar.RelField = null; |
507 | ········pm.Save(); |
508 | ········pm.UnloadCache(); |
509 | ········QueryOwn(); |
510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
511 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
512 | ····} |
513 | ····[Test] |
514 | ····public void TestChangeKeyHolderLeft() |
515 | ····{ |
516 | ········CreateObjects(); |
517 | ········QueryOwn(); |
518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
519 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
520 | ········int x = ownVar.RelField.Dummy; |
521 | ········ownVar.Dummy = 4711; |
522 | ········pm.Save(); |
523 | ········pm.UnloadCache(); |
524 | ········QueryOwn(); |
525 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
526 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
527 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
528 | ····} |
529 | ····[Test] |
530 | ····public void TestChangeKeyHolderRight() |
531 | ····{ |
532 | ········CreateObjects(); |
533 | ········QueryOther(); |
534 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
535 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
536 | ········int x = otherVar.RelField.Dummy; |
537 | ········otherVar.Dummy = 4711; |
538 | ········pm.Save(); |
539 | ········pm.UnloadCache(); |
540 | ········QueryOther(); |
541 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
542 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
543 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
544 | ····} |
545 | ····[Test] |
546 | ····public void TestChangeKeyHolderLeftNoTouch() |
547 | ····{ |
548 | ········CreateObjects(); |
549 | ········QueryOwn(); |
550 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
551 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
552 | ········ownVar.Dummy = 4711; |
553 | ········pm.Save(); |
554 | ········pm.UnloadCache(); |
555 | ········QueryOwn(); |
556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
557 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
558 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
559 | ····} |
560 | ····[Test] |
561 | ····public void TestChangeKeyHolderRightNoTouch() |
562 | ····{ |
563 | ········CreateObjects(); |
564 | ········QueryOther(); |
565 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
566 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
567 | ········otherVar.Dummy = 4711; |
568 | ········pm.Save(); |
569 | ········pm.UnloadCache(); |
570 | ········QueryOther(); |
571 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
572 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
573 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
574 | ····} |
575 | ····[Test] |
576 | ····public void TestRelationHash() |
577 | ····{ |
578 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11TblAutoLeft)); |
579 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
580 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11TblAutoRight)); |
581 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
582 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
583 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
584 | ····} |
585 | ····void CreateObjects() |
586 | ····{ |
587 | ········pm.MakePersistent(ownVar); |
588 | ········pm.MakePersistent(otherVar); |
589 | ········ownVar.AssignRelation(otherVar); |
590 | ········pm.Save(); |
591 | ········pm.UnloadCache(); |
592 | ····} |
593 | ····void QueryOwn() |
594 | ····{ |
595 | ········var q = new NDOQuery<AgrBi11TblAutoLeft>(pm); |
596 | ········ownVar = q.ExecuteSingle(); |
597 | ····} |
598 | ····void QueryOther() |
599 | ····{ |
600 | ········var q = new NDOQuery<AgrBi11TblAutoRight>(pm); |
601 | ········otherVar = q.ExecuteSingle(); |
602 | ····} |
603 | } |
604 | |
605 | |
606 | [TestFixture] |
607 | public class TestAgrDirnNoTblAuto : NDOTest |
608 | { |
609 | ····AgrDirnNoTblAutoLeft ownVar; |
610 | ····AgrDirnNoTblAutoRight otherVar; |
611 | ····PersistenceManager pm; |
612 | ····[SetUp] |
613 | ····public void Setup() |
614 | ····{ |
615 | ········pm = PmFactory.NewPersistenceManager(); |
616 | ········ownVar = new AgrDirnNoTblAutoLeft(); |
617 | ········otherVar = new AgrDirnNoTblAutoRight(); |
618 | ····} |
619 | ····[TearDown] |
620 | ····public void TearDown() |
621 | ····{ |
622 | ········try |
623 | ········{ |
624 | ············pm.UnloadCache(); |
625 | ············var l = pm.Objects<AgrDirnNoTblAutoLeft>().ResultTable; |
626 | ············pm.Delete(l); |
627 | ············pm.Save(); |
628 | ············pm.UnloadCache(); |
629 | ············var m = pm.Objects<AgrDirnNoTblAutoRight>().ResultTable; |
630 | ············pm.Delete(m); |
631 | ············pm.Save(); |
632 | ············pm.UnloadCache(); |
633 | ············decimal count; |
634 | ············count = (decimal) new NDOQuery<AgrDirnNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
636 | ············count = (decimal) new NDOQuery<AgrDirnNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
637 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
638 | ········} |
639 | ········catch (Exception) |
640 | ········{ |
641 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
642 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
644 | ········} |
645 | ····} |
646 | ····[Test] |
647 | ····public void TestSaveReload() |
648 | ····{ |
649 | ········CreateObjects(); |
650 | ········QueryOwn(); |
651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
652 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
653 | ····} |
654 | ····[Test] |
655 | ····public void TestSaveReloadNull() |
656 | ····{ |
657 | ········CreateObjects(); |
658 | ········QueryOwn(); |
659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
660 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
661 | ········ownVar.RelField = new List<AgrDirnNoTblAutoRight>(); |
662 | ········pm.Save(); |
663 | ········pm.UnloadCache(); |
664 | ········QueryOwn(); |
665 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
666 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
667 | ····} |
668 | ····[Test] |
669 | ····public void TestSaveReloadRemove() |
670 | ····{ |
671 | ········CreateObjects(); |
672 | ········QueryOwn(); |
673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
674 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
675 | ········ownVar.RemoveRelatedObject(); |
676 | ········pm.Save(); |
677 | ········pm.UnloadCache(); |
678 | ········QueryOwn(); |
679 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
680 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
681 | ····} |
682 | ····[Test] |
683 | ····public void TestUpdateOrder() |
684 | ····{ |
685 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
686 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
687 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnNoTblAutoLeft)})) |
688 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnNoTblAutoRight)})), "Wrong order #1"); |
689 | ········Debug.WriteLine("AgrDirnNoTblAutoLeft"); |
690 | ····} |
691 | ····void CreateObjects() |
692 | ····{ |
693 | ········pm.MakePersistent(ownVar); |
694 | ········pm.MakePersistent(otherVar); |
695 | ········ownVar.AssignRelation(otherVar); |
696 | ········pm.Save(); |
697 | ········pm.UnloadCache(); |
698 | ····} |
699 | ····void QueryOwn() |
700 | ····{ |
701 | ········var q = new NDOQuery<AgrDirnNoTblAutoLeft>(pm); |
702 | ········ownVar = q.ExecuteSingle(); |
703 | ····} |
704 | ····void QueryOther() |
705 | ····{ |
706 | ········var q = new NDOQuery<AgrDirnNoTblAutoRight>(pm); |
707 | ········otherVar = q.ExecuteSingle(); |
708 | ····} |
709 | } |
710 | |
711 | |
712 | [TestFixture] |
713 | public class TestAgrDirnTblAuto : NDOTest |
714 | { |
715 | ····AgrDirnTblAutoLeft ownVar; |
716 | ····AgrDirnTblAutoRight otherVar; |
717 | ····PersistenceManager pm; |
718 | ····[SetUp] |
719 | ····public void Setup() |
720 | ····{ |
721 | ········pm = PmFactory.NewPersistenceManager(); |
722 | ········ownVar = new AgrDirnTblAutoLeft(); |
723 | ········otherVar = new AgrDirnTblAutoRight(); |
724 | ····} |
725 | ····[TearDown] |
726 | ····public void TearDown() |
727 | ····{ |
728 | ········try |
729 | ········{ |
730 | ············pm.UnloadCache(); |
731 | ············var l = pm.Objects<AgrDirnTblAutoLeft>().ResultTable; |
732 | ············pm.Delete(l); |
733 | ············pm.Save(); |
734 | ············pm.UnloadCache(); |
735 | ············var m = pm.Objects<AgrDirnTblAutoRight>().ResultTable; |
736 | ············pm.Delete(m); |
737 | ············pm.Save(); |
738 | ············pm.UnloadCache(); |
739 | ············decimal count; |
740 | ············count = (decimal) new NDOQuery<AgrDirnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
741 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
742 | ············count = (decimal) new NDOQuery<AgrDirnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
743 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
744 | ········} |
745 | ········catch (Exception) |
746 | ········{ |
747 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
748 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
749 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
750 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
751 | ········} |
752 | ····} |
753 | ····[Test] |
754 | ····public void TestSaveReload() |
755 | ····{ |
756 | ········CreateObjects(); |
757 | ········QueryOwn(); |
758 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
759 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
760 | ····} |
761 | ····[Test] |
762 | ····public void TestSaveReloadNull() |
763 | ····{ |
764 | ········CreateObjects(); |
765 | ········QueryOwn(); |
766 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
767 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
768 | ········ownVar.RelField = new List<AgrDirnTblAutoRight>(); |
769 | ········pm.Save(); |
770 | ········pm.UnloadCache(); |
771 | ········QueryOwn(); |
772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
773 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
774 | ····} |
775 | ····[Test] |
776 | ····public void TestSaveReloadRemove() |
777 | ····{ |
778 | ········CreateObjects(); |
779 | ········QueryOwn(); |
780 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
781 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
782 | ········ownVar.RemoveRelatedObject(); |
783 | ········pm.Save(); |
784 | ········pm.UnloadCache(); |
785 | ········QueryOwn(); |
786 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
787 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
788 | ····} |
789 | ····void CreateObjects() |
790 | ····{ |
791 | ········pm.MakePersistent(ownVar); |
792 | ········pm.MakePersistent(otherVar); |
793 | ········ownVar.AssignRelation(otherVar); |
794 | ········pm.Save(); |
795 | ········pm.UnloadCache(); |
796 | ····} |
797 | ····void QueryOwn() |
798 | ····{ |
799 | ········var q = new NDOQuery<AgrDirnTblAutoLeft>(pm); |
800 | ········ownVar = q.ExecuteSingle(); |
801 | ····} |
802 | ····void QueryOther() |
803 | ····{ |
804 | ········var q = new NDOQuery<AgrDirnTblAutoRight>(pm); |
805 | ········otherVar = q.ExecuteSingle(); |
806 | ····} |
807 | } |
808 | |
809 | |
810 | [TestFixture] |
811 | public class TestAgrBin1NoTblAuto : NDOTest |
812 | { |
813 | ····AgrBin1NoTblAutoLeft ownVar; |
814 | ····AgrBin1NoTblAutoRight otherVar; |
815 | ····PersistenceManager pm; |
816 | ····[SetUp] |
817 | ····public void Setup() |
818 | ····{ |
819 | ········pm = PmFactory.NewPersistenceManager(); |
820 | ········ownVar = new AgrBin1NoTblAutoLeft(); |
821 | ········otherVar = new AgrBin1NoTblAutoRight(); |
822 | ····} |
823 | ····[TearDown] |
824 | ····public void TearDown() |
825 | ····{ |
826 | ········try |
827 | ········{ |
828 | ············pm.UnloadCache(); |
829 | ············var l = pm.Objects<AgrBin1NoTblAutoLeft>().ResultTable; |
830 | ············pm.Delete(l); |
831 | ············pm.Save(); |
832 | ············pm.UnloadCache(); |
833 | ············var m = pm.Objects<AgrBin1NoTblAutoRight>().ResultTable; |
834 | ············pm.Delete(m); |
835 | ············pm.Save(); |
836 | ············pm.UnloadCache(); |
837 | ············decimal count; |
838 | ············count = (decimal) new NDOQuery<AgrBin1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
839 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
840 | ············count = (decimal) new NDOQuery<AgrBin1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
841 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
842 | ········} |
843 | ········catch (Exception) |
844 | ········{ |
845 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
846 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
847 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
848 | ········} |
849 | ····} |
850 | ····[Test] |
851 | ····public void TestSaveReload() |
852 | ····{ |
853 | ········CreateObjects(); |
854 | ········QueryOwn(); |
855 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
856 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
857 | ····} |
858 | ····[Test] |
859 | ····public void TestSaveReloadNull() |
860 | ····{ |
861 | ········CreateObjects(); |
862 | ········QueryOwn(); |
863 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
864 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
865 | ········ownVar.RelField = new List<AgrBin1NoTblAutoRight>(); |
866 | ········pm.Save(); |
867 | ········pm.UnloadCache(); |
868 | ········QueryOwn(); |
869 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
870 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
871 | ····} |
872 | ····[Test] |
873 | ····public void TestSaveReloadRemove() |
874 | ····{ |
875 | ········CreateObjects(); |
876 | ········QueryOwn(); |
877 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
878 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
879 | ········ownVar.RemoveRelatedObject(); |
880 | ········pm.Save(); |
881 | ········pm.UnloadCache(); |
882 | ········QueryOwn(); |
883 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
884 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
885 | ····} |
886 | ····[Test] |
887 | ····public void TestChangeKeyHolderRight() |
888 | ····{ |
889 | ········CreateObjects(); |
890 | ········QueryOther(); |
891 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
892 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
893 | ········int x = otherVar.RelField.Dummy; |
894 | ········otherVar.Dummy = 4711; |
895 | ········pm.Save(); |
896 | ········pm.UnloadCache(); |
897 | ········QueryOther(); |
898 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
899 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
900 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
901 | ····} |
902 | ····[Test] |
903 | ····public void TestChangeKeyHolderRightNoTouch() |
904 | ····{ |
905 | ········CreateObjects(); |
906 | ········QueryOther(); |
907 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
908 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
909 | ········otherVar.Dummy = 4711; |
910 | ········pm.Save(); |
911 | ········pm.UnloadCache(); |
912 | ········QueryOther(); |
913 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
914 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
915 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
916 | ····} |
917 | ····[Test] |
918 | ····public void TestUpdateOrder() |
919 | ····{ |
920 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
921 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
922 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1NoTblAutoLeft)})) |
923 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1NoTblAutoRight)})), "Wrong order #1"); |
924 | ········Debug.WriteLine("AgrBin1NoTblAutoLeft"); |
925 | ····} |
926 | ····[Test] |
927 | ····public void TestRelationHash() |
928 | ····{ |
929 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblAutoLeft)); |
930 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
931 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblAutoRight)); |
932 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
933 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
934 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
935 | ····} |
936 | ····void CreateObjects() |
937 | ····{ |
938 | ········pm.MakePersistent(ownVar); |
939 | ········pm.MakePersistent(otherVar); |
940 | ········ownVar.AssignRelation(otherVar); |
941 | ········pm.Save(); |
942 | ········pm.UnloadCache(); |
943 | ····} |
944 | ····void QueryOwn() |
945 | ····{ |
946 | ········var q = new NDOQuery<AgrBin1NoTblAutoLeft>(pm); |
947 | ········ownVar = q.ExecuteSingle(); |
948 | ····} |
949 | ····void QueryOther() |
950 | ····{ |
951 | ········var q = new NDOQuery<AgrBin1NoTblAutoRight>(pm); |
952 | ········otherVar = q.ExecuteSingle(); |
953 | ····} |
954 | } |
955 | |
956 | |
957 | [TestFixture] |
958 | public class TestAgrBin1TblAuto : NDOTest |
959 | { |
960 | ····AgrBin1TblAutoLeft ownVar; |
961 | ····AgrBin1TblAutoRight otherVar; |
962 | ····PersistenceManager pm; |
963 | ····[SetUp] |
964 | ····public void Setup() |
965 | ····{ |
966 | ········pm = PmFactory.NewPersistenceManager(); |
967 | ········ownVar = new AgrBin1TblAutoLeft(); |
968 | ········otherVar = new AgrBin1TblAutoRight(); |
969 | ····} |
970 | ····[TearDown] |
971 | ····public void TearDown() |
972 | ····{ |
973 | ········try |
974 | ········{ |
975 | ············pm.UnloadCache(); |
976 | ············var l = pm.Objects<AgrBin1TblAutoLeft>().ResultTable; |
977 | ············pm.Delete(l); |
978 | ············pm.Save(); |
979 | ············pm.UnloadCache(); |
980 | ············var m = pm.Objects<AgrBin1TblAutoRight>().ResultTable; |
981 | ············pm.Delete(m); |
982 | ············pm.Save(); |
983 | ············pm.UnloadCache(); |
984 | ············decimal count; |
985 | ············count = (decimal) new NDOQuery<AgrBin1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
986 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
987 | ············count = (decimal) new NDOQuery<AgrBin1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
988 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
989 | ········} |
990 | ········catch (Exception) |
991 | ········{ |
992 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
993 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
994 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
995 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
996 | ········} |
997 | ····} |
998 | ····[Test] |
999 | ····public void TestSaveReload() |
1000 | ····{ |
1001 | ········CreateObjects(); |
1002 | ········QueryOwn(); |
1003 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1004 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1005 | ····} |
1006 | ····[Test] |
1007 | ····public void TestSaveReloadNull() |
1008 | ····{ |
1009 | ········CreateObjects(); |
1010 | ········QueryOwn(); |
1011 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1012 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1013 | ········ownVar.RelField = new List<AgrBin1TblAutoRight>(); |
1014 | ········pm.Save(); |
1015 | ········pm.UnloadCache(); |
1016 | ········QueryOwn(); |
1017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1018 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1019 | ····} |
1020 | ····[Test] |
1021 | ····public void TestSaveReloadRemove() |
1022 | ····{ |
1023 | ········CreateObjects(); |
1024 | ········QueryOwn(); |
1025 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1026 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1027 | ········ownVar.RemoveRelatedObject(); |
1028 | ········pm.Save(); |
1029 | ········pm.UnloadCache(); |
1030 | ········QueryOwn(); |
1031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1032 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1033 | ····} |
1034 | ····[Test] |
1035 | ····public void TestChangeKeyHolderRight() |
1036 | ····{ |
1037 | ········CreateObjects(); |
1038 | ········QueryOther(); |
1039 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1040 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1041 | ········int x = otherVar.RelField.Dummy; |
1042 | ········otherVar.Dummy = 4711; |
1043 | ········pm.Save(); |
1044 | ········pm.UnloadCache(); |
1045 | ········QueryOther(); |
1046 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1047 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1048 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1049 | ····} |
1050 | ····[Test] |
1051 | ····public void TestChangeKeyHolderRightNoTouch() |
1052 | ····{ |
1053 | ········CreateObjects(); |
1054 | ········QueryOther(); |
1055 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1056 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1057 | ········otherVar.Dummy = 4711; |
1058 | ········pm.Save(); |
1059 | ········pm.UnloadCache(); |
1060 | ········QueryOther(); |
1061 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1062 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1063 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1064 | ····} |
1065 | ····[Test] |
1066 | ····public void TestRelationHash() |
1067 | ····{ |
1068 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1TblAutoLeft)); |
1069 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1070 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1TblAutoRight)); |
1071 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1072 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1073 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1074 | ····} |
1075 | ····void CreateObjects() |
1076 | ····{ |
1077 | ········pm.MakePersistent(ownVar); |
1078 | ········pm.MakePersistent(otherVar); |
1079 | ········ownVar.AssignRelation(otherVar); |
1080 | ········pm.Save(); |
1081 | ········pm.UnloadCache(); |
1082 | ····} |
1083 | ····void QueryOwn() |
1084 | ····{ |
1085 | ········var q = new NDOQuery<AgrBin1TblAutoLeft>(pm); |
1086 | ········ownVar = q.ExecuteSingle(); |
1087 | ····} |
1088 | ····void QueryOther() |
1089 | ····{ |
1090 | ········var q = new NDOQuery<AgrBin1TblAutoRight>(pm); |
1091 | ········otherVar = q.ExecuteSingle(); |
1092 | ····} |
1093 | } |
1094 | |
1095 | |
1096 | [TestFixture] |
1097 | public class TestAgrBi1nNoTblAuto : NDOTest |
1098 | { |
1099 | ····AgrBi1nNoTblAutoLeft ownVar; |
1100 | ····AgrBi1nNoTblAutoRight otherVar; |
1101 | ····PersistenceManager pm; |
1102 | ····[SetUp] |
1103 | ····public void Setup() |
1104 | ····{ |
1105 | ········pm = PmFactory.NewPersistenceManager(); |
1106 | ········ownVar = new AgrBi1nNoTblAutoLeft(); |
1107 | ········otherVar = new AgrBi1nNoTblAutoRight(); |
1108 | ····} |
1109 | ····[TearDown] |
1110 | ····public void TearDown() |
1111 | ····{ |
1112 | ········try |
1113 | ········{ |
1114 | ············pm.UnloadCache(); |
1115 | ············var l = pm.Objects<AgrBi1nNoTblAutoLeft>().ResultTable; |
1116 | ············pm.Delete(l); |
1117 | ············pm.Save(); |
1118 | ············pm.UnloadCache(); |
1119 | ············var m = pm.Objects<AgrBi1nNoTblAutoRight>().ResultTable; |
1120 | ············pm.Delete(m); |
1121 | ············pm.Save(); |
1122 | ············pm.UnloadCache(); |
1123 | ············decimal count; |
1124 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1125 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1126 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1127 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1128 | ········} |
1129 | ········catch (Exception) |
1130 | ········{ |
1131 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1132 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1133 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1134 | ········} |
1135 | ····} |
1136 | ····[Test] |
1137 | ····public void TestSaveReload() |
1138 | ····{ |
1139 | ········CreateObjects(); |
1140 | ········QueryOwn(); |
1141 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1142 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1143 | ····} |
1144 | ····[Test] |
1145 | ····public void TestSaveReloadNull() |
1146 | ····{ |
1147 | ········CreateObjects(); |
1148 | ········QueryOwn(); |
1149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1151 | ········ownVar.RelField = null; |
1152 | ········pm.Save(); |
1153 | ········pm.UnloadCache(); |
1154 | ········QueryOwn(); |
1155 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1156 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1157 | ····} |
1158 | ····[Test] |
1159 | ····public void TestChangeKeyHolderLeft() |
1160 | ····{ |
1161 | ········CreateObjects(); |
1162 | ········QueryOwn(); |
1163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1164 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1165 | ········int x = ownVar.RelField.Dummy; |
1166 | ········ownVar.Dummy = 4711; |
1167 | ········pm.Save(); |
1168 | ········pm.UnloadCache(); |
1169 | ········QueryOwn(); |
1170 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1171 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1172 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1173 | ····} |
1174 | ····[Test] |
1175 | ····public void TestChangeKeyHolderLeftNoTouch() |
1176 | ····{ |
1177 | ········CreateObjects(); |
1178 | ········QueryOwn(); |
1179 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1181 | ········ownVar.Dummy = 4711; |
1182 | ········pm.Save(); |
1183 | ········pm.UnloadCache(); |
1184 | ········QueryOwn(); |
1185 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1186 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1187 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1188 | ····} |
1189 | ····[Test] |
1190 | ····public void TestUpdateOrder() |
1191 | ····{ |
1192 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
1193 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
1194 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nNoTblAutoLeft)})) |
1195 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nNoTblAutoRight)})), "Wrong order #1"); |
1196 | ········Debug.WriteLine("AgrBi1nNoTblAutoLeft"); |
1197 | ····} |
1198 | ····[Test] |
1199 | ····public void TestRelationHash() |
1200 | ····{ |
1201 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblAutoLeft)); |
1202 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1203 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblAutoRight)); |
1204 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1205 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1206 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1207 | ····} |
1208 | ····void CreateObjects() |
1209 | ····{ |
1210 | ········pm.MakePersistent(ownVar); |
1211 | ········pm.MakePersistent(otherVar); |
1212 | ········ownVar.AssignRelation(otherVar); |
1213 | ········pm.Save(); |
1214 | ········pm.UnloadCache(); |
1215 | ····} |
1216 | ····void QueryOwn() |
1217 | ····{ |
1218 | ········var q = new NDOQuery<AgrBi1nNoTblAutoLeft>(pm); |
1219 | ········ownVar = q.ExecuteSingle(); |
1220 | ····} |
1221 | ····void QueryOther() |
1222 | ····{ |
1223 | ········var q = new NDOQuery<AgrBi1nNoTblAutoRight>(pm); |
1224 | ········otherVar = q.ExecuteSingle(); |
1225 | ····} |
1226 | } |
1227 | |
1228 | |
1229 | [TestFixture] |
1230 | public class TestAgrBi1nTblAuto : NDOTest |
1231 | { |
1232 | ····AgrBi1nTblAutoLeft ownVar; |
1233 | ····AgrBi1nTblAutoRight otherVar; |
1234 | ····PersistenceManager pm; |
1235 | ····[SetUp] |
1236 | ····public void Setup() |
1237 | ····{ |
1238 | ········pm = PmFactory.NewPersistenceManager(); |
1239 | ········ownVar = new AgrBi1nTblAutoLeft(); |
1240 | ········otherVar = new AgrBi1nTblAutoRight(); |
1241 | ····} |
1242 | ····[TearDown] |
1243 | ····public void TearDown() |
1244 | ····{ |
1245 | ········try |
1246 | ········{ |
1247 | ············pm.UnloadCache(); |
1248 | ············var l = pm.Objects<AgrBi1nTblAutoLeft>().ResultTable; |
1249 | ············pm.Delete(l); |
1250 | ············pm.Save(); |
1251 | ············pm.UnloadCache(); |
1252 | ············var m = pm.Objects<AgrBi1nTblAutoRight>().ResultTable; |
1253 | ············pm.Delete(m); |
1254 | ············pm.Save(); |
1255 | ············pm.UnloadCache(); |
1256 | ············decimal count; |
1257 | ············count = (decimal) new NDOQuery<AgrBi1nTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1258 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1259 | ············count = (decimal) new NDOQuery<AgrBi1nTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1260 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1261 | ········} |
1262 | ········catch (Exception) |
1263 | ········{ |
1264 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1265 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1266 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1267 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1268 | ········} |
1269 | ····} |
1270 | ····[Test] |
1271 | ····public void TestSaveReload() |
1272 | ····{ |
1273 | ········CreateObjects(); |
1274 | ········QueryOwn(); |
1275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1276 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1277 | ····} |
1278 | ····[Test] |
1279 | ····public void TestSaveReloadNull() |
1280 | ····{ |
1281 | ········CreateObjects(); |
1282 | ········QueryOwn(); |
1283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1284 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1285 | ········ownVar.RelField = null; |
1286 | ········pm.Save(); |
1287 | ········pm.UnloadCache(); |
1288 | ········QueryOwn(); |
1289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1290 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1291 | ····} |
1292 | ····[Test] |
1293 | ····public void TestChangeKeyHolderLeft() |
1294 | ····{ |
1295 | ········CreateObjects(); |
1296 | ········QueryOwn(); |
1297 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1298 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1299 | ········int x = ownVar.RelField.Dummy; |
1300 | ········ownVar.Dummy = 4711; |
1301 | ········pm.Save(); |
1302 | ········pm.UnloadCache(); |
1303 | ········QueryOwn(); |
1304 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1305 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1306 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1307 | ····} |
1308 | ····[Test] |
1309 | ····public void TestChangeKeyHolderLeftNoTouch() |
1310 | ····{ |
1311 | ········CreateObjects(); |
1312 | ········QueryOwn(); |
1313 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1315 | ········ownVar.Dummy = 4711; |
1316 | ········pm.Save(); |
1317 | ········pm.UnloadCache(); |
1318 | ········QueryOwn(); |
1319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1320 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1321 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1322 | ····} |
1323 | ····[Test] |
1324 | ····public void TestRelationHash() |
1325 | ····{ |
1326 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nTblAutoLeft)); |
1327 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1328 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nTblAutoRight)); |
1329 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1330 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1331 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1332 | ····} |
1333 | ····void CreateObjects() |
1334 | ····{ |
1335 | ········pm.MakePersistent(ownVar); |
1336 | ········pm.MakePersistent(otherVar); |
1337 | ········ownVar.AssignRelation(otherVar); |
1338 | ········pm.Save(); |
1339 | ········pm.UnloadCache(); |
1340 | ····} |
1341 | ····void QueryOwn() |
1342 | ····{ |
1343 | ········var q = new NDOQuery<AgrBi1nTblAutoLeft>(pm); |
1344 | ········ownVar = q.ExecuteSingle(); |
1345 | ····} |
1346 | ····void QueryOther() |
1347 | ····{ |
1348 | ········var q = new NDOQuery<AgrBi1nTblAutoRight>(pm); |
1349 | ········otherVar = q.ExecuteSingle(); |
1350 | ····} |
1351 | } |
1352 | |
1353 | |
1354 | [TestFixture] |
1355 | public class TestAgrBinnTblAuto : NDOTest |
1356 | { |
1357 | ····AgrBinnTblAutoLeft ownVar; |
1358 | ····AgrBinnTblAutoRight otherVar; |
1359 | ····PersistenceManager pm; |
1360 | ····[SetUp] |
1361 | ····public void Setup() |
1362 | ····{ |
1363 | ········pm = PmFactory.NewPersistenceManager(); |
1364 | ········ownVar = new AgrBinnTblAutoLeft(); |
1365 | ········otherVar = new AgrBinnTblAutoRight(); |
1366 | ····} |
1367 | ····[TearDown] |
1368 | ····public void TearDown() |
1369 | ····{ |
1370 | ········try |
1371 | ········{ |
1372 | ············pm.UnloadCache(); |
1373 | ············var l = pm.Objects<AgrBinnTblAutoLeft>().ResultTable; |
1374 | ············pm.Delete(l); |
1375 | ············pm.Save(); |
1376 | ············pm.UnloadCache(); |
1377 | ············var m = pm.Objects<AgrBinnTblAutoRight>().ResultTable; |
1378 | ············pm.Delete(m); |
1379 | ············pm.Save(); |
1380 | ············pm.UnloadCache(); |
1381 | ············decimal count; |
1382 | ············count = (decimal) new NDOQuery<AgrBinnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1383 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1384 | ············count = (decimal) new NDOQuery<AgrBinnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1385 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1386 | ········} |
1387 | ········catch (Exception) |
1388 | ········{ |
1389 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1390 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1391 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1392 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1393 | ········} |
1394 | ····} |
1395 | ····[Test] |
1396 | ····public void TestSaveReload() |
1397 | ····{ |
1398 | ········CreateObjects(); |
1399 | ········QueryOwn(); |
1400 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1401 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1402 | ····} |
1403 | ····[Test] |
1404 | ····public void TestSaveReloadNull() |
1405 | ····{ |
1406 | ········CreateObjects(); |
1407 | ········QueryOwn(); |
1408 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1409 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1410 | ········ownVar.RelField = new List<AgrBinnTblAutoRight>(); |
1411 | ········pm.Save(); |
1412 | ········pm.UnloadCache(); |
1413 | ········QueryOwn(); |
1414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1415 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1416 | ····} |
1417 | ····[Test] |
1418 | ····public void TestSaveReloadRemove() |
1419 | ····{ |
1420 | ········CreateObjects(); |
1421 | ········QueryOwn(); |
1422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1424 | ········ownVar.RemoveRelatedObject(); |
1425 | ········pm.Save(); |
1426 | ········pm.UnloadCache(); |
1427 | ········QueryOwn(); |
1428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1429 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
1430 | ····} |
1431 | ····[Test] |
1432 | ····public void TestRelationHash() |
1433 | ····{ |
1434 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnTblAutoLeft)); |
1435 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1436 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnTblAutoRight)); |
1437 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1438 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1439 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1440 | ····} |
1441 | ····void CreateObjects() |
1442 | ····{ |
1443 | ········pm.MakePersistent(ownVar); |
1444 | ········pm.MakePersistent(otherVar); |
1445 | ········ownVar.AssignRelation(otherVar); |
1446 | ········pm.Save(); |
1447 | ········pm.UnloadCache(); |
1448 | ····} |
1449 | ····void QueryOwn() |
1450 | ····{ |
1451 | ········var q = new NDOQuery<AgrBinnTblAutoLeft>(pm); |
1452 | ········ownVar = q.ExecuteSingle(); |
1453 | ····} |
1454 | ····void QueryOther() |
1455 | ····{ |
1456 | ········var q = new NDOQuery<AgrBinnTblAutoRight>(pm); |
1457 | ········otherVar = q.ExecuteSingle(); |
1458 | ····} |
1459 | } |
1460 | |
1461 | |
1462 | [TestFixture] |
1463 | public class TestCmpDir1NoTblAuto : NDOTest |
1464 | { |
1465 | ····CmpDir1NoTblAutoLeft ownVar; |
1466 | ····CmpDir1NoTblAutoRight otherVar; |
1467 | ····PersistenceManager pm; |
1468 | ····[SetUp] |
1469 | ····public void Setup() |
1470 | ····{ |
1471 | ········pm = PmFactory.NewPersistenceManager(); |
1472 | ········ownVar = new CmpDir1NoTblAutoLeft(); |
1473 | ········otherVar = new CmpDir1NoTblAutoRight(); |
1474 | ····} |
1475 | ····[TearDown] |
1476 | ····public void TearDown() |
1477 | ····{ |
1478 | ········try |
1479 | ········{ |
1480 | ············pm.UnloadCache(); |
1481 | ············var l = pm.Objects<CmpDir1NoTblAutoLeft>().ResultTable; |
1482 | ············pm.Delete(l); |
1483 | ············pm.Save(); |
1484 | ············pm.UnloadCache(); |
1485 | ············decimal count; |
1486 | ············count = (decimal) new NDOQuery<CmpDir1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1487 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1488 | ············count = (decimal) new NDOQuery<CmpDir1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1489 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1490 | ········} |
1491 | ········catch (Exception) |
1492 | ········{ |
1493 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1494 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1495 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1496 | ········} |
1497 | ····} |
1498 | ····[Test] |
1499 | ····public void TestSaveReload() |
1500 | ····{ |
1501 | ········CreateObjects(); |
1502 | ········QueryOwn(); |
1503 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1504 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1505 | ····} |
1506 | ····[Test] |
1507 | ····public void TestSaveReloadNull() |
1508 | ····{ |
1509 | ········CreateObjects(); |
1510 | ········QueryOwn(); |
1511 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1512 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1513 | ········ownVar.RelField = null; |
1514 | ········pm.Save(); |
1515 | ········pm.UnloadCache(); |
1516 | ········QueryOwn(); |
1517 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1518 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1519 | ····} |
1520 | ····[Test] |
1521 | ····public void TestChangeKeyHolderLeft() |
1522 | ····{ |
1523 | ········CreateObjects(); |
1524 | ········QueryOwn(); |
1525 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1526 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1527 | ········int x = ownVar.RelField.Dummy; |
1528 | ········ownVar.Dummy = 4711; |
1529 | ········pm.Save(); |
1530 | ········pm.UnloadCache(); |
1531 | ········QueryOwn(); |
1532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1533 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1534 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1535 | ····} |
1536 | ····[Test] |
1537 | ····public void TestChangeKeyHolderLeftNoTouch() |
1538 | ····{ |
1539 | ········CreateObjects(); |
1540 | ········QueryOwn(); |
1541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1542 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1543 | ········ownVar.Dummy = 4711; |
1544 | ········pm.Save(); |
1545 | ········pm.UnloadCache(); |
1546 | ········QueryOwn(); |
1547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1548 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1549 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1550 | ····} |
1551 | ····[Test] |
1552 | ····public void TestUpdateOrder() |
1553 | ····{ |
1554 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
1555 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
1556 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1NoTblAutoLeft)})) |
1557 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1NoTblAutoRight)})), "Wrong order #1"); |
1558 | ········Debug.WriteLine("CmpDir1NoTblAutoLeft"); |
1559 | ····} |
1560 | ····void CreateObjects() |
1561 | ····{ |
1562 | ········pm.MakePersistent(ownVar); |
1563 | ········ownVar.AssignRelation(otherVar); |
1564 | ········pm.Save(); |
1565 | ········pm.UnloadCache(); |
1566 | ····} |
1567 | ····void QueryOwn() |
1568 | ····{ |
1569 | ········var q = new NDOQuery<CmpDir1NoTblAutoLeft>(pm); |
1570 | ········ownVar = q.ExecuteSingle(); |
1571 | ····} |
1572 | ····void QueryOther() |
1573 | ····{ |
1574 | ········var q = new NDOQuery<CmpDir1NoTblAutoRight>(pm); |
1575 | ········otherVar = q.ExecuteSingle(); |
1576 | ····} |
1577 | } |
1578 | |
1579 | |
1580 | [TestFixture] |
1581 | public class TestCmpDir1TblAuto : NDOTest |
1582 | { |
1583 | ····CmpDir1TblAutoLeft ownVar; |
1584 | ····CmpDir1TblAutoRight otherVar; |
1585 | ····PersistenceManager pm; |
1586 | ····[SetUp] |
1587 | ····public void Setup() |
1588 | ····{ |
1589 | ········pm = PmFactory.NewPersistenceManager(); |
1590 | ········ownVar = new CmpDir1TblAutoLeft(); |
1591 | ········otherVar = new CmpDir1TblAutoRight(); |
1592 | ····} |
1593 | ····[TearDown] |
1594 | ····public void TearDown() |
1595 | ····{ |
1596 | ········try |
1597 | ········{ |
1598 | ············pm.UnloadCache(); |
1599 | ············var l = pm.Objects<CmpDir1TblAutoLeft>().ResultTable; |
1600 | ············pm.Delete(l); |
1601 | ············pm.Save(); |
1602 | ············pm.UnloadCache(); |
1603 | ············decimal count; |
1604 | ············count = (decimal) new NDOQuery<CmpDir1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1605 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1606 | ············count = (decimal) new NDOQuery<CmpDir1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1607 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1608 | ········} |
1609 | ········catch (Exception) |
1610 | ········{ |
1611 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1612 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1613 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1614 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1615 | ········} |
1616 | ····} |
1617 | ····[Test] |
1618 | ····public void TestSaveReload() |
1619 | ····{ |
1620 | ········CreateObjects(); |
1621 | ········QueryOwn(); |
1622 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1623 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1624 | ····} |
1625 | ····[Test] |
1626 | ····public void TestSaveReloadNull() |
1627 | ····{ |
1628 | ········CreateObjects(); |
1629 | ········QueryOwn(); |
1630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1631 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1632 | ········ownVar.RelField = null; |
1633 | ········pm.Save(); |
1634 | ········pm.UnloadCache(); |
1635 | ········QueryOwn(); |
1636 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1637 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1638 | ····} |
1639 | ····[Test] |
1640 | ····public void TestChangeKeyHolderLeft() |
1641 | ····{ |
1642 | ········CreateObjects(); |
1643 | ········QueryOwn(); |
1644 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1645 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1646 | ········int x = ownVar.RelField.Dummy; |
1647 | ········ownVar.Dummy = 4711; |
1648 | ········pm.Save(); |
1649 | ········pm.UnloadCache(); |
1650 | ········QueryOwn(); |
1651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1652 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1654 | ····} |
1655 | ····[Test] |
1656 | ····public void TestChangeKeyHolderLeftNoTouch() |
1657 | ····{ |
1658 | ········CreateObjects(); |
1659 | ········QueryOwn(); |
1660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1662 | ········ownVar.Dummy = 4711; |
1663 | ········pm.Save(); |
1664 | ········pm.UnloadCache(); |
1665 | ········QueryOwn(); |
1666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1667 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1669 | ····} |
1670 | ····void CreateObjects() |
1671 | ····{ |
1672 | ········pm.MakePersistent(ownVar); |
1673 | ········ownVar.AssignRelation(otherVar); |
1674 | ········pm.Save(); |
1675 | ········pm.UnloadCache(); |
1676 | ····} |
1677 | ····void QueryOwn() |
1678 | ····{ |
1679 | ········var q = new NDOQuery<CmpDir1TblAutoLeft>(pm); |
1680 | ········ownVar = q.ExecuteSingle(); |
1681 | ····} |
1682 | ····void QueryOther() |
1683 | ····{ |
1684 | ········var q = new NDOQuery<CmpDir1TblAutoRight>(pm); |
1685 | ········otherVar = q.ExecuteSingle(); |
1686 | ····} |
1687 | } |
1688 | |
1689 | |
1690 | [TestFixture] |
1691 | public class TestCmpBi11NoTblAuto : NDOTest |
1692 | { |
1693 | ····CmpBi11NoTblAutoLeft ownVar; |
1694 | ····CmpBi11NoTblAutoRight otherVar; |
1695 | ····PersistenceManager pm; |
1696 | ····[SetUp] |
1697 | ····public void Setup() |
1698 | ····{ |
1699 | ········pm = PmFactory.NewPersistenceManager(); |
1700 | ········ownVar = new CmpBi11NoTblAutoLeft(); |
1701 | ········otherVar = new CmpBi11NoTblAutoRight(); |
1702 | ····} |
1703 | ····[TearDown] |
1704 | ····public void TearDown() |
1705 | ····{ |
1706 | ········try |
1707 | ········{ |
1708 | ············pm.UnloadCache(); |
1709 | ············var l = pm.Objects<CmpBi11NoTblAutoLeft>().ResultTable; |
1710 | ············pm.Delete(l); |
1711 | ············pm.Save(); |
1712 | ············pm.UnloadCache(); |
1713 | ············decimal count; |
1714 | ············count = (decimal) new NDOQuery<CmpBi11NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1715 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1716 | ············count = (decimal) new NDOQuery<CmpBi11NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1717 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1718 | ········} |
1719 | ········catch (Exception) |
1720 | ········{ |
1721 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1722 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1723 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1724 | ········} |
1725 | ····} |
1726 | ····[Test] |
1727 | ····public void TestSaveReload() |
1728 | ····{ |
1729 | ········CreateObjects(); |
1730 | ········QueryOwn(); |
1731 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1732 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1733 | ····} |
1734 | ····[Test] |
1735 | ····public void TestSaveReloadNull() |
1736 | ····{ |
1737 | ········CreateObjects(); |
1738 | ········QueryOwn(); |
1739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1740 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1741 | ········ownVar.RelField = null; |
1742 | ········pm.Save(); |
1743 | ········pm.UnloadCache(); |
1744 | ········QueryOwn(); |
1745 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1746 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1747 | ····} |
1748 | ····[Test] |
1749 | ····public void TestChangeKeyHolderLeft() |
1750 | ····{ |
1751 | ········CreateObjects(); |
1752 | ········QueryOwn(); |
1753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1754 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1755 | ········int x = ownVar.RelField.Dummy; |
1756 | ········ownVar.Dummy = 4711; |
1757 | ········pm.Save(); |
1758 | ········pm.UnloadCache(); |
1759 | ········QueryOwn(); |
1760 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1761 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1762 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1763 | ····} |
1764 | ····[Test] |
1765 | ····public void TestChangeKeyHolderRight() |
1766 | ····{ |
1767 | ········CreateObjects(); |
1768 | ········QueryOther(); |
1769 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1770 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1771 | ········int x = otherVar.RelField.Dummy; |
1772 | ········otherVar.Dummy = 4711; |
1773 | ········pm.Save(); |
1774 | ········pm.UnloadCache(); |
1775 | ········QueryOther(); |
1776 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1777 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1778 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1779 | ····} |
1780 | ····[Test] |
1781 | ····public void TestChangeKeyHolderLeftNoTouch() |
1782 | ····{ |
1783 | ········CreateObjects(); |
1784 | ········QueryOwn(); |
1785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1787 | ········ownVar.Dummy = 4711; |
1788 | ········pm.Save(); |
1789 | ········pm.UnloadCache(); |
1790 | ········QueryOwn(); |
1791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1792 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1793 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1794 | ····} |
1795 | ····[Test] |
1796 | ····public void TestChangeKeyHolderRightNoTouch() |
1797 | ····{ |
1798 | ········CreateObjects(); |
1799 | ········QueryOther(); |
1800 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1801 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1802 | ········otherVar.Dummy = 4711; |
1803 | ········pm.Save(); |
1804 | ········pm.UnloadCache(); |
1805 | ········QueryOther(); |
1806 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1807 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1808 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1809 | ····} |
1810 | ····[Test] |
1811 | ····public void TestRelationHash() |
1812 | ····{ |
1813 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblAutoLeft)); |
1814 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1815 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblAutoRight)); |
1816 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1817 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1818 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1819 | ····} |
1820 | ····void CreateObjects() |
1821 | ····{ |
1822 | ········pm.MakePersistent(ownVar); |
1823 | ········ownVar.AssignRelation(otherVar); |
1824 | ········pm.Save(); |
1825 | ········pm.UnloadCache(); |
1826 | ····} |
1827 | ····void QueryOwn() |
1828 | ····{ |
1829 | ········var q = new NDOQuery<CmpBi11NoTblAutoLeft>(pm); |
1830 | ········ownVar = q.ExecuteSingle(); |
1831 | ····} |
1832 | ····void QueryOther() |
1833 | ····{ |
1834 | ········var q = new NDOQuery<CmpBi11NoTblAutoRight>(pm); |
1835 | ········otherVar = q.ExecuteSingle(); |
1836 | ····} |
1837 | } |
1838 | |
1839 | |
1840 | [TestFixture] |
1841 | public class TestCmpBi11TblAuto : NDOTest |
1842 | { |
1843 | ····CmpBi11TblAutoLeft ownVar; |
1844 | ····CmpBi11TblAutoRight otherVar; |
1845 | ····PersistenceManager pm; |
1846 | ····[SetUp] |
1847 | ····public void Setup() |
1848 | ····{ |
1849 | ········pm = PmFactory.NewPersistenceManager(); |
1850 | ········ownVar = new CmpBi11TblAutoLeft(); |
1851 | ········otherVar = new CmpBi11TblAutoRight(); |
1852 | ····} |
1853 | ····[TearDown] |
1854 | ····public void TearDown() |
1855 | ····{ |
1856 | ········try |
1857 | ········{ |
1858 | ············pm.UnloadCache(); |
1859 | ············var l = pm.Objects<CmpBi11TblAutoLeft>().ResultTable; |
1860 | ············pm.Delete(l); |
1861 | ············pm.Save(); |
1862 | ············pm.UnloadCache(); |
1863 | ············decimal count; |
1864 | ············count = (decimal) new NDOQuery<CmpBi11TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
1866 | ············count = (decimal) new NDOQuery<CmpBi11TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
1867 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
1868 | ········} |
1869 | ········catch (Exception) |
1870 | ········{ |
1871 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
1872 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
1873 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
1874 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
1875 | ········} |
1876 | ····} |
1877 | ····[Test] |
1878 | ····public void TestSaveReload() |
1879 | ····{ |
1880 | ········CreateObjects(); |
1881 | ········QueryOwn(); |
1882 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1883 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1884 | ····} |
1885 | ····[Test] |
1886 | ····public void TestSaveReloadNull() |
1887 | ····{ |
1888 | ········CreateObjects(); |
1889 | ········QueryOwn(); |
1890 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1891 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1892 | ········ownVar.RelField = null; |
1893 | ········pm.Save(); |
1894 | ········pm.UnloadCache(); |
1895 | ········QueryOwn(); |
1896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1897 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
1898 | ····} |
1899 | ····[Test] |
1900 | ····public void TestChangeKeyHolderLeft() |
1901 | ····{ |
1902 | ········CreateObjects(); |
1903 | ········QueryOwn(); |
1904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1905 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1906 | ········int x = ownVar.RelField.Dummy; |
1907 | ········ownVar.Dummy = 4711; |
1908 | ········pm.Save(); |
1909 | ········pm.UnloadCache(); |
1910 | ········QueryOwn(); |
1911 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1912 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1913 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1914 | ····} |
1915 | ····[Test] |
1916 | ····public void TestChangeKeyHolderRight() |
1917 | ····{ |
1918 | ········CreateObjects(); |
1919 | ········QueryOther(); |
1920 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1921 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1922 | ········int x = otherVar.RelField.Dummy; |
1923 | ········otherVar.Dummy = 4711; |
1924 | ········pm.Save(); |
1925 | ········pm.UnloadCache(); |
1926 | ········QueryOther(); |
1927 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1928 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1929 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1930 | ····} |
1931 | ····[Test] |
1932 | ····public void TestChangeKeyHolderLeftNoTouch() |
1933 | ····{ |
1934 | ········CreateObjects(); |
1935 | ········QueryOwn(); |
1936 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1937 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1938 | ········ownVar.Dummy = 4711; |
1939 | ········pm.Save(); |
1940 | ········pm.UnloadCache(); |
1941 | ········QueryOwn(); |
1942 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
1943 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
1945 | ····} |
1946 | ····[Test] |
1947 | ····public void TestChangeKeyHolderRightNoTouch() |
1948 | ····{ |
1949 | ········CreateObjects(); |
1950 | ········QueryOther(); |
1951 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1952 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1953 | ········otherVar.Dummy = 4711; |
1954 | ········pm.Save(); |
1955 | ········pm.UnloadCache(); |
1956 | ········QueryOther(); |
1957 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
1958 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
1959 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
1960 | ····} |
1961 | ····[Test] |
1962 | ····public void TestRelationHash() |
1963 | ····{ |
1964 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11TblAutoLeft)); |
1965 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
1966 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11TblAutoRight)); |
1967 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
1968 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
1969 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
1970 | ····} |
1971 | ····void CreateObjects() |
1972 | ····{ |
1973 | ········pm.MakePersistent(ownVar); |
1974 | ········ownVar.AssignRelation(otherVar); |
1975 | ········pm.Save(); |
1976 | ········pm.UnloadCache(); |
1977 | ····} |
1978 | ····void QueryOwn() |
1979 | ····{ |
1980 | ········var q = new NDOQuery<CmpBi11TblAutoLeft>(pm); |
1981 | ········ownVar = q.ExecuteSingle(); |
1982 | ····} |
1983 | ····void QueryOther() |
1984 | ····{ |
1985 | ········var q = new NDOQuery<CmpBi11TblAutoRight>(pm); |
1986 | ········otherVar = q.ExecuteSingle(); |
1987 | ····} |
1988 | } |
1989 | |
1990 | |
1991 | [TestFixture] |
1992 | public class TestCmpDirnNoTblAuto : NDOTest |
1993 | { |
1994 | ····CmpDirnNoTblAutoLeft ownVar; |
1995 | ····CmpDirnNoTblAutoRight otherVar; |
1996 | ····PersistenceManager pm; |
1997 | ····[SetUp] |
1998 | ····public void Setup() |
1999 | ····{ |
2000 | ········pm = PmFactory.NewPersistenceManager(); |
2001 | ········ownVar = new CmpDirnNoTblAutoLeft(); |
2002 | ········otherVar = new CmpDirnNoTblAutoRight(); |
2003 | ····} |
2004 | ····[TearDown] |
2005 | ····public void TearDown() |
2006 | ····{ |
2007 | ········try |
2008 | ········{ |
2009 | ············pm.UnloadCache(); |
2010 | ············var l = pm.Objects<CmpDirnNoTblAutoLeft>().ResultTable; |
2011 | ············pm.Delete(l); |
2012 | ············pm.Save(); |
2013 | ············pm.UnloadCache(); |
2014 | ············decimal count; |
2015 | ············count = (decimal) new NDOQuery<CmpDirnNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2016 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2017 | ············count = (decimal) new NDOQuery<CmpDirnNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2018 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2019 | ········} |
2020 | ········catch (Exception) |
2021 | ········{ |
2022 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2023 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2024 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2025 | ········} |
2026 | ····} |
2027 | ····[Test] |
2028 | ····public void TestSaveReload() |
2029 | ····{ |
2030 | ········CreateObjects(); |
2031 | ········QueryOwn(); |
2032 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2033 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2034 | ····} |
2035 | ····[Test] |
2036 | ····public void TestSaveReloadNull() |
2037 | ····{ |
2038 | ········CreateObjects(); |
2039 | ········QueryOwn(); |
2040 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2041 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2042 | ········ownVar.RelField = new List<CmpDirnNoTblAutoRight>(); |
2043 | ········pm.Save(); |
2044 | ········pm.UnloadCache(); |
2045 | ········QueryOwn(); |
2046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2047 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2048 | ····} |
2049 | ····[Test] |
2050 | ····public void TestSaveReloadRemove() |
2051 | ····{ |
2052 | ········CreateObjects(); |
2053 | ········QueryOwn(); |
2054 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2055 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2056 | ········ownVar.RemoveRelatedObject(); |
2057 | ········pm.Save(); |
2058 | ········pm.UnloadCache(); |
2059 | ········QueryOwn(); |
2060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2061 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2062 | ····} |
2063 | ····[Test] |
2064 | ····public void TestUpdateOrder() |
2065 | ····{ |
2066 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2067 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2068 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnNoTblAutoLeft)})) |
2069 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnNoTblAutoRight)})), "Wrong order #1"); |
2070 | ········Debug.WriteLine("CmpDirnNoTblAutoLeft"); |
2071 | ····} |
2072 | ····void CreateObjects() |
2073 | ····{ |
2074 | ········pm.MakePersistent(ownVar); |
2075 | ········ownVar.AssignRelation(otherVar); |
2076 | ········pm.Save(); |
2077 | ········pm.UnloadCache(); |
2078 | ····} |
2079 | ····void QueryOwn() |
2080 | ····{ |
2081 | ········var q = new NDOQuery<CmpDirnNoTblAutoLeft>(pm); |
2082 | ········ownVar = q.ExecuteSingle(); |
2083 | ····} |
2084 | ····void QueryOther() |
2085 | ····{ |
2086 | ········var q = new NDOQuery<CmpDirnNoTblAutoRight>(pm); |
2087 | ········otherVar = q.ExecuteSingle(); |
2088 | ····} |
2089 | } |
2090 | |
2091 | |
2092 | [TestFixture] |
2093 | public class TestCmpDirnTblAuto : NDOTest |
2094 | { |
2095 | ····CmpDirnTblAutoLeft ownVar; |
2096 | ····CmpDirnTblAutoRight otherVar; |
2097 | ····PersistenceManager pm; |
2098 | ····[SetUp] |
2099 | ····public void Setup() |
2100 | ····{ |
2101 | ········pm = PmFactory.NewPersistenceManager(); |
2102 | ········ownVar = new CmpDirnTblAutoLeft(); |
2103 | ········otherVar = new CmpDirnTblAutoRight(); |
2104 | ····} |
2105 | ····[TearDown] |
2106 | ····public void TearDown() |
2107 | ····{ |
2108 | ········try |
2109 | ········{ |
2110 | ············pm.UnloadCache(); |
2111 | ············var l = pm.Objects<CmpDirnTblAutoLeft>().ResultTable; |
2112 | ············pm.Delete(l); |
2113 | ············pm.Save(); |
2114 | ············pm.UnloadCache(); |
2115 | ············decimal count; |
2116 | ············count = (decimal) new NDOQuery<CmpDirnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2117 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2118 | ············count = (decimal) new NDOQuery<CmpDirnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2119 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2120 | ········} |
2121 | ········catch (Exception) |
2122 | ········{ |
2123 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2124 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2125 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2126 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2127 | ········} |
2128 | ····} |
2129 | ····[Test] |
2130 | ····public void TestSaveReload() |
2131 | ····{ |
2132 | ········CreateObjects(); |
2133 | ········QueryOwn(); |
2134 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2135 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2136 | ····} |
2137 | ····[Test] |
2138 | ····public void TestSaveReloadNull() |
2139 | ····{ |
2140 | ········CreateObjects(); |
2141 | ········QueryOwn(); |
2142 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2143 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2144 | ········ownVar.RelField = new List<CmpDirnTblAutoRight>(); |
2145 | ········pm.Save(); |
2146 | ········pm.UnloadCache(); |
2147 | ········QueryOwn(); |
2148 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2149 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2150 | ····} |
2151 | ····[Test] |
2152 | ····public void TestSaveReloadRemove() |
2153 | ····{ |
2154 | ········CreateObjects(); |
2155 | ········QueryOwn(); |
2156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2157 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2158 | ········ownVar.RemoveRelatedObject(); |
2159 | ········pm.Save(); |
2160 | ········pm.UnloadCache(); |
2161 | ········QueryOwn(); |
2162 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2163 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2164 | ····} |
2165 | ····void CreateObjects() |
2166 | ····{ |
2167 | ········pm.MakePersistent(ownVar); |
2168 | ········ownVar.AssignRelation(otherVar); |
2169 | ········pm.Save(); |
2170 | ········pm.UnloadCache(); |
2171 | ····} |
2172 | ····void QueryOwn() |
2173 | ····{ |
2174 | ········var q = new NDOQuery<CmpDirnTblAutoLeft>(pm); |
2175 | ········ownVar = q.ExecuteSingle(); |
2176 | ····} |
2177 | ····void QueryOther() |
2178 | ····{ |
2179 | ········var q = new NDOQuery<CmpDirnTblAutoRight>(pm); |
2180 | ········otherVar = q.ExecuteSingle(); |
2181 | ····} |
2182 | } |
2183 | |
2184 | |
2185 | [TestFixture] |
2186 | public class TestCmpBin1NoTblAuto : NDOTest |
2187 | { |
2188 | ····CmpBin1NoTblAutoLeft ownVar; |
2189 | ····CmpBin1NoTblAutoRight otherVar; |
2190 | ····PersistenceManager pm; |
2191 | ····[SetUp] |
2192 | ····public void Setup() |
2193 | ····{ |
2194 | ········pm = PmFactory.NewPersistenceManager(); |
2195 | ········ownVar = new CmpBin1NoTblAutoLeft(); |
2196 | ········otherVar = new CmpBin1NoTblAutoRight(); |
2197 | ····} |
2198 | ····[TearDown] |
2199 | ····public void TearDown() |
2200 | ····{ |
2201 | ········try |
2202 | ········{ |
2203 | ············pm.UnloadCache(); |
2204 | ············var l = pm.Objects<CmpBin1NoTblAutoLeft>().ResultTable; |
2205 | ············pm.Delete(l); |
2206 | ············pm.Save(); |
2207 | ············pm.UnloadCache(); |
2208 | ············decimal count; |
2209 | ············count = (decimal) new NDOQuery<CmpBin1NoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2210 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2211 | ············count = (decimal) new NDOQuery<CmpBin1NoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2212 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2213 | ········} |
2214 | ········catch (Exception) |
2215 | ········{ |
2216 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2218 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2219 | ········} |
2220 | ····} |
2221 | ····[Test] |
2222 | ····public void TestSaveReload() |
2223 | ····{ |
2224 | ········CreateObjects(); |
2225 | ········QueryOwn(); |
2226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2227 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2228 | ····} |
2229 | ····[Test] |
2230 | ····public void TestSaveReloadNull() |
2231 | ····{ |
2232 | ········CreateObjects(); |
2233 | ········QueryOwn(); |
2234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2235 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2236 | ········ownVar.RelField = new List<CmpBin1NoTblAutoRight>(); |
2237 | ········pm.Save(); |
2238 | ········pm.UnloadCache(); |
2239 | ········QueryOwn(); |
2240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2241 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2242 | ····} |
2243 | ····[Test] |
2244 | ····public void TestSaveReloadRemove() |
2245 | ····{ |
2246 | ········CreateObjects(); |
2247 | ········QueryOwn(); |
2248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2249 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2250 | ········ownVar.RemoveRelatedObject(); |
2251 | ········pm.Save(); |
2252 | ········pm.UnloadCache(); |
2253 | ········QueryOwn(); |
2254 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2255 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2256 | ····} |
2257 | ····[Test] |
2258 | ····public void TestChangeKeyHolderRight() |
2259 | ····{ |
2260 | ········CreateObjects(); |
2261 | ········QueryOther(); |
2262 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2263 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2264 | ········int x = otherVar.RelField.Dummy; |
2265 | ········otherVar.Dummy = 4711; |
2266 | ········pm.Save(); |
2267 | ········pm.UnloadCache(); |
2268 | ········QueryOther(); |
2269 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2270 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2271 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2272 | ····} |
2273 | ····[Test] |
2274 | ····public void TestChangeKeyHolderRightNoTouch() |
2275 | ····{ |
2276 | ········CreateObjects(); |
2277 | ········QueryOther(); |
2278 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2279 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2280 | ········otherVar.Dummy = 4711; |
2281 | ········pm.Save(); |
2282 | ········pm.UnloadCache(); |
2283 | ········QueryOther(); |
2284 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2285 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2286 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2287 | ····} |
2288 | ····[Test] |
2289 | ····public void TestUpdateOrder() |
2290 | ····{ |
2291 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2292 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2293 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1NoTblAutoLeft)})) |
2294 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1NoTblAutoRight)})), "Wrong order #1"); |
2295 | ········Debug.WriteLine("CmpBin1NoTblAutoLeft"); |
2296 | ····} |
2297 | ····[Test] |
2298 | ····public void TestRelationHash() |
2299 | ····{ |
2300 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblAutoLeft)); |
2301 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2302 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblAutoRight)); |
2303 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2304 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2305 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2306 | ····} |
2307 | ····void CreateObjects() |
2308 | ····{ |
2309 | ········pm.MakePersistent(ownVar); |
2310 | ········ownVar.AssignRelation(otherVar); |
2311 | ········pm.Save(); |
2312 | ········pm.UnloadCache(); |
2313 | ····} |
2314 | ····void QueryOwn() |
2315 | ····{ |
2316 | ········var q = new NDOQuery<CmpBin1NoTblAutoLeft>(pm); |
2317 | ········ownVar = q.ExecuteSingle(); |
2318 | ····} |
2319 | ····void QueryOther() |
2320 | ····{ |
2321 | ········var q = new NDOQuery<CmpBin1NoTblAutoRight>(pm); |
2322 | ········otherVar = q.ExecuteSingle(); |
2323 | ····} |
2324 | } |
2325 | |
2326 | |
2327 | [TestFixture] |
2328 | public class TestCmpBin1TblAuto : NDOTest |
2329 | { |
2330 | ····CmpBin1TblAutoLeft ownVar; |
2331 | ····CmpBin1TblAutoRight otherVar; |
2332 | ····PersistenceManager pm; |
2333 | ····[SetUp] |
2334 | ····public void Setup() |
2335 | ····{ |
2336 | ········pm = PmFactory.NewPersistenceManager(); |
2337 | ········ownVar = new CmpBin1TblAutoLeft(); |
2338 | ········otherVar = new CmpBin1TblAutoRight(); |
2339 | ····} |
2340 | ····[TearDown] |
2341 | ····public void TearDown() |
2342 | ····{ |
2343 | ········try |
2344 | ········{ |
2345 | ············pm.UnloadCache(); |
2346 | ············var l = pm.Objects<CmpBin1TblAutoLeft>().ResultTable; |
2347 | ············pm.Delete(l); |
2348 | ············pm.Save(); |
2349 | ············pm.UnloadCache(); |
2350 | ············decimal count; |
2351 | ············count = (decimal) new NDOQuery<CmpBin1TblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2352 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2353 | ············count = (decimal) new NDOQuery<CmpBin1TblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2354 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2355 | ········} |
2356 | ········catch (Exception) |
2357 | ········{ |
2358 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2359 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2360 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2361 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2362 | ········} |
2363 | ····} |
2364 | ····[Test] |
2365 | ····public void TestSaveReload() |
2366 | ····{ |
2367 | ········CreateObjects(); |
2368 | ········QueryOwn(); |
2369 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2370 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2371 | ····} |
2372 | ····[Test] |
2373 | ····public void TestSaveReloadNull() |
2374 | ····{ |
2375 | ········CreateObjects(); |
2376 | ········QueryOwn(); |
2377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2378 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2379 | ········ownVar.RelField = new List<CmpBin1TblAutoRight>(); |
2380 | ········pm.Save(); |
2381 | ········pm.UnloadCache(); |
2382 | ········QueryOwn(); |
2383 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2384 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2385 | ····} |
2386 | ····[Test] |
2387 | ····public void TestSaveReloadRemove() |
2388 | ····{ |
2389 | ········CreateObjects(); |
2390 | ········QueryOwn(); |
2391 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2392 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2393 | ········ownVar.RemoveRelatedObject(); |
2394 | ········pm.Save(); |
2395 | ········pm.UnloadCache(); |
2396 | ········QueryOwn(); |
2397 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2398 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2399 | ····} |
2400 | ····[Test] |
2401 | ····public void TestChangeKeyHolderRight() |
2402 | ····{ |
2403 | ········CreateObjects(); |
2404 | ········QueryOther(); |
2405 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2406 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2407 | ········int x = otherVar.RelField.Dummy; |
2408 | ········otherVar.Dummy = 4711; |
2409 | ········pm.Save(); |
2410 | ········pm.UnloadCache(); |
2411 | ········QueryOther(); |
2412 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2413 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2414 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2415 | ····} |
2416 | ····[Test] |
2417 | ····public void TestChangeKeyHolderRightNoTouch() |
2418 | ····{ |
2419 | ········CreateObjects(); |
2420 | ········QueryOther(); |
2421 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2422 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2423 | ········otherVar.Dummy = 4711; |
2424 | ········pm.Save(); |
2425 | ········pm.UnloadCache(); |
2426 | ········QueryOther(); |
2427 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
2428 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2429 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
2430 | ····} |
2431 | ····[Test] |
2432 | ····public void TestRelationHash() |
2433 | ····{ |
2434 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1TblAutoLeft)); |
2435 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2436 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1TblAutoRight)); |
2437 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2438 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2439 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2440 | ····} |
2441 | ····void CreateObjects() |
2442 | ····{ |
2443 | ········pm.MakePersistent(ownVar); |
2444 | ········ownVar.AssignRelation(otherVar); |
2445 | ········pm.Save(); |
2446 | ········pm.UnloadCache(); |
2447 | ····} |
2448 | ····void QueryOwn() |
2449 | ····{ |
2450 | ········var q = new NDOQuery<CmpBin1TblAutoLeft>(pm); |
2451 | ········ownVar = q.ExecuteSingle(); |
2452 | ····} |
2453 | ····void QueryOther() |
2454 | ····{ |
2455 | ········var q = new NDOQuery<CmpBin1TblAutoRight>(pm); |
2456 | ········otherVar = q.ExecuteSingle(); |
2457 | ····} |
2458 | } |
2459 | |
2460 | |
2461 | [TestFixture] |
2462 | public class TestCmpBi1nNoTblAuto : NDOTest |
2463 | { |
2464 | ····CmpBi1nNoTblAutoLeft ownVar; |
2465 | ····CmpBi1nNoTblAutoRight otherVar; |
2466 | ····PersistenceManager pm; |
2467 | ····[SetUp] |
2468 | ····public void Setup() |
2469 | ····{ |
2470 | ········pm = PmFactory.NewPersistenceManager(); |
2471 | ········ownVar = new CmpBi1nNoTblAutoLeft(); |
2472 | ········otherVar = new CmpBi1nNoTblAutoRight(); |
2473 | ····} |
2474 | ····[TearDown] |
2475 | ····public void TearDown() |
2476 | ····{ |
2477 | ········try |
2478 | ········{ |
2479 | ············pm.UnloadCache(); |
2480 | ············var l = pm.Objects<CmpBi1nNoTblAutoLeft>().ResultTable; |
2481 | ············pm.Delete(l); |
2482 | ············pm.Save(); |
2483 | ············pm.UnloadCache(); |
2484 | ············decimal count; |
2485 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2486 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2487 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2488 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2489 | ········} |
2490 | ········catch (Exception) |
2491 | ········{ |
2492 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2493 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2494 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2495 | ········} |
2496 | ····} |
2497 | ····[Test] |
2498 | ····public void TestSaveReload() |
2499 | ····{ |
2500 | ········CreateObjects(); |
2501 | ········QueryOwn(); |
2502 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2503 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2504 | ····} |
2505 | ····[Test] |
2506 | ····public void TestSaveReloadNull() |
2507 | ····{ |
2508 | ········CreateObjects(); |
2509 | ········QueryOwn(); |
2510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2511 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2512 | ········ownVar.RelField = null; |
2513 | ········pm.Save(); |
2514 | ········pm.UnloadCache(); |
2515 | ········QueryOwn(); |
2516 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2517 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2518 | ····} |
2519 | ····[Test] |
2520 | ····public void TestChangeKeyHolderLeft() |
2521 | ····{ |
2522 | ········CreateObjects(); |
2523 | ········QueryOwn(); |
2524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2525 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2526 | ········int x = ownVar.RelField.Dummy; |
2527 | ········ownVar.Dummy = 4711; |
2528 | ········pm.Save(); |
2529 | ········pm.UnloadCache(); |
2530 | ········QueryOwn(); |
2531 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2532 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2533 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2534 | ····} |
2535 | ····[Test] |
2536 | ····public void TestChangeKeyHolderLeftNoTouch() |
2537 | ····{ |
2538 | ········CreateObjects(); |
2539 | ········QueryOwn(); |
2540 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2541 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2542 | ········ownVar.Dummy = 4711; |
2543 | ········pm.Save(); |
2544 | ········pm.UnloadCache(); |
2545 | ········QueryOwn(); |
2546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2547 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2548 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2549 | ····} |
2550 | ····[Test] |
2551 | ····public void TestUpdateOrder() |
2552 | ····{ |
2553 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2554 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2555 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBi1nNoTblAutoLeft)})) |
2556 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpBi1nNoTblAutoRight)})), "Wrong order #1"); |
2557 | ········Debug.WriteLine("CmpBi1nNoTblAutoLeft"); |
2558 | ····} |
2559 | ····[Test] |
2560 | ····public void TestRelationHash() |
2561 | ····{ |
2562 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblAutoLeft)); |
2563 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2564 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblAutoRight)); |
2565 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2566 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2567 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2568 | ····} |
2569 | ····void CreateObjects() |
2570 | ····{ |
2571 | ········pm.MakePersistent(ownVar); |
2572 | ········ownVar.AssignRelation(otherVar); |
2573 | ········pm.Save(); |
2574 | ········pm.UnloadCache(); |
2575 | ····} |
2576 | ····void QueryOwn() |
2577 | ····{ |
2578 | ········var q = new NDOQuery<CmpBi1nNoTblAutoLeft>(pm); |
2579 | ········ownVar = q.ExecuteSingle(); |
2580 | ····} |
2581 | ····void QueryOther() |
2582 | ····{ |
2583 | ········var q = new NDOQuery<CmpBi1nNoTblAutoRight>(pm); |
2584 | ········otherVar = q.ExecuteSingle(); |
2585 | ····} |
2586 | } |
2587 | |
2588 | |
2589 | [TestFixture] |
2590 | public class TestCmpBi1nTblAuto : NDOTest |
2591 | { |
2592 | ····CmpBi1nTblAutoLeft ownVar; |
2593 | ····CmpBi1nTblAutoRight otherVar; |
2594 | ····PersistenceManager pm; |
2595 | ····[SetUp] |
2596 | ····public void Setup() |
2597 | ····{ |
2598 | ········pm = PmFactory.NewPersistenceManager(); |
2599 | ········ownVar = new CmpBi1nTblAutoLeft(); |
2600 | ········otherVar = new CmpBi1nTblAutoRight(); |
2601 | ····} |
2602 | ····[TearDown] |
2603 | ····public void TearDown() |
2604 | ····{ |
2605 | ········try |
2606 | ········{ |
2607 | ············pm.UnloadCache(); |
2608 | ············var l = pm.Objects<CmpBi1nTblAutoLeft>().ResultTable; |
2609 | ············pm.Delete(l); |
2610 | ············pm.Save(); |
2611 | ············pm.UnloadCache(); |
2612 | ············decimal count; |
2613 | ············count = (decimal) new NDOQuery<CmpBi1nTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2614 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2615 | ············count = (decimal) new NDOQuery<CmpBi1nTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2616 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2617 | ········} |
2618 | ········catch (Exception) |
2619 | ········{ |
2620 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2621 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2622 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2623 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2624 | ········} |
2625 | ····} |
2626 | ····[Test] |
2627 | ····public void TestSaveReload() |
2628 | ····{ |
2629 | ········CreateObjects(); |
2630 | ········QueryOwn(); |
2631 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2632 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2633 | ····} |
2634 | ····[Test] |
2635 | ····public void TestSaveReloadNull() |
2636 | ····{ |
2637 | ········CreateObjects(); |
2638 | ········QueryOwn(); |
2639 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2640 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2641 | ········ownVar.RelField = null; |
2642 | ········pm.Save(); |
2643 | ········pm.UnloadCache(); |
2644 | ········QueryOwn(); |
2645 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2646 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2647 | ····} |
2648 | ····[Test] |
2649 | ····public void TestChangeKeyHolderLeft() |
2650 | ····{ |
2651 | ········CreateObjects(); |
2652 | ········QueryOwn(); |
2653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2654 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2655 | ········int x = ownVar.RelField.Dummy; |
2656 | ········ownVar.Dummy = 4711; |
2657 | ········pm.Save(); |
2658 | ········pm.UnloadCache(); |
2659 | ········QueryOwn(); |
2660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2661 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2662 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2663 | ····} |
2664 | ····[Test] |
2665 | ····public void TestChangeKeyHolderLeftNoTouch() |
2666 | ····{ |
2667 | ········CreateObjects(); |
2668 | ········QueryOwn(); |
2669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2670 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2671 | ········ownVar.Dummy = 4711; |
2672 | ········pm.Save(); |
2673 | ········pm.UnloadCache(); |
2674 | ········QueryOwn(); |
2675 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2676 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2677 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2678 | ····} |
2679 | ····[Test] |
2680 | ····public void TestRelationHash() |
2681 | ····{ |
2682 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nTblAutoLeft)); |
2683 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2684 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nTblAutoRight)); |
2685 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2686 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2687 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2688 | ····} |
2689 | ····void CreateObjects() |
2690 | ····{ |
2691 | ········pm.MakePersistent(ownVar); |
2692 | ········ownVar.AssignRelation(otherVar); |
2693 | ········pm.Save(); |
2694 | ········pm.UnloadCache(); |
2695 | ····} |
2696 | ····void QueryOwn() |
2697 | ····{ |
2698 | ········var q = new NDOQuery<CmpBi1nTblAutoLeft>(pm); |
2699 | ········ownVar = q.ExecuteSingle(); |
2700 | ····} |
2701 | ····void QueryOther() |
2702 | ····{ |
2703 | ········var q = new NDOQuery<CmpBi1nTblAutoRight>(pm); |
2704 | ········otherVar = q.ExecuteSingle(); |
2705 | ····} |
2706 | } |
2707 | |
2708 | |
2709 | [TestFixture] |
2710 | public class TestCmpBinnTblAuto : NDOTest |
2711 | { |
2712 | ····CmpBinnTblAutoLeft ownVar; |
2713 | ····CmpBinnTblAutoRight otherVar; |
2714 | ····PersistenceManager pm; |
2715 | ····[SetUp] |
2716 | ····public void Setup() |
2717 | ····{ |
2718 | ········pm = PmFactory.NewPersistenceManager(); |
2719 | ········ownVar = new CmpBinnTblAutoLeft(); |
2720 | ········otherVar = new CmpBinnTblAutoRight(); |
2721 | ····} |
2722 | ····[TearDown] |
2723 | ····public void TearDown() |
2724 | ····{ |
2725 | ········try |
2726 | ········{ |
2727 | ············pm.UnloadCache(); |
2728 | ············var l = pm.Objects<CmpBinnTblAutoLeft>().ResultTable; |
2729 | ············pm.Delete(l); |
2730 | ············pm.Save(); |
2731 | ············pm.UnloadCache(); |
2732 | ············decimal count; |
2733 | ············count = (decimal) new NDOQuery<CmpBinnTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2734 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2735 | ············count = (decimal) new NDOQuery<CmpBinnTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2736 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2737 | ········} |
2738 | ········catch (Exception) |
2739 | ········{ |
2740 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2741 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2742 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2743 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2744 | ········} |
2745 | ····} |
2746 | ····[Test] |
2747 | ····public void TestSaveReload() |
2748 | ····{ |
2749 | ········CreateObjects(); |
2750 | ········QueryOwn(); |
2751 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2752 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2753 | ····} |
2754 | ····[Test] |
2755 | ····public void TestSaveReloadNull() |
2756 | ····{ |
2757 | ········CreateObjects(); |
2758 | ········QueryOwn(); |
2759 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2760 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2761 | ········ownVar.RelField = new List<CmpBinnTblAutoRight>(); |
2762 | ········pm.Save(); |
2763 | ········pm.UnloadCache(); |
2764 | ········QueryOwn(); |
2765 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2766 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2767 | ····} |
2768 | ····[Test] |
2769 | ····public void TestSaveReloadRemove() |
2770 | ····{ |
2771 | ········CreateObjects(); |
2772 | ········QueryOwn(); |
2773 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2774 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2775 | ········ownVar.RemoveRelatedObject(); |
2776 | ········pm.Save(); |
2777 | ········pm.UnloadCache(); |
2778 | ········QueryOwn(); |
2779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2780 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
2781 | ····} |
2782 | ····[Test] |
2783 | ····public void TestRelationHash() |
2784 | ····{ |
2785 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnTblAutoLeft)); |
2786 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
2787 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnTblAutoRight)); |
2788 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
2789 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
2790 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
2791 | ····} |
2792 | ····void CreateObjects() |
2793 | ····{ |
2794 | ········pm.MakePersistent(ownVar); |
2795 | ········ownVar.AssignRelation(otherVar); |
2796 | ········pm.Save(); |
2797 | ········pm.UnloadCache(); |
2798 | ····} |
2799 | ····void QueryOwn() |
2800 | ····{ |
2801 | ········var q = new NDOQuery<CmpBinnTblAutoLeft>(pm); |
2802 | ········ownVar = q.ExecuteSingle(); |
2803 | ····} |
2804 | ····void QueryOther() |
2805 | ····{ |
2806 | ········var q = new NDOQuery<CmpBinnTblAutoRight>(pm); |
2807 | ········otherVar = q.ExecuteSingle(); |
2808 | ····} |
2809 | } |
2810 | |
2811 | |
2812 | [TestFixture] |
2813 | public class TestAgrDir1OwnpconNoTblAuto : NDOTest |
2814 | { |
2815 | ····AgrDir1OwnpconNoTblAutoLeftBase ownVar; |
2816 | ····AgrDir1OwnpconNoTblAutoRight otherVar; |
2817 | ····PersistenceManager pm; |
2818 | ····[SetUp] |
2819 | ····public void Setup() |
2820 | ····{ |
2821 | ········pm = PmFactory.NewPersistenceManager(); |
2822 | ········ownVar = new AgrDir1OwnpconNoTblAutoLeftDerived(); |
2823 | ········otherVar = new AgrDir1OwnpconNoTblAutoRight(); |
2824 | ····} |
2825 | ····[TearDown] |
2826 | ····public void TearDown() |
2827 | ····{ |
2828 | ········try |
2829 | ········{ |
2830 | ············pm.UnloadCache(); |
2831 | ············var l = pm.Objects<AgrDir1OwnpconNoTblAutoLeftBase>().ResultTable; |
2832 | ············pm.Delete(l); |
2833 | ············pm.Save(); |
2834 | ············pm.UnloadCache(); |
2835 | ············var m = pm.Objects<AgrDir1OwnpconNoTblAutoRight>().ResultTable; |
2836 | ············pm.Delete(m); |
2837 | ············pm.Save(); |
2838 | ············pm.UnloadCache(); |
2839 | ············decimal count; |
2840 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2841 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2842 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2843 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2844 | ········} |
2845 | ········catch (Exception) |
2846 | ········{ |
2847 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2848 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2849 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2850 | ········} |
2851 | ····} |
2852 | ····[Test] |
2853 | ····public void TestSaveReload() |
2854 | ····{ |
2855 | ········CreateObjects(); |
2856 | ········QueryOwn(); |
2857 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2858 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2859 | ····} |
2860 | ····[Test] |
2861 | ····public void TestSaveReloadNull() |
2862 | ····{ |
2863 | ········CreateObjects(); |
2864 | ········QueryOwn(); |
2865 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2866 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2867 | ········ownVar.RelField = null; |
2868 | ········pm.Save(); |
2869 | ········pm.UnloadCache(); |
2870 | ········QueryOwn(); |
2871 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2872 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2873 | ····} |
2874 | ····[Test] |
2875 | ····public void TestChangeKeyHolderLeft() |
2876 | ····{ |
2877 | ········CreateObjects(); |
2878 | ········QueryOwn(); |
2879 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2880 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2881 | ········int x = ownVar.RelField.Dummy; |
2882 | ········ownVar.Dummy = 4711; |
2883 | ········pm.Save(); |
2884 | ········pm.UnloadCache(); |
2885 | ········QueryOwn(); |
2886 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2887 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2888 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2889 | ····} |
2890 | ····[Test] |
2891 | ····public void TestChangeKeyHolderLeftNoTouch() |
2892 | ····{ |
2893 | ········CreateObjects(); |
2894 | ········QueryOwn(); |
2895 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2896 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2897 | ········ownVar.Dummy = 4711; |
2898 | ········pm.Save(); |
2899 | ········pm.UnloadCache(); |
2900 | ········QueryOwn(); |
2901 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2902 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
2903 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2904 | ····} |
2905 | ····[Test] |
2906 | ····public void TestUpdateOrder() |
2907 | ····{ |
2908 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
2909 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
2910 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoLeftBase)})) |
2911 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
2912 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoLeftDerived)})) |
2913 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
2914 | ········Debug.WriteLine("AgrDir1OwnpconNoTblAutoLeftBase"); |
2915 | ····} |
2916 | ····void CreateObjects() |
2917 | ····{ |
2918 | ········pm.MakePersistent(ownVar); |
2919 | ········pm.MakePersistent(otherVar); |
2920 | ········ownVar.AssignRelation(otherVar); |
2921 | ········pm.Save(); |
2922 | ········pm.UnloadCache(); |
2923 | ····} |
2924 | ····void QueryOwn() |
2925 | ····{ |
2926 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblAutoLeftBase>(pm); |
2927 | ········ownVar = q.ExecuteSingle(); |
2928 | ····} |
2929 | ····void QueryOther() |
2930 | ····{ |
2931 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblAutoRight>(pm); |
2932 | ········otherVar = q.ExecuteSingle(); |
2933 | ····} |
2934 | } |
2935 | |
2936 | |
2937 | [TestFixture] |
2938 | public class TestAgrDir1OwnpconTblAuto : NDOTest |
2939 | { |
2940 | ····AgrDir1OwnpconTblAutoLeftBase ownVar; |
2941 | ····AgrDir1OwnpconTblAutoRight otherVar; |
2942 | ····PersistenceManager pm; |
2943 | ····[SetUp] |
2944 | ····public void Setup() |
2945 | ····{ |
2946 | ········pm = PmFactory.NewPersistenceManager(); |
2947 | ········ownVar = new AgrDir1OwnpconTblAutoLeftDerived(); |
2948 | ········otherVar = new AgrDir1OwnpconTblAutoRight(); |
2949 | ····} |
2950 | ····[TearDown] |
2951 | ····public void TearDown() |
2952 | ····{ |
2953 | ········try |
2954 | ········{ |
2955 | ············pm.UnloadCache(); |
2956 | ············var l = pm.Objects<AgrDir1OwnpconTblAutoLeftBase>().ResultTable; |
2957 | ············pm.Delete(l); |
2958 | ············pm.Save(); |
2959 | ············pm.UnloadCache(); |
2960 | ············var m = pm.Objects<AgrDir1OwnpconTblAutoRight>().ResultTable; |
2961 | ············pm.Delete(m); |
2962 | ············pm.Save(); |
2963 | ············pm.UnloadCache(); |
2964 | ············decimal count; |
2965 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2966 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
2967 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
2968 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
2969 | ········} |
2970 | ········catch (Exception) |
2971 | ········{ |
2972 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
2973 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
2974 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
2975 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
2976 | ········} |
2977 | ····} |
2978 | ····[Test] |
2979 | ····public void TestSaveReload() |
2980 | ····{ |
2981 | ········CreateObjects(); |
2982 | ········QueryOwn(); |
2983 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2984 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2985 | ····} |
2986 | ····[Test] |
2987 | ····public void TestSaveReloadNull() |
2988 | ····{ |
2989 | ········CreateObjects(); |
2990 | ········QueryOwn(); |
2991 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2992 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
2993 | ········ownVar.RelField = null; |
2994 | ········pm.Save(); |
2995 | ········pm.UnloadCache(); |
2996 | ········QueryOwn(); |
2997 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
2998 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
2999 | ····} |
3000 | ····[Test] |
3001 | ····public void TestChangeKeyHolderLeft() |
3002 | ····{ |
3003 | ········CreateObjects(); |
3004 | ········QueryOwn(); |
3005 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3006 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3007 | ········int x = ownVar.RelField.Dummy; |
3008 | ········ownVar.Dummy = 4711; |
3009 | ········pm.Save(); |
3010 | ········pm.UnloadCache(); |
3011 | ········QueryOwn(); |
3012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3013 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3014 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3015 | ····} |
3016 | ····[Test] |
3017 | ····public void TestChangeKeyHolderLeftNoTouch() |
3018 | ····{ |
3019 | ········CreateObjects(); |
3020 | ········QueryOwn(); |
3021 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3022 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3023 | ········ownVar.Dummy = 4711; |
3024 | ········pm.Save(); |
3025 | ········pm.UnloadCache(); |
3026 | ········QueryOwn(); |
3027 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3028 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3029 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3030 | ····} |
3031 | ····void CreateObjects() |
3032 | ····{ |
3033 | ········pm.MakePersistent(ownVar); |
3034 | ········pm.MakePersistent(otherVar); |
3035 | ········ownVar.AssignRelation(otherVar); |
3036 | ········pm.Save(); |
3037 | ········pm.UnloadCache(); |
3038 | ····} |
3039 | ····void QueryOwn() |
3040 | ····{ |
3041 | ········var q = new NDOQuery<AgrDir1OwnpconTblAutoLeftBase>(pm); |
3042 | ········ownVar = q.ExecuteSingle(); |
3043 | ····} |
3044 | ····void QueryOther() |
3045 | ····{ |
3046 | ········var q = new NDOQuery<AgrDir1OwnpconTblAutoRight>(pm); |
3047 | ········otherVar = q.ExecuteSingle(); |
3048 | ····} |
3049 | } |
3050 | |
3051 | |
3052 | [TestFixture] |
3053 | public class TestAgrBi11OwnpconNoTblAuto : NDOTest |
3054 | { |
3055 | ····AgrBi11OwnpconNoTblAutoLeftBase ownVar; |
3056 | ····AgrBi11OwnpconNoTblAutoRight otherVar; |
3057 | ····PersistenceManager pm; |
3058 | ····[SetUp] |
3059 | ····public void Setup() |
3060 | ····{ |
3061 | ········pm = PmFactory.NewPersistenceManager(); |
3062 | ········ownVar = new AgrBi11OwnpconNoTblAutoLeftDerived(); |
3063 | ········otherVar = new AgrBi11OwnpconNoTblAutoRight(); |
3064 | ····} |
3065 | ····[TearDown] |
3066 | ····public void TearDown() |
3067 | ····{ |
3068 | ········try |
3069 | ········{ |
3070 | ············pm.UnloadCache(); |
3071 | ············var l = pm.Objects<AgrBi11OwnpconNoTblAutoLeftBase>().ResultTable; |
3072 | ············pm.Delete(l); |
3073 | ············pm.Save(); |
3074 | ············pm.UnloadCache(); |
3075 | ············var m = pm.Objects<AgrBi11OwnpconNoTblAutoRight>().ResultTable; |
3076 | ············pm.Delete(m); |
3077 | ············pm.Save(); |
3078 | ············pm.UnloadCache(); |
3079 | ············decimal count; |
3080 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3081 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3082 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3083 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3084 | ········} |
3085 | ········catch (Exception) |
3086 | ········{ |
3087 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3088 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3089 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3090 | ········} |
3091 | ····} |
3092 | ····[Test] |
3093 | ····public void TestSaveReload() |
3094 | ····{ |
3095 | ········CreateObjects(); |
3096 | ········QueryOwn(); |
3097 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3098 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3099 | ····} |
3100 | ····[Test] |
3101 | ····public void TestSaveReloadNull() |
3102 | ····{ |
3103 | ········CreateObjects(); |
3104 | ········QueryOwn(); |
3105 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3106 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3107 | ········ownVar.RelField = null; |
3108 | ········pm.Save(); |
3109 | ········pm.UnloadCache(); |
3110 | ········QueryOwn(); |
3111 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3112 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3113 | ····} |
3114 | ····[Test] |
3115 | ····public void TestChangeKeyHolderLeft() |
3116 | ····{ |
3117 | ········CreateObjects(); |
3118 | ········QueryOwn(); |
3119 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3120 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3121 | ········int x = ownVar.RelField.Dummy; |
3122 | ········ownVar.Dummy = 4711; |
3123 | ········pm.Save(); |
3124 | ········pm.UnloadCache(); |
3125 | ········QueryOwn(); |
3126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3127 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3128 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3129 | ····} |
3130 | ····[Test] |
3131 | ····public void TestChangeKeyHolderRight() |
3132 | ····{ |
3133 | ········CreateObjects(); |
3134 | ········QueryOther(); |
3135 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3136 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3137 | ········int x = otherVar.RelField.Dummy; |
3138 | ········otherVar.Dummy = 4711; |
3139 | ········pm.Save(); |
3140 | ········pm.UnloadCache(); |
3141 | ········QueryOther(); |
3142 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3143 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3144 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3145 | ····} |
3146 | ····[Test] |
3147 | ····public void TestChangeKeyHolderLeftNoTouch() |
3148 | ····{ |
3149 | ········CreateObjects(); |
3150 | ········QueryOwn(); |
3151 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3152 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3153 | ········ownVar.Dummy = 4711; |
3154 | ········pm.Save(); |
3155 | ········pm.UnloadCache(); |
3156 | ········QueryOwn(); |
3157 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3158 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3159 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3160 | ····} |
3161 | ····[Test] |
3162 | ····public void TestChangeKeyHolderRightNoTouch() |
3163 | ····{ |
3164 | ········CreateObjects(); |
3165 | ········QueryOther(); |
3166 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3167 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3168 | ········otherVar.Dummy = 4711; |
3169 | ········pm.Save(); |
3170 | ········pm.UnloadCache(); |
3171 | ········QueryOther(); |
3172 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3173 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3174 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3175 | ····} |
3176 | ····[Test] |
3177 | ····public void TestRelationHash() |
3178 | ····{ |
3179 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoLeftBase)); |
3180 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3181 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoRight)); |
3182 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3183 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3184 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3185 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblAutoLeftDerived)); |
3186 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3187 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3188 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3189 | ····} |
3190 | ····void CreateObjects() |
3191 | ····{ |
3192 | ········pm.MakePersistent(ownVar); |
3193 | ········pm.MakePersistent(otherVar); |
3194 | ········pm.Save(); |
3195 | ········ownVar.AssignRelation(otherVar); |
3196 | ········pm.Save(); |
3197 | ········pm.UnloadCache(); |
3198 | ····} |
3199 | ····void QueryOwn() |
3200 | ····{ |
3201 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblAutoLeftBase>(pm); |
3202 | ········ownVar = q.ExecuteSingle(); |
3203 | ····} |
3204 | ····void QueryOther() |
3205 | ····{ |
3206 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblAutoRight>(pm); |
3207 | ········otherVar = q.ExecuteSingle(); |
3208 | ····} |
3209 | } |
3210 | |
3211 | |
3212 | [TestFixture] |
3213 | public class TestAgrBi11OwnpconTblAuto : NDOTest |
3214 | { |
3215 | ····AgrBi11OwnpconTblAutoLeftBase ownVar; |
3216 | ····AgrBi11OwnpconTblAutoRight otherVar; |
3217 | ····PersistenceManager pm; |
3218 | ····[SetUp] |
3219 | ····public void Setup() |
3220 | ····{ |
3221 | ········pm = PmFactory.NewPersistenceManager(); |
3222 | ········ownVar = new AgrBi11OwnpconTblAutoLeftDerived(); |
3223 | ········otherVar = new AgrBi11OwnpconTblAutoRight(); |
3224 | ····} |
3225 | ····[TearDown] |
3226 | ····public void TearDown() |
3227 | ····{ |
3228 | ········try |
3229 | ········{ |
3230 | ············pm.UnloadCache(); |
3231 | ············var l = pm.Objects<AgrBi11OwnpconTblAutoLeftBase>().ResultTable; |
3232 | ············pm.Delete(l); |
3233 | ············pm.Save(); |
3234 | ············pm.UnloadCache(); |
3235 | ············var m = pm.Objects<AgrBi11OwnpconTblAutoRight>().ResultTable; |
3236 | ············pm.Delete(m); |
3237 | ············pm.Save(); |
3238 | ············pm.UnloadCache(); |
3239 | ············decimal count; |
3240 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3241 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3242 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3243 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3244 | ········} |
3245 | ········catch (Exception) |
3246 | ········{ |
3247 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3248 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3249 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3250 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3251 | ········} |
3252 | ····} |
3253 | ····[Test] |
3254 | ····public void TestSaveReload() |
3255 | ····{ |
3256 | ········CreateObjects(); |
3257 | ········QueryOwn(); |
3258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3259 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3260 | ····} |
3261 | ····[Test] |
3262 | ····public void TestSaveReloadNull() |
3263 | ····{ |
3264 | ········CreateObjects(); |
3265 | ········QueryOwn(); |
3266 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3268 | ········ownVar.RelField = null; |
3269 | ········pm.Save(); |
3270 | ········pm.UnloadCache(); |
3271 | ········QueryOwn(); |
3272 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3273 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3274 | ····} |
3275 | ····[Test] |
3276 | ····public void TestChangeKeyHolderLeft() |
3277 | ····{ |
3278 | ········CreateObjects(); |
3279 | ········QueryOwn(); |
3280 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3281 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3282 | ········int x = ownVar.RelField.Dummy; |
3283 | ········ownVar.Dummy = 4711; |
3284 | ········pm.Save(); |
3285 | ········pm.UnloadCache(); |
3286 | ········QueryOwn(); |
3287 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3288 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3289 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3290 | ····} |
3291 | ····[Test] |
3292 | ····public void TestChangeKeyHolderRight() |
3293 | ····{ |
3294 | ········CreateObjects(); |
3295 | ········QueryOther(); |
3296 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3297 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3298 | ········int x = otherVar.RelField.Dummy; |
3299 | ········otherVar.Dummy = 4711; |
3300 | ········pm.Save(); |
3301 | ········pm.UnloadCache(); |
3302 | ········QueryOther(); |
3303 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3304 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3305 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3306 | ····} |
3307 | ····[Test] |
3308 | ····public void TestChangeKeyHolderLeftNoTouch() |
3309 | ····{ |
3310 | ········CreateObjects(); |
3311 | ········QueryOwn(); |
3312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3313 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3314 | ········ownVar.Dummy = 4711; |
3315 | ········pm.Save(); |
3316 | ········pm.UnloadCache(); |
3317 | ········QueryOwn(); |
3318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3319 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3321 | ····} |
3322 | ····[Test] |
3323 | ····public void TestChangeKeyHolderRightNoTouch() |
3324 | ····{ |
3325 | ········CreateObjects(); |
3326 | ········QueryOther(); |
3327 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3328 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3329 | ········otherVar.Dummy = 4711; |
3330 | ········pm.Save(); |
3331 | ········pm.UnloadCache(); |
3332 | ········QueryOther(); |
3333 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3334 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3335 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3336 | ····} |
3337 | ····[Test] |
3338 | ····public void TestRelationHash() |
3339 | ····{ |
3340 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoLeftBase)); |
3341 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3342 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoRight)); |
3343 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3344 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3345 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3346 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblAutoLeftDerived)); |
3347 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3348 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3349 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3350 | ····} |
3351 | ····void CreateObjects() |
3352 | ····{ |
3353 | ········pm.MakePersistent(ownVar); |
3354 | ········pm.MakePersistent(otherVar); |
3355 | ········pm.Save(); |
3356 | ········ownVar.AssignRelation(otherVar); |
3357 | ········pm.Save(); |
3358 | ········pm.UnloadCache(); |
3359 | ····} |
3360 | ····void QueryOwn() |
3361 | ····{ |
3362 | ········var q = new NDOQuery<AgrBi11OwnpconTblAutoLeftBase>(pm); |
3363 | ········ownVar = q.ExecuteSingle(); |
3364 | ····} |
3365 | ····void QueryOther() |
3366 | ····{ |
3367 | ········var q = new NDOQuery<AgrBi11OwnpconTblAutoRight>(pm); |
3368 | ········otherVar = q.ExecuteSingle(); |
3369 | ····} |
3370 | } |
3371 | |
3372 | |
3373 | [TestFixture] |
3374 | public class TestAgrDirnOwnpconNoTblAuto : NDOTest |
3375 | { |
3376 | ····AgrDirnOwnpconNoTblAutoLeftBase ownVar; |
3377 | ····AgrDirnOwnpconNoTblAutoRight otherVar; |
3378 | ····PersistenceManager pm; |
3379 | ····[SetUp] |
3380 | ····public void Setup() |
3381 | ····{ |
3382 | ········pm = PmFactory.NewPersistenceManager(); |
3383 | ········ownVar = new AgrDirnOwnpconNoTblAutoLeftDerived(); |
3384 | ········otherVar = new AgrDirnOwnpconNoTblAutoRight(); |
3385 | ····} |
3386 | ····[TearDown] |
3387 | ····public void TearDown() |
3388 | ····{ |
3389 | ········try |
3390 | ········{ |
3391 | ············pm.UnloadCache(); |
3392 | ············var l = pm.Objects<AgrDirnOwnpconNoTblAutoLeftBase>().ResultTable; |
3393 | ············pm.Delete(l); |
3394 | ············pm.Save(); |
3395 | ············pm.UnloadCache(); |
3396 | ············var m = pm.Objects<AgrDirnOwnpconNoTblAutoRight>().ResultTable; |
3397 | ············pm.Delete(m); |
3398 | ············pm.Save(); |
3399 | ············pm.UnloadCache(); |
3400 | ············decimal count; |
3401 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3402 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3403 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3404 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3405 | ········} |
3406 | ········catch (Exception) |
3407 | ········{ |
3408 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3409 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3410 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3411 | ········} |
3412 | ····} |
3413 | ····[Test] |
3414 | ····public void TestSaveReload() |
3415 | ····{ |
3416 | ········CreateObjects(); |
3417 | ········QueryOwn(); |
3418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3419 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3420 | ····} |
3421 | ····[Test] |
3422 | ····public void TestSaveReloadNull() |
3423 | ····{ |
3424 | ········CreateObjects(); |
3425 | ········QueryOwn(); |
3426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3427 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3428 | ········ownVar.RelField = new List<AgrDirnOwnpconNoTblAutoRight>(); |
3429 | ········pm.Save(); |
3430 | ········pm.UnloadCache(); |
3431 | ········QueryOwn(); |
3432 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3433 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3434 | ····} |
3435 | ····[Test] |
3436 | ····public void TestSaveReloadRemove() |
3437 | ····{ |
3438 | ········CreateObjects(); |
3439 | ········QueryOwn(); |
3440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3441 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3442 | ········ownVar.RemoveRelatedObject(); |
3443 | ········pm.Save(); |
3444 | ········pm.UnloadCache(); |
3445 | ········QueryOwn(); |
3446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3447 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3448 | ····} |
3449 | ····[Test] |
3450 | ····public void TestUpdateOrder() |
3451 | ····{ |
3452 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
3453 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
3454 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoLeftBase)})) |
3455 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoRight)})), "Wrong order #1"); |
3456 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoLeftDerived)})) |
3457 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpconNoTblAutoRight)})), "Wrong order #2"); |
3458 | ········Debug.WriteLine("AgrDirnOwnpconNoTblAutoLeftBase"); |
3459 | ····} |
3460 | ····void CreateObjects() |
3461 | ····{ |
3462 | ········pm.MakePersistent(ownVar); |
3463 | ········pm.MakePersistent(otherVar); |
3464 | ········ownVar.AssignRelation(otherVar); |
3465 | ········pm.Save(); |
3466 | ········pm.UnloadCache(); |
3467 | ····} |
3468 | ····void QueryOwn() |
3469 | ····{ |
3470 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblAutoLeftBase>(pm); |
3471 | ········ownVar = q.ExecuteSingle(); |
3472 | ····} |
3473 | ····void QueryOther() |
3474 | ····{ |
3475 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblAutoRight>(pm); |
3476 | ········otherVar = q.ExecuteSingle(); |
3477 | ····} |
3478 | } |
3479 | |
3480 | |
3481 | [TestFixture] |
3482 | public class TestAgrDirnOwnpconTblAuto : NDOTest |
3483 | { |
3484 | ····AgrDirnOwnpconTblAutoLeftBase ownVar; |
3485 | ····AgrDirnOwnpconTblAutoRight otherVar; |
3486 | ····PersistenceManager pm; |
3487 | ····[SetUp] |
3488 | ····public void Setup() |
3489 | ····{ |
3490 | ········pm = PmFactory.NewPersistenceManager(); |
3491 | ········ownVar = new AgrDirnOwnpconTblAutoLeftDerived(); |
3492 | ········otherVar = new AgrDirnOwnpconTblAutoRight(); |
3493 | ····} |
3494 | ····[TearDown] |
3495 | ····public void TearDown() |
3496 | ····{ |
3497 | ········try |
3498 | ········{ |
3499 | ············pm.UnloadCache(); |
3500 | ············var l = pm.Objects<AgrDirnOwnpconTblAutoLeftBase>().ResultTable; |
3501 | ············pm.Delete(l); |
3502 | ············pm.Save(); |
3503 | ············pm.UnloadCache(); |
3504 | ············var m = pm.Objects<AgrDirnOwnpconTblAutoRight>().ResultTable; |
3505 | ············pm.Delete(m); |
3506 | ············pm.Save(); |
3507 | ············pm.UnloadCache(); |
3508 | ············decimal count; |
3509 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3510 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3511 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3512 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3513 | ········} |
3514 | ········catch (Exception) |
3515 | ········{ |
3516 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3517 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3518 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3519 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3520 | ········} |
3521 | ····} |
3522 | ····[Test] |
3523 | ····public void TestSaveReload() |
3524 | ····{ |
3525 | ········CreateObjects(); |
3526 | ········QueryOwn(); |
3527 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3528 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3529 | ····} |
3530 | ····[Test] |
3531 | ····public void TestSaveReloadNull() |
3532 | ····{ |
3533 | ········CreateObjects(); |
3534 | ········QueryOwn(); |
3535 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3536 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3537 | ········ownVar.RelField = new List<AgrDirnOwnpconTblAutoRight>(); |
3538 | ········pm.Save(); |
3539 | ········pm.UnloadCache(); |
3540 | ········QueryOwn(); |
3541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3542 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3543 | ····} |
3544 | ····[Test] |
3545 | ····public void TestSaveReloadRemove() |
3546 | ····{ |
3547 | ········CreateObjects(); |
3548 | ········QueryOwn(); |
3549 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3550 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3551 | ········ownVar.RemoveRelatedObject(); |
3552 | ········pm.Save(); |
3553 | ········pm.UnloadCache(); |
3554 | ········QueryOwn(); |
3555 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3556 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3557 | ····} |
3558 | ····void CreateObjects() |
3559 | ····{ |
3560 | ········pm.MakePersistent(ownVar); |
3561 | ········pm.MakePersistent(otherVar); |
3562 | ········ownVar.AssignRelation(otherVar); |
3563 | ········pm.Save(); |
3564 | ········pm.UnloadCache(); |
3565 | ····} |
3566 | ····void QueryOwn() |
3567 | ····{ |
3568 | ········var q = new NDOQuery<AgrDirnOwnpconTblAutoLeftBase>(pm); |
3569 | ········ownVar = q.ExecuteSingle(); |
3570 | ····} |
3571 | ····void QueryOther() |
3572 | ····{ |
3573 | ········var q = new NDOQuery<AgrDirnOwnpconTblAutoRight>(pm); |
3574 | ········otherVar = q.ExecuteSingle(); |
3575 | ····} |
3576 | } |
3577 | |
3578 | |
3579 | [TestFixture] |
3580 | public class TestAgrBin1OwnpconNoTblAuto : NDOTest |
3581 | { |
3582 | ····AgrBin1OwnpconNoTblAutoLeftBase ownVar; |
3583 | ····AgrBin1OwnpconNoTblAutoRight otherVar; |
3584 | ····PersistenceManager pm; |
3585 | ····[SetUp] |
3586 | ····public void Setup() |
3587 | ····{ |
3588 | ········pm = PmFactory.NewPersistenceManager(); |
3589 | ········ownVar = new AgrBin1OwnpconNoTblAutoLeftDerived(); |
3590 | ········otherVar = new AgrBin1OwnpconNoTblAutoRight(); |
3591 | ····} |
3592 | ····[TearDown] |
3593 | ····public void TearDown() |
3594 | ····{ |
3595 | ········try |
3596 | ········{ |
3597 | ············pm.UnloadCache(); |
3598 | ············var l = pm.Objects<AgrBin1OwnpconNoTblAutoLeftBase>().ResultTable; |
3599 | ············pm.Delete(l); |
3600 | ············pm.Save(); |
3601 | ············pm.UnloadCache(); |
3602 | ············var m = pm.Objects<AgrBin1OwnpconNoTblAutoRight>().ResultTable; |
3603 | ············pm.Delete(m); |
3604 | ············pm.Save(); |
3605 | ············pm.UnloadCache(); |
3606 | ············decimal count; |
3607 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3608 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3609 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3610 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3611 | ········} |
3612 | ········catch (Exception) |
3613 | ········{ |
3614 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3615 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3616 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3617 | ········} |
3618 | ····} |
3619 | ····[Test] |
3620 | ····public void TestSaveReload() |
3621 | ····{ |
3622 | ········CreateObjects(); |
3623 | ········QueryOwn(); |
3624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3625 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3626 | ····} |
3627 | ····[Test] |
3628 | ····public void TestSaveReloadNull() |
3629 | ····{ |
3630 | ········CreateObjects(); |
3631 | ········QueryOwn(); |
3632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3633 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3634 | ········ownVar.RelField = new List<AgrBin1OwnpconNoTblAutoRight>(); |
3635 | ········pm.Save(); |
3636 | ········pm.UnloadCache(); |
3637 | ········QueryOwn(); |
3638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3639 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3640 | ····} |
3641 | ····[Test] |
3642 | ····public void TestSaveReloadRemove() |
3643 | ····{ |
3644 | ········CreateObjects(); |
3645 | ········QueryOwn(); |
3646 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3647 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3648 | ········ownVar.RemoveRelatedObject(); |
3649 | ········pm.Save(); |
3650 | ········pm.UnloadCache(); |
3651 | ········QueryOwn(); |
3652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3653 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3654 | ····} |
3655 | ····[Test] |
3656 | ····public void TestChangeKeyHolderRight() |
3657 | ····{ |
3658 | ········CreateObjects(); |
3659 | ········QueryOther(); |
3660 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3661 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3662 | ········int x = otherVar.RelField.Dummy; |
3663 | ········otherVar.Dummy = 4711; |
3664 | ········pm.Save(); |
3665 | ········pm.UnloadCache(); |
3666 | ········QueryOther(); |
3667 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3668 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3669 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3670 | ····} |
3671 | ····[Test] |
3672 | ····public void TestChangeKeyHolderRightNoTouch() |
3673 | ····{ |
3674 | ········CreateObjects(); |
3675 | ········QueryOther(); |
3676 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3677 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3678 | ········otherVar.Dummy = 4711; |
3679 | ········pm.Save(); |
3680 | ········pm.UnloadCache(); |
3681 | ········QueryOther(); |
3682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3683 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3684 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3685 | ····} |
3686 | ····[Test] |
3687 | ····public void TestUpdateOrder() |
3688 | ····{ |
3689 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
3690 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
3691 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoLeftBase)})) |
3692 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
3693 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoLeftDerived)})) |
3694 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
3695 | ········Debug.WriteLine("AgrBin1OwnpconNoTblAutoLeftBase"); |
3696 | ····} |
3697 | ····[Test] |
3698 | ····public void TestRelationHash() |
3699 | ····{ |
3700 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoLeftBase)); |
3701 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3702 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoRight)); |
3703 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3704 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3705 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3706 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblAutoLeftDerived)); |
3707 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3708 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3709 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3710 | ····} |
3711 | ····void CreateObjects() |
3712 | ····{ |
3713 | ········pm.MakePersistent(ownVar); |
3714 | ········pm.MakePersistent(otherVar); |
3715 | ········pm.Save(); |
3716 | ········ownVar.AssignRelation(otherVar); |
3717 | ········pm.Save(); |
3718 | ········pm.UnloadCache(); |
3719 | ····} |
3720 | ····void QueryOwn() |
3721 | ····{ |
3722 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblAutoLeftBase>(pm); |
3723 | ········ownVar = q.ExecuteSingle(); |
3724 | ····} |
3725 | ····void QueryOther() |
3726 | ····{ |
3727 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblAutoRight>(pm); |
3728 | ········otherVar = q.ExecuteSingle(); |
3729 | ····} |
3730 | } |
3731 | |
3732 | |
3733 | [TestFixture] |
3734 | public class TestAgrBin1OwnpconTblAuto : NDOTest |
3735 | { |
3736 | ····AgrBin1OwnpconTblAutoLeftBase ownVar; |
3737 | ····AgrBin1OwnpconTblAutoRight otherVar; |
3738 | ····PersistenceManager pm; |
3739 | ····[SetUp] |
3740 | ····public void Setup() |
3741 | ····{ |
3742 | ········pm = PmFactory.NewPersistenceManager(); |
3743 | ········ownVar = new AgrBin1OwnpconTblAutoLeftDerived(); |
3744 | ········otherVar = new AgrBin1OwnpconTblAutoRight(); |
3745 | ····} |
3746 | ····[TearDown] |
3747 | ····public void TearDown() |
3748 | ····{ |
3749 | ········try |
3750 | ········{ |
3751 | ············pm.UnloadCache(); |
3752 | ············var l = pm.Objects<AgrBin1OwnpconTblAutoLeftBase>().ResultTable; |
3753 | ············pm.Delete(l); |
3754 | ············pm.Save(); |
3755 | ············pm.UnloadCache(); |
3756 | ············var m = pm.Objects<AgrBin1OwnpconTblAutoRight>().ResultTable; |
3757 | ············pm.Delete(m); |
3758 | ············pm.Save(); |
3759 | ············pm.UnloadCache(); |
3760 | ············decimal count; |
3761 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3763 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3764 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3765 | ········} |
3766 | ········catch (Exception) |
3767 | ········{ |
3768 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3769 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3770 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3771 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3772 | ········} |
3773 | ····} |
3774 | ····[Test] |
3775 | ····public void TestSaveReload() |
3776 | ····{ |
3777 | ········CreateObjects(); |
3778 | ········QueryOwn(); |
3779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3780 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3781 | ····} |
3782 | ····[Test] |
3783 | ····public void TestSaveReloadNull() |
3784 | ····{ |
3785 | ········CreateObjects(); |
3786 | ········QueryOwn(); |
3787 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3788 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3789 | ········ownVar.RelField = new List<AgrBin1OwnpconTblAutoRight>(); |
3790 | ········pm.Save(); |
3791 | ········pm.UnloadCache(); |
3792 | ········QueryOwn(); |
3793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3794 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3795 | ····} |
3796 | ····[Test] |
3797 | ····public void TestSaveReloadRemove() |
3798 | ····{ |
3799 | ········CreateObjects(); |
3800 | ········QueryOwn(); |
3801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3802 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3803 | ········ownVar.RemoveRelatedObject(); |
3804 | ········pm.Save(); |
3805 | ········pm.UnloadCache(); |
3806 | ········QueryOwn(); |
3807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3808 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
3809 | ····} |
3810 | ····[Test] |
3811 | ····public void TestChangeKeyHolderRight() |
3812 | ····{ |
3813 | ········CreateObjects(); |
3814 | ········QueryOther(); |
3815 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3816 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3817 | ········int x = otherVar.RelField.Dummy; |
3818 | ········otherVar.Dummy = 4711; |
3819 | ········pm.Save(); |
3820 | ········pm.UnloadCache(); |
3821 | ········QueryOther(); |
3822 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3823 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3824 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3825 | ····} |
3826 | ····[Test] |
3827 | ····public void TestChangeKeyHolderRightNoTouch() |
3828 | ····{ |
3829 | ········CreateObjects(); |
3830 | ········QueryOther(); |
3831 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3832 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3833 | ········otherVar.Dummy = 4711; |
3834 | ········pm.Save(); |
3835 | ········pm.UnloadCache(); |
3836 | ········QueryOther(); |
3837 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
3838 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3839 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
3840 | ····} |
3841 | ····[Test] |
3842 | ····public void TestRelationHash() |
3843 | ····{ |
3844 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoLeftBase)); |
3845 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3846 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoRight)); |
3847 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3848 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3849 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3850 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblAutoLeftDerived)); |
3851 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3852 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3853 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3854 | ····} |
3855 | ····void CreateObjects() |
3856 | ····{ |
3857 | ········pm.MakePersistent(ownVar); |
3858 | ········pm.MakePersistent(otherVar); |
3859 | ········pm.Save(); |
3860 | ········ownVar.AssignRelation(otherVar); |
3861 | ········pm.Save(); |
3862 | ········pm.UnloadCache(); |
3863 | ····} |
3864 | ····void QueryOwn() |
3865 | ····{ |
3866 | ········var q = new NDOQuery<AgrBin1OwnpconTblAutoLeftBase>(pm); |
3867 | ········ownVar = q.ExecuteSingle(); |
3868 | ····} |
3869 | ····void QueryOther() |
3870 | ····{ |
3871 | ········var q = new NDOQuery<AgrBin1OwnpconTblAutoRight>(pm); |
3872 | ········otherVar = q.ExecuteSingle(); |
3873 | ····} |
3874 | } |
3875 | |
3876 | |
3877 | [TestFixture] |
3878 | public class TestAgrBi1nOwnpconTblAuto : NDOTest |
3879 | { |
3880 | ····AgrBi1nOwnpconTblAutoLeftBase ownVar; |
3881 | ····AgrBi1nOwnpconTblAutoRight otherVar; |
3882 | ····PersistenceManager pm; |
3883 | ····[SetUp] |
3884 | ····public void Setup() |
3885 | ····{ |
3886 | ········pm = PmFactory.NewPersistenceManager(); |
3887 | ········ownVar = new AgrBi1nOwnpconTblAutoLeftDerived(); |
3888 | ········otherVar = new AgrBi1nOwnpconTblAutoRight(); |
3889 | ····} |
3890 | ····[TearDown] |
3891 | ····public void TearDown() |
3892 | ····{ |
3893 | ········try |
3894 | ········{ |
3895 | ············pm.UnloadCache(); |
3896 | ············var l = pm.Objects<AgrBi1nOwnpconTblAutoLeftBase>().ResultTable; |
3897 | ············pm.Delete(l); |
3898 | ············pm.Save(); |
3899 | ············pm.UnloadCache(); |
3900 | ············var m = pm.Objects<AgrBi1nOwnpconTblAutoRight>().ResultTable; |
3901 | ············pm.Delete(m); |
3902 | ············pm.Save(); |
3903 | ············pm.UnloadCache(); |
3904 | ············decimal count; |
3905 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3906 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
3907 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
3908 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
3909 | ········} |
3910 | ········catch (Exception) |
3911 | ········{ |
3912 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
3913 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
3914 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
3915 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
3916 | ········} |
3917 | ····} |
3918 | ····[Test] |
3919 | ····public void TestSaveReload() |
3920 | ····{ |
3921 | ········CreateObjects(); |
3922 | ········QueryOwn(); |
3923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3924 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3925 | ····} |
3926 | ····[Test] |
3927 | ····public void TestSaveReloadNull() |
3928 | ····{ |
3929 | ········CreateObjects(); |
3930 | ········QueryOwn(); |
3931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3932 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3933 | ········ownVar.RelField = null; |
3934 | ········pm.Save(); |
3935 | ········pm.UnloadCache(); |
3936 | ········QueryOwn(); |
3937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3938 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
3939 | ····} |
3940 | ····[Test] |
3941 | ····public void TestChangeKeyHolderLeft() |
3942 | ····{ |
3943 | ········CreateObjects(); |
3944 | ········QueryOwn(); |
3945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3947 | ········int x = ownVar.RelField.Dummy; |
3948 | ········ownVar.Dummy = 4711; |
3949 | ········pm.Save(); |
3950 | ········pm.UnloadCache(); |
3951 | ········QueryOwn(); |
3952 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3953 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3954 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3955 | ····} |
3956 | ····[Test] |
3957 | ····public void TestChangeKeyHolderLeftNoTouch() |
3958 | ····{ |
3959 | ········CreateObjects(); |
3960 | ········QueryOwn(); |
3961 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3962 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3963 | ········ownVar.Dummy = 4711; |
3964 | ········pm.Save(); |
3965 | ········pm.UnloadCache(); |
3966 | ········QueryOwn(); |
3967 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
3968 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
3969 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
3970 | ····} |
3971 | ····[Test] |
3972 | ····public void TestRelationHash() |
3973 | ····{ |
3974 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoLeftBase)); |
3975 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
3976 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoRight)); |
3977 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
3978 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
3979 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
3980 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblAutoLeftDerived)); |
3981 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
3982 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
3983 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
3984 | ····} |
3985 | ····void CreateObjects() |
3986 | ····{ |
3987 | ········pm.MakePersistent(ownVar); |
3988 | ········pm.MakePersistent(otherVar); |
3989 | ········ownVar.AssignRelation(otherVar); |
3990 | ········pm.Save(); |
3991 | ········pm.UnloadCache(); |
3992 | ····} |
3993 | ····void QueryOwn() |
3994 | ····{ |
3995 | ········var q = new NDOQuery<AgrBi1nOwnpconTblAutoLeftBase>(pm); |
3996 | ········ownVar = q.ExecuteSingle(); |
3997 | ····} |
3998 | ····void QueryOther() |
3999 | ····{ |
4000 | ········var q = new NDOQuery<AgrBi1nOwnpconTblAutoRight>(pm); |
4001 | ········otherVar = q.ExecuteSingle(); |
4002 | ····} |
4003 | } |
4004 | |
4005 | |
4006 | [TestFixture] |
4007 | public class TestAgrBinnOwnpconTblAuto : NDOTest |
4008 | { |
4009 | ····AgrBinnOwnpconTblAutoLeftBase ownVar; |
4010 | ····AgrBinnOwnpconTblAutoRight otherVar; |
4011 | ····PersistenceManager pm; |
4012 | ····[SetUp] |
4013 | ····public void Setup() |
4014 | ····{ |
4015 | ········pm = PmFactory.NewPersistenceManager(); |
4016 | ········ownVar = new AgrBinnOwnpconTblAutoLeftDerived(); |
4017 | ········otherVar = new AgrBinnOwnpconTblAutoRight(); |
4018 | ····} |
4019 | ····[TearDown] |
4020 | ····public void TearDown() |
4021 | ····{ |
4022 | ········try |
4023 | ········{ |
4024 | ············pm.UnloadCache(); |
4025 | ············var l = pm.Objects<AgrBinnOwnpconTblAutoLeftBase>().ResultTable; |
4026 | ············pm.Delete(l); |
4027 | ············pm.Save(); |
4028 | ············pm.UnloadCache(); |
4029 | ············var m = pm.Objects<AgrBinnOwnpconTblAutoRight>().ResultTable; |
4030 | ············pm.Delete(m); |
4031 | ············pm.Save(); |
4032 | ············pm.UnloadCache(); |
4033 | ············decimal count; |
4034 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4035 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4036 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4037 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4038 | ········} |
4039 | ········catch (Exception) |
4040 | ········{ |
4041 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4042 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4043 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4044 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4045 | ········} |
4046 | ····} |
4047 | ····[Test] |
4048 | ····public void TestSaveReload() |
4049 | ····{ |
4050 | ········CreateObjects(); |
4051 | ········QueryOwn(); |
4052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4053 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4054 | ····} |
4055 | ····[Test] |
4056 | ····public void TestSaveReloadNull() |
4057 | ····{ |
4058 | ········CreateObjects(); |
4059 | ········QueryOwn(); |
4060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4061 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4062 | ········ownVar.RelField = new List<AgrBinnOwnpconTblAutoRight>(); |
4063 | ········pm.Save(); |
4064 | ········pm.UnloadCache(); |
4065 | ········QueryOwn(); |
4066 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4067 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4068 | ····} |
4069 | ····[Test] |
4070 | ····public void TestSaveReloadRemove() |
4071 | ····{ |
4072 | ········CreateObjects(); |
4073 | ········QueryOwn(); |
4074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4075 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4076 | ········ownVar.RemoveRelatedObject(); |
4077 | ········pm.Save(); |
4078 | ········pm.UnloadCache(); |
4079 | ········QueryOwn(); |
4080 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4081 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4082 | ····} |
4083 | ····[Test] |
4084 | ····public void TestRelationHash() |
4085 | ····{ |
4086 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoLeftBase)); |
4087 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4088 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoRight)); |
4089 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4090 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4091 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4092 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblAutoLeftDerived)); |
4093 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4094 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4095 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4096 | ····} |
4097 | ····void CreateObjects() |
4098 | ····{ |
4099 | ········pm.MakePersistent(ownVar); |
4100 | ········pm.MakePersistent(otherVar); |
4101 | ········ownVar.AssignRelation(otherVar); |
4102 | ········pm.Save(); |
4103 | ········pm.UnloadCache(); |
4104 | ····} |
4105 | ····void QueryOwn() |
4106 | ····{ |
4107 | ········var q = new NDOQuery<AgrBinnOwnpconTblAutoLeftBase>(pm); |
4108 | ········ownVar = q.ExecuteSingle(); |
4109 | ····} |
4110 | ····void QueryOther() |
4111 | ····{ |
4112 | ········var q = new NDOQuery<AgrBinnOwnpconTblAutoRight>(pm); |
4113 | ········otherVar = q.ExecuteSingle(); |
4114 | ····} |
4115 | } |
4116 | |
4117 | |
4118 | [TestFixture] |
4119 | public class TestCmpDir1OwnpconNoTblAuto : NDOTest |
4120 | { |
4121 | ····CmpDir1OwnpconNoTblAutoLeftBase ownVar; |
4122 | ····CmpDir1OwnpconNoTblAutoRight otherVar; |
4123 | ····PersistenceManager pm; |
4124 | ····[SetUp] |
4125 | ····public void Setup() |
4126 | ····{ |
4127 | ········pm = PmFactory.NewPersistenceManager(); |
4128 | ········ownVar = new CmpDir1OwnpconNoTblAutoLeftDerived(); |
4129 | ········otherVar = new CmpDir1OwnpconNoTblAutoRight(); |
4130 | ····} |
4131 | ····[TearDown] |
4132 | ····public void TearDown() |
4133 | ····{ |
4134 | ········try |
4135 | ········{ |
4136 | ············pm.UnloadCache(); |
4137 | ············var l = pm.Objects<CmpDir1OwnpconNoTblAutoLeftBase>().ResultTable; |
4138 | ············pm.Delete(l); |
4139 | ············pm.Save(); |
4140 | ············pm.UnloadCache(); |
4141 | ············decimal count; |
4142 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4143 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4144 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4145 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4146 | ········} |
4147 | ········catch (Exception) |
4148 | ········{ |
4149 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4150 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4151 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4152 | ········} |
4153 | ····} |
4154 | ····[Test] |
4155 | ····public void TestSaveReload() |
4156 | ····{ |
4157 | ········CreateObjects(); |
4158 | ········QueryOwn(); |
4159 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4160 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4161 | ····} |
4162 | ····[Test] |
4163 | ····public void TestSaveReloadNull() |
4164 | ····{ |
4165 | ········CreateObjects(); |
4166 | ········QueryOwn(); |
4167 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4168 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4169 | ········ownVar.RelField = null; |
4170 | ········pm.Save(); |
4171 | ········pm.UnloadCache(); |
4172 | ········QueryOwn(); |
4173 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4174 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4175 | ····} |
4176 | ····[Test] |
4177 | ····public void TestChangeKeyHolderLeft() |
4178 | ····{ |
4179 | ········CreateObjects(); |
4180 | ········QueryOwn(); |
4181 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4182 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4183 | ········int x = ownVar.RelField.Dummy; |
4184 | ········ownVar.Dummy = 4711; |
4185 | ········pm.Save(); |
4186 | ········pm.UnloadCache(); |
4187 | ········QueryOwn(); |
4188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4189 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4190 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4191 | ····} |
4192 | ····[Test] |
4193 | ····public void TestChangeKeyHolderLeftNoTouch() |
4194 | ····{ |
4195 | ········CreateObjects(); |
4196 | ········QueryOwn(); |
4197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4198 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4199 | ········ownVar.Dummy = 4711; |
4200 | ········pm.Save(); |
4201 | ········pm.UnloadCache(); |
4202 | ········QueryOwn(); |
4203 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4204 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4205 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4206 | ····} |
4207 | ····[Test] |
4208 | ····public void TestUpdateOrder() |
4209 | ····{ |
4210 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4211 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4212 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoLeftBase)})) |
4213 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
4214 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoLeftDerived)})) |
4215 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
4216 | ········Debug.WriteLine("CmpDir1OwnpconNoTblAutoLeftBase"); |
4217 | ····} |
4218 | ····void CreateObjects() |
4219 | ····{ |
4220 | ········pm.MakePersistent(ownVar); |
4221 | ········pm.Save(); |
4222 | ········ownVar.AssignRelation(otherVar); |
4223 | ········pm.Save(); |
4224 | ········pm.UnloadCache(); |
4225 | ····} |
4226 | ····void QueryOwn() |
4227 | ····{ |
4228 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblAutoLeftBase>(pm); |
4229 | ········ownVar = q.ExecuteSingle(); |
4230 | ····} |
4231 | ····void QueryOther() |
4232 | ····{ |
4233 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblAutoRight>(pm); |
4234 | ········otherVar = q.ExecuteSingle(); |
4235 | ····} |
4236 | } |
4237 | |
4238 | |
4239 | [TestFixture] |
4240 | public class TestCmpDir1OwnpconTblAuto : NDOTest |
4241 | { |
4242 | ····CmpDir1OwnpconTblAutoLeftBase ownVar; |
4243 | ····CmpDir1OwnpconTblAutoRight otherVar; |
4244 | ····PersistenceManager pm; |
4245 | ····[SetUp] |
4246 | ····public void Setup() |
4247 | ····{ |
4248 | ········pm = PmFactory.NewPersistenceManager(); |
4249 | ········ownVar = new CmpDir1OwnpconTblAutoLeftDerived(); |
4250 | ········otherVar = new CmpDir1OwnpconTblAutoRight(); |
4251 | ····} |
4252 | ····[TearDown] |
4253 | ····public void TearDown() |
4254 | ····{ |
4255 | ········try |
4256 | ········{ |
4257 | ············pm.UnloadCache(); |
4258 | ············var l = pm.Objects<CmpDir1OwnpconTblAutoLeftBase>().ResultTable; |
4259 | ············pm.Delete(l); |
4260 | ············pm.Save(); |
4261 | ············pm.UnloadCache(); |
4262 | ············decimal count; |
4263 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4264 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4265 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4266 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4267 | ········} |
4268 | ········catch (Exception) |
4269 | ········{ |
4270 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4271 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4272 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4273 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4274 | ········} |
4275 | ····} |
4276 | ····[Test] |
4277 | ····public void TestSaveReload() |
4278 | ····{ |
4279 | ········CreateObjects(); |
4280 | ········QueryOwn(); |
4281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4282 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4283 | ····} |
4284 | ····[Test] |
4285 | ····public void TestSaveReloadNull() |
4286 | ····{ |
4287 | ········CreateObjects(); |
4288 | ········QueryOwn(); |
4289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4290 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4291 | ········ownVar.RelField = null; |
4292 | ········pm.Save(); |
4293 | ········pm.UnloadCache(); |
4294 | ········QueryOwn(); |
4295 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4296 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4297 | ····} |
4298 | ····[Test] |
4299 | ····public void TestChangeKeyHolderLeft() |
4300 | ····{ |
4301 | ········CreateObjects(); |
4302 | ········QueryOwn(); |
4303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4304 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4305 | ········int x = ownVar.RelField.Dummy; |
4306 | ········ownVar.Dummy = 4711; |
4307 | ········pm.Save(); |
4308 | ········pm.UnloadCache(); |
4309 | ········QueryOwn(); |
4310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4311 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4312 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4313 | ····} |
4314 | ····[Test] |
4315 | ····public void TestChangeKeyHolderLeftNoTouch() |
4316 | ····{ |
4317 | ········CreateObjects(); |
4318 | ········QueryOwn(); |
4319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4321 | ········ownVar.Dummy = 4711; |
4322 | ········pm.Save(); |
4323 | ········pm.UnloadCache(); |
4324 | ········QueryOwn(); |
4325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4326 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4327 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4328 | ····} |
4329 | ····void CreateObjects() |
4330 | ····{ |
4331 | ········pm.MakePersistent(ownVar); |
4332 | ········ownVar.AssignRelation(otherVar); |
4333 | ········pm.Save(); |
4334 | ········pm.UnloadCache(); |
4335 | ····} |
4336 | ····void QueryOwn() |
4337 | ····{ |
4338 | ········var q = new NDOQuery<CmpDir1OwnpconTblAutoLeftBase>(pm); |
4339 | ········ownVar = q.ExecuteSingle(); |
4340 | ····} |
4341 | ····void QueryOther() |
4342 | ····{ |
4343 | ········var q = new NDOQuery<CmpDir1OwnpconTblAutoRight>(pm); |
4344 | ········otherVar = q.ExecuteSingle(); |
4345 | ····} |
4346 | } |
4347 | |
4348 | |
4349 | [TestFixture] |
4350 | public class TestCmpBi11OwnpconNoTblAuto : NDOTest |
4351 | { |
4352 | ····CmpBi11OwnpconNoTblAutoLeftBase ownVar; |
4353 | ····CmpBi11OwnpconNoTblAutoRight otherVar; |
4354 | ····PersistenceManager pm; |
4355 | ····[SetUp] |
4356 | ····public void Setup() |
4357 | ····{ |
4358 | ········pm = PmFactory.NewPersistenceManager(); |
4359 | ········ownVar = new CmpBi11OwnpconNoTblAutoLeftDerived(); |
4360 | ········otherVar = new CmpBi11OwnpconNoTblAutoRight(); |
4361 | ····} |
4362 | ····[TearDown] |
4363 | ····public void TearDown() |
4364 | ····{ |
4365 | ········try |
4366 | ········{ |
4367 | ············pm.UnloadCache(); |
4368 | ············var l = pm.Objects<CmpBi11OwnpconNoTblAutoLeftBase>().ResultTable; |
4369 | ············pm.Delete(l); |
4370 | ············pm.Save(); |
4371 | ············pm.UnloadCache(); |
4372 | ············decimal count; |
4373 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4374 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4375 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4376 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4377 | ········} |
4378 | ········catch (Exception) |
4379 | ········{ |
4380 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4382 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4383 | ········} |
4384 | ····} |
4385 | ····[Test] |
4386 | ····public void TestSaveReload() |
4387 | ····{ |
4388 | ········CreateObjects(); |
4389 | ········QueryOwn(); |
4390 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4391 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4392 | ····} |
4393 | ····[Test] |
4394 | ····public void TestSaveReloadNull() |
4395 | ····{ |
4396 | ········CreateObjects(); |
4397 | ········QueryOwn(); |
4398 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4399 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4400 | ········ownVar.RelField = null; |
4401 | ········pm.Save(); |
4402 | ········pm.UnloadCache(); |
4403 | ········QueryOwn(); |
4404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4405 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4406 | ····} |
4407 | ····[Test] |
4408 | ····public void TestChangeKeyHolderLeft() |
4409 | ····{ |
4410 | ········CreateObjects(); |
4411 | ········QueryOwn(); |
4412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4413 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4414 | ········int x = ownVar.RelField.Dummy; |
4415 | ········ownVar.Dummy = 4711; |
4416 | ········pm.Save(); |
4417 | ········pm.UnloadCache(); |
4418 | ········QueryOwn(); |
4419 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4420 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4422 | ····} |
4423 | ····[Test] |
4424 | ····public void TestChangeKeyHolderRight() |
4425 | ····{ |
4426 | ········CreateObjects(); |
4427 | ········QueryOther(); |
4428 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4429 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4430 | ········int x = otherVar.RelField.Dummy; |
4431 | ········otherVar.Dummy = 4711; |
4432 | ········pm.Save(); |
4433 | ········pm.UnloadCache(); |
4434 | ········QueryOther(); |
4435 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4436 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4437 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4438 | ····} |
4439 | ····[Test] |
4440 | ····public void TestChangeKeyHolderLeftNoTouch() |
4441 | ····{ |
4442 | ········CreateObjects(); |
4443 | ········QueryOwn(); |
4444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4445 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4446 | ········ownVar.Dummy = 4711; |
4447 | ········pm.Save(); |
4448 | ········pm.UnloadCache(); |
4449 | ········QueryOwn(); |
4450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4451 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4452 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4453 | ····} |
4454 | ····[Test] |
4455 | ····public void TestChangeKeyHolderRightNoTouch() |
4456 | ····{ |
4457 | ········CreateObjects(); |
4458 | ········QueryOther(); |
4459 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4460 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4461 | ········otherVar.Dummy = 4711; |
4462 | ········pm.Save(); |
4463 | ········pm.UnloadCache(); |
4464 | ········QueryOther(); |
4465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4468 | ····} |
4469 | ····[Test] |
4470 | ····public void TestRelationHash() |
4471 | ····{ |
4472 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoLeftBase)); |
4473 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4474 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoRight)); |
4475 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4476 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4477 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4478 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblAutoLeftDerived)); |
4479 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4480 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4481 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4482 | ····} |
4483 | ····void CreateObjects() |
4484 | ····{ |
4485 | ········pm.MakePersistent(ownVar); |
4486 | ········pm.Save(); |
4487 | ········ownVar.AssignRelation(otherVar); |
4488 | ········pm.Save(); |
4489 | ········pm.UnloadCache(); |
4490 | ····} |
4491 | ····void QueryOwn() |
4492 | ····{ |
4493 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblAutoLeftBase>(pm); |
4494 | ········ownVar = q.ExecuteSingle(); |
4495 | ····} |
4496 | ····void QueryOther() |
4497 | ····{ |
4498 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblAutoRight>(pm); |
4499 | ········otherVar = q.ExecuteSingle(); |
4500 | ····} |
4501 | } |
4502 | |
4503 | |
4504 | [TestFixture] |
4505 | public class TestCmpBi11OwnpconTblAuto : NDOTest |
4506 | { |
4507 | ····CmpBi11OwnpconTblAutoLeftBase ownVar; |
4508 | ····CmpBi11OwnpconTblAutoRight otherVar; |
4509 | ····PersistenceManager pm; |
4510 | ····[SetUp] |
4511 | ····public void Setup() |
4512 | ····{ |
4513 | ········pm = PmFactory.NewPersistenceManager(); |
4514 | ········ownVar = new CmpBi11OwnpconTblAutoLeftDerived(); |
4515 | ········otherVar = new CmpBi11OwnpconTblAutoRight(); |
4516 | ····} |
4517 | ····[TearDown] |
4518 | ····public void TearDown() |
4519 | ····{ |
4520 | ········try |
4521 | ········{ |
4522 | ············pm.UnloadCache(); |
4523 | ············var l = pm.Objects<CmpBi11OwnpconTblAutoLeftBase>().ResultTable; |
4524 | ············pm.Delete(l); |
4525 | ············pm.Save(); |
4526 | ············pm.UnloadCache(); |
4527 | ············decimal count; |
4528 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4529 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4530 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4532 | ········} |
4533 | ········catch (Exception) |
4534 | ········{ |
4535 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4537 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4538 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4539 | ········} |
4540 | ····} |
4541 | ····[Test] |
4542 | ····public void TestSaveReload() |
4543 | ····{ |
4544 | ········CreateObjects(); |
4545 | ········QueryOwn(); |
4546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4547 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4548 | ····} |
4549 | ····[Test] |
4550 | ····public void TestSaveReloadNull() |
4551 | ····{ |
4552 | ········CreateObjects(); |
4553 | ········QueryOwn(); |
4554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4555 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4556 | ········ownVar.RelField = null; |
4557 | ········pm.Save(); |
4558 | ········pm.UnloadCache(); |
4559 | ········QueryOwn(); |
4560 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4561 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
4562 | ····} |
4563 | ····[Test] |
4564 | ····public void TestChangeKeyHolderLeft() |
4565 | ····{ |
4566 | ········CreateObjects(); |
4567 | ········QueryOwn(); |
4568 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4569 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4570 | ········int x = ownVar.RelField.Dummy; |
4571 | ········ownVar.Dummy = 4711; |
4572 | ········pm.Save(); |
4573 | ········pm.UnloadCache(); |
4574 | ········QueryOwn(); |
4575 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4576 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4577 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4578 | ····} |
4579 | ····[Test] |
4580 | ····public void TestChangeKeyHolderRight() |
4581 | ····{ |
4582 | ········CreateObjects(); |
4583 | ········QueryOther(); |
4584 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4585 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4586 | ········int x = otherVar.RelField.Dummy; |
4587 | ········otherVar.Dummy = 4711; |
4588 | ········pm.Save(); |
4589 | ········pm.UnloadCache(); |
4590 | ········QueryOther(); |
4591 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4592 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4593 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4594 | ····} |
4595 | ····[Test] |
4596 | ····public void TestChangeKeyHolderLeftNoTouch() |
4597 | ····{ |
4598 | ········CreateObjects(); |
4599 | ········QueryOwn(); |
4600 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4601 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4602 | ········ownVar.Dummy = 4711; |
4603 | ········pm.Save(); |
4604 | ········pm.UnloadCache(); |
4605 | ········QueryOwn(); |
4606 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4607 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4608 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
4609 | ····} |
4610 | ····[Test] |
4611 | ····public void TestChangeKeyHolderRightNoTouch() |
4612 | ····{ |
4613 | ········CreateObjects(); |
4614 | ········QueryOther(); |
4615 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4616 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4617 | ········otherVar.Dummy = 4711; |
4618 | ········pm.Save(); |
4619 | ········pm.UnloadCache(); |
4620 | ········QueryOther(); |
4621 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4622 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4623 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4624 | ····} |
4625 | ····[Test] |
4626 | ····public void TestRelationHash() |
4627 | ····{ |
4628 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoLeftBase)); |
4629 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4630 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoRight)); |
4631 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4632 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4633 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4634 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblAutoLeftDerived)); |
4635 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4636 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4637 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4638 | ····} |
4639 | ····void CreateObjects() |
4640 | ····{ |
4641 | ········pm.MakePersistent(ownVar); |
4642 | ········ownVar.AssignRelation(otherVar); |
4643 | ········pm.Save(); |
4644 | ········pm.UnloadCache(); |
4645 | ····} |
4646 | ····void QueryOwn() |
4647 | ····{ |
4648 | ········var q = new NDOQuery<CmpBi11OwnpconTblAutoLeftBase>(pm); |
4649 | ········ownVar = q.ExecuteSingle(); |
4650 | ····} |
4651 | ····void QueryOther() |
4652 | ····{ |
4653 | ········var q = new NDOQuery<CmpBi11OwnpconTblAutoRight>(pm); |
4654 | ········otherVar = q.ExecuteSingle(); |
4655 | ····} |
4656 | } |
4657 | |
4658 | |
4659 | [TestFixture] |
4660 | public class TestCmpDirnOwnpconNoTblAuto : NDOTest |
4661 | { |
4662 | ····CmpDirnOwnpconNoTblAutoLeftBase ownVar; |
4663 | ····CmpDirnOwnpconNoTblAutoRight otherVar; |
4664 | ····PersistenceManager pm; |
4665 | ····[SetUp] |
4666 | ····public void Setup() |
4667 | ····{ |
4668 | ········pm = PmFactory.NewPersistenceManager(); |
4669 | ········ownVar = new CmpDirnOwnpconNoTblAutoLeftDerived(); |
4670 | ········otherVar = new CmpDirnOwnpconNoTblAutoRight(); |
4671 | ····} |
4672 | ····[TearDown] |
4673 | ····public void TearDown() |
4674 | ····{ |
4675 | ········try |
4676 | ········{ |
4677 | ············pm.UnloadCache(); |
4678 | ············var l = pm.Objects<CmpDirnOwnpconNoTblAutoLeftBase>().ResultTable; |
4679 | ············pm.Delete(l); |
4680 | ············pm.Save(); |
4681 | ············pm.UnloadCache(); |
4682 | ············decimal count; |
4683 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4684 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4685 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4686 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4687 | ········} |
4688 | ········catch (Exception) |
4689 | ········{ |
4690 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4691 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4692 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4693 | ········} |
4694 | ····} |
4695 | ····[Test] |
4696 | ····public void TestSaveReload() |
4697 | ····{ |
4698 | ········CreateObjects(); |
4699 | ········QueryOwn(); |
4700 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4701 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4702 | ····} |
4703 | ····[Test] |
4704 | ····public void TestSaveReloadNull() |
4705 | ····{ |
4706 | ········CreateObjects(); |
4707 | ········QueryOwn(); |
4708 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4709 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4710 | ········ownVar.RelField = new List<CmpDirnOwnpconNoTblAutoRight>(); |
4711 | ········pm.Save(); |
4712 | ········pm.UnloadCache(); |
4713 | ········QueryOwn(); |
4714 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4715 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4716 | ····} |
4717 | ····[Test] |
4718 | ····public void TestSaveReloadRemove() |
4719 | ····{ |
4720 | ········CreateObjects(); |
4721 | ········QueryOwn(); |
4722 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4723 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4724 | ········ownVar.RemoveRelatedObject(); |
4725 | ········pm.Save(); |
4726 | ········pm.UnloadCache(); |
4727 | ········QueryOwn(); |
4728 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4729 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4730 | ····} |
4731 | ····[Test] |
4732 | ····public void TestUpdateOrder() |
4733 | ····{ |
4734 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4735 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4736 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoLeftBase)})) |
4737 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoRight)})), "Wrong order #1"); |
4738 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoLeftDerived)})) |
4739 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpconNoTblAutoRight)})), "Wrong order #2"); |
4740 | ········Debug.WriteLine("CmpDirnOwnpconNoTblAutoLeftBase"); |
4741 | ····} |
4742 | ····void CreateObjects() |
4743 | ····{ |
4744 | ········pm.MakePersistent(ownVar); |
4745 | ········ownVar.AssignRelation(otherVar); |
4746 | ········pm.Save(); |
4747 | ········pm.UnloadCache(); |
4748 | ····} |
4749 | ····void QueryOwn() |
4750 | ····{ |
4751 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblAutoLeftBase>(pm); |
4752 | ········ownVar = q.ExecuteSingle(); |
4753 | ····} |
4754 | ····void QueryOther() |
4755 | ····{ |
4756 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblAutoRight>(pm); |
4757 | ········otherVar = q.ExecuteSingle(); |
4758 | ····} |
4759 | } |
4760 | |
4761 | |
4762 | [TestFixture] |
4763 | public class TestCmpDirnOwnpconTblAuto : NDOTest |
4764 | { |
4765 | ····CmpDirnOwnpconTblAutoLeftBase ownVar; |
4766 | ····CmpDirnOwnpconTblAutoRight otherVar; |
4767 | ····PersistenceManager pm; |
4768 | ····[SetUp] |
4769 | ····public void Setup() |
4770 | ····{ |
4771 | ········pm = PmFactory.NewPersistenceManager(); |
4772 | ········ownVar = new CmpDirnOwnpconTblAutoLeftDerived(); |
4773 | ········otherVar = new CmpDirnOwnpconTblAutoRight(); |
4774 | ····} |
4775 | ····[TearDown] |
4776 | ····public void TearDown() |
4777 | ····{ |
4778 | ········try |
4779 | ········{ |
4780 | ············pm.UnloadCache(); |
4781 | ············var l = pm.Objects<CmpDirnOwnpconTblAutoLeftBase>().ResultTable; |
4782 | ············pm.Delete(l); |
4783 | ············pm.Save(); |
4784 | ············pm.UnloadCache(); |
4785 | ············decimal count; |
4786 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4787 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4788 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4789 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4790 | ········} |
4791 | ········catch (Exception) |
4792 | ········{ |
4793 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4794 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4795 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4796 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
4797 | ········} |
4798 | ····} |
4799 | ····[Test] |
4800 | ····public void TestSaveReload() |
4801 | ····{ |
4802 | ········CreateObjects(); |
4803 | ········QueryOwn(); |
4804 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4805 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4806 | ····} |
4807 | ····[Test] |
4808 | ····public void TestSaveReloadNull() |
4809 | ····{ |
4810 | ········CreateObjects(); |
4811 | ········QueryOwn(); |
4812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4813 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4814 | ········ownVar.RelField = new List<CmpDirnOwnpconTblAutoRight>(); |
4815 | ········pm.Save(); |
4816 | ········pm.UnloadCache(); |
4817 | ········QueryOwn(); |
4818 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4819 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4820 | ····} |
4821 | ····[Test] |
4822 | ····public void TestSaveReloadRemove() |
4823 | ····{ |
4824 | ········CreateObjects(); |
4825 | ········QueryOwn(); |
4826 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4827 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4828 | ········ownVar.RemoveRelatedObject(); |
4829 | ········pm.Save(); |
4830 | ········pm.UnloadCache(); |
4831 | ········QueryOwn(); |
4832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4833 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4834 | ····} |
4835 | ····void CreateObjects() |
4836 | ····{ |
4837 | ········pm.MakePersistent(ownVar); |
4838 | ········ownVar.AssignRelation(otherVar); |
4839 | ········pm.Save(); |
4840 | ········pm.UnloadCache(); |
4841 | ····} |
4842 | ····void QueryOwn() |
4843 | ····{ |
4844 | ········var q = new NDOQuery<CmpDirnOwnpconTblAutoLeftBase>(pm); |
4845 | ········ownVar = q.ExecuteSingle(); |
4846 | ····} |
4847 | ····void QueryOther() |
4848 | ····{ |
4849 | ········var q = new NDOQuery<CmpDirnOwnpconTblAutoRight>(pm); |
4850 | ········otherVar = q.ExecuteSingle(); |
4851 | ····} |
4852 | } |
4853 | |
4854 | |
4855 | [TestFixture] |
4856 | public class TestCmpBin1OwnpconNoTblAuto : NDOTest |
4857 | { |
4858 | ····CmpBin1OwnpconNoTblAutoLeftBase ownVar; |
4859 | ····CmpBin1OwnpconNoTblAutoRight otherVar; |
4860 | ····PersistenceManager pm; |
4861 | ····[SetUp] |
4862 | ····public void Setup() |
4863 | ····{ |
4864 | ········pm = PmFactory.NewPersistenceManager(); |
4865 | ········ownVar = new CmpBin1OwnpconNoTblAutoLeftDerived(); |
4866 | ········otherVar = new CmpBin1OwnpconNoTblAutoRight(); |
4867 | ····} |
4868 | ····[TearDown] |
4869 | ····public void TearDown() |
4870 | ····{ |
4871 | ········try |
4872 | ········{ |
4873 | ············pm.UnloadCache(); |
4874 | ············var l = pm.Objects<CmpBin1OwnpconNoTblAutoLeftBase>().ResultTable; |
4875 | ············pm.Delete(l); |
4876 | ············pm.Save(); |
4877 | ············pm.UnloadCache(); |
4878 | ············decimal count; |
4879 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4880 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
4881 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
4882 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
4883 | ········} |
4884 | ········catch (Exception) |
4885 | ········{ |
4886 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
4887 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
4888 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
4889 | ········} |
4890 | ····} |
4891 | ····[Test] |
4892 | ····public void TestSaveReload() |
4893 | ····{ |
4894 | ········CreateObjects(); |
4895 | ········QueryOwn(); |
4896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4897 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4898 | ····} |
4899 | ····[Test] |
4900 | ····public void TestSaveReloadNull() |
4901 | ····{ |
4902 | ········CreateObjects(); |
4903 | ········QueryOwn(); |
4904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4905 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4906 | ········ownVar.RelField = new List<CmpBin1OwnpconNoTblAutoRight>(); |
4907 | ········pm.Save(); |
4908 | ········pm.UnloadCache(); |
4909 | ········QueryOwn(); |
4910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4911 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4912 | ····} |
4913 | ····[Test] |
4914 | ····public void TestSaveReloadRemove() |
4915 | ····{ |
4916 | ········CreateObjects(); |
4917 | ········QueryOwn(); |
4918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4920 | ········ownVar.RemoveRelatedObject(); |
4921 | ········pm.Save(); |
4922 | ········pm.UnloadCache(); |
4923 | ········QueryOwn(); |
4924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
4925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
4926 | ····} |
4927 | ····[Test] |
4928 | ····public void TestChangeKeyHolderRight() |
4929 | ····{ |
4930 | ········CreateObjects(); |
4931 | ········QueryOther(); |
4932 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4933 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4934 | ········int x = otherVar.RelField.Dummy; |
4935 | ········otherVar.Dummy = 4711; |
4936 | ········pm.Save(); |
4937 | ········pm.UnloadCache(); |
4938 | ········QueryOther(); |
4939 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4940 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4941 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4942 | ····} |
4943 | ····[Test] |
4944 | ····public void TestChangeKeyHolderRightNoTouch() |
4945 | ····{ |
4946 | ········CreateObjects(); |
4947 | ········QueryOther(); |
4948 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4949 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4950 | ········otherVar.Dummy = 4711; |
4951 | ········pm.Save(); |
4952 | ········pm.UnloadCache(); |
4953 | ········QueryOther(); |
4954 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
4955 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
4956 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
4957 | ····} |
4958 | ····[Test] |
4959 | ····public void TestUpdateOrder() |
4960 | ····{ |
4961 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
4962 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
4963 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoLeftBase)})) |
4964 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoRight)})), "Wrong order #1"); |
4965 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoLeftDerived)})) |
4966 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpconNoTblAutoRight)})), "Wrong order #2"); |
4967 | ········Debug.WriteLine("CmpBin1OwnpconNoTblAutoLeftBase"); |
4968 | ····} |
4969 | ····[Test] |
4970 | ····public void TestRelationHash() |
4971 | ····{ |
4972 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoLeftBase)); |
4973 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
4974 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoRight)); |
4975 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
4976 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
4977 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
4978 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblAutoLeftDerived)); |
4979 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
4980 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
4981 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
4982 | ····} |
4983 | ····void CreateObjects() |
4984 | ····{ |
4985 | ········pm.MakePersistent(ownVar); |
4986 | ········ownVar.AssignRelation(otherVar); |
4987 | ········pm.Save(); |
4988 | ········pm.UnloadCache(); |
4989 | ····} |
4990 | ····void QueryOwn() |
4991 | ····{ |
4992 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblAutoLeftBase>(pm); |
4993 | ········ownVar = q.ExecuteSingle(); |
4994 | ····} |
4995 | ····void QueryOther() |
4996 | ····{ |
4997 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblAutoRight>(pm); |
4998 | ········otherVar = q.ExecuteSingle(); |
4999 | ····} |
5000 | } |
5001 | |
5002 | |
5003 | [TestFixture] |
5004 | public class TestCmpBin1OwnpconTblAuto : NDOTest |
5005 | { |
5006 | ····CmpBin1OwnpconTblAutoLeftBase ownVar; |
5007 | ····CmpBin1OwnpconTblAutoRight otherVar; |
5008 | ····PersistenceManager pm; |
5009 | ····[SetUp] |
5010 | ····public void Setup() |
5011 | ····{ |
5012 | ········pm = PmFactory.NewPersistenceManager(); |
5013 | ········ownVar = new CmpBin1OwnpconTblAutoLeftDerived(); |
5014 | ········otherVar = new CmpBin1OwnpconTblAutoRight(); |
5015 | ····} |
5016 | ····[TearDown] |
5017 | ····public void TearDown() |
5018 | ····{ |
5019 | ········try |
5020 | ········{ |
5021 | ············pm.UnloadCache(); |
5022 | ············var l = pm.Objects<CmpBin1OwnpconTblAutoLeftBase>().ResultTable; |
5023 | ············pm.Delete(l); |
5024 | ············pm.Save(); |
5025 | ············pm.UnloadCache(); |
5026 | ············decimal count; |
5027 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5028 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5029 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5030 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5031 | ········} |
5032 | ········catch (Exception) |
5033 | ········{ |
5034 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5035 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5036 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5037 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5038 | ········} |
5039 | ····} |
5040 | ····[Test] |
5041 | ····public void TestSaveReload() |
5042 | ····{ |
5043 | ········CreateObjects(); |
5044 | ········QueryOwn(); |
5045 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5046 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5047 | ····} |
5048 | ····[Test] |
5049 | ····public void TestSaveReloadNull() |
5050 | ····{ |
5051 | ········CreateObjects(); |
5052 | ········QueryOwn(); |
5053 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5054 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5055 | ········ownVar.RelField = new List<CmpBin1OwnpconTblAutoRight>(); |
5056 | ········pm.Save(); |
5057 | ········pm.UnloadCache(); |
5058 | ········QueryOwn(); |
5059 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5060 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5061 | ····} |
5062 | ····[Test] |
5063 | ····public void TestSaveReloadRemove() |
5064 | ····{ |
5065 | ········CreateObjects(); |
5066 | ········QueryOwn(); |
5067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5068 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5069 | ········ownVar.RemoveRelatedObject(); |
5070 | ········pm.Save(); |
5071 | ········pm.UnloadCache(); |
5072 | ········QueryOwn(); |
5073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5074 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5075 | ····} |
5076 | ····[Test] |
5077 | ····public void TestChangeKeyHolderRight() |
5078 | ····{ |
5079 | ········CreateObjects(); |
5080 | ········QueryOther(); |
5081 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5082 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5083 | ········int x = otherVar.RelField.Dummy; |
5084 | ········otherVar.Dummy = 4711; |
5085 | ········pm.Save(); |
5086 | ········pm.UnloadCache(); |
5087 | ········QueryOther(); |
5088 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5089 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5090 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5091 | ····} |
5092 | ····[Test] |
5093 | ····public void TestChangeKeyHolderRightNoTouch() |
5094 | ····{ |
5095 | ········CreateObjects(); |
5096 | ········QueryOther(); |
5097 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5098 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5099 | ········otherVar.Dummy = 4711; |
5100 | ········pm.Save(); |
5101 | ········pm.UnloadCache(); |
5102 | ········QueryOther(); |
5103 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5104 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5105 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5106 | ····} |
5107 | ····[Test] |
5108 | ····public void TestRelationHash() |
5109 | ····{ |
5110 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoLeftBase)); |
5111 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5112 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoRight)); |
5113 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5114 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5115 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5116 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblAutoLeftDerived)); |
5117 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5118 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5119 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5120 | ····} |
5121 | ····void CreateObjects() |
5122 | ····{ |
5123 | ········pm.MakePersistent(ownVar); |
5124 | ········ownVar.AssignRelation(otherVar); |
5125 | ········pm.Save(); |
5126 | ········pm.UnloadCache(); |
5127 | ····} |
5128 | ····void QueryOwn() |
5129 | ····{ |
5130 | ········var q = new NDOQuery<CmpBin1OwnpconTblAutoLeftBase>(pm); |
5131 | ········ownVar = q.ExecuteSingle(); |
5132 | ····} |
5133 | ····void QueryOther() |
5134 | ····{ |
5135 | ········var q = new NDOQuery<CmpBin1OwnpconTblAutoRight>(pm); |
5136 | ········otherVar = q.ExecuteSingle(); |
5137 | ····} |
5138 | } |
5139 | |
5140 | |
5141 | [TestFixture] |
5142 | public class TestCmpBi1nOwnpconTblAuto : NDOTest |
5143 | { |
5144 | ····CmpBi1nOwnpconTblAutoLeftBase ownVar; |
5145 | ····CmpBi1nOwnpconTblAutoRight otherVar; |
5146 | ····PersistenceManager pm; |
5147 | ····[SetUp] |
5148 | ····public void Setup() |
5149 | ····{ |
5150 | ········pm = PmFactory.NewPersistenceManager(); |
5151 | ········ownVar = new CmpBi1nOwnpconTblAutoLeftDerived(); |
5152 | ········otherVar = new CmpBi1nOwnpconTblAutoRight(); |
5153 | ····} |
5154 | ····[TearDown] |
5155 | ····public void TearDown() |
5156 | ····{ |
5157 | ········try |
5158 | ········{ |
5159 | ············pm.UnloadCache(); |
5160 | ············var l = pm.Objects<CmpBi1nOwnpconTblAutoLeftBase>().ResultTable; |
5161 | ············pm.Delete(l); |
5162 | ············pm.Save(); |
5163 | ············pm.UnloadCache(); |
5164 | ············decimal count; |
5165 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5166 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5167 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5168 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5169 | ········} |
5170 | ········catch (Exception) |
5171 | ········{ |
5172 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5173 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5174 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5175 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5176 | ········} |
5177 | ····} |
5178 | ····[Test] |
5179 | ····public void TestSaveReload() |
5180 | ····{ |
5181 | ········CreateObjects(); |
5182 | ········QueryOwn(); |
5183 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5184 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5185 | ····} |
5186 | ····[Test] |
5187 | ····public void TestSaveReloadNull() |
5188 | ····{ |
5189 | ········CreateObjects(); |
5190 | ········QueryOwn(); |
5191 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5192 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5193 | ········ownVar.RelField = null; |
5194 | ········pm.Save(); |
5195 | ········pm.UnloadCache(); |
5196 | ········QueryOwn(); |
5197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5198 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5199 | ····} |
5200 | ····[Test] |
5201 | ····public void TestChangeKeyHolderLeft() |
5202 | ····{ |
5203 | ········CreateObjects(); |
5204 | ········QueryOwn(); |
5205 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5207 | ········int x = ownVar.RelField.Dummy; |
5208 | ········ownVar.Dummy = 4711; |
5209 | ········pm.Save(); |
5210 | ········pm.UnloadCache(); |
5211 | ········QueryOwn(); |
5212 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5213 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5214 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5215 | ····} |
5216 | ····[Test] |
5217 | ····public void TestChangeKeyHolderLeftNoTouch() |
5218 | ····{ |
5219 | ········CreateObjects(); |
5220 | ········QueryOwn(); |
5221 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5222 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5223 | ········ownVar.Dummy = 4711; |
5224 | ········pm.Save(); |
5225 | ········pm.UnloadCache(); |
5226 | ········QueryOwn(); |
5227 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5228 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5229 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5230 | ····} |
5231 | ····[Test] |
5232 | ····public void TestRelationHash() |
5233 | ····{ |
5234 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoLeftBase)); |
5235 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5236 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoRight)); |
5237 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5238 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5239 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5240 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblAutoLeftDerived)); |
5241 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5242 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5243 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5244 | ····} |
5245 | ····void CreateObjects() |
5246 | ····{ |
5247 | ········pm.MakePersistent(ownVar); |
5248 | ········ownVar.AssignRelation(otherVar); |
5249 | ········pm.Save(); |
5250 | ········pm.UnloadCache(); |
5251 | ····} |
5252 | ····void QueryOwn() |
5253 | ····{ |
5254 | ········var q = new NDOQuery<CmpBi1nOwnpconTblAutoLeftBase>(pm); |
5255 | ········ownVar = q.ExecuteSingle(); |
5256 | ····} |
5257 | ····void QueryOther() |
5258 | ····{ |
5259 | ········var q = new NDOQuery<CmpBi1nOwnpconTblAutoRight>(pm); |
5260 | ········otherVar = q.ExecuteSingle(); |
5261 | ····} |
5262 | } |
5263 | |
5264 | |
5265 | [TestFixture] |
5266 | public class TestCmpBinnOwnpconTblAuto : NDOTest |
5267 | { |
5268 | ····CmpBinnOwnpconTblAutoLeftBase ownVar; |
5269 | ····CmpBinnOwnpconTblAutoRight otherVar; |
5270 | ····PersistenceManager pm; |
5271 | ····[SetUp] |
5272 | ····public void Setup() |
5273 | ····{ |
5274 | ········pm = PmFactory.NewPersistenceManager(); |
5275 | ········ownVar = new CmpBinnOwnpconTblAutoLeftDerived(); |
5276 | ········otherVar = new CmpBinnOwnpconTblAutoRight(); |
5277 | ····} |
5278 | ····[TearDown] |
5279 | ····public void TearDown() |
5280 | ····{ |
5281 | ········try |
5282 | ········{ |
5283 | ············pm.UnloadCache(); |
5284 | ············var l = pm.Objects<CmpBinnOwnpconTblAutoLeftBase>().ResultTable; |
5285 | ············pm.Delete(l); |
5286 | ············pm.Save(); |
5287 | ············pm.UnloadCache(); |
5288 | ············decimal count; |
5289 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5290 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5291 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5292 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5293 | ········} |
5294 | ········catch (Exception) |
5295 | ········{ |
5296 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5297 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5298 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5299 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5300 | ········} |
5301 | ····} |
5302 | ····[Test] |
5303 | ····public void TestSaveReload() |
5304 | ····{ |
5305 | ········CreateObjects(); |
5306 | ········QueryOwn(); |
5307 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5308 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5309 | ····} |
5310 | ····[Test] |
5311 | ····public void TestSaveReloadNull() |
5312 | ····{ |
5313 | ········CreateObjects(); |
5314 | ········QueryOwn(); |
5315 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5316 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5317 | ········ownVar.RelField = new List<CmpBinnOwnpconTblAutoRight>(); |
5318 | ········pm.Save(); |
5319 | ········pm.UnloadCache(); |
5320 | ········QueryOwn(); |
5321 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5322 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5323 | ····} |
5324 | ····[Test] |
5325 | ····public void TestSaveReloadRemove() |
5326 | ····{ |
5327 | ········CreateObjects(); |
5328 | ········QueryOwn(); |
5329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5330 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5331 | ········ownVar.RemoveRelatedObject(); |
5332 | ········pm.Save(); |
5333 | ········pm.UnloadCache(); |
5334 | ········QueryOwn(); |
5335 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5336 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5337 | ····} |
5338 | ····[Test] |
5339 | ····public void TestRelationHash() |
5340 | ····{ |
5341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoLeftBase)); |
5342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoRight)); |
5344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5347 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblAutoLeftDerived)); |
5348 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
5349 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
5350 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
5351 | ····} |
5352 | ····void CreateObjects() |
5353 | ····{ |
5354 | ········pm.MakePersistent(ownVar); |
5355 | ········ownVar.AssignRelation(otherVar); |
5356 | ········pm.Save(); |
5357 | ········pm.UnloadCache(); |
5358 | ····} |
5359 | ····void QueryOwn() |
5360 | ····{ |
5361 | ········var q = new NDOQuery<CmpBinnOwnpconTblAutoLeftBase>(pm); |
5362 | ········ownVar = q.ExecuteSingle(); |
5363 | ····} |
5364 | ····void QueryOther() |
5365 | ····{ |
5366 | ········var q = new NDOQuery<CmpBinnOwnpconTblAutoRight>(pm); |
5367 | ········otherVar = q.ExecuteSingle(); |
5368 | ····} |
5369 | } |
5370 | |
5371 | |
5372 | [TestFixture] |
5373 | public class TestAgrDir1OthpconNoTblAuto : NDOTest |
5374 | { |
5375 | ····AgrDir1OthpconNoTblAutoLeft ownVar; |
5376 | ····AgrDir1OthpconNoTblAutoRightBase otherVar; |
5377 | ····PersistenceManager pm; |
5378 | ····[SetUp] |
5379 | ····public void Setup() |
5380 | ····{ |
5381 | ········pm = PmFactory.NewPersistenceManager(); |
5382 | ········ownVar = new AgrDir1OthpconNoTblAutoLeft(); |
5383 | ········otherVar = new AgrDir1OthpconNoTblAutoRightDerived(); |
5384 | ····} |
5385 | ····[TearDown] |
5386 | ····public void TearDown() |
5387 | ····{ |
5388 | ········try |
5389 | ········{ |
5390 | ············pm.UnloadCache(); |
5391 | ············var l = pm.Objects<AgrDir1OthpconNoTblAutoLeft>().ResultTable; |
5392 | ············pm.Delete(l); |
5393 | ············pm.Save(); |
5394 | ············pm.UnloadCache(); |
5395 | ············var m = pm.Objects<AgrDir1OthpconNoTblAutoRightBase>().ResultTable; |
5396 | ············pm.Delete(m); |
5397 | ············pm.Save(); |
5398 | ············pm.UnloadCache(); |
5399 | ············decimal count; |
5400 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5401 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5402 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5403 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5404 | ········} |
5405 | ········catch (Exception) |
5406 | ········{ |
5407 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5408 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5409 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5410 | ········} |
5411 | ····} |
5412 | ····[Test] |
5413 | ····public void TestSaveReload() |
5414 | ····{ |
5415 | ········CreateObjects(); |
5416 | ········QueryOwn(); |
5417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5419 | ····} |
5420 | ····[Test] |
5421 | ····public void TestSaveReloadNull() |
5422 | ····{ |
5423 | ········CreateObjects(); |
5424 | ········QueryOwn(); |
5425 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5426 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5427 | ········ownVar.RelField = null; |
5428 | ········pm.Save(); |
5429 | ········pm.UnloadCache(); |
5430 | ········QueryOwn(); |
5431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5432 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5433 | ····} |
5434 | ····[Test] |
5435 | ····public void TestChangeKeyHolderLeft() |
5436 | ····{ |
5437 | ········CreateObjects(); |
5438 | ········QueryOwn(); |
5439 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5440 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5441 | ········int x = ownVar.RelField.Dummy; |
5442 | ········ownVar.Dummy = 4711; |
5443 | ········pm.Save(); |
5444 | ········pm.UnloadCache(); |
5445 | ········QueryOwn(); |
5446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5447 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5448 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5449 | ····} |
5450 | ····[Test] |
5451 | ····public void TestChangeKeyHolderLeftNoTouch() |
5452 | ····{ |
5453 | ········CreateObjects(); |
5454 | ········QueryOwn(); |
5455 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5456 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5457 | ········ownVar.Dummy = 4711; |
5458 | ········pm.Save(); |
5459 | ········pm.UnloadCache(); |
5460 | ········QueryOwn(); |
5461 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5462 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5463 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5464 | ····} |
5465 | ····[Test] |
5466 | ····public void TestUpdateOrder() |
5467 | ····{ |
5468 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
5469 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
5470 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoLeft)})) |
5471 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoRightBase)})), "Wrong order #1"); |
5472 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoLeft)})) |
5473 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
5474 | ········Debug.WriteLine("AgrDir1OthpconNoTblAutoLeft"); |
5475 | ····} |
5476 | ····void CreateObjects() |
5477 | ····{ |
5478 | ········pm.MakePersistent(ownVar); |
5479 | ········pm.Save(); |
5480 | ········pm.MakePersistent(otherVar); |
5481 | ········pm.Save(); |
5482 | ········ownVar.AssignRelation(otherVar); |
5483 | ········pm.Save(); |
5484 | ········pm.UnloadCache(); |
5485 | ····} |
5486 | ····void QueryOwn() |
5487 | ····{ |
5488 | ········var q = new NDOQuery<AgrDir1OthpconNoTblAutoLeft>(pm); |
5489 | ········ownVar = q.ExecuteSingle(); |
5490 | ····} |
5491 | ····void QueryOther() |
5492 | ····{ |
5493 | ········var q = new NDOQuery<AgrDir1OthpconNoTblAutoRightBase>(pm); |
5494 | ········otherVar = q.ExecuteSingle(); |
5495 | ····} |
5496 | } |
5497 | |
5498 | |
5499 | [TestFixture] |
5500 | public class TestAgrDir1OthpconTblAuto : NDOTest |
5501 | { |
5502 | ····AgrDir1OthpconTblAutoLeft ownVar; |
5503 | ····AgrDir1OthpconTblAutoRightBase otherVar; |
5504 | ····PersistenceManager pm; |
5505 | ····[SetUp] |
5506 | ····public void Setup() |
5507 | ····{ |
5508 | ········pm = PmFactory.NewPersistenceManager(); |
5509 | ········ownVar = new AgrDir1OthpconTblAutoLeft(); |
5510 | ········otherVar = new AgrDir1OthpconTblAutoRightDerived(); |
5511 | ····} |
5512 | ····[TearDown] |
5513 | ····public void TearDown() |
5514 | ····{ |
5515 | ········try |
5516 | ········{ |
5517 | ············pm.UnloadCache(); |
5518 | ············var l = pm.Objects<AgrDir1OthpconTblAutoLeft>().ResultTable; |
5519 | ············pm.Delete(l); |
5520 | ············pm.Save(); |
5521 | ············pm.UnloadCache(); |
5522 | ············var m = pm.Objects<AgrDir1OthpconTblAutoRightBase>().ResultTable; |
5523 | ············pm.Delete(m); |
5524 | ············pm.Save(); |
5525 | ············pm.UnloadCache(); |
5526 | ············decimal count; |
5527 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5528 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5529 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5530 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5531 | ········} |
5532 | ········catch (Exception) |
5533 | ········{ |
5534 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5535 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5537 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5538 | ········} |
5539 | ····} |
5540 | ····[Test] |
5541 | ····public void TestSaveReload() |
5542 | ····{ |
5543 | ········CreateObjects(); |
5544 | ········QueryOwn(); |
5545 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5546 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5547 | ····} |
5548 | ····[Test] |
5549 | ····public void TestSaveReloadNull() |
5550 | ····{ |
5551 | ········CreateObjects(); |
5552 | ········QueryOwn(); |
5553 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5554 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5555 | ········ownVar.RelField = null; |
5556 | ········pm.Save(); |
5557 | ········pm.UnloadCache(); |
5558 | ········QueryOwn(); |
5559 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5560 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5561 | ····} |
5562 | ····[Test] |
5563 | ····public void TestChangeKeyHolderLeft() |
5564 | ····{ |
5565 | ········CreateObjects(); |
5566 | ········QueryOwn(); |
5567 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5568 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5569 | ········int x = ownVar.RelField.Dummy; |
5570 | ········ownVar.Dummy = 4711; |
5571 | ········pm.Save(); |
5572 | ········pm.UnloadCache(); |
5573 | ········QueryOwn(); |
5574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5575 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5576 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5577 | ····} |
5578 | ····[Test] |
5579 | ····public void TestChangeKeyHolderLeftNoTouch() |
5580 | ····{ |
5581 | ········CreateObjects(); |
5582 | ········QueryOwn(); |
5583 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5584 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5585 | ········ownVar.Dummy = 4711; |
5586 | ········pm.Save(); |
5587 | ········pm.UnloadCache(); |
5588 | ········QueryOwn(); |
5589 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5590 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5591 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5592 | ····} |
5593 | ····void CreateObjects() |
5594 | ····{ |
5595 | ········pm.MakePersistent(ownVar); |
5596 | ········pm.MakePersistent(otherVar); |
5597 | ········ownVar.AssignRelation(otherVar); |
5598 | ········pm.Save(); |
5599 | ········pm.UnloadCache(); |
5600 | ····} |
5601 | ····void QueryOwn() |
5602 | ····{ |
5603 | ········var q = new NDOQuery<AgrDir1OthpconTblAutoLeft>(pm); |
5604 | ········ownVar = q.ExecuteSingle(); |
5605 | ····} |
5606 | ····void QueryOther() |
5607 | ····{ |
5608 | ········var q = new NDOQuery<AgrDir1OthpconTblAutoRightBase>(pm); |
5609 | ········otherVar = q.ExecuteSingle(); |
5610 | ····} |
5611 | } |
5612 | |
5613 | |
5614 | [TestFixture] |
5615 | public class TestAgrBi11OthpconNoTblAuto : NDOTest |
5616 | { |
5617 | ····AgrBi11OthpconNoTblAutoLeft ownVar; |
5618 | ····AgrBi11OthpconNoTblAutoRightBase otherVar; |
5619 | ····PersistenceManager pm; |
5620 | ····[SetUp] |
5621 | ····public void Setup() |
5622 | ····{ |
5623 | ········pm = PmFactory.NewPersistenceManager(); |
5624 | ········ownVar = new AgrBi11OthpconNoTblAutoLeft(); |
5625 | ········otherVar = new AgrBi11OthpconNoTblAutoRightDerived(); |
5626 | ····} |
5627 | ····[TearDown] |
5628 | ····public void TearDown() |
5629 | ····{ |
5630 | ········try |
5631 | ········{ |
5632 | ············pm.UnloadCache(); |
5633 | ············var l = pm.Objects<AgrBi11OthpconNoTblAutoLeft>().ResultTable; |
5634 | ············pm.Delete(l); |
5635 | ············pm.Save(); |
5636 | ············pm.UnloadCache(); |
5637 | ············var m = pm.Objects<AgrBi11OthpconNoTblAutoRightBase>().ResultTable; |
5638 | ············pm.Delete(m); |
5639 | ············pm.Save(); |
5640 | ············pm.UnloadCache(); |
5641 | ············decimal count; |
5642 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5643 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5644 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5645 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5646 | ········} |
5647 | ········catch (Exception) |
5648 | ········{ |
5649 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5650 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5651 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5652 | ········} |
5653 | ····} |
5654 | ····[Test] |
5655 | ····public void TestSaveReload() |
5656 | ····{ |
5657 | ········CreateObjects(); |
5658 | ········QueryOwn(); |
5659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5660 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5661 | ····} |
5662 | ····[Test] |
5663 | ····public void TestSaveReloadNull() |
5664 | ····{ |
5665 | ········CreateObjects(); |
5666 | ········QueryOwn(); |
5667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5669 | ········ownVar.RelField = null; |
5670 | ········pm.Save(); |
5671 | ········pm.UnloadCache(); |
5672 | ········QueryOwn(); |
5673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5674 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5675 | ····} |
5676 | ····[Test] |
5677 | ····public void TestChangeKeyHolderLeft() |
5678 | ····{ |
5679 | ········CreateObjects(); |
5680 | ········QueryOwn(); |
5681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5682 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5683 | ········int x = ownVar.RelField.Dummy; |
5684 | ········ownVar.Dummy = 4711; |
5685 | ········pm.Save(); |
5686 | ········pm.UnloadCache(); |
5687 | ········QueryOwn(); |
5688 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5689 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5690 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5691 | ····} |
5692 | ····[Test] |
5693 | ····public void TestChangeKeyHolderRight() |
5694 | ····{ |
5695 | ········CreateObjects(); |
5696 | ········QueryOther(); |
5697 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5698 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5699 | ········int x = otherVar.RelField.Dummy; |
5700 | ········otherVar.Dummy = 4711; |
5701 | ········pm.Save(); |
5702 | ········pm.UnloadCache(); |
5703 | ········QueryOther(); |
5704 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5705 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5706 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5707 | ····} |
5708 | ····[Test] |
5709 | ····public void TestChangeKeyHolderLeftNoTouch() |
5710 | ····{ |
5711 | ········CreateObjects(); |
5712 | ········QueryOwn(); |
5713 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5714 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5715 | ········ownVar.Dummy = 4711; |
5716 | ········pm.Save(); |
5717 | ········pm.UnloadCache(); |
5718 | ········QueryOwn(); |
5719 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5720 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5721 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5722 | ····} |
5723 | ····[Test] |
5724 | ····public void TestChangeKeyHolderRightNoTouch() |
5725 | ····{ |
5726 | ········CreateObjects(); |
5727 | ········QueryOther(); |
5728 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5729 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5730 | ········otherVar.Dummy = 4711; |
5731 | ········pm.Save(); |
5732 | ········pm.UnloadCache(); |
5733 | ········QueryOther(); |
5734 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5735 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5736 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5737 | ····} |
5738 | ····[Test] |
5739 | ····public void TestRelationHash() |
5740 | ····{ |
5741 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoLeft)); |
5742 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5743 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoRightBase)); |
5744 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5745 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5746 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5747 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblAutoRightDerived)); |
5748 | ········Relation relderRight = clderRight.FindRelation("relField"); |
5749 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
5750 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
5751 | ····} |
5752 | ····void CreateObjects() |
5753 | ····{ |
5754 | ········pm.MakePersistent(ownVar); |
5755 | ········pm.Save(); |
5756 | ········pm.MakePersistent(otherVar); |
5757 | ········pm.Save(); |
5758 | ········ownVar.AssignRelation(otherVar); |
5759 | ········pm.Save(); |
5760 | ········pm.UnloadCache(); |
5761 | ····} |
5762 | ····void QueryOwn() |
5763 | ····{ |
5764 | ········var q = new NDOQuery<AgrBi11OthpconNoTblAutoLeft>(pm); |
5765 | ········ownVar = q.ExecuteSingle(); |
5766 | ····} |
5767 | ····void QueryOther() |
5768 | ····{ |
5769 | ········var q = new NDOQuery<AgrBi11OthpconNoTblAutoRightBase>(pm); |
5770 | ········otherVar = q.ExecuteSingle(); |
5771 | ····} |
5772 | } |
5773 | |
5774 | |
5775 | [TestFixture] |
5776 | public class TestAgrBi11OthpconTblAuto : NDOTest |
5777 | { |
5778 | ····AgrBi11OthpconTblAutoLeft ownVar; |
5779 | ····AgrBi11OthpconTblAutoRightBase otherVar; |
5780 | ····PersistenceManager pm; |
5781 | ····[SetUp] |
5782 | ····public void Setup() |
5783 | ····{ |
5784 | ········pm = PmFactory.NewPersistenceManager(); |
5785 | ········ownVar = new AgrBi11OthpconTblAutoLeft(); |
5786 | ········otherVar = new AgrBi11OthpconTblAutoRightDerived(); |
5787 | ····} |
5788 | ····[TearDown] |
5789 | ····public void TearDown() |
5790 | ····{ |
5791 | ········try |
5792 | ········{ |
5793 | ············pm.UnloadCache(); |
5794 | ············var l = pm.Objects<AgrBi11OthpconTblAutoLeft>().ResultTable; |
5795 | ············pm.Delete(l); |
5796 | ············pm.Save(); |
5797 | ············pm.UnloadCache(); |
5798 | ············var m = pm.Objects<AgrBi11OthpconTblAutoRightBase>().ResultTable; |
5799 | ············pm.Delete(m); |
5800 | ············pm.Save(); |
5801 | ············pm.UnloadCache(); |
5802 | ············decimal count; |
5803 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5804 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5805 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5806 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5807 | ········} |
5808 | ········catch (Exception) |
5809 | ········{ |
5810 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5811 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5812 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5813 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5814 | ········} |
5815 | ····} |
5816 | ····[Test] |
5817 | ····public void TestSaveReload() |
5818 | ····{ |
5819 | ········CreateObjects(); |
5820 | ········QueryOwn(); |
5821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5823 | ····} |
5824 | ····[Test] |
5825 | ····public void TestSaveReloadNull() |
5826 | ····{ |
5827 | ········CreateObjects(); |
5828 | ········QueryOwn(); |
5829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5831 | ········ownVar.RelField = null; |
5832 | ········pm.Save(); |
5833 | ········pm.UnloadCache(); |
5834 | ········QueryOwn(); |
5835 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5836 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
5837 | ····} |
5838 | ····[Test] |
5839 | ····public void TestChangeKeyHolderLeft() |
5840 | ····{ |
5841 | ········CreateObjects(); |
5842 | ········QueryOwn(); |
5843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5844 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5845 | ········int x = ownVar.RelField.Dummy; |
5846 | ········ownVar.Dummy = 4711; |
5847 | ········pm.Save(); |
5848 | ········pm.UnloadCache(); |
5849 | ········QueryOwn(); |
5850 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5851 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5853 | ····} |
5854 | ····[Test] |
5855 | ····public void TestChangeKeyHolderRight() |
5856 | ····{ |
5857 | ········CreateObjects(); |
5858 | ········QueryOther(); |
5859 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5860 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5861 | ········int x = otherVar.RelField.Dummy; |
5862 | ········otherVar.Dummy = 4711; |
5863 | ········pm.Save(); |
5864 | ········pm.UnloadCache(); |
5865 | ········QueryOther(); |
5866 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5867 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5868 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5869 | ····} |
5870 | ····[Test] |
5871 | ····public void TestChangeKeyHolderLeftNoTouch() |
5872 | ····{ |
5873 | ········CreateObjects(); |
5874 | ········QueryOwn(); |
5875 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5876 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5877 | ········ownVar.Dummy = 4711; |
5878 | ········pm.Save(); |
5879 | ········pm.UnloadCache(); |
5880 | ········QueryOwn(); |
5881 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5882 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5883 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
5884 | ····} |
5885 | ····[Test] |
5886 | ····public void TestChangeKeyHolderRightNoTouch() |
5887 | ····{ |
5888 | ········CreateObjects(); |
5889 | ········QueryOther(); |
5890 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5891 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5892 | ········otherVar.Dummy = 4711; |
5893 | ········pm.Save(); |
5894 | ········pm.UnloadCache(); |
5895 | ········QueryOther(); |
5896 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
5897 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
5898 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
5899 | ····} |
5900 | ····[Test] |
5901 | ····public void TestRelationHash() |
5902 | ····{ |
5903 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoLeft)); |
5904 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
5905 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoRightBase)); |
5906 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
5907 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
5908 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
5909 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblAutoRightDerived)); |
5910 | ········Relation relderRight = clderRight.FindRelation("relField"); |
5911 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
5912 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
5913 | ····} |
5914 | ····void CreateObjects() |
5915 | ····{ |
5916 | ········pm.MakePersistent(ownVar); |
5917 | ········pm.MakePersistent(otherVar); |
5918 | ········ownVar.AssignRelation(otherVar); |
5919 | ········pm.Save(); |
5920 | ········pm.UnloadCache(); |
5921 | ····} |
5922 | ····void QueryOwn() |
5923 | ····{ |
5924 | ········var q = new NDOQuery<AgrBi11OthpconTblAutoLeft>(pm); |
5925 | ········ownVar = q.ExecuteSingle(); |
5926 | ····} |
5927 | ····void QueryOther() |
5928 | ····{ |
5929 | ········var q = new NDOQuery<AgrBi11OthpconTblAutoRightBase>(pm); |
5930 | ········otherVar = q.ExecuteSingle(); |
5931 | ····} |
5932 | } |
5933 | |
5934 | |
5935 | [TestFixture] |
5936 | public class TestAgrDirnOthpconTblAuto : NDOTest |
5937 | { |
5938 | ····AgrDirnOthpconTblAutoLeft ownVar; |
5939 | ····AgrDirnOthpconTblAutoRightBase otherVar; |
5940 | ····PersistenceManager pm; |
5941 | ····[SetUp] |
5942 | ····public void Setup() |
5943 | ····{ |
5944 | ········pm = PmFactory.NewPersistenceManager(); |
5945 | ········ownVar = new AgrDirnOthpconTblAutoLeft(); |
5946 | ········otherVar = new AgrDirnOthpconTblAutoRightDerived(); |
5947 | ····} |
5948 | ····[TearDown] |
5949 | ····public void TearDown() |
5950 | ····{ |
5951 | ········try |
5952 | ········{ |
5953 | ············pm.UnloadCache(); |
5954 | ············var l = pm.Objects<AgrDirnOthpconTblAutoLeft>().ResultTable; |
5955 | ············pm.Delete(l); |
5956 | ············pm.Save(); |
5957 | ············pm.UnloadCache(); |
5958 | ············var m = pm.Objects<AgrDirnOthpconTblAutoRightBase>().ResultTable; |
5959 | ············pm.Delete(m); |
5960 | ············pm.Save(); |
5961 | ············pm.UnloadCache(); |
5962 | ············decimal count; |
5963 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5964 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
5965 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
5966 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
5967 | ········} |
5968 | ········catch (Exception) |
5969 | ········{ |
5970 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
5971 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
5972 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
5973 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
5974 | ········} |
5975 | ····} |
5976 | ····[Test] |
5977 | ····public void TestSaveReload() |
5978 | ····{ |
5979 | ········CreateObjects(); |
5980 | ········QueryOwn(); |
5981 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5982 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5983 | ····} |
5984 | ····[Test] |
5985 | ····public void TestSaveReloadNull() |
5986 | ····{ |
5987 | ········CreateObjects(); |
5988 | ········QueryOwn(); |
5989 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5990 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5991 | ········ownVar.RelField = new List<AgrDirnOthpconTblAutoRightBase>(); |
5992 | ········pm.Save(); |
5993 | ········pm.UnloadCache(); |
5994 | ········QueryOwn(); |
5995 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
5996 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
5997 | ····} |
5998 | ····[Test] |
5999 | ····public void TestSaveReloadRemove() |
6000 | ····{ |
6001 | ········CreateObjects(); |
6002 | ········QueryOwn(); |
6003 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6004 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6005 | ········ownVar.RemoveRelatedObject(); |
6006 | ········pm.Save(); |
6007 | ········pm.UnloadCache(); |
6008 | ········QueryOwn(); |
6009 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6010 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6011 | ····} |
6012 | ····void CreateObjects() |
6013 | ····{ |
6014 | ········pm.MakePersistent(ownVar); |
6015 | ········pm.MakePersistent(otherVar); |
6016 | ········ownVar.AssignRelation(otherVar); |
6017 | ········pm.Save(); |
6018 | ········pm.UnloadCache(); |
6019 | ····} |
6020 | ····void QueryOwn() |
6021 | ····{ |
6022 | ········var q = new NDOQuery<AgrDirnOthpconTblAutoLeft>(pm); |
6023 | ········ownVar = q.ExecuteSingle(); |
6024 | ····} |
6025 | ····void QueryOther() |
6026 | ····{ |
6027 | ········var q = new NDOQuery<AgrDirnOthpconTblAutoRightBase>(pm); |
6028 | ········otherVar = q.ExecuteSingle(); |
6029 | ····} |
6030 | } |
6031 | |
6032 | |
6033 | [TestFixture] |
6034 | public class TestAgrBin1OthpconTblAuto : NDOTest |
6035 | { |
6036 | ····AgrBin1OthpconTblAutoLeft ownVar; |
6037 | ····AgrBin1OthpconTblAutoRightBase otherVar; |
6038 | ····PersistenceManager pm; |
6039 | ····[SetUp] |
6040 | ····public void Setup() |
6041 | ····{ |
6042 | ········pm = PmFactory.NewPersistenceManager(); |
6043 | ········ownVar = new AgrBin1OthpconTblAutoLeft(); |
6044 | ········otherVar = new AgrBin1OthpconTblAutoRightDerived(); |
6045 | ····} |
6046 | ····[TearDown] |
6047 | ····public void TearDown() |
6048 | ····{ |
6049 | ········try |
6050 | ········{ |
6051 | ············pm.UnloadCache(); |
6052 | ············var l = pm.Objects<AgrBin1OthpconTblAutoLeft>().ResultTable; |
6053 | ············pm.Delete(l); |
6054 | ············pm.Save(); |
6055 | ············pm.UnloadCache(); |
6056 | ············var m = pm.Objects<AgrBin1OthpconTblAutoRightBase>().ResultTable; |
6057 | ············pm.Delete(m); |
6058 | ············pm.Save(); |
6059 | ············pm.UnloadCache(); |
6060 | ············decimal count; |
6061 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6063 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6064 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6065 | ········} |
6066 | ········catch (Exception) |
6067 | ········{ |
6068 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6069 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6070 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6071 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6072 | ········} |
6073 | ····} |
6074 | ····[Test] |
6075 | ····public void TestSaveReload() |
6076 | ····{ |
6077 | ········CreateObjects(); |
6078 | ········QueryOwn(); |
6079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6080 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6081 | ····} |
6082 | ····[Test] |
6083 | ····public void TestSaveReloadNull() |
6084 | ····{ |
6085 | ········CreateObjects(); |
6086 | ········QueryOwn(); |
6087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6088 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6089 | ········ownVar.RelField = new List<AgrBin1OthpconTblAutoRightBase>(); |
6090 | ········pm.Save(); |
6091 | ········pm.UnloadCache(); |
6092 | ········QueryOwn(); |
6093 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6094 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6095 | ····} |
6096 | ····[Test] |
6097 | ····public void TestSaveReloadRemove() |
6098 | ····{ |
6099 | ········CreateObjects(); |
6100 | ········QueryOwn(); |
6101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6102 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6103 | ········ownVar.RemoveRelatedObject(); |
6104 | ········pm.Save(); |
6105 | ········pm.UnloadCache(); |
6106 | ········QueryOwn(); |
6107 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6108 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6109 | ····} |
6110 | ····[Test] |
6111 | ····public void TestChangeKeyHolderRight() |
6112 | ····{ |
6113 | ········CreateObjects(); |
6114 | ········QueryOther(); |
6115 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6116 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6117 | ········int x = otherVar.RelField.Dummy; |
6118 | ········otherVar.Dummy = 4711; |
6119 | ········pm.Save(); |
6120 | ········pm.UnloadCache(); |
6121 | ········QueryOther(); |
6122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6125 | ····} |
6126 | ····[Test] |
6127 | ····public void TestChangeKeyHolderRightNoTouch() |
6128 | ····{ |
6129 | ········CreateObjects(); |
6130 | ········QueryOther(); |
6131 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6132 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6133 | ········otherVar.Dummy = 4711; |
6134 | ········pm.Save(); |
6135 | ········pm.UnloadCache(); |
6136 | ········QueryOther(); |
6137 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6138 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6139 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6140 | ····} |
6141 | ····[Test] |
6142 | ····public void TestRelationHash() |
6143 | ····{ |
6144 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoLeft)); |
6145 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6146 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoRightBase)); |
6147 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6148 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6149 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6150 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblAutoRightDerived)); |
6151 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6152 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6153 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6154 | ····} |
6155 | ····void CreateObjects() |
6156 | ····{ |
6157 | ········pm.MakePersistent(ownVar); |
6158 | ········pm.MakePersistent(otherVar); |
6159 | ········ownVar.AssignRelation(otherVar); |
6160 | ········pm.Save(); |
6161 | ········pm.UnloadCache(); |
6162 | ····} |
6163 | ····void QueryOwn() |
6164 | ····{ |
6165 | ········var q = new NDOQuery<AgrBin1OthpconTblAutoLeft>(pm); |
6166 | ········ownVar = q.ExecuteSingle(); |
6167 | ····} |
6168 | ····void QueryOther() |
6169 | ····{ |
6170 | ········var q = new NDOQuery<AgrBin1OthpconTblAutoRightBase>(pm); |
6171 | ········otherVar = q.ExecuteSingle(); |
6172 | ····} |
6173 | } |
6174 | |
6175 | |
6176 | [TestFixture] |
6177 | public class TestAgrBi1nOthpconNoTblAuto : NDOTest |
6178 | { |
6179 | ····AgrBi1nOthpconNoTblAutoLeft ownVar; |
6180 | ····AgrBi1nOthpconNoTblAutoRightBase otherVar; |
6181 | ····PersistenceManager pm; |
6182 | ····[SetUp] |
6183 | ····public void Setup() |
6184 | ····{ |
6185 | ········pm = PmFactory.NewPersistenceManager(); |
6186 | ········ownVar = new AgrBi1nOthpconNoTblAutoLeft(); |
6187 | ········otherVar = new AgrBi1nOthpconNoTblAutoRightDerived(); |
6188 | ····} |
6189 | ····[TearDown] |
6190 | ····public void TearDown() |
6191 | ····{ |
6192 | ········try |
6193 | ········{ |
6194 | ············pm.UnloadCache(); |
6195 | ············var l = pm.Objects<AgrBi1nOthpconNoTblAutoLeft>().ResultTable; |
6196 | ············pm.Delete(l); |
6197 | ············pm.Save(); |
6198 | ············pm.UnloadCache(); |
6199 | ············var m = pm.Objects<AgrBi1nOthpconNoTblAutoRightBase>().ResultTable; |
6200 | ············pm.Delete(m); |
6201 | ············pm.Save(); |
6202 | ············pm.UnloadCache(); |
6203 | ············decimal count; |
6204 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6205 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6206 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6207 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6208 | ········} |
6209 | ········catch (Exception) |
6210 | ········{ |
6211 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6212 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6213 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6214 | ········} |
6215 | ····} |
6216 | ····[Test] |
6217 | ····public void TestSaveReload() |
6218 | ····{ |
6219 | ········CreateObjects(); |
6220 | ········QueryOwn(); |
6221 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6222 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6223 | ····} |
6224 | ····[Test] |
6225 | ····public void TestSaveReloadNull() |
6226 | ····{ |
6227 | ········CreateObjects(); |
6228 | ········QueryOwn(); |
6229 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6230 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6231 | ········ownVar.RelField = null; |
6232 | ········pm.Save(); |
6233 | ········pm.UnloadCache(); |
6234 | ········QueryOwn(); |
6235 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6236 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6237 | ····} |
6238 | ····[Test] |
6239 | ····public void TestChangeKeyHolderLeft() |
6240 | ····{ |
6241 | ········CreateObjects(); |
6242 | ········QueryOwn(); |
6243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6244 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6245 | ········int x = ownVar.RelField.Dummy; |
6246 | ········ownVar.Dummy = 4711; |
6247 | ········pm.Save(); |
6248 | ········pm.UnloadCache(); |
6249 | ········QueryOwn(); |
6250 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6251 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6252 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6253 | ····} |
6254 | ····[Test] |
6255 | ····public void TestChangeKeyHolderLeftNoTouch() |
6256 | ····{ |
6257 | ········CreateObjects(); |
6258 | ········QueryOwn(); |
6259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6261 | ········ownVar.Dummy = 4711; |
6262 | ········pm.Save(); |
6263 | ········pm.UnloadCache(); |
6264 | ········QueryOwn(); |
6265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6266 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6268 | ····} |
6269 | ····[Test] |
6270 | ····public void TestUpdateOrder() |
6271 | ····{ |
6272 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
6273 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
6274 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoLeft)})) |
6275 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoRightBase)})), "Wrong order #1"); |
6276 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoLeft)})) |
6277 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
6278 | ········Debug.WriteLine("AgrBi1nOthpconNoTblAutoLeft"); |
6279 | ····} |
6280 | ····[Test] |
6281 | ····public void TestRelationHash() |
6282 | ····{ |
6283 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoLeft)); |
6284 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6285 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoRightBase)); |
6286 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6287 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6288 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6289 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblAutoRightDerived)); |
6290 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6291 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6292 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6293 | ····} |
6294 | ····void CreateObjects() |
6295 | ····{ |
6296 | ········pm.MakePersistent(ownVar); |
6297 | ········pm.Save(); |
6298 | ········pm.MakePersistent(otherVar); |
6299 | ········pm.Save(); |
6300 | ········ownVar.AssignRelation(otherVar); |
6301 | ········pm.Save(); |
6302 | ········pm.UnloadCache(); |
6303 | ····} |
6304 | ····void QueryOwn() |
6305 | ····{ |
6306 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblAutoLeft>(pm); |
6307 | ········ownVar = q.ExecuteSingle(); |
6308 | ····} |
6309 | ····void QueryOther() |
6310 | ····{ |
6311 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblAutoRightBase>(pm); |
6312 | ········otherVar = q.ExecuteSingle(); |
6313 | ····} |
6314 | } |
6315 | |
6316 | |
6317 | [TestFixture] |
6318 | public class TestAgrBi1nOthpconTblAuto : NDOTest |
6319 | { |
6320 | ····AgrBi1nOthpconTblAutoLeft ownVar; |
6321 | ····AgrBi1nOthpconTblAutoRightBase otherVar; |
6322 | ····PersistenceManager pm; |
6323 | ····[SetUp] |
6324 | ····public void Setup() |
6325 | ····{ |
6326 | ········pm = PmFactory.NewPersistenceManager(); |
6327 | ········ownVar = new AgrBi1nOthpconTblAutoLeft(); |
6328 | ········otherVar = new AgrBi1nOthpconTblAutoRightDerived(); |
6329 | ····} |
6330 | ····[TearDown] |
6331 | ····public void TearDown() |
6332 | ····{ |
6333 | ········try |
6334 | ········{ |
6335 | ············pm.UnloadCache(); |
6336 | ············var l = pm.Objects<AgrBi1nOthpconTblAutoLeft>().ResultTable; |
6337 | ············pm.Delete(l); |
6338 | ············pm.Save(); |
6339 | ············pm.UnloadCache(); |
6340 | ············var m = pm.Objects<AgrBi1nOthpconTblAutoRightBase>().ResultTable; |
6341 | ············pm.Delete(m); |
6342 | ············pm.Save(); |
6343 | ············pm.UnloadCache(); |
6344 | ············decimal count; |
6345 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6346 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6347 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6348 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6349 | ········} |
6350 | ········catch (Exception) |
6351 | ········{ |
6352 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6353 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6354 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6355 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6356 | ········} |
6357 | ····} |
6358 | ····[Test] |
6359 | ····public void TestSaveReload() |
6360 | ····{ |
6361 | ········CreateObjects(); |
6362 | ········QueryOwn(); |
6363 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6364 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6365 | ····} |
6366 | ····[Test] |
6367 | ····public void TestSaveReloadNull() |
6368 | ····{ |
6369 | ········CreateObjects(); |
6370 | ········QueryOwn(); |
6371 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6372 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6373 | ········ownVar.RelField = null; |
6374 | ········pm.Save(); |
6375 | ········pm.UnloadCache(); |
6376 | ········QueryOwn(); |
6377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6378 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6379 | ····} |
6380 | ····[Test] |
6381 | ····public void TestChangeKeyHolderLeft() |
6382 | ····{ |
6383 | ········CreateObjects(); |
6384 | ········QueryOwn(); |
6385 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6386 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6387 | ········int x = ownVar.RelField.Dummy; |
6388 | ········ownVar.Dummy = 4711; |
6389 | ········pm.Save(); |
6390 | ········pm.UnloadCache(); |
6391 | ········QueryOwn(); |
6392 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6393 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6394 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6395 | ····} |
6396 | ····[Test] |
6397 | ····public void TestChangeKeyHolderLeftNoTouch() |
6398 | ····{ |
6399 | ········CreateObjects(); |
6400 | ········QueryOwn(); |
6401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6402 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6403 | ········ownVar.Dummy = 4711; |
6404 | ········pm.Save(); |
6405 | ········pm.UnloadCache(); |
6406 | ········QueryOwn(); |
6407 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6408 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6409 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6410 | ····} |
6411 | ····[Test] |
6412 | ····public void TestRelationHash() |
6413 | ····{ |
6414 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoLeft)); |
6415 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6416 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoRightBase)); |
6417 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6418 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6419 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6420 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblAutoRightDerived)); |
6421 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6422 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6423 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6424 | ····} |
6425 | ····void CreateObjects() |
6426 | ····{ |
6427 | ········pm.MakePersistent(ownVar); |
6428 | ········pm.MakePersistent(otherVar); |
6429 | ········ownVar.AssignRelation(otherVar); |
6430 | ········pm.Save(); |
6431 | ········pm.UnloadCache(); |
6432 | ····} |
6433 | ····void QueryOwn() |
6434 | ····{ |
6435 | ········var q = new NDOQuery<AgrBi1nOthpconTblAutoLeft>(pm); |
6436 | ········ownVar = q.ExecuteSingle(); |
6437 | ····} |
6438 | ····void QueryOther() |
6439 | ····{ |
6440 | ········var q = new NDOQuery<AgrBi1nOthpconTblAutoRightBase>(pm); |
6441 | ········otherVar = q.ExecuteSingle(); |
6442 | ····} |
6443 | } |
6444 | |
6445 | |
6446 | [TestFixture] |
6447 | public class TestAgrBinnOthpconTblAuto : NDOTest |
6448 | { |
6449 | ····AgrBinnOthpconTblAutoLeft ownVar; |
6450 | ····AgrBinnOthpconTblAutoRightBase otherVar; |
6451 | ····PersistenceManager pm; |
6452 | ····[SetUp] |
6453 | ····public void Setup() |
6454 | ····{ |
6455 | ········pm = PmFactory.NewPersistenceManager(); |
6456 | ········ownVar = new AgrBinnOthpconTblAutoLeft(); |
6457 | ········otherVar = new AgrBinnOthpconTblAutoRightDerived(); |
6458 | ····} |
6459 | ····[TearDown] |
6460 | ····public void TearDown() |
6461 | ····{ |
6462 | ········try |
6463 | ········{ |
6464 | ············pm.UnloadCache(); |
6465 | ············var l = pm.Objects<AgrBinnOthpconTblAutoLeft>().ResultTable; |
6466 | ············pm.Delete(l); |
6467 | ············pm.Save(); |
6468 | ············pm.UnloadCache(); |
6469 | ············var m = pm.Objects<AgrBinnOthpconTblAutoRightBase>().ResultTable; |
6470 | ············pm.Delete(m); |
6471 | ············pm.Save(); |
6472 | ············pm.UnloadCache(); |
6473 | ············decimal count; |
6474 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6475 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6476 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6477 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6478 | ········} |
6479 | ········catch (Exception) |
6480 | ········{ |
6481 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6482 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6483 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6484 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6485 | ········} |
6486 | ····} |
6487 | ····[Test] |
6488 | ····public void TestSaveReload() |
6489 | ····{ |
6490 | ········CreateObjects(); |
6491 | ········QueryOwn(); |
6492 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6493 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6494 | ····} |
6495 | ····[Test] |
6496 | ····public void TestSaveReloadNull() |
6497 | ····{ |
6498 | ········CreateObjects(); |
6499 | ········QueryOwn(); |
6500 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6501 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6502 | ········ownVar.RelField = new List<AgrBinnOthpconTblAutoRightBase>(); |
6503 | ········pm.Save(); |
6504 | ········pm.UnloadCache(); |
6505 | ········QueryOwn(); |
6506 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6507 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6508 | ····} |
6509 | ····[Test] |
6510 | ····public void TestSaveReloadRemove() |
6511 | ····{ |
6512 | ········CreateObjects(); |
6513 | ········QueryOwn(); |
6514 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6515 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6516 | ········ownVar.RemoveRelatedObject(); |
6517 | ········pm.Save(); |
6518 | ········pm.UnloadCache(); |
6519 | ········QueryOwn(); |
6520 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6521 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
6522 | ····} |
6523 | ····[Test] |
6524 | ····public void TestRelationHash() |
6525 | ····{ |
6526 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoLeft)); |
6527 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6528 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoRightBase)); |
6529 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6530 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6531 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6532 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblAutoRightDerived)); |
6533 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6534 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6535 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6536 | ····} |
6537 | ····void CreateObjects() |
6538 | ····{ |
6539 | ········pm.MakePersistent(ownVar); |
6540 | ········pm.MakePersistent(otherVar); |
6541 | ········ownVar.AssignRelation(otherVar); |
6542 | ········pm.Save(); |
6543 | ········pm.UnloadCache(); |
6544 | ····} |
6545 | ····void QueryOwn() |
6546 | ····{ |
6547 | ········var q = new NDOQuery<AgrBinnOthpconTblAutoLeft>(pm); |
6548 | ········ownVar = q.ExecuteSingle(); |
6549 | ····} |
6550 | ····void QueryOther() |
6551 | ····{ |
6552 | ········var q = new NDOQuery<AgrBinnOthpconTblAutoRightBase>(pm); |
6553 | ········otherVar = q.ExecuteSingle(); |
6554 | ····} |
6555 | } |
6556 | |
6557 | |
6558 | [TestFixture] |
6559 | public class TestCmpDir1OthpconNoTblAuto : NDOTest |
6560 | { |
6561 | ····CmpDir1OthpconNoTblAutoLeft ownVar; |
6562 | ····CmpDir1OthpconNoTblAutoRightBase otherVar; |
6563 | ····PersistenceManager pm; |
6564 | ····[SetUp] |
6565 | ····public void Setup() |
6566 | ····{ |
6567 | ········pm = PmFactory.NewPersistenceManager(); |
6568 | ········ownVar = new CmpDir1OthpconNoTblAutoLeft(); |
6569 | ········otherVar = new CmpDir1OthpconNoTblAutoRightDerived(); |
6570 | ····} |
6571 | ····[TearDown] |
6572 | ····public void TearDown() |
6573 | ····{ |
6574 | ········try |
6575 | ········{ |
6576 | ············pm.UnloadCache(); |
6577 | ············var l = pm.Objects<CmpDir1OthpconNoTblAutoLeft>().ResultTable; |
6578 | ············pm.Delete(l); |
6579 | ············pm.Save(); |
6580 | ············pm.UnloadCache(); |
6581 | ············decimal count; |
6582 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6583 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6584 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6585 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6586 | ········} |
6587 | ········catch (Exception) |
6588 | ········{ |
6589 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6590 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6591 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6592 | ········} |
6593 | ····} |
6594 | ····[Test] |
6595 | ····public void TestSaveReload() |
6596 | ····{ |
6597 | ········bool thrown = false; |
6598 | ········try |
6599 | ········{ |
6600 | ············CreateObjects(); |
6601 | ············QueryOwn(); |
6602 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6603 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6604 | ········} |
6605 | ········catch (NDOException) |
6606 | ········{ |
6607 | ············thrown = true; |
6608 | ········} |
6609 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6610 | ····} |
6611 | ····[Test] |
6612 | ····public void TestSaveReloadNull() |
6613 | ····{ |
6614 | ········bool thrown = false; |
6615 | ········try |
6616 | ········{ |
6617 | ············CreateObjects(); |
6618 | ············QueryOwn(); |
6619 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6620 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6621 | ············ownVar.RelField = null; |
6622 | ············pm.Save(); |
6623 | ············pm.UnloadCache(); |
6624 | ············QueryOwn(); |
6625 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6626 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6627 | ········} |
6628 | ········catch (NDOException) |
6629 | ········{ |
6630 | ············thrown = true; |
6631 | ········} |
6632 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6633 | ····} |
6634 | ····void CreateObjects() |
6635 | ····{ |
6636 | ········pm.MakePersistent(ownVar); |
6637 | ········pm.Save(); |
6638 | ········ownVar.AssignRelation(otherVar); |
6639 | ········pm.Save(); |
6640 | ········pm.UnloadCache(); |
6641 | ····} |
6642 | ····void QueryOwn() |
6643 | ····{ |
6644 | ········var q = new NDOQuery<CmpDir1OthpconNoTblAutoLeft>(pm); |
6645 | ········ownVar = q.ExecuteSingle(); |
6646 | ····} |
6647 | ····void QueryOther() |
6648 | ····{ |
6649 | ········var q = new NDOQuery<CmpDir1OthpconNoTblAutoRightBase>(pm); |
6650 | ········otherVar = q.ExecuteSingle(); |
6651 | ····} |
6652 | } |
6653 | |
6654 | |
6655 | [TestFixture] |
6656 | public class TestCmpDir1OthpconTblAuto : NDOTest |
6657 | { |
6658 | ····CmpDir1OthpconTblAutoLeft ownVar; |
6659 | ····CmpDir1OthpconTblAutoRightBase otherVar; |
6660 | ····PersistenceManager pm; |
6661 | ····[SetUp] |
6662 | ····public void Setup() |
6663 | ····{ |
6664 | ········pm = PmFactory.NewPersistenceManager(); |
6665 | ········ownVar = new CmpDir1OthpconTblAutoLeft(); |
6666 | ········otherVar = new CmpDir1OthpconTblAutoRightDerived(); |
6667 | ····} |
6668 | ····[TearDown] |
6669 | ····public void TearDown() |
6670 | ····{ |
6671 | ········try |
6672 | ········{ |
6673 | ············pm.UnloadCache(); |
6674 | ············var l = pm.Objects<CmpDir1OthpconTblAutoLeft>().ResultTable; |
6675 | ············pm.Delete(l); |
6676 | ············pm.Save(); |
6677 | ············pm.UnloadCache(); |
6678 | ············decimal count; |
6679 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6680 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6681 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6682 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6683 | ········} |
6684 | ········catch (Exception) |
6685 | ········{ |
6686 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6687 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6688 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6689 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6690 | ········} |
6691 | ····} |
6692 | ····[Test] |
6693 | ····public void TestSaveReload() |
6694 | ····{ |
6695 | ········CreateObjects(); |
6696 | ········QueryOwn(); |
6697 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6698 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6699 | ····} |
6700 | ····[Test] |
6701 | ····public void TestSaveReloadNull() |
6702 | ····{ |
6703 | ········CreateObjects(); |
6704 | ········QueryOwn(); |
6705 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6706 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6707 | ········ownVar.RelField = null; |
6708 | ········pm.Save(); |
6709 | ········pm.UnloadCache(); |
6710 | ········QueryOwn(); |
6711 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6712 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6713 | ····} |
6714 | ····[Test] |
6715 | ····public void TestChangeKeyHolderLeft() |
6716 | ····{ |
6717 | ········CreateObjects(); |
6718 | ········QueryOwn(); |
6719 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6720 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6721 | ········int x = ownVar.RelField.Dummy; |
6722 | ········ownVar.Dummy = 4711; |
6723 | ········pm.Save(); |
6724 | ········pm.UnloadCache(); |
6725 | ········QueryOwn(); |
6726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6727 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6728 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6729 | ····} |
6730 | ····[Test] |
6731 | ····public void TestChangeKeyHolderLeftNoTouch() |
6732 | ····{ |
6733 | ········CreateObjects(); |
6734 | ········QueryOwn(); |
6735 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6736 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6737 | ········ownVar.Dummy = 4711; |
6738 | ········pm.Save(); |
6739 | ········pm.UnloadCache(); |
6740 | ········QueryOwn(); |
6741 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6742 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6744 | ····} |
6745 | ····void CreateObjects() |
6746 | ····{ |
6747 | ········pm.MakePersistent(ownVar); |
6748 | ········ownVar.AssignRelation(otherVar); |
6749 | ········pm.Save(); |
6750 | ········pm.UnloadCache(); |
6751 | ····} |
6752 | ····void QueryOwn() |
6753 | ····{ |
6754 | ········var q = new NDOQuery<CmpDir1OthpconTblAutoLeft>(pm); |
6755 | ········ownVar = q.ExecuteSingle(); |
6756 | ····} |
6757 | ····void QueryOther() |
6758 | ····{ |
6759 | ········var q = new NDOQuery<CmpDir1OthpconTblAutoRightBase>(pm); |
6760 | ········otherVar = q.ExecuteSingle(); |
6761 | ····} |
6762 | } |
6763 | |
6764 | |
6765 | [TestFixture] |
6766 | public class TestCmpBi11OthpconNoTblAuto : NDOTest |
6767 | { |
6768 | ····CmpBi11OthpconNoTblAutoLeft ownVar; |
6769 | ····CmpBi11OthpconNoTblAutoRightBase otherVar; |
6770 | ····PersistenceManager pm; |
6771 | ····[SetUp] |
6772 | ····public void Setup() |
6773 | ····{ |
6774 | ········pm = PmFactory.NewPersistenceManager(); |
6775 | ········ownVar = new CmpBi11OthpconNoTblAutoLeft(); |
6776 | ········otherVar = new CmpBi11OthpconNoTblAutoRightDerived(); |
6777 | ····} |
6778 | ····[TearDown] |
6779 | ····public void TearDown() |
6780 | ····{ |
6781 | ········try |
6782 | ········{ |
6783 | ············pm.UnloadCache(); |
6784 | ············var l = pm.Objects<CmpBi11OthpconNoTblAutoLeft>().ResultTable; |
6785 | ············pm.Delete(l); |
6786 | ············pm.Save(); |
6787 | ············pm.UnloadCache(); |
6788 | ············decimal count; |
6789 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6790 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6791 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6792 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6793 | ········} |
6794 | ········catch (Exception) |
6795 | ········{ |
6796 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6797 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6798 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6799 | ········} |
6800 | ····} |
6801 | ····[Test] |
6802 | ····public void TestSaveReload() |
6803 | ····{ |
6804 | ········bool thrown = false; |
6805 | ········try |
6806 | ········{ |
6807 | ············CreateObjects(); |
6808 | ············QueryOwn(); |
6809 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6810 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6811 | ········} |
6812 | ········catch (NDOException) |
6813 | ········{ |
6814 | ············thrown = true; |
6815 | ········} |
6816 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6817 | ····} |
6818 | ····[Test] |
6819 | ····public void TestSaveReloadNull() |
6820 | ····{ |
6821 | ········bool thrown = false; |
6822 | ········try |
6823 | ········{ |
6824 | ············CreateObjects(); |
6825 | ············QueryOwn(); |
6826 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6827 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6828 | ············ownVar.RelField = null; |
6829 | ············pm.Save(); |
6830 | ············pm.UnloadCache(); |
6831 | ············QueryOwn(); |
6832 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6833 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6834 | ········} |
6835 | ········catch (NDOException) |
6836 | ········{ |
6837 | ············thrown = true; |
6838 | ········} |
6839 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
6840 | ····} |
6841 | ····[Test] |
6842 | ····public void TestRelationHash() |
6843 | ····{ |
6844 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoLeft)); |
6845 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
6846 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoRightBase)); |
6847 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
6848 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
6849 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
6850 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblAutoRightDerived)); |
6851 | ········Relation relderRight = clderRight.FindRelation("relField"); |
6852 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
6853 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
6854 | ····} |
6855 | ····void CreateObjects() |
6856 | ····{ |
6857 | ········pm.MakePersistent(ownVar); |
6858 | ········pm.Save(); |
6859 | ········ownVar.AssignRelation(otherVar); |
6860 | ········pm.Save(); |
6861 | ········pm.UnloadCache(); |
6862 | ····} |
6863 | ····void QueryOwn() |
6864 | ····{ |
6865 | ········var q = new NDOQuery<CmpBi11OthpconNoTblAutoLeft>(pm); |
6866 | ········ownVar = q.ExecuteSingle(); |
6867 | ····} |
6868 | ····void QueryOther() |
6869 | ····{ |
6870 | ········var q = new NDOQuery<CmpBi11OthpconNoTblAutoRightBase>(pm); |
6871 | ········otherVar = q.ExecuteSingle(); |
6872 | ····} |
6873 | } |
6874 | |
6875 | |
6876 | [TestFixture] |
6877 | public class TestCmpBi11OthpconTblAuto : NDOTest |
6878 | { |
6879 | ····CmpBi11OthpconTblAutoLeft ownVar; |
6880 | ····CmpBi11OthpconTblAutoRightBase otherVar; |
6881 | ····PersistenceManager pm; |
6882 | ····[SetUp] |
6883 | ····public void Setup() |
6884 | ····{ |
6885 | ········pm = PmFactory.NewPersistenceManager(); |
6886 | ········ownVar = new CmpBi11OthpconTblAutoLeft(); |
6887 | ········otherVar = new CmpBi11OthpconTblAutoRightDerived(); |
6888 | ····} |
6889 | ····[TearDown] |
6890 | ····public void TearDown() |
6891 | ····{ |
6892 | ········try |
6893 | ········{ |
6894 | ············pm.UnloadCache(); |
6895 | ············var l = pm.Objects<CmpBi11OthpconTblAutoLeft>().ResultTable; |
6896 | ············pm.Delete(l); |
6897 | ············pm.Save(); |
6898 | ············pm.UnloadCache(); |
6899 | ············decimal count; |
6900 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6901 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
6902 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
6903 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
6904 | ········} |
6905 | ········catch (Exception) |
6906 | ········{ |
6907 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
6908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
6909 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
6910 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
6911 | ········} |
6912 | ····} |
6913 | ····[Test] |
6914 | ····public void TestSaveReload() |
6915 | ····{ |
6916 | ········CreateObjects(); |
6917 | ········QueryOwn(); |
6918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6919 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6920 | ····} |
6921 | ····[Test] |
6922 | ····public void TestSaveReloadNull() |
6923 | ····{ |
6924 | ········CreateObjects(); |
6925 | ········QueryOwn(); |
6926 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6927 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6928 | ········ownVar.RelField = null; |
6929 | ········pm.Save(); |
6930 | ········pm.UnloadCache(); |
6931 | ········QueryOwn(); |
6932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6933 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
6934 | ····} |
6935 | ····[Test] |
6936 | ····public void TestChangeKeyHolderLeft() |
6937 | ····{ |
6938 | ········CreateObjects(); |
6939 | ········QueryOwn(); |
6940 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6941 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6942 | ········int x = ownVar.RelField.Dummy; |
6943 | ········ownVar.Dummy = 4711; |
6944 | ········pm.Save(); |
6945 | ········pm.UnloadCache(); |
6946 | ········QueryOwn(); |
6947 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6948 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6949 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6950 | ····} |
6951 | ····[Test] |
6952 | ····public void TestChangeKeyHolderRight() |
6953 | ····{ |
6954 | ········CreateObjects(); |
6955 | ········QueryOther(); |
6956 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6957 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6958 | ········int x = otherVar.RelField.Dummy; |
6959 | ········otherVar.Dummy = 4711; |
6960 | ········pm.Save(); |
6961 | ········pm.UnloadCache(); |
6962 | ········QueryOther(); |
6963 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6964 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6965 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6966 | ····} |
6967 | ····[Test] |
6968 | ····public void TestChangeKeyHolderLeftNoTouch() |
6969 | ····{ |
6970 | ········CreateObjects(); |
6971 | ········QueryOwn(); |
6972 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6973 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6974 | ········ownVar.Dummy = 4711; |
6975 | ········pm.Save(); |
6976 | ········pm.UnloadCache(); |
6977 | ········QueryOwn(); |
6978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
6979 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6980 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
6981 | ····} |
6982 | ····[Test] |
6983 | ····public void TestChangeKeyHolderRightNoTouch() |
6984 | ····{ |
6985 | ········CreateObjects(); |
6986 | ········QueryOther(); |
6987 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6988 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6989 | ········otherVar.Dummy = 4711; |
6990 | ········pm.Save(); |
6991 | ········pm.UnloadCache(); |
6992 | ········QueryOther(); |
6993 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
6994 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
6995 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
6996 | ····} |
6997 | ····[Test] |
6998 | ····public void TestRelationHash() |
6999 | ····{ |
7000 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoLeft)); |
7001 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7002 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoRightBase)); |
7003 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7004 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7005 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7006 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblAutoRightDerived)); |
7007 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7008 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7009 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7010 | ····} |
7011 | ····void CreateObjects() |
7012 | ····{ |
7013 | ········pm.MakePersistent(ownVar); |
7014 | ········ownVar.AssignRelation(otherVar); |
7015 | ········pm.Save(); |
7016 | ········pm.UnloadCache(); |
7017 | ····} |
7018 | ····void QueryOwn() |
7019 | ····{ |
7020 | ········var q = new NDOQuery<CmpBi11OthpconTblAutoLeft>(pm); |
7021 | ········ownVar = q.ExecuteSingle(); |
7022 | ····} |
7023 | ····void QueryOther() |
7024 | ····{ |
7025 | ········var q = new NDOQuery<CmpBi11OthpconTblAutoRightBase>(pm); |
7026 | ········otherVar = q.ExecuteSingle(); |
7027 | ····} |
7028 | } |
7029 | |
7030 | |
7031 | [TestFixture] |
7032 | public class TestCmpDirnOthpconTblAuto : NDOTest |
7033 | { |
7034 | ····CmpDirnOthpconTblAutoLeft ownVar; |
7035 | ····CmpDirnOthpconTblAutoRightBase otherVar; |
7036 | ····PersistenceManager pm; |
7037 | ····[SetUp] |
7038 | ····public void Setup() |
7039 | ····{ |
7040 | ········pm = PmFactory.NewPersistenceManager(); |
7041 | ········ownVar = new CmpDirnOthpconTblAutoLeft(); |
7042 | ········otherVar = new CmpDirnOthpconTblAutoRightDerived(); |
7043 | ····} |
7044 | ····[TearDown] |
7045 | ····public void TearDown() |
7046 | ····{ |
7047 | ········try |
7048 | ········{ |
7049 | ············pm.UnloadCache(); |
7050 | ············var l = pm.Objects<CmpDirnOthpconTblAutoLeft>().ResultTable; |
7051 | ············pm.Delete(l); |
7052 | ············pm.Save(); |
7053 | ············pm.UnloadCache(); |
7054 | ············decimal count; |
7055 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7056 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7057 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7058 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7059 | ········} |
7060 | ········catch (Exception) |
7061 | ········{ |
7062 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7063 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7064 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7065 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7066 | ········} |
7067 | ····} |
7068 | ····[Test] |
7069 | ····public void TestSaveReload() |
7070 | ····{ |
7071 | ········CreateObjects(); |
7072 | ········QueryOwn(); |
7073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7074 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7075 | ····} |
7076 | ····[Test] |
7077 | ····public void TestSaveReloadNull() |
7078 | ····{ |
7079 | ········CreateObjects(); |
7080 | ········QueryOwn(); |
7081 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7082 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7083 | ········ownVar.RelField = new List<CmpDirnOthpconTblAutoRightBase>(); |
7084 | ········pm.Save(); |
7085 | ········pm.UnloadCache(); |
7086 | ········QueryOwn(); |
7087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7088 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7089 | ····} |
7090 | ····[Test] |
7091 | ····public void TestSaveReloadRemove() |
7092 | ····{ |
7093 | ········CreateObjects(); |
7094 | ········QueryOwn(); |
7095 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7096 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7097 | ········ownVar.RemoveRelatedObject(); |
7098 | ········pm.Save(); |
7099 | ········pm.UnloadCache(); |
7100 | ········QueryOwn(); |
7101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7102 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7103 | ····} |
7104 | ····void CreateObjects() |
7105 | ····{ |
7106 | ········pm.MakePersistent(ownVar); |
7107 | ········ownVar.AssignRelation(otherVar); |
7108 | ········pm.Save(); |
7109 | ········pm.UnloadCache(); |
7110 | ····} |
7111 | ····void QueryOwn() |
7112 | ····{ |
7113 | ········var q = new NDOQuery<CmpDirnOthpconTblAutoLeft>(pm); |
7114 | ········ownVar = q.ExecuteSingle(); |
7115 | ····} |
7116 | ····void QueryOther() |
7117 | ····{ |
7118 | ········var q = new NDOQuery<CmpDirnOthpconTblAutoRightBase>(pm); |
7119 | ········otherVar = q.ExecuteSingle(); |
7120 | ····} |
7121 | } |
7122 | |
7123 | |
7124 | [TestFixture] |
7125 | public class TestCmpBin1OthpconTblAuto : NDOTest |
7126 | { |
7127 | ····CmpBin1OthpconTblAutoLeft ownVar; |
7128 | ····CmpBin1OthpconTblAutoRightBase otherVar; |
7129 | ····PersistenceManager pm; |
7130 | ····[SetUp] |
7131 | ····public void Setup() |
7132 | ····{ |
7133 | ········pm = PmFactory.NewPersistenceManager(); |
7134 | ········ownVar = new CmpBin1OthpconTblAutoLeft(); |
7135 | ········otherVar = new CmpBin1OthpconTblAutoRightDerived(); |
7136 | ····} |
7137 | ····[TearDown] |
7138 | ····public void TearDown() |
7139 | ····{ |
7140 | ········try |
7141 | ········{ |
7142 | ············pm.UnloadCache(); |
7143 | ············var l = pm.Objects<CmpBin1OthpconTblAutoLeft>().ResultTable; |
7144 | ············pm.Delete(l); |
7145 | ············pm.Save(); |
7146 | ············pm.UnloadCache(); |
7147 | ············decimal count; |
7148 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7150 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7151 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7152 | ········} |
7153 | ········catch (Exception) |
7154 | ········{ |
7155 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7156 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7158 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7159 | ········} |
7160 | ····} |
7161 | ····[Test] |
7162 | ····public void TestSaveReload() |
7163 | ····{ |
7164 | ········CreateObjects(); |
7165 | ········QueryOwn(); |
7166 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7167 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7168 | ····} |
7169 | ····[Test] |
7170 | ····public void TestSaveReloadNull() |
7171 | ····{ |
7172 | ········CreateObjects(); |
7173 | ········QueryOwn(); |
7174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7175 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7176 | ········ownVar.RelField = new List<CmpBin1OthpconTblAutoRightBase>(); |
7177 | ········pm.Save(); |
7178 | ········pm.UnloadCache(); |
7179 | ········QueryOwn(); |
7180 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7181 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7182 | ····} |
7183 | ····[Test] |
7184 | ····public void TestSaveReloadRemove() |
7185 | ····{ |
7186 | ········CreateObjects(); |
7187 | ········QueryOwn(); |
7188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7189 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7190 | ········ownVar.RemoveRelatedObject(); |
7191 | ········pm.Save(); |
7192 | ········pm.UnloadCache(); |
7193 | ········QueryOwn(); |
7194 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7195 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7196 | ····} |
7197 | ····[Test] |
7198 | ····public void TestChangeKeyHolderRight() |
7199 | ····{ |
7200 | ········CreateObjects(); |
7201 | ········QueryOther(); |
7202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7204 | ········int x = otherVar.RelField.Dummy; |
7205 | ········otherVar.Dummy = 4711; |
7206 | ········pm.Save(); |
7207 | ········pm.UnloadCache(); |
7208 | ········QueryOther(); |
7209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7212 | ····} |
7213 | ····[Test] |
7214 | ····public void TestChangeKeyHolderRightNoTouch() |
7215 | ····{ |
7216 | ········CreateObjects(); |
7217 | ········QueryOther(); |
7218 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7219 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7220 | ········otherVar.Dummy = 4711; |
7221 | ········pm.Save(); |
7222 | ········pm.UnloadCache(); |
7223 | ········QueryOther(); |
7224 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7225 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7226 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7227 | ····} |
7228 | ····[Test] |
7229 | ····public void TestRelationHash() |
7230 | ····{ |
7231 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoLeft)); |
7232 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7233 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoRightBase)); |
7234 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7235 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7236 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7237 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblAutoRightDerived)); |
7238 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7239 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7240 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7241 | ····} |
7242 | ····void CreateObjects() |
7243 | ····{ |
7244 | ········pm.MakePersistent(ownVar); |
7245 | ········ownVar.AssignRelation(otherVar); |
7246 | ········pm.Save(); |
7247 | ········pm.UnloadCache(); |
7248 | ····} |
7249 | ····void QueryOwn() |
7250 | ····{ |
7251 | ········var q = new NDOQuery<CmpBin1OthpconTblAutoLeft>(pm); |
7252 | ········ownVar = q.ExecuteSingle(); |
7253 | ····} |
7254 | ····void QueryOther() |
7255 | ····{ |
7256 | ········var q = new NDOQuery<CmpBin1OthpconTblAutoRightBase>(pm); |
7257 | ········otherVar = q.ExecuteSingle(); |
7258 | ····} |
7259 | } |
7260 | |
7261 | |
7262 | [TestFixture] |
7263 | public class TestCmpBi1nOthpconNoTblAuto : NDOTest |
7264 | { |
7265 | ····CmpBi1nOthpconNoTblAutoLeft ownVar; |
7266 | ····CmpBi1nOthpconNoTblAutoRightBase otherVar; |
7267 | ····PersistenceManager pm; |
7268 | ····[SetUp] |
7269 | ····public void Setup() |
7270 | ····{ |
7271 | ········pm = PmFactory.NewPersistenceManager(); |
7272 | ········ownVar = new CmpBi1nOthpconNoTblAutoLeft(); |
7273 | ········otherVar = new CmpBi1nOthpconNoTblAutoRightDerived(); |
7274 | ····} |
7275 | ····[TearDown] |
7276 | ····public void TearDown() |
7277 | ····{ |
7278 | ········try |
7279 | ········{ |
7280 | ············pm.UnloadCache(); |
7281 | ············var l = pm.Objects<CmpBi1nOthpconNoTblAutoLeft>().ResultTable; |
7282 | ············pm.Delete(l); |
7283 | ············pm.Save(); |
7284 | ············pm.UnloadCache(); |
7285 | ············decimal count; |
7286 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7287 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7288 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7289 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7290 | ········} |
7291 | ········catch (Exception) |
7292 | ········{ |
7293 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7294 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7295 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7296 | ········} |
7297 | ····} |
7298 | ····[Test] |
7299 | ····public void TestSaveReload() |
7300 | ····{ |
7301 | ········bool thrown = false; |
7302 | ········try |
7303 | ········{ |
7304 | ············CreateObjects(); |
7305 | ············QueryOwn(); |
7306 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7307 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7308 | ········} |
7309 | ········catch (NDOException) |
7310 | ········{ |
7311 | ············thrown = true; |
7312 | ········} |
7313 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
7314 | ····} |
7315 | ····[Test] |
7316 | ····public void TestSaveReloadNull() |
7317 | ····{ |
7318 | ········bool thrown = false; |
7319 | ········try |
7320 | ········{ |
7321 | ············CreateObjects(); |
7322 | ············QueryOwn(); |
7323 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7324 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7325 | ············ownVar.RelField = null; |
7326 | ············pm.Save(); |
7327 | ············pm.UnloadCache(); |
7328 | ············QueryOwn(); |
7329 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7330 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7331 | ········} |
7332 | ········catch (NDOException) |
7333 | ········{ |
7334 | ············thrown = true; |
7335 | ········} |
7336 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
7337 | ····} |
7338 | ····[Test] |
7339 | ····public void TestRelationHash() |
7340 | ····{ |
7341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoLeft)); |
7342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoRightBase)); |
7344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7347 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblAutoRightDerived)); |
7348 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7349 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7350 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7351 | ····} |
7352 | ····void CreateObjects() |
7353 | ····{ |
7354 | ········pm.MakePersistent(ownVar); |
7355 | ········pm.Save(); |
7356 | ········ownVar.AssignRelation(otherVar); |
7357 | ········pm.Save(); |
7358 | ········pm.UnloadCache(); |
7359 | ····} |
7360 | ····void QueryOwn() |
7361 | ····{ |
7362 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblAutoLeft>(pm); |
7363 | ········ownVar = q.ExecuteSingle(); |
7364 | ····} |
7365 | ····void QueryOther() |
7366 | ····{ |
7367 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblAutoRightBase>(pm); |
7368 | ········otherVar = q.ExecuteSingle(); |
7369 | ····} |
7370 | } |
7371 | |
7372 | |
7373 | [TestFixture] |
7374 | public class TestCmpBi1nOthpconTblAuto : NDOTest |
7375 | { |
7376 | ····CmpBi1nOthpconTblAutoLeft ownVar; |
7377 | ····CmpBi1nOthpconTblAutoRightBase otherVar; |
7378 | ····PersistenceManager pm; |
7379 | ····[SetUp] |
7380 | ····public void Setup() |
7381 | ····{ |
7382 | ········pm = PmFactory.NewPersistenceManager(); |
7383 | ········ownVar = new CmpBi1nOthpconTblAutoLeft(); |
7384 | ········otherVar = new CmpBi1nOthpconTblAutoRightDerived(); |
7385 | ····} |
7386 | ····[TearDown] |
7387 | ····public void TearDown() |
7388 | ····{ |
7389 | ········try |
7390 | ········{ |
7391 | ············pm.UnloadCache(); |
7392 | ············var l = pm.Objects<CmpBi1nOthpconTblAutoLeft>().ResultTable; |
7393 | ············pm.Delete(l); |
7394 | ············pm.Save(); |
7395 | ············pm.UnloadCache(); |
7396 | ············decimal count; |
7397 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7398 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7399 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7400 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7401 | ········} |
7402 | ········catch (Exception) |
7403 | ········{ |
7404 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7405 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7406 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7407 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7408 | ········} |
7409 | ····} |
7410 | ····[Test] |
7411 | ····public void TestSaveReload() |
7412 | ····{ |
7413 | ········CreateObjects(); |
7414 | ········QueryOwn(); |
7415 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7416 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7417 | ····} |
7418 | ····[Test] |
7419 | ····public void TestSaveReloadNull() |
7420 | ····{ |
7421 | ········CreateObjects(); |
7422 | ········QueryOwn(); |
7423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7424 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7425 | ········ownVar.RelField = null; |
7426 | ········pm.Save(); |
7427 | ········pm.UnloadCache(); |
7428 | ········QueryOwn(); |
7429 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7430 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7431 | ····} |
7432 | ····[Test] |
7433 | ····public void TestChangeKeyHolderLeft() |
7434 | ····{ |
7435 | ········CreateObjects(); |
7436 | ········QueryOwn(); |
7437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7438 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7439 | ········int x = ownVar.RelField.Dummy; |
7440 | ········ownVar.Dummy = 4711; |
7441 | ········pm.Save(); |
7442 | ········pm.UnloadCache(); |
7443 | ········QueryOwn(); |
7444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7445 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7447 | ····} |
7448 | ····[Test] |
7449 | ····public void TestChangeKeyHolderLeftNoTouch() |
7450 | ····{ |
7451 | ········CreateObjects(); |
7452 | ········QueryOwn(); |
7453 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7454 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7455 | ········ownVar.Dummy = 4711; |
7456 | ········pm.Save(); |
7457 | ········pm.UnloadCache(); |
7458 | ········QueryOwn(); |
7459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7460 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7462 | ····} |
7463 | ····[Test] |
7464 | ····public void TestRelationHash() |
7465 | ····{ |
7466 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoLeft)); |
7467 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7468 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoRightBase)); |
7469 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7470 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7471 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7472 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblAutoRightDerived)); |
7473 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7474 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7475 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7476 | ····} |
7477 | ····void CreateObjects() |
7478 | ····{ |
7479 | ········pm.MakePersistent(ownVar); |
7480 | ········ownVar.AssignRelation(otherVar); |
7481 | ········pm.Save(); |
7482 | ········pm.UnloadCache(); |
7483 | ····} |
7484 | ····void QueryOwn() |
7485 | ····{ |
7486 | ········var q = new NDOQuery<CmpBi1nOthpconTblAutoLeft>(pm); |
7487 | ········ownVar = q.ExecuteSingle(); |
7488 | ····} |
7489 | ····void QueryOther() |
7490 | ····{ |
7491 | ········var q = new NDOQuery<CmpBi1nOthpconTblAutoRightBase>(pm); |
7492 | ········otherVar = q.ExecuteSingle(); |
7493 | ····} |
7494 | } |
7495 | |
7496 | |
7497 | [TestFixture] |
7498 | public class TestCmpBinnOthpconTblAuto : NDOTest |
7499 | { |
7500 | ····CmpBinnOthpconTblAutoLeft ownVar; |
7501 | ····CmpBinnOthpconTblAutoRightBase otherVar; |
7502 | ····PersistenceManager pm; |
7503 | ····[SetUp] |
7504 | ····public void Setup() |
7505 | ····{ |
7506 | ········pm = PmFactory.NewPersistenceManager(); |
7507 | ········ownVar = new CmpBinnOthpconTblAutoLeft(); |
7508 | ········otherVar = new CmpBinnOthpconTblAutoRightDerived(); |
7509 | ····} |
7510 | ····[TearDown] |
7511 | ····public void TearDown() |
7512 | ····{ |
7513 | ········try |
7514 | ········{ |
7515 | ············pm.UnloadCache(); |
7516 | ············var l = pm.Objects<CmpBinnOthpconTblAutoLeft>().ResultTable; |
7517 | ············pm.Delete(l); |
7518 | ············pm.Save(); |
7519 | ············pm.UnloadCache(); |
7520 | ············decimal count; |
7521 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7522 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7523 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7524 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7525 | ········} |
7526 | ········catch (Exception) |
7527 | ········{ |
7528 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7529 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7530 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7531 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7532 | ········} |
7533 | ····} |
7534 | ····[Test] |
7535 | ····public void TestSaveReload() |
7536 | ····{ |
7537 | ········CreateObjects(); |
7538 | ········QueryOwn(); |
7539 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7540 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7541 | ····} |
7542 | ····[Test] |
7543 | ····public void TestSaveReloadNull() |
7544 | ····{ |
7545 | ········CreateObjects(); |
7546 | ········QueryOwn(); |
7547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7548 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7549 | ········ownVar.RelField = new List<CmpBinnOthpconTblAutoRightBase>(); |
7550 | ········pm.Save(); |
7551 | ········pm.UnloadCache(); |
7552 | ········QueryOwn(); |
7553 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7554 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7555 | ····} |
7556 | ····[Test] |
7557 | ····public void TestSaveReloadRemove() |
7558 | ····{ |
7559 | ········CreateObjects(); |
7560 | ········QueryOwn(); |
7561 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7562 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7563 | ········ownVar.RemoveRelatedObject(); |
7564 | ········pm.Save(); |
7565 | ········pm.UnloadCache(); |
7566 | ········QueryOwn(); |
7567 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7568 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
7569 | ····} |
7570 | ····[Test] |
7571 | ····public void TestRelationHash() |
7572 | ····{ |
7573 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoLeft)); |
7574 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7575 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoRightBase)); |
7576 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7577 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7578 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7579 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblAutoRightDerived)); |
7580 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7581 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7582 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7583 | ····} |
7584 | ····void CreateObjects() |
7585 | ····{ |
7586 | ········pm.MakePersistent(ownVar); |
7587 | ········ownVar.AssignRelation(otherVar); |
7588 | ········pm.Save(); |
7589 | ········pm.UnloadCache(); |
7590 | ····} |
7591 | ····void QueryOwn() |
7592 | ····{ |
7593 | ········var q = new NDOQuery<CmpBinnOthpconTblAutoLeft>(pm); |
7594 | ········ownVar = q.ExecuteSingle(); |
7595 | ····} |
7596 | ····void QueryOther() |
7597 | ····{ |
7598 | ········var q = new NDOQuery<CmpBinnOthpconTblAutoRightBase>(pm); |
7599 | ········otherVar = q.ExecuteSingle(); |
7600 | ····} |
7601 | } |
7602 | |
7603 | |
7604 | [TestFixture] |
7605 | public class TestAgrDir1OwnpconOthpconNoTblAuto : NDOTest |
7606 | { |
7607 | ····AgrDir1OwnpconOthpconNoTblAutoLeftBase ownVar; |
7608 | ····AgrDir1OwnpconOthpconNoTblAutoRightBase otherVar; |
7609 | ····PersistenceManager pm; |
7610 | ····[SetUp] |
7611 | ····public void Setup() |
7612 | ····{ |
7613 | ········pm = PmFactory.NewPersistenceManager(); |
7614 | ········ownVar = new AgrDir1OwnpconOthpconNoTblAutoLeftDerived(); |
7615 | ········otherVar = new AgrDir1OwnpconOthpconNoTblAutoRightDerived(); |
7616 | ····} |
7617 | ····[TearDown] |
7618 | ····public void TearDown() |
7619 | ····{ |
7620 | ········try |
7621 | ········{ |
7622 | ············pm.UnloadCache(); |
7623 | ············var l = pm.Objects<AgrDir1OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
7624 | ············pm.Delete(l); |
7625 | ············pm.Save(); |
7626 | ············pm.UnloadCache(); |
7627 | ············var m = pm.Objects<AgrDir1OwnpconOthpconNoTblAutoRightBase>().ResultTable; |
7628 | ············pm.Delete(m); |
7629 | ············pm.Save(); |
7630 | ············pm.UnloadCache(); |
7631 | ············decimal count; |
7632 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7633 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7634 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7636 | ········} |
7637 | ········catch (Exception) |
7638 | ········{ |
7639 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7640 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7641 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7642 | ········} |
7643 | ····} |
7644 | ····[Test] |
7645 | ····public void TestSaveReload() |
7646 | ····{ |
7647 | ········CreateObjects(); |
7648 | ········QueryOwn(); |
7649 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7650 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7651 | ····} |
7652 | ····[Test] |
7653 | ····public void TestSaveReloadNull() |
7654 | ····{ |
7655 | ········CreateObjects(); |
7656 | ········QueryOwn(); |
7657 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7658 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7659 | ········ownVar.RelField = null; |
7660 | ········pm.Save(); |
7661 | ········pm.UnloadCache(); |
7662 | ········QueryOwn(); |
7663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7664 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7665 | ····} |
7666 | ····[Test] |
7667 | ····public void TestChangeKeyHolderLeft() |
7668 | ····{ |
7669 | ········CreateObjects(); |
7670 | ········QueryOwn(); |
7671 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7672 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7673 | ········int x = ownVar.RelField.Dummy; |
7674 | ········ownVar.Dummy = 4711; |
7675 | ········pm.Save(); |
7676 | ········pm.UnloadCache(); |
7677 | ········QueryOwn(); |
7678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7679 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7680 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7681 | ····} |
7682 | ····[Test] |
7683 | ····public void TestChangeKeyHolderLeftNoTouch() |
7684 | ····{ |
7685 | ········CreateObjects(); |
7686 | ········QueryOwn(); |
7687 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7688 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7689 | ········ownVar.Dummy = 4711; |
7690 | ········pm.Save(); |
7691 | ········pm.UnloadCache(); |
7692 | ········QueryOwn(); |
7693 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7694 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7695 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7696 | ····} |
7697 | ····[Test] |
7698 | ····public void TestUpdateOrder() |
7699 | ····{ |
7700 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
7701 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
7702 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoLeftBase)})) |
7703 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoRightBase)})), "Wrong order #1"); |
7704 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoLeftDerived)})) |
7705 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpconOthpconNoTblAutoRightDerived)})), "Wrong order #2"); |
7706 | ········Debug.WriteLine("AgrDir1OwnpconOthpconNoTblAutoLeftBase"); |
7707 | ····} |
7708 | ····void CreateObjects() |
7709 | ····{ |
7710 | ········pm.MakePersistent(ownVar); |
7711 | ········pm.Save(); |
7712 | ········pm.MakePersistent(otherVar); |
7713 | ········pm.Save(); |
7714 | ········ownVar.AssignRelation(otherVar); |
7715 | ········pm.Save(); |
7716 | ········pm.UnloadCache(); |
7717 | ····} |
7718 | ····void QueryOwn() |
7719 | ····{ |
7720 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoLeftBase>(pm); |
7721 | ········ownVar = q.ExecuteSingle(); |
7722 | ····} |
7723 | ····void QueryOther() |
7724 | ····{ |
7725 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblAutoRightBase>(pm); |
7726 | ········otherVar = q.ExecuteSingle(); |
7727 | ····} |
7728 | } |
7729 | |
7730 | |
7731 | [TestFixture] |
7732 | public class TestAgrDir1OwnpconOthpconTblAuto : NDOTest |
7733 | { |
7734 | ····AgrDir1OwnpconOthpconTblAutoLeftBase ownVar; |
7735 | ····AgrDir1OwnpconOthpconTblAutoRightBase otherVar; |
7736 | ····PersistenceManager pm; |
7737 | ····[SetUp] |
7738 | ····public void Setup() |
7739 | ····{ |
7740 | ········pm = PmFactory.NewPersistenceManager(); |
7741 | ········ownVar = new AgrDir1OwnpconOthpconTblAutoLeftDerived(); |
7742 | ········otherVar = new AgrDir1OwnpconOthpconTblAutoRightDerived(); |
7743 | ····} |
7744 | ····[TearDown] |
7745 | ····public void TearDown() |
7746 | ····{ |
7747 | ········try |
7748 | ········{ |
7749 | ············pm.UnloadCache(); |
7750 | ············var l = pm.Objects<AgrDir1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
7751 | ············pm.Delete(l); |
7752 | ············pm.Save(); |
7753 | ············pm.UnloadCache(); |
7754 | ············var m = pm.Objects<AgrDir1OwnpconOthpconTblAutoRightBase>().ResultTable; |
7755 | ············pm.Delete(m); |
7756 | ············pm.Save(); |
7757 | ············pm.UnloadCache(); |
7758 | ············decimal count; |
7759 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7761 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7763 | ········} |
7764 | ········catch (Exception) |
7765 | ········{ |
7766 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7767 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7768 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7769 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
7770 | ········} |
7771 | ····} |
7772 | ····[Test] |
7773 | ····public void TestSaveReload() |
7774 | ····{ |
7775 | ········CreateObjects(); |
7776 | ········QueryOwn(); |
7777 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7778 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7779 | ····} |
7780 | ····[Test] |
7781 | ····public void TestSaveReloadNull() |
7782 | ····{ |
7783 | ········CreateObjects(); |
7784 | ········QueryOwn(); |
7785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7787 | ········ownVar.RelField = null; |
7788 | ········pm.Save(); |
7789 | ········pm.UnloadCache(); |
7790 | ········QueryOwn(); |
7791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7792 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7793 | ····} |
7794 | ····[Test] |
7795 | ····public void TestChangeKeyHolderLeft() |
7796 | ····{ |
7797 | ········CreateObjects(); |
7798 | ········QueryOwn(); |
7799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7800 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7801 | ········int x = ownVar.RelField.Dummy; |
7802 | ········ownVar.Dummy = 4711; |
7803 | ········pm.Save(); |
7804 | ········pm.UnloadCache(); |
7805 | ········QueryOwn(); |
7806 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7807 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7809 | ····} |
7810 | ····[Test] |
7811 | ····public void TestChangeKeyHolderLeftNoTouch() |
7812 | ····{ |
7813 | ········CreateObjects(); |
7814 | ········QueryOwn(); |
7815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7817 | ········ownVar.Dummy = 4711; |
7818 | ········pm.Save(); |
7819 | ········pm.UnloadCache(); |
7820 | ········QueryOwn(); |
7821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7822 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7823 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7824 | ····} |
7825 | ····void CreateObjects() |
7826 | ····{ |
7827 | ········pm.MakePersistent(ownVar); |
7828 | ········pm.MakePersistent(otherVar); |
7829 | ········ownVar.AssignRelation(otherVar); |
7830 | ········pm.Save(); |
7831 | ········pm.UnloadCache(); |
7832 | ····} |
7833 | ····void QueryOwn() |
7834 | ····{ |
7835 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblAutoLeftBase>(pm); |
7836 | ········ownVar = q.ExecuteSingle(); |
7837 | ····} |
7838 | ····void QueryOther() |
7839 | ····{ |
7840 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblAutoRightBase>(pm); |
7841 | ········otherVar = q.ExecuteSingle(); |
7842 | ····} |
7843 | } |
7844 | |
7845 | |
7846 | [TestFixture] |
7847 | public class TestAgrBi11OwnpconOthpconNoTblAuto : NDOTest |
7848 | { |
7849 | ····AgrBi11OwnpconOthpconNoTblAutoLeftBase ownVar; |
7850 | ····AgrBi11OwnpconOthpconNoTblAutoRightBase otherVar; |
7851 | ····PersistenceManager pm; |
7852 | ····[SetUp] |
7853 | ····public void Setup() |
7854 | ····{ |
7855 | ········pm = PmFactory.NewPersistenceManager(); |
7856 | ········ownVar = new AgrBi11OwnpconOthpconNoTblAutoLeftDerived(); |
7857 | ········otherVar = new AgrBi11OwnpconOthpconNoTblAutoRightDerived(); |
7858 | ····} |
7859 | ····[TearDown] |
7860 | ····public void TearDown() |
7861 | ····{ |
7862 | ········try |
7863 | ········{ |
7864 | ············pm.UnloadCache(); |
7865 | ············var l = pm.Objects<AgrBi11OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
7866 | ············pm.Delete(l); |
7867 | ············pm.Save(); |
7868 | ············pm.UnloadCache(); |
7869 | ············var m = pm.Objects<AgrBi11OwnpconOthpconNoTblAutoRightBase>().ResultTable; |
7870 | ············pm.Delete(m); |
7871 | ············pm.Save(); |
7872 | ············pm.UnloadCache(); |
7873 | ············decimal count; |
7874 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7875 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
7876 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
7877 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
7878 | ········} |
7879 | ········catch (Exception) |
7880 | ········{ |
7881 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
7882 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
7883 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
7884 | ········} |
7885 | ····} |
7886 | ····[Test] |
7887 | ····public void TestSaveReload() |
7888 | ····{ |
7889 | ········CreateObjects(); |
7890 | ········QueryOwn(); |
7891 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7892 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7893 | ····} |
7894 | ····[Test] |
7895 | ····public void TestSaveReloadNull() |
7896 | ····{ |
7897 | ········CreateObjects(); |
7898 | ········QueryOwn(); |
7899 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7900 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7901 | ········ownVar.RelField = null; |
7902 | ········pm.Save(); |
7903 | ········pm.UnloadCache(); |
7904 | ········QueryOwn(); |
7905 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7906 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
7907 | ····} |
7908 | ····[Test] |
7909 | ····public void TestChangeKeyHolderLeft() |
7910 | ····{ |
7911 | ········CreateObjects(); |
7912 | ········QueryOwn(); |
7913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7915 | ········int x = ownVar.RelField.Dummy; |
7916 | ········ownVar.Dummy = 4711; |
7917 | ········pm.Save(); |
7918 | ········pm.UnloadCache(); |
7919 | ········QueryOwn(); |
7920 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7921 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7922 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7923 | ····} |
7924 | ····[Test] |
7925 | ····public void TestChangeKeyHolderRight() |
7926 | ····{ |
7927 | ········CreateObjects(); |
7928 | ········QueryOther(); |
7929 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7930 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7931 | ········int x = otherVar.RelField.Dummy; |
7932 | ········otherVar.Dummy = 4711; |
7933 | ········pm.Save(); |
7934 | ········pm.UnloadCache(); |
7935 | ········QueryOther(); |
7936 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7937 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7938 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7939 | ····} |
7940 | ····[Test] |
7941 | ····public void TestChangeKeyHolderLeftNoTouch() |
7942 | ····{ |
7943 | ········CreateObjects(); |
7944 | ········QueryOwn(); |
7945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7947 | ········ownVar.Dummy = 4711; |
7948 | ········pm.Save(); |
7949 | ········pm.UnloadCache(); |
7950 | ········QueryOwn(); |
7951 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
7952 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7953 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
7954 | ····} |
7955 | ····[Test] |
7956 | ····public void TestChangeKeyHolderRightNoTouch() |
7957 | ····{ |
7958 | ········CreateObjects(); |
7959 | ········QueryOther(); |
7960 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7961 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7962 | ········otherVar.Dummy = 4711; |
7963 | ········pm.Save(); |
7964 | ········pm.UnloadCache(); |
7965 | ········QueryOther(); |
7966 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
7967 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
7968 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
7969 | ····} |
7970 | ····[Test] |
7971 | ····public void TestRelationHash() |
7972 | ····{ |
7973 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoLeftBase)); |
7974 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
7975 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoRightBase)); |
7976 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
7977 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
7978 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
7979 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoLeftDerived)); |
7980 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
7981 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
7982 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
7983 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblAutoRightDerived)); |
7984 | ········Relation relderRight = clderRight.FindRelation("relField"); |
7985 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
7986 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
7987 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
7988 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
7989 | ····} |
7990 | ····void CreateObjects() |
7991 | ····{ |
7992 | ········pm.MakePersistent(ownVar); |
7993 | ········pm.Save(); |
7994 | ········pm.MakePersistent(otherVar); |
7995 | ········pm.Save(); |
7996 | ········pm.Save(); |
7997 | ········ownVar.AssignRelation(otherVar); |
7998 | ········pm.Save(); |
7999 | ········pm.UnloadCache(); |
8000 | ····} |
8001 | ····void QueryOwn() |
8002 | ····{ |
8003 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoLeftBase>(pm); |
8004 | ········ownVar = q.ExecuteSingle(); |
8005 | ····} |
8006 | ····void QueryOther() |
8007 | ····{ |
8008 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblAutoRightBase>(pm); |
8009 | ········otherVar = q.ExecuteSingle(); |
8010 | ····} |
8011 | } |
8012 | |
8013 | |
8014 | [TestFixture] |
8015 | public class TestAgrBi11OwnpconOthpconTblAuto : NDOTest |
8016 | { |
8017 | ····AgrBi11OwnpconOthpconTblAutoLeftBase ownVar; |
8018 | ····AgrBi11OwnpconOthpconTblAutoRightBase otherVar; |
8019 | ····PersistenceManager pm; |
8020 | ····[SetUp] |
8021 | ····public void Setup() |
8022 | ····{ |
8023 | ········pm = PmFactory.NewPersistenceManager(); |
8024 | ········ownVar = new AgrBi11OwnpconOthpconTblAutoLeftDerived(); |
8025 | ········otherVar = new AgrBi11OwnpconOthpconTblAutoRightDerived(); |
8026 | ····} |
8027 | ····[TearDown] |
8028 | ····public void TearDown() |
8029 | ····{ |
8030 | ········try |
8031 | ········{ |
8032 | ············pm.UnloadCache(); |
8033 | ············var l = pm.Objects<AgrBi11OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8034 | ············pm.Delete(l); |
8035 | ············pm.Save(); |
8036 | ············pm.UnloadCache(); |
8037 | ············var m = pm.Objects<AgrBi11OwnpconOthpconTblAutoRightBase>().ResultTable; |
8038 | ············pm.Delete(m); |
8039 | ············pm.Save(); |
8040 | ············pm.UnloadCache(); |
8041 | ············decimal count; |
8042 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8044 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8045 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8046 | ········} |
8047 | ········catch (Exception) |
8048 | ········{ |
8049 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8050 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8051 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8052 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8053 | ········} |
8054 | ····} |
8055 | ····[Test] |
8056 | ····public void TestSaveReload() |
8057 | ····{ |
8058 | ········CreateObjects(); |
8059 | ········QueryOwn(); |
8060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8062 | ····} |
8063 | ····[Test] |
8064 | ····public void TestSaveReloadNull() |
8065 | ····{ |
8066 | ········CreateObjects(); |
8067 | ········QueryOwn(); |
8068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8070 | ········ownVar.RelField = null; |
8071 | ········pm.Save(); |
8072 | ········pm.UnloadCache(); |
8073 | ········QueryOwn(); |
8074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8075 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8076 | ····} |
8077 | ····[Test] |
8078 | ····public void TestChangeKeyHolderLeft() |
8079 | ····{ |
8080 | ········CreateObjects(); |
8081 | ········QueryOwn(); |
8082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8083 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8084 | ········int x = ownVar.RelField.Dummy; |
8085 | ········ownVar.Dummy = 4711; |
8086 | ········pm.Save(); |
8087 | ········pm.UnloadCache(); |
8088 | ········QueryOwn(); |
8089 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8090 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8091 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8092 | ····} |
8093 | ····[Test] |
8094 | ····public void TestChangeKeyHolderRight() |
8095 | ····{ |
8096 | ········CreateObjects(); |
8097 | ········QueryOther(); |
8098 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8099 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8100 | ········int x = otherVar.RelField.Dummy; |
8101 | ········otherVar.Dummy = 4711; |
8102 | ········pm.Save(); |
8103 | ········pm.UnloadCache(); |
8104 | ········QueryOther(); |
8105 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8106 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8107 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8108 | ····} |
8109 | ····[Test] |
8110 | ····public void TestChangeKeyHolderLeftNoTouch() |
8111 | ····{ |
8112 | ········CreateObjects(); |
8113 | ········QueryOwn(); |
8114 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8115 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8116 | ········ownVar.Dummy = 4711; |
8117 | ········pm.Save(); |
8118 | ········pm.UnloadCache(); |
8119 | ········QueryOwn(); |
8120 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8121 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8122 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8123 | ····} |
8124 | ····[Test] |
8125 | ····public void TestChangeKeyHolderRightNoTouch() |
8126 | ····{ |
8127 | ········CreateObjects(); |
8128 | ········QueryOther(); |
8129 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8130 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8131 | ········otherVar.Dummy = 4711; |
8132 | ········pm.Save(); |
8133 | ········pm.UnloadCache(); |
8134 | ········QueryOther(); |
8135 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8136 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8137 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8138 | ····} |
8139 | ····[Test] |
8140 | ····public void TestRelationHash() |
8141 | ····{ |
8142 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoLeftBase)); |
8143 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8144 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoRightBase)); |
8145 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8146 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8147 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8148 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoLeftDerived)); |
8149 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8150 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8151 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8152 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblAutoRightDerived)); |
8153 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8154 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8155 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8156 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8157 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8158 | ····} |
8159 | ····void CreateObjects() |
8160 | ····{ |
8161 | ········pm.MakePersistent(ownVar); |
8162 | ········pm.MakePersistent(otherVar); |
8163 | ········pm.Save(); |
8164 | ········ownVar.AssignRelation(otherVar); |
8165 | ········pm.Save(); |
8166 | ········pm.UnloadCache(); |
8167 | ····} |
8168 | ····void QueryOwn() |
8169 | ····{ |
8170 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblAutoLeftBase>(pm); |
8171 | ········ownVar = q.ExecuteSingle(); |
8172 | ····} |
8173 | ····void QueryOther() |
8174 | ····{ |
8175 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblAutoRightBase>(pm); |
8176 | ········otherVar = q.ExecuteSingle(); |
8177 | ····} |
8178 | } |
8179 | |
8180 | |
8181 | [TestFixture] |
8182 | public class TestAgrDirnOwnpconOthpconTblAuto : NDOTest |
8183 | { |
8184 | ····AgrDirnOwnpconOthpconTblAutoLeftBase ownVar; |
8185 | ····AgrDirnOwnpconOthpconTblAutoRightBase otherVar; |
8186 | ····PersistenceManager pm; |
8187 | ····[SetUp] |
8188 | ····public void Setup() |
8189 | ····{ |
8190 | ········pm = PmFactory.NewPersistenceManager(); |
8191 | ········ownVar = new AgrDirnOwnpconOthpconTblAutoLeftDerived(); |
8192 | ········otherVar = new AgrDirnOwnpconOthpconTblAutoRightDerived(); |
8193 | ····} |
8194 | ····[TearDown] |
8195 | ····public void TearDown() |
8196 | ····{ |
8197 | ········try |
8198 | ········{ |
8199 | ············pm.UnloadCache(); |
8200 | ············var l = pm.Objects<AgrDirnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8201 | ············pm.Delete(l); |
8202 | ············pm.Save(); |
8203 | ············pm.UnloadCache(); |
8204 | ············var m = pm.Objects<AgrDirnOwnpconOthpconTblAutoRightBase>().ResultTable; |
8205 | ············pm.Delete(m); |
8206 | ············pm.Save(); |
8207 | ············pm.UnloadCache(); |
8208 | ············decimal count; |
8209 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8210 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8211 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8212 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8213 | ········} |
8214 | ········catch (Exception) |
8215 | ········{ |
8216 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8218 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8219 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8220 | ········} |
8221 | ····} |
8222 | ····[Test] |
8223 | ····public void TestSaveReload() |
8224 | ····{ |
8225 | ········CreateObjects(); |
8226 | ········QueryOwn(); |
8227 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8228 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8229 | ····} |
8230 | ····[Test] |
8231 | ····public void TestSaveReloadNull() |
8232 | ····{ |
8233 | ········CreateObjects(); |
8234 | ········QueryOwn(); |
8235 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8236 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8237 | ········ownVar.RelField = new List<AgrDirnOwnpconOthpconTblAutoRightBase>(); |
8238 | ········pm.Save(); |
8239 | ········pm.UnloadCache(); |
8240 | ········QueryOwn(); |
8241 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8242 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8243 | ····} |
8244 | ····[Test] |
8245 | ····public void TestSaveReloadRemove() |
8246 | ····{ |
8247 | ········CreateObjects(); |
8248 | ········QueryOwn(); |
8249 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8250 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8251 | ········ownVar.RemoveRelatedObject(); |
8252 | ········pm.Save(); |
8253 | ········pm.UnloadCache(); |
8254 | ········QueryOwn(); |
8255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8256 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8257 | ····} |
8258 | ····void CreateObjects() |
8259 | ····{ |
8260 | ········pm.MakePersistent(ownVar); |
8261 | ········pm.MakePersistent(otherVar); |
8262 | ········ownVar.AssignRelation(otherVar); |
8263 | ········pm.Save(); |
8264 | ········pm.UnloadCache(); |
8265 | ····} |
8266 | ····void QueryOwn() |
8267 | ····{ |
8268 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblAutoLeftBase>(pm); |
8269 | ········ownVar = q.ExecuteSingle(); |
8270 | ····} |
8271 | ····void QueryOther() |
8272 | ····{ |
8273 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblAutoRightBase>(pm); |
8274 | ········otherVar = q.ExecuteSingle(); |
8275 | ····} |
8276 | } |
8277 | |
8278 | |
8279 | [TestFixture] |
8280 | public class TestAgrBin1OwnpconOthpconTblAuto : NDOTest |
8281 | { |
8282 | ····AgrBin1OwnpconOthpconTblAutoLeftBase ownVar; |
8283 | ····AgrBin1OwnpconOthpconTblAutoRightBase otherVar; |
8284 | ····PersistenceManager pm; |
8285 | ····[SetUp] |
8286 | ····public void Setup() |
8287 | ····{ |
8288 | ········pm = PmFactory.NewPersistenceManager(); |
8289 | ········ownVar = new AgrBin1OwnpconOthpconTblAutoLeftDerived(); |
8290 | ········otherVar = new AgrBin1OwnpconOthpconTblAutoRightDerived(); |
8291 | ····} |
8292 | ····[TearDown] |
8293 | ····public void TearDown() |
8294 | ····{ |
8295 | ········try |
8296 | ········{ |
8297 | ············pm.UnloadCache(); |
8298 | ············var l = pm.Objects<AgrBin1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8299 | ············pm.Delete(l); |
8300 | ············pm.Save(); |
8301 | ············pm.UnloadCache(); |
8302 | ············var m = pm.Objects<AgrBin1OwnpconOthpconTblAutoRightBase>().ResultTable; |
8303 | ············pm.Delete(m); |
8304 | ············pm.Save(); |
8305 | ············pm.UnloadCache(); |
8306 | ············decimal count; |
8307 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8308 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8309 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8310 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8311 | ········} |
8312 | ········catch (Exception) |
8313 | ········{ |
8314 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8315 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8316 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8317 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8318 | ········} |
8319 | ····} |
8320 | ····[Test] |
8321 | ····public void TestSaveReload() |
8322 | ····{ |
8323 | ········CreateObjects(); |
8324 | ········QueryOwn(); |
8325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8326 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8327 | ····} |
8328 | ····[Test] |
8329 | ····public void TestSaveReloadNull() |
8330 | ····{ |
8331 | ········CreateObjects(); |
8332 | ········QueryOwn(); |
8333 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8334 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8335 | ········ownVar.RelField = new List<AgrBin1OwnpconOthpconTblAutoRightBase>(); |
8336 | ········pm.Save(); |
8337 | ········pm.UnloadCache(); |
8338 | ········QueryOwn(); |
8339 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8340 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8341 | ····} |
8342 | ····[Test] |
8343 | ····public void TestSaveReloadRemove() |
8344 | ····{ |
8345 | ········CreateObjects(); |
8346 | ········QueryOwn(); |
8347 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8348 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8349 | ········ownVar.RemoveRelatedObject(); |
8350 | ········pm.Save(); |
8351 | ········pm.UnloadCache(); |
8352 | ········QueryOwn(); |
8353 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8354 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8355 | ····} |
8356 | ····[Test] |
8357 | ····public void TestChangeKeyHolderRight() |
8358 | ····{ |
8359 | ········CreateObjects(); |
8360 | ········QueryOther(); |
8361 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8362 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8363 | ········int x = otherVar.RelField.Dummy; |
8364 | ········otherVar.Dummy = 4711; |
8365 | ········pm.Save(); |
8366 | ········pm.UnloadCache(); |
8367 | ········QueryOther(); |
8368 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8369 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8370 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8371 | ····} |
8372 | ····[Test] |
8373 | ····public void TestChangeKeyHolderRightNoTouch() |
8374 | ····{ |
8375 | ········CreateObjects(); |
8376 | ········QueryOther(); |
8377 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8378 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8379 | ········otherVar.Dummy = 4711; |
8380 | ········pm.Save(); |
8381 | ········pm.UnloadCache(); |
8382 | ········QueryOther(); |
8383 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
8384 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8385 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
8386 | ····} |
8387 | ····[Test] |
8388 | ····public void TestRelationHash() |
8389 | ····{ |
8390 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoLeftBase)); |
8391 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8392 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoRightBase)); |
8393 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8394 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8395 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8396 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoLeftDerived)); |
8397 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8398 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8399 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8400 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblAutoRightDerived)); |
8401 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8402 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8403 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8404 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8405 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8406 | ····} |
8407 | ····void CreateObjects() |
8408 | ····{ |
8409 | ········pm.MakePersistent(ownVar); |
8410 | ········pm.MakePersistent(otherVar); |
8411 | ········pm.Save(); |
8412 | ········ownVar.AssignRelation(otherVar); |
8413 | ········pm.Save(); |
8414 | ········pm.UnloadCache(); |
8415 | ····} |
8416 | ····void QueryOwn() |
8417 | ····{ |
8418 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblAutoLeftBase>(pm); |
8419 | ········ownVar = q.ExecuteSingle(); |
8420 | ····} |
8421 | ····void QueryOther() |
8422 | ····{ |
8423 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblAutoRightBase>(pm); |
8424 | ········otherVar = q.ExecuteSingle(); |
8425 | ····} |
8426 | } |
8427 | |
8428 | |
8429 | [TestFixture] |
8430 | public class TestAgrBi1nOwnpconOthpconTblAuto : NDOTest |
8431 | { |
8432 | ····AgrBi1nOwnpconOthpconTblAutoLeftBase ownVar; |
8433 | ····AgrBi1nOwnpconOthpconTblAutoRightBase otherVar; |
8434 | ····PersistenceManager pm; |
8435 | ····[SetUp] |
8436 | ····public void Setup() |
8437 | ····{ |
8438 | ········pm = PmFactory.NewPersistenceManager(); |
8439 | ········ownVar = new AgrBi1nOwnpconOthpconTblAutoLeftDerived(); |
8440 | ········otherVar = new AgrBi1nOwnpconOthpconTblAutoRightDerived(); |
8441 | ····} |
8442 | ····[TearDown] |
8443 | ····public void TearDown() |
8444 | ····{ |
8445 | ········try |
8446 | ········{ |
8447 | ············pm.UnloadCache(); |
8448 | ············var l = pm.Objects<AgrBi1nOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8449 | ············pm.Delete(l); |
8450 | ············pm.Save(); |
8451 | ············pm.UnloadCache(); |
8452 | ············var m = pm.Objects<AgrBi1nOwnpconOthpconTblAutoRightBase>().ResultTable; |
8453 | ············pm.Delete(m); |
8454 | ············pm.Save(); |
8455 | ············pm.UnloadCache(); |
8456 | ············decimal count; |
8457 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8458 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8459 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8460 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8461 | ········} |
8462 | ········catch (Exception) |
8463 | ········{ |
8464 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8465 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8466 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8467 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8468 | ········} |
8469 | ····} |
8470 | ····[Test] |
8471 | ····public void TestSaveReload() |
8472 | ····{ |
8473 | ········CreateObjects(); |
8474 | ········QueryOwn(); |
8475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8476 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8477 | ····} |
8478 | ····[Test] |
8479 | ····public void TestSaveReloadNull() |
8480 | ····{ |
8481 | ········CreateObjects(); |
8482 | ········QueryOwn(); |
8483 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8484 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8485 | ········ownVar.RelField = null; |
8486 | ········pm.Save(); |
8487 | ········pm.UnloadCache(); |
8488 | ········QueryOwn(); |
8489 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8490 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8491 | ····} |
8492 | ····[Test] |
8493 | ····public void TestChangeKeyHolderLeft() |
8494 | ····{ |
8495 | ········CreateObjects(); |
8496 | ········QueryOwn(); |
8497 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8498 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8499 | ········int x = ownVar.RelField.Dummy; |
8500 | ········ownVar.Dummy = 4711; |
8501 | ········pm.Save(); |
8502 | ········pm.UnloadCache(); |
8503 | ········QueryOwn(); |
8504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8505 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8506 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8507 | ····} |
8508 | ····[Test] |
8509 | ····public void TestChangeKeyHolderLeftNoTouch() |
8510 | ····{ |
8511 | ········CreateObjects(); |
8512 | ········QueryOwn(); |
8513 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8514 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8515 | ········ownVar.Dummy = 4711; |
8516 | ········pm.Save(); |
8517 | ········pm.UnloadCache(); |
8518 | ········QueryOwn(); |
8519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8520 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8521 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8522 | ····} |
8523 | ····[Test] |
8524 | ····public void TestRelationHash() |
8525 | ····{ |
8526 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoLeftBase)); |
8527 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8528 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoRightBase)); |
8529 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8530 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8531 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8532 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoLeftDerived)); |
8533 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8534 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8535 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8536 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblAutoRightDerived)); |
8537 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8538 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8539 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8540 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8541 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8542 | ····} |
8543 | ····void CreateObjects() |
8544 | ····{ |
8545 | ········pm.MakePersistent(ownVar); |
8546 | ········pm.MakePersistent(otherVar); |
8547 | ········ownVar.AssignRelation(otherVar); |
8548 | ········pm.Save(); |
8549 | ········pm.UnloadCache(); |
8550 | ····} |
8551 | ····void QueryOwn() |
8552 | ····{ |
8553 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblAutoLeftBase>(pm); |
8554 | ········ownVar = q.ExecuteSingle(); |
8555 | ····} |
8556 | ····void QueryOther() |
8557 | ····{ |
8558 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblAutoRightBase>(pm); |
8559 | ········otherVar = q.ExecuteSingle(); |
8560 | ····} |
8561 | } |
8562 | |
8563 | |
8564 | [TestFixture] |
8565 | public class TestAgrBinnOwnpconOthpconTblAuto : NDOTest |
8566 | { |
8567 | ····AgrBinnOwnpconOthpconTblAutoLeftBase ownVar; |
8568 | ····AgrBinnOwnpconOthpconTblAutoRightBase otherVar; |
8569 | ····PersistenceManager pm; |
8570 | ····[SetUp] |
8571 | ····public void Setup() |
8572 | ····{ |
8573 | ········pm = PmFactory.NewPersistenceManager(); |
8574 | ········ownVar = new AgrBinnOwnpconOthpconTblAutoLeftDerived(); |
8575 | ········otherVar = new AgrBinnOwnpconOthpconTblAutoRightDerived(); |
8576 | ····} |
8577 | ····[TearDown] |
8578 | ····public void TearDown() |
8579 | ····{ |
8580 | ········try |
8581 | ········{ |
8582 | ············pm.UnloadCache(); |
8583 | ············var l = pm.Objects<AgrBinnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
8584 | ············pm.Delete(l); |
8585 | ············pm.Save(); |
8586 | ············pm.UnloadCache(); |
8587 | ············var m = pm.Objects<AgrBinnOwnpconOthpconTblAutoRightBase>().ResultTable; |
8588 | ············pm.Delete(m); |
8589 | ············pm.Save(); |
8590 | ············pm.UnloadCache(); |
8591 | ············decimal count; |
8592 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8593 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8594 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8595 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8596 | ········} |
8597 | ········catch (Exception) |
8598 | ········{ |
8599 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8600 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8601 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8602 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8603 | ········} |
8604 | ····} |
8605 | ····[Test] |
8606 | ····public void TestSaveReload() |
8607 | ····{ |
8608 | ········CreateObjects(); |
8609 | ········QueryOwn(); |
8610 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8611 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8612 | ····} |
8613 | ····[Test] |
8614 | ····public void TestSaveReloadNull() |
8615 | ····{ |
8616 | ········CreateObjects(); |
8617 | ········QueryOwn(); |
8618 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8619 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8620 | ········ownVar.RelField = new List<AgrBinnOwnpconOthpconTblAutoRightBase>(); |
8621 | ········pm.Save(); |
8622 | ········pm.UnloadCache(); |
8623 | ········QueryOwn(); |
8624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8625 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8626 | ····} |
8627 | ····[Test] |
8628 | ····public void TestSaveReloadRemove() |
8629 | ····{ |
8630 | ········CreateObjects(); |
8631 | ········QueryOwn(); |
8632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8633 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8634 | ········ownVar.RemoveRelatedObject(); |
8635 | ········pm.Save(); |
8636 | ········pm.UnloadCache(); |
8637 | ········QueryOwn(); |
8638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8639 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
8640 | ····} |
8641 | ····[Test] |
8642 | ····public void TestRelationHash() |
8643 | ····{ |
8644 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoLeftBase)); |
8645 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8646 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoRightBase)); |
8647 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8648 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8649 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8650 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoLeftDerived)); |
8651 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8652 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8653 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8654 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblAutoRightDerived)); |
8655 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8656 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8657 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8658 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8659 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8660 | ····} |
8661 | ····void CreateObjects() |
8662 | ····{ |
8663 | ········pm.MakePersistent(ownVar); |
8664 | ········pm.MakePersistent(otherVar); |
8665 | ········ownVar.AssignRelation(otherVar); |
8666 | ········pm.Save(); |
8667 | ········pm.UnloadCache(); |
8668 | ····} |
8669 | ····void QueryOwn() |
8670 | ····{ |
8671 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblAutoLeftBase>(pm); |
8672 | ········ownVar = q.ExecuteSingle(); |
8673 | ····} |
8674 | ····void QueryOther() |
8675 | ····{ |
8676 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblAutoRightBase>(pm); |
8677 | ········otherVar = q.ExecuteSingle(); |
8678 | ····} |
8679 | } |
8680 | |
8681 | |
8682 | [TestFixture] |
8683 | public class TestCmpDir1OwnpconOthpconNoTblAuto : NDOTest |
8684 | { |
8685 | ····CmpDir1OwnpconOthpconNoTblAutoLeftBase ownVar; |
8686 | ····CmpDir1OwnpconOthpconNoTblAutoRightBase otherVar; |
8687 | ····PersistenceManager pm; |
8688 | ····[SetUp] |
8689 | ····public void Setup() |
8690 | ····{ |
8691 | ········pm = PmFactory.NewPersistenceManager(); |
8692 | ········ownVar = new CmpDir1OwnpconOthpconNoTblAutoLeftDerived(); |
8693 | ········otherVar = new CmpDir1OwnpconOthpconNoTblAutoRightDerived(); |
8694 | ····} |
8695 | ····[TearDown] |
8696 | ····public void TearDown() |
8697 | ····{ |
8698 | ········try |
8699 | ········{ |
8700 | ············pm.UnloadCache(); |
8701 | ············var l = pm.Objects<CmpDir1OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
8702 | ············pm.Delete(l); |
8703 | ············pm.Save(); |
8704 | ············pm.UnloadCache(); |
8705 | ············decimal count; |
8706 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8707 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8708 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8709 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8710 | ········} |
8711 | ········catch (Exception) |
8712 | ········{ |
8713 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8714 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8715 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8716 | ········} |
8717 | ····} |
8718 | ····[Test] |
8719 | ····public void TestSaveReload() |
8720 | ····{ |
8721 | ········bool thrown = false; |
8722 | ········try |
8723 | ········{ |
8724 | ············CreateObjects(); |
8725 | ············QueryOwn(); |
8726 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8727 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8728 | ········} |
8729 | ········catch (NDOException) |
8730 | ········{ |
8731 | ············thrown = true; |
8732 | ········} |
8733 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8734 | ····} |
8735 | ····[Test] |
8736 | ····public void TestSaveReloadNull() |
8737 | ····{ |
8738 | ········bool thrown = false; |
8739 | ········try |
8740 | ········{ |
8741 | ············CreateObjects(); |
8742 | ············QueryOwn(); |
8743 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8744 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8745 | ············ownVar.RelField = null; |
8746 | ············pm.Save(); |
8747 | ············pm.UnloadCache(); |
8748 | ············QueryOwn(); |
8749 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8750 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8751 | ········} |
8752 | ········catch (NDOException) |
8753 | ········{ |
8754 | ············thrown = true; |
8755 | ········} |
8756 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8757 | ····} |
8758 | ····void CreateObjects() |
8759 | ····{ |
8760 | ········pm.MakePersistent(ownVar); |
8761 | ········pm.Save(); |
8762 | ········ownVar.AssignRelation(otherVar); |
8763 | ········pm.Save(); |
8764 | ········pm.UnloadCache(); |
8765 | ····} |
8766 | ····void QueryOwn() |
8767 | ····{ |
8768 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoLeftBase>(pm); |
8769 | ········ownVar = q.ExecuteSingle(); |
8770 | ····} |
8771 | ····void QueryOther() |
8772 | ····{ |
8773 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblAutoRightBase>(pm); |
8774 | ········otherVar = q.ExecuteSingle(); |
8775 | ····} |
8776 | } |
8777 | |
8778 | |
8779 | [TestFixture] |
8780 | public class TestCmpDir1OwnpconOthpconTblAuto : NDOTest |
8781 | { |
8782 | ····CmpDir1OwnpconOthpconTblAutoLeftBase ownVar; |
8783 | ····CmpDir1OwnpconOthpconTblAutoRightBase otherVar; |
8784 | ····PersistenceManager pm; |
8785 | ····[SetUp] |
8786 | ····public void Setup() |
8787 | ····{ |
8788 | ········pm = PmFactory.NewPersistenceManager(); |
8789 | ········ownVar = new CmpDir1OwnpconOthpconTblAutoLeftDerived(); |
8790 | ········otherVar = new CmpDir1OwnpconOthpconTblAutoRightDerived(); |
8791 | ····} |
8792 | ····[TearDown] |
8793 | ····public void TearDown() |
8794 | ····{ |
8795 | ········try |
8796 | ········{ |
8797 | ············pm.UnloadCache(); |
8798 | ············var l = pm.Objects<CmpDir1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
8799 | ············pm.Delete(l); |
8800 | ············pm.Save(); |
8801 | ············pm.UnloadCache(); |
8802 | ············decimal count; |
8803 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8804 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8805 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8806 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8807 | ········} |
8808 | ········catch (Exception) |
8809 | ········{ |
8810 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8811 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8812 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8813 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
8814 | ········} |
8815 | ····} |
8816 | ····[Test] |
8817 | ····public void TestSaveReload() |
8818 | ····{ |
8819 | ········CreateObjects(); |
8820 | ········QueryOwn(); |
8821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8823 | ····} |
8824 | ····[Test] |
8825 | ····public void TestSaveReloadNull() |
8826 | ····{ |
8827 | ········CreateObjects(); |
8828 | ········QueryOwn(); |
8829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8831 | ········ownVar.RelField = null; |
8832 | ········pm.Save(); |
8833 | ········pm.UnloadCache(); |
8834 | ········QueryOwn(); |
8835 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8836 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8837 | ····} |
8838 | ····[Test] |
8839 | ····public void TestChangeKeyHolderLeft() |
8840 | ····{ |
8841 | ········CreateObjects(); |
8842 | ········QueryOwn(); |
8843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8844 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8845 | ········int x = ownVar.RelField.Dummy; |
8846 | ········ownVar.Dummy = 4711; |
8847 | ········pm.Save(); |
8848 | ········pm.UnloadCache(); |
8849 | ········QueryOwn(); |
8850 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8851 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8853 | ····} |
8854 | ····[Test] |
8855 | ····public void TestChangeKeyHolderLeftNoTouch() |
8856 | ····{ |
8857 | ········CreateObjects(); |
8858 | ········QueryOwn(); |
8859 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8861 | ········ownVar.Dummy = 4711; |
8862 | ········pm.Save(); |
8863 | ········pm.UnloadCache(); |
8864 | ········QueryOwn(); |
8865 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8866 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
8867 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8868 | ····} |
8869 | ····void CreateObjects() |
8870 | ····{ |
8871 | ········pm.MakePersistent(ownVar); |
8872 | ········ownVar.AssignRelation(otherVar); |
8873 | ········pm.Save(); |
8874 | ········pm.UnloadCache(); |
8875 | ····} |
8876 | ····void QueryOwn() |
8877 | ····{ |
8878 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblAutoLeftBase>(pm); |
8879 | ········ownVar = q.ExecuteSingle(); |
8880 | ····} |
8881 | ····void QueryOther() |
8882 | ····{ |
8883 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblAutoRightBase>(pm); |
8884 | ········otherVar = q.ExecuteSingle(); |
8885 | ····} |
8886 | } |
8887 | |
8888 | |
8889 | [TestFixture] |
8890 | public class TestCmpBi11OwnpconOthpconNoTblAuto : NDOTest |
8891 | { |
8892 | ····CmpBi11OwnpconOthpconNoTblAutoLeftBase ownVar; |
8893 | ····CmpBi11OwnpconOthpconNoTblAutoRightBase otherVar; |
8894 | ····PersistenceManager pm; |
8895 | ····[SetUp] |
8896 | ····public void Setup() |
8897 | ····{ |
8898 | ········pm = PmFactory.NewPersistenceManager(); |
8899 | ········ownVar = new CmpBi11OwnpconOthpconNoTblAutoLeftDerived(); |
8900 | ········otherVar = new CmpBi11OwnpconOthpconNoTblAutoRightDerived(); |
8901 | ····} |
8902 | ····[TearDown] |
8903 | ····public void TearDown() |
8904 | ····{ |
8905 | ········try |
8906 | ········{ |
8907 | ············pm.UnloadCache(); |
8908 | ············var l = pm.Objects<CmpBi11OwnpconOthpconNoTblAutoLeftBase>().ResultTable; |
8909 | ············pm.Delete(l); |
8910 | ············pm.Save(); |
8911 | ············pm.UnloadCache(); |
8912 | ············decimal count; |
8913 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8914 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
8915 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
8916 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
8917 | ········} |
8918 | ········catch (Exception) |
8919 | ········{ |
8920 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
8921 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
8922 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
8923 | ········} |
8924 | ····} |
8925 | ····[Test] |
8926 | ····public void TestSaveReload() |
8927 | ····{ |
8928 | ········bool thrown = false; |
8929 | ········try |
8930 | ········{ |
8931 | ············CreateObjects(); |
8932 | ············QueryOwn(); |
8933 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8934 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8935 | ········} |
8936 | ········catch (NDOException) |
8937 | ········{ |
8938 | ············thrown = true; |
8939 | ········} |
8940 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8941 | ····} |
8942 | ····[Test] |
8943 | ····public void TestSaveReloadNull() |
8944 | ····{ |
8945 | ········bool thrown = false; |
8946 | ········try |
8947 | ········{ |
8948 | ············CreateObjects(); |
8949 | ············QueryOwn(); |
8950 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8951 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
8952 | ············ownVar.RelField = null; |
8953 | ············pm.Save(); |
8954 | ············pm.UnloadCache(); |
8955 | ············QueryOwn(); |
8956 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
8957 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
8958 | ········} |
8959 | ········catch (NDOException) |
8960 | ········{ |
8961 | ············thrown = true; |
8962 | ········} |
8963 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
8964 | ····} |
8965 | ····[Test] |
8966 | ····public void TestRelationHash() |
8967 | ····{ |
8968 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoLeftBase)); |
8969 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
8970 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoRightBase)); |
8971 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
8972 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
8973 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
8974 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoLeftDerived)); |
8975 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
8976 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
8977 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
8978 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblAutoRightDerived)); |
8979 | ········Relation relderRight = clderRight.FindRelation("relField"); |
8980 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
8981 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
8982 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
8983 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
8984 | ····} |
8985 | ····void CreateObjects() |
8986 | ····{ |
8987 | ········pm.MakePersistent(ownVar); |
8988 | ········pm.Save(); |
8989 | ········ownVar.AssignRelation(otherVar); |
8990 | ········pm.Save(); |
8991 | ········pm.UnloadCache(); |
8992 | ····} |
8993 | ····void QueryOwn() |
8994 | ····{ |
8995 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoLeftBase>(pm); |
8996 | ········ownVar = q.ExecuteSingle(); |
8997 | ····} |
8998 | ····void QueryOther() |
8999 | ····{ |
9000 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblAutoRightBase>(pm); |
9001 | ········otherVar = q.ExecuteSingle(); |
9002 | ····} |
9003 | } |
9004 | |
9005 | |
9006 | [TestFixture] |
9007 | public class TestCmpBi11OwnpconOthpconTblAuto : NDOTest |
9008 | { |
9009 | ····CmpBi11OwnpconOthpconTblAutoLeftBase ownVar; |
9010 | ····CmpBi11OwnpconOthpconTblAutoRightBase otherVar; |
9011 | ····PersistenceManager pm; |
9012 | ····[SetUp] |
9013 | ····public void Setup() |
9014 | ····{ |
9015 | ········pm = PmFactory.NewPersistenceManager(); |
9016 | ········ownVar = new CmpBi11OwnpconOthpconTblAutoLeftDerived(); |
9017 | ········otherVar = new CmpBi11OwnpconOthpconTblAutoRightDerived(); |
9018 | ····} |
9019 | ····[TearDown] |
9020 | ····public void TearDown() |
9021 | ····{ |
9022 | ········try |
9023 | ········{ |
9024 | ············pm.UnloadCache(); |
9025 | ············var l = pm.Objects<CmpBi11OwnpconOthpconTblAutoLeftBase>().ResultTable; |
9026 | ············pm.Delete(l); |
9027 | ············pm.Save(); |
9028 | ············pm.UnloadCache(); |
9029 | ············decimal count; |
9030 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9031 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9032 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9033 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9034 | ········} |
9035 | ········catch (Exception) |
9036 | ········{ |
9037 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9038 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9039 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9040 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9041 | ········} |
9042 | ····} |
9043 | ····[Test] |
9044 | ····public void TestSaveReload() |
9045 | ····{ |
9046 | ········CreateObjects(); |
9047 | ········QueryOwn(); |
9048 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9049 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9050 | ····} |
9051 | ····[Test] |
9052 | ····public void TestSaveReloadNull() |
9053 | ····{ |
9054 | ········CreateObjects(); |
9055 | ········QueryOwn(); |
9056 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9057 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9058 | ········ownVar.RelField = null; |
9059 | ········pm.Save(); |
9060 | ········pm.UnloadCache(); |
9061 | ········QueryOwn(); |
9062 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9063 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9064 | ····} |
9065 | ····[Test] |
9066 | ····public void TestChangeKeyHolderLeft() |
9067 | ····{ |
9068 | ········CreateObjects(); |
9069 | ········QueryOwn(); |
9070 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9071 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9072 | ········int x = ownVar.RelField.Dummy; |
9073 | ········ownVar.Dummy = 4711; |
9074 | ········pm.Save(); |
9075 | ········pm.UnloadCache(); |
9076 | ········QueryOwn(); |
9077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9078 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9079 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9080 | ····} |
9081 | ····[Test] |
9082 | ····public void TestChangeKeyHolderRight() |
9083 | ····{ |
9084 | ········CreateObjects(); |
9085 | ········QueryOther(); |
9086 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9087 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9088 | ········int x = otherVar.RelField.Dummy; |
9089 | ········otherVar.Dummy = 4711; |
9090 | ········pm.Save(); |
9091 | ········pm.UnloadCache(); |
9092 | ········QueryOther(); |
9093 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9094 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9095 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9096 | ····} |
9097 | ····[Test] |
9098 | ····public void TestChangeKeyHolderLeftNoTouch() |
9099 | ····{ |
9100 | ········CreateObjects(); |
9101 | ········QueryOwn(); |
9102 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9104 | ········ownVar.Dummy = 4711; |
9105 | ········pm.Save(); |
9106 | ········pm.UnloadCache(); |
9107 | ········QueryOwn(); |
9108 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9109 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9110 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9111 | ····} |
9112 | ····[Test] |
9113 | ····public void TestChangeKeyHolderRightNoTouch() |
9114 | ····{ |
9115 | ········CreateObjects(); |
9116 | ········QueryOther(); |
9117 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9118 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9119 | ········otherVar.Dummy = 4711; |
9120 | ········pm.Save(); |
9121 | ········pm.UnloadCache(); |
9122 | ········QueryOther(); |
9123 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9124 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9125 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9126 | ····} |
9127 | ····[Test] |
9128 | ····public void TestRelationHash() |
9129 | ····{ |
9130 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoLeftBase)); |
9131 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9132 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoRightBase)); |
9133 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9134 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9135 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9136 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoLeftDerived)); |
9137 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9138 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9139 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9140 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblAutoRightDerived)); |
9141 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9142 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9143 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9144 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9145 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9146 | ····} |
9147 | ····void CreateObjects() |
9148 | ····{ |
9149 | ········pm.MakePersistent(ownVar); |
9150 | ········ownVar.AssignRelation(otherVar); |
9151 | ········pm.Save(); |
9152 | ········pm.UnloadCache(); |
9153 | ····} |
9154 | ····void QueryOwn() |
9155 | ····{ |
9156 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblAutoLeftBase>(pm); |
9157 | ········ownVar = q.ExecuteSingle(); |
9158 | ····} |
9159 | ····void QueryOther() |
9160 | ····{ |
9161 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblAutoRightBase>(pm); |
9162 | ········otherVar = q.ExecuteSingle(); |
9163 | ····} |
9164 | } |
9165 | |
9166 | |
9167 | [TestFixture] |
9168 | public class TestCmpDirnOwnpconOthpconTblAuto : NDOTest |
9169 | { |
9170 | ····CmpDirnOwnpconOthpconTblAutoLeftBase ownVar; |
9171 | ····CmpDirnOwnpconOthpconTblAutoRightBase otherVar; |
9172 | ····PersistenceManager pm; |
9173 | ····[SetUp] |
9174 | ····public void Setup() |
9175 | ····{ |
9176 | ········pm = PmFactory.NewPersistenceManager(); |
9177 | ········ownVar = new CmpDirnOwnpconOthpconTblAutoLeftDerived(); |
9178 | ········otherVar = new CmpDirnOwnpconOthpconTblAutoRightDerived(); |
9179 | ····} |
9180 | ····[TearDown] |
9181 | ····public void TearDown() |
9182 | ····{ |
9183 | ········try |
9184 | ········{ |
9185 | ············pm.UnloadCache(); |
9186 | ············var l = pm.Objects<CmpDirnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9187 | ············pm.Delete(l); |
9188 | ············pm.Save(); |
9189 | ············pm.UnloadCache(); |
9190 | ············decimal count; |
9191 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9192 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9193 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9194 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9195 | ········} |
9196 | ········catch (Exception) |
9197 | ········{ |
9198 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9199 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9200 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9201 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9202 | ········} |
9203 | ····} |
9204 | ····[Test] |
9205 | ····public void TestSaveReload() |
9206 | ····{ |
9207 | ········CreateObjects(); |
9208 | ········QueryOwn(); |
9209 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9210 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9211 | ····} |
9212 | ····[Test] |
9213 | ····public void TestSaveReloadNull() |
9214 | ····{ |
9215 | ········CreateObjects(); |
9216 | ········QueryOwn(); |
9217 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9218 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9219 | ········ownVar.RelField = new List<CmpDirnOwnpconOthpconTblAutoRightBase>(); |
9220 | ········pm.Save(); |
9221 | ········pm.UnloadCache(); |
9222 | ········QueryOwn(); |
9223 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9224 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9225 | ····} |
9226 | ····[Test] |
9227 | ····public void TestSaveReloadRemove() |
9228 | ····{ |
9229 | ········CreateObjects(); |
9230 | ········QueryOwn(); |
9231 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9232 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9233 | ········ownVar.RemoveRelatedObject(); |
9234 | ········pm.Save(); |
9235 | ········pm.UnloadCache(); |
9236 | ········QueryOwn(); |
9237 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9238 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9239 | ····} |
9240 | ····void CreateObjects() |
9241 | ····{ |
9242 | ········pm.MakePersistent(ownVar); |
9243 | ········ownVar.AssignRelation(otherVar); |
9244 | ········pm.Save(); |
9245 | ········pm.UnloadCache(); |
9246 | ····} |
9247 | ····void QueryOwn() |
9248 | ····{ |
9249 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblAutoLeftBase>(pm); |
9250 | ········ownVar = q.ExecuteSingle(); |
9251 | ····} |
9252 | ····void QueryOther() |
9253 | ····{ |
9254 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblAutoRightBase>(pm); |
9255 | ········otherVar = q.ExecuteSingle(); |
9256 | ····} |
9257 | } |
9258 | |
9259 | |
9260 | [TestFixture] |
9261 | public class TestCmpBin1OwnpconOthpconTblAuto : NDOTest |
9262 | { |
9263 | ····CmpBin1OwnpconOthpconTblAutoLeftBase ownVar; |
9264 | ····CmpBin1OwnpconOthpconTblAutoRightBase otherVar; |
9265 | ····PersistenceManager pm; |
9266 | ····[SetUp] |
9267 | ····public void Setup() |
9268 | ····{ |
9269 | ········pm = PmFactory.NewPersistenceManager(); |
9270 | ········ownVar = new CmpBin1OwnpconOthpconTblAutoLeftDerived(); |
9271 | ········otherVar = new CmpBin1OwnpconOthpconTblAutoRightDerived(); |
9272 | ····} |
9273 | ····[TearDown] |
9274 | ····public void TearDown() |
9275 | ····{ |
9276 | ········try |
9277 | ········{ |
9278 | ············pm.UnloadCache(); |
9279 | ············var l = pm.Objects<CmpBin1OwnpconOthpconTblAutoLeftBase>().ResultTable; |
9280 | ············pm.Delete(l); |
9281 | ············pm.Save(); |
9282 | ············pm.UnloadCache(); |
9283 | ············decimal count; |
9284 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9285 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9286 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9287 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9288 | ········} |
9289 | ········catch (Exception) |
9290 | ········{ |
9291 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9292 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9293 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9294 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9295 | ········} |
9296 | ····} |
9297 | ····[Test] |
9298 | ····public void TestSaveReload() |
9299 | ····{ |
9300 | ········CreateObjects(); |
9301 | ········QueryOwn(); |
9302 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9303 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9304 | ····} |
9305 | ····[Test] |
9306 | ····public void TestSaveReloadNull() |
9307 | ····{ |
9308 | ········CreateObjects(); |
9309 | ········QueryOwn(); |
9310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9311 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9312 | ········ownVar.RelField = new List<CmpBin1OwnpconOthpconTblAutoRightBase>(); |
9313 | ········pm.Save(); |
9314 | ········pm.UnloadCache(); |
9315 | ········QueryOwn(); |
9316 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9317 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9318 | ····} |
9319 | ····[Test] |
9320 | ····public void TestSaveReloadRemove() |
9321 | ····{ |
9322 | ········CreateObjects(); |
9323 | ········QueryOwn(); |
9324 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9325 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9326 | ········ownVar.RemoveRelatedObject(); |
9327 | ········pm.Save(); |
9328 | ········pm.UnloadCache(); |
9329 | ········QueryOwn(); |
9330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9331 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9332 | ····} |
9333 | ····[Test] |
9334 | ····public void TestChangeKeyHolderRight() |
9335 | ····{ |
9336 | ········CreateObjects(); |
9337 | ········QueryOther(); |
9338 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9339 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9340 | ········int x = otherVar.RelField.Dummy; |
9341 | ········otherVar.Dummy = 4711; |
9342 | ········pm.Save(); |
9343 | ········pm.UnloadCache(); |
9344 | ········QueryOther(); |
9345 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9346 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9347 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9348 | ····} |
9349 | ····[Test] |
9350 | ····public void TestChangeKeyHolderRightNoTouch() |
9351 | ····{ |
9352 | ········CreateObjects(); |
9353 | ········QueryOther(); |
9354 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9355 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9356 | ········otherVar.Dummy = 4711; |
9357 | ········pm.Save(); |
9358 | ········pm.UnloadCache(); |
9359 | ········QueryOther(); |
9360 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9361 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9362 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9363 | ····} |
9364 | ····[Test] |
9365 | ····public void TestRelationHash() |
9366 | ····{ |
9367 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoLeftBase)); |
9368 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9369 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoRightBase)); |
9370 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9371 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9372 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9373 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoLeftDerived)); |
9374 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9375 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9376 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9377 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblAutoRightDerived)); |
9378 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9379 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9380 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9381 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9382 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9383 | ····} |
9384 | ····void CreateObjects() |
9385 | ····{ |
9386 | ········pm.MakePersistent(ownVar); |
9387 | ········ownVar.AssignRelation(otherVar); |
9388 | ········pm.Save(); |
9389 | ········pm.UnloadCache(); |
9390 | ····} |
9391 | ····void QueryOwn() |
9392 | ····{ |
9393 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblAutoLeftBase>(pm); |
9394 | ········ownVar = q.ExecuteSingle(); |
9395 | ····} |
9396 | ····void QueryOther() |
9397 | ····{ |
9398 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblAutoRightBase>(pm); |
9399 | ········otherVar = q.ExecuteSingle(); |
9400 | ····} |
9401 | } |
9402 | |
9403 | |
9404 | [TestFixture] |
9405 | public class TestCmpBi1nOwnpconOthpconTblAuto : NDOTest |
9406 | { |
9407 | ····CmpBi1nOwnpconOthpconTblAutoLeftBase ownVar; |
9408 | ····CmpBi1nOwnpconOthpconTblAutoRightBase otherVar; |
9409 | ····PersistenceManager pm; |
9410 | ····[SetUp] |
9411 | ····public void Setup() |
9412 | ····{ |
9413 | ········pm = PmFactory.NewPersistenceManager(); |
9414 | ········ownVar = new CmpBi1nOwnpconOthpconTblAutoLeftDerived(); |
9415 | ········otherVar = new CmpBi1nOwnpconOthpconTblAutoRightDerived(); |
9416 | ····} |
9417 | ····[TearDown] |
9418 | ····public void TearDown() |
9419 | ····{ |
9420 | ········try |
9421 | ········{ |
9422 | ············pm.UnloadCache(); |
9423 | ············var l = pm.Objects<CmpBi1nOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9424 | ············pm.Delete(l); |
9425 | ············pm.Save(); |
9426 | ············pm.UnloadCache(); |
9427 | ············decimal count; |
9428 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9429 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9430 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9431 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9432 | ········} |
9433 | ········catch (Exception) |
9434 | ········{ |
9435 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9436 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9437 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9438 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9439 | ········} |
9440 | ····} |
9441 | ····[Test] |
9442 | ····public void TestSaveReload() |
9443 | ····{ |
9444 | ········CreateObjects(); |
9445 | ········QueryOwn(); |
9446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9447 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9448 | ····} |
9449 | ····[Test] |
9450 | ····public void TestSaveReloadNull() |
9451 | ····{ |
9452 | ········CreateObjects(); |
9453 | ········QueryOwn(); |
9454 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9455 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9456 | ········ownVar.RelField = null; |
9457 | ········pm.Save(); |
9458 | ········pm.UnloadCache(); |
9459 | ········QueryOwn(); |
9460 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9461 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9462 | ····} |
9463 | ····[Test] |
9464 | ····public void TestChangeKeyHolderLeft() |
9465 | ····{ |
9466 | ········CreateObjects(); |
9467 | ········QueryOwn(); |
9468 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9469 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9470 | ········int x = ownVar.RelField.Dummy; |
9471 | ········ownVar.Dummy = 4711; |
9472 | ········pm.Save(); |
9473 | ········pm.UnloadCache(); |
9474 | ········QueryOwn(); |
9475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9476 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9477 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9478 | ····} |
9479 | ····[Test] |
9480 | ····public void TestChangeKeyHolderLeftNoTouch() |
9481 | ····{ |
9482 | ········CreateObjects(); |
9483 | ········QueryOwn(); |
9484 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9485 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9486 | ········ownVar.Dummy = 4711; |
9487 | ········pm.Save(); |
9488 | ········pm.UnloadCache(); |
9489 | ········QueryOwn(); |
9490 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9491 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9492 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9493 | ····} |
9494 | ····[Test] |
9495 | ····public void TestRelationHash() |
9496 | ····{ |
9497 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoLeftBase)); |
9498 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9499 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoRightBase)); |
9500 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9501 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9502 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9503 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoLeftDerived)); |
9504 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9505 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9506 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9507 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblAutoRightDerived)); |
9508 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9509 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9510 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9511 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9512 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9513 | ····} |
9514 | ····void CreateObjects() |
9515 | ····{ |
9516 | ········pm.MakePersistent(ownVar); |
9517 | ········ownVar.AssignRelation(otherVar); |
9518 | ········pm.Save(); |
9519 | ········pm.UnloadCache(); |
9520 | ····} |
9521 | ····void QueryOwn() |
9522 | ····{ |
9523 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblAutoLeftBase>(pm); |
9524 | ········ownVar = q.ExecuteSingle(); |
9525 | ····} |
9526 | ····void QueryOther() |
9527 | ····{ |
9528 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblAutoRightBase>(pm); |
9529 | ········otherVar = q.ExecuteSingle(); |
9530 | ····} |
9531 | } |
9532 | |
9533 | |
9534 | [TestFixture] |
9535 | public class TestCmpBinnOwnpconOthpconTblAuto : NDOTest |
9536 | { |
9537 | ····CmpBinnOwnpconOthpconTblAutoLeftBase ownVar; |
9538 | ····CmpBinnOwnpconOthpconTblAutoRightBase otherVar; |
9539 | ····PersistenceManager pm; |
9540 | ····[SetUp] |
9541 | ····public void Setup() |
9542 | ····{ |
9543 | ········pm = PmFactory.NewPersistenceManager(); |
9544 | ········ownVar = new CmpBinnOwnpconOthpconTblAutoLeftDerived(); |
9545 | ········otherVar = new CmpBinnOwnpconOthpconTblAutoRightDerived(); |
9546 | ····} |
9547 | ····[TearDown] |
9548 | ····public void TearDown() |
9549 | ····{ |
9550 | ········try |
9551 | ········{ |
9552 | ············pm.UnloadCache(); |
9553 | ············var l = pm.Objects<CmpBinnOwnpconOthpconTblAutoLeftBase>().ResultTable; |
9554 | ············pm.Delete(l); |
9555 | ············pm.Save(); |
9556 | ············pm.UnloadCache(); |
9557 | ············decimal count; |
9558 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9559 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9560 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9561 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9562 | ········} |
9563 | ········catch (Exception) |
9564 | ········{ |
9565 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9566 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9567 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9568 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9569 | ········} |
9570 | ····} |
9571 | ····[Test] |
9572 | ····public void TestSaveReload() |
9573 | ····{ |
9574 | ········CreateObjects(); |
9575 | ········QueryOwn(); |
9576 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9577 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9578 | ····} |
9579 | ····[Test] |
9580 | ····public void TestSaveReloadNull() |
9581 | ····{ |
9582 | ········CreateObjects(); |
9583 | ········QueryOwn(); |
9584 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9585 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9586 | ········ownVar.RelField = new List<CmpBinnOwnpconOthpconTblAutoRightBase>(); |
9587 | ········pm.Save(); |
9588 | ········pm.UnloadCache(); |
9589 | ········QueryOwn(); |
9590 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9591 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9592 | ····} |
9593 | ····[Test] |
9594 | ····public void TestSaveReloadRemove() |
9595 | ····{ |
9596 | ········CreateObjects(); |
9597 | ········QueryOwn(); |
9598 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9599 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9600 | ········ownVar.RemoveRelatedObject(); |
9601 | ········pm.Save(); |
9602 | ········pm.UnloadCache(); |
9603 | ········QueryOwn(); |
9604 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9605 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
9606 | ····} |
9607 | ····[Test] |
9608 | ····public void TestRelationHash() |
9609 | ····{ |
9610 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoLeftBase)); |
9611 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
9612 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoRightBase)); |
9613 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
9614 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
9615 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
9616 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoLeftDerived)); |
9617 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
9618 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
9619 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
9620 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblAutoRightDerived)); |
9621 | ········Relation relderRight = clderRight.FindRelation("relField"); |
9622 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
9623 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
9624 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
9625 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
9626 | ····} |
9627 | ····void CreateObjects() |
9628 | ····{ |
9629 | ········pm.MakePersistent(ownVar); |
9630 | ········ownVar.AssignRelation(otherVar); |
9631 | ········pm.Save(); |
9632 | ········pm.UnloadCache(); |
9633 | ····} |
9634 | ····void QueryOwn() |
9635 | ····{ |
9636 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblAutoLeftBase>(pm); |
9637 | ········ownVar = q.ExecuteSingle(); |
9638 | ····} |
9639 | ····void QueryOther() |
9640 | ····{ |
9641 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblAutoRightBase>(pm); |
9642 | ········otherVar = q.ExecuteSingle(); |
9643 | ····} |
9644 | } |
9645 | |
9646 | |
9647 | [TestFixture] |
9648 | public class TestAgrDir1NoTblGuid : NDOTest |
9649 | { |
9650 | ····AgrDir1NoTblGuidLeft ownVar; |
9651 | ····AgrDir1NoTblGuidRight otherVar; |
9652 | ····PersistenceManager pm; |
9653 | ····[SetUp] |
9654 | ····public void Setup() |
9655 | ····{ |
9656 | ········pm = PmFactory.NewPersistenceManager(); |
9657 | ········ownVar = new AgrDir1NoTblGuidLeft(); |
9658 | ········otherVar = new AgrDir1NoTblGuidRight(); |
9659 | ····} |
9660 | ····[TearDown] |
9661 | ····public void TearDown() |
9662 | ····{ |
9663 | ········try |
9664 | ········{ |
9665 | ············pm.UnloadCache(); |
9666 | ············var l = pm.Objects<AgrDir1NoTblGuidLeft>().ResultTable; |
9667 | ············pm.Delete(l); |
9668 | ············pm.Save(); |
9669 | ············pm.UnloadCache(); |
9670 | ············var m = pm.Objects<AgrDir1NoTblGuidRight>().ResultTable; |
9671 | ············pm.Delete(m); |
9672 | ············pm.Save(); |
9673 | ············pm.UnloadCache(); |
9674 | ············decimal count; |
9675 | ············count = (decimal) new NDOQuery<AgrDir1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9676 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9677 | ············count = (decimal) new NDOQuery<AgrDir1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9678 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9679 | ········} |
9680 | ········catch (Exception) |
9681 | ········{ |
9682 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9683 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9684 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9685 | ········} |
9686 | ····} |
9687 | ····[Test] |
9688 | ····public void TestSaveReload() |
9689 | ····{ |
9690 | ········CreateObjects(); |
9691 | ········QueryOwn(); |
9692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9693 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9694 | ····} |
9695 | ····[Test] |
9696 | ····public void TestSaveReloadNull() |
9697 | ····{ |
9698 | ········CreateObjects(); |
9699 | ········QueryOwn(); |
9700 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9701 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9702 | ········ownVar.RelField = null; |
9703 | ········pm.Save(); |
9704 | ········pm.UnloadCache(); |
9705 | ········QueryOwn(); |
9706 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9707 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9708 | ····} |
9709 | ····[Test] |
9710 | ····public void TestChangeKeyHolderLeft() |
9711 | ····{ |
9712 | ········CreateObjects(); |
9713 | ········QueryOwn(); |
9714 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9715 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9716 | ········int x = ownVar.RelField.Dummy; |
9717 | ········ownVar.Dummy = 4711; |
9718 | ········pm.Save(); |
9719 | ········pm.UnloadCache(); |
9720 | ········QueryOwn(); |
9721 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9722 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9723 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9724 | ····} |
9725 | ····[Test] |
9726 | ····public void TestChangeKeyHolderLeftNoTouch() |
9727 | ····{ |
9728 | ········CreateObjects(); |
9729 | ········QueryOwn(); |
9730 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9731 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9732 | ········ownVar.Dummy = 4711; |
9733 | ········pm.Save(); |
9734 | ········pm.UnloadCache(); |
9735 | ········QueryOwn(); |
9736 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9737 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9738 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9739 | ····} |
9740 | ····void CreateObjects() |
9741 | ····{ |
9742 | ········pm.MakePersistent(ownVar); |
9743 | ········pm.MakePersistent(otherVar); |
9744 | ········ownVar.AssignRelation(otherVar); |
9745 | ········pm.Save(); |
9746 | ········pm.UnloadCache(); |
9747 | ····} |
9748 | ····void QueryOwn() |
9749 | ····{ |
9750 | ········var q = new NDOQuery<AgrDir1NoTblGuidLeft>(pm); |
9751 | ········ownVar = q.ExecuteSingle(); |
9752 | ····} |
9753 | ····void QueryOther() |
9754 | ····{ |
9755 | ········var q = new NDOQuery<AgrDir1NoTblGuidRight>(pm); |
9756 | ········otherVar = q.ExecuteSingle(); |
9757 | ····} |
9758 | } |
9759 | |
9760 | |
9761 | [TestFixture] |
9762 | public class TestAgrDir1TblGuid : NDOTest |
9763 | { |
9764 | ····AgrDir1TblGuidLeft ownVar; |
9765 | ····AgrDir1TblGuidRight otherVar; |
9766 | ····PersistenceManager pm; |
9767 | ····[SetUp] |
9768 | ····public void Setup() |
9769 | ····{ |
9770 | ········pm = PmFactory.NewPersistenceManager(); |
9771 | ········ownVar = new AgrDir1TblGuidLeft(); |
9772 | ········otherVar = new AgrDir1TblGuidRight(); |
9773 | ····} |
9774 | ····[TearDown] |
9775 | ····public void TearDown() |
9776 | ····{ |
9777 | ········try |
9778 | ········{ |
9779 | ············pm.UnloadCache(); |
9780 | ············var l = pm.Objects<AgrDir1TblGuidLeft>().ResultTable; |
9781 | ············pm.Delete(l); |
9782 | ············pm.Save(); |
9783 | ············pm.UnloadCache(); |
9784 | ············var m = pm.Objects<AgrDir1TblGuidRight>().ResultTable; |
9785 | ············pm.Delete(m); |
9786 | ············pm.Save(); |
9787 | ············pm.UnloadCache(); |
9788 | ············decimal count; |
9789 | ············count = (decimal) new NDOQuery<AgrDir1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9790 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9791 | ············count = (decimal) new NDOQuery<AgrDir1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9792 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9793 | ········} |
9794 | ········catch (Exception) |
9795 | ········{ |
9796 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9797 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9798 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9799 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
9800 | ········} |
9801 | ····} |
9802 | ····[Test] |
9803 | ····public void TestSaveReload() |
9804 | ····{ |
9805 | ········CreateObjects(); |
9806 | ········QueryOwn(); |
9807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9809 | ····} |
9810 | ····[Test] |
9811 | ····public void TestSaveReloadNull() |
9812 | ····{ |
9813 | ········CreateObjects(); |
9814 | ········QueryOwn(); |
9815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9817 | ········ownVar.RelField = null; |
9818 | ········pm.Save(); |
9819 | ········pm.UnloadCache(); |
9820 | ········QueryOwn(); |
9821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9822 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9823 | ····} |
9824 | ····[Test] |
9825 | ····public void TestChangeKeyHolderLeft() |
9826 | ····{ |
9827 | ········CreateObjects(); |
9828 | ········QueryOwn(); |
9829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9831 | ········int x = ownVar.RelField.Dummy; |
9832 | ········ownVar.Dummy = 4711; |
9833 | ········pm.Save(); |
9834 | ········pm.UnloadCache(); |
9835 | ········QueryOwn(); |
9836 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9837 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9838 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9839 | ····} |
9840 | ····[Test] |
9841 | ····public void TestChangeKeyHolderLeftNoTouch() |
9842 | ····{ |
9843 | ········CreateObjects(); |
9844 | ········QueryOwn(); |
9845 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9846 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9847 | ········ownVar.Dummy = 4711; |
9848 | ········pm.Save(); |
9849 | ········pm.UnloadCache(); |
9850 | ········QueryOwn(); |
9851 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9852 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9853 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9854 | ····} |
9855 | ····void CreateObjects() |
9856 | ····{ |
9857 | ········pm.MakePersistent(ownVar); |
9858 | ········pm.MakePersistent(otherVar); |
9859 | ········ownVar.AssignRelation(otherVar); |
9860 | ········pm.Save(); |
9861 | ········pm.UnloadCache(); |
9862 | ····} |
9863 | ····void QueryOwn() |
9864 | ····{ |
9865 | ········var q = new NDOQuery<AgrDir1TblGuidLeft>(pm); |
9866 | ········ownVar = q.ExecuteSingle(); |
9867 | ····} |
9868 | ····void QueryOther() |
9869 | ····{ |
9870 | ········var q = new NDOQuery<AgrDir1TblGuidRight>(pm); |
9871 | ········otherVar = q.ExecuteSingle(); |
9872 | ····} |
9873 | } |
9874 | |
9875 | |
9876 | [TestFixture] |
9877 | public class TestAgrBi11NoTblGuid : NDOTest |
9878 | { |
9879 | ····AgrBi11NoTblGuidLeft ownVar; |
9880 | ····AgrBi11NoTblGuidRight otherVar; |
9881 | ····PersistenceManager pm; |
9882 | ····[SetUp] |
9883 | ····public void Setup() |
9884 | ····{ |
9885 | ········pm = PmFactory.NewPersistenceManager(); |
9886 | ········ownVar = new AgrBi11NoTblGuidLeft(); |
9887 | ········otherVar = new AgrBi11NoTblGuidRight(); |
9888 | ····} |
9889 | ····[TearDown] |
9890 | ····public void TearDown() |
9891 | ····{ |
9892 | ········try |
9893 | ········{ |
9894 | ············pm.UnloadCache(); |
9895 | ············var l = pm.Objects<AgrBi11NoTblGuidLeft>().ResultTable; |
9896 | ············pm.Delete(l); |
9897 | ············pm.Save(); |
9898 | ············pm.UnloadCache(); |
9899 | ············var m = pm.Objects<AgrBi11NoTblGuidRight>().ResultTable; |
9900 | ············pm.Delete(m); |
9901 | ············pm.Save(); |
9902 | ············pm.UnloadCache(); |
9903 | ············decimal count; |
9904 | ············count = (decimal) new NDOQuery<AgrBi11NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9905 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
9906 | ············count = (decimal) new NDOQuery<AgrBi11NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
9907 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
9908 | ········} |
9909 | ········catch (Exception) |
9910 | ········{ |
9911 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
9912 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
9913 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
9914 | ········} |
9915 | ····} |
9916 | ····[Test] |
9917 | ····public void TestSaveReload() |
9918 | ····{ |
9919 | ········CreateObjects(); |
9920 | ········QueryOwn(); |
9921 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9922 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9923 | ····} |
9924 | ····[Test] |
9925 | ····public void TestSaveReloadNull() |
9926 | ····{ |
9927 | ········CreateObjects(); |
9928 | ········QueryOwn(); |
9929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9930 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9931 | ········ownVar.RelField = null; |
9932 | ········pm.Save(); |
9933 | ········pm.UnloadCache(); |
9934 | ········QueryOwn(); |
9935 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9936 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
9937 | ····} |
9938 | ····[Test] |
9939 | ····public void TestChangeKeyHolderLeft() |
9940 | ····{ |
9941 | ········CreateObjects(); |
9942 | ········QueryOwn(); |
9943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9945 | ········int x = ownVar.RelField.Dummy; |
9946 | ········ownVar.Dummy = 4711; |
9947 | ········pm.Save(); |
9948 | ········pm.UnloadCache(); |
9949 | ········QueryOwn(); |
9950 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9951 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9952 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9953 | ····} |
9954 | ····[Test] |
9955 | ····public void TestChangeKeyHolderRight() |
9956 | ····{ |
9957 | ········CreateObjects(); |
9958 | ········QueryOther(); |
9959 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9960 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9961 | ········int x = otherVar.RelField.Dummy; |
9962 | ········otherVar.Dummy = 4711; |
9963 | ········pm.Save(); |
9964 | ········pm.UnloadCache(); |
9965 | ········QueryOther(); |
9966 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9967 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9968 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9969 | ····} |
9970 | ····[Test] |
9971 | ····public void TestChangeKeyHolderLeftNoTouch() |
9972 | ····{ |
9973 | ········CreateObjects(); |
9974 | ········QueryOwn(); |
9975 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9976 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9977 | ········ownVar.Dummy = 4711; |
9978 | ········pm.Save(); |
9979 | ········pm.UnloadCache(); |
9980 | ········QueryOwn(); |
9981 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
9982 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9983 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
9984 | ····} |
9985 | ····[Test] |
9986 | ····public void TestChangeKeyHolderRightNoTouch() |
9987 | ····{ |
9988 | ········CreateObjects(); |
9989 | ········QueryOther(); |
9990 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9991 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9992 | ········otherVar.Dummy = 4711; |
9993 | ········pm.Save(); |
9994 | ········pm.UnloadCache(); |
9995 | ········QueryOther(); |
9996 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
9997 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
9998 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
9999 | ····} |
10000 | ····[Test] |
10001 | ····public void TestRelationHash() |
10002 | ····{ |
10003 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblGuidLeft)); |
10004 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10005 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11NoTblGuidRight)); |
10006 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10007 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10008 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10009 | ····} |
10010 | ····void CreateObjects() |
10011 | ····{ |
10012 | ········pm.MakePersistent(ownVar); |
10013 | ········pm.MakePersistent(otherVar); |
10014 | ········ownVar.AssignRelation(otherVar); |
10015 | ········pm.Save(); |
10016 | ········pm.UnloadCache(); |
10017 | ····} |
10018 | ····void QueryOwn() |
10019 | ····{ |
10020 | ········var q = new NDOQuery<AgrBi11NoTblGuidLeft>(pm); |
10021 | ········ownVar = q.ExecuteSingle(); |
10022 | ····} |
10023 | ····void QueryOther() |
10024 | ····{ |
10025 | ········var q = new NDOQuery<AgrBi11NoTblGuidRight>(pm); |
10026 | ········otherVar = q.ExecuteSingle(); |
10027 | ····} |
10028 | } |
10029 | |
10030 | |
10031 | [TestFixture] |
10032 | public class TestAgrBi11TblGuid : NDOTest |
10033 | { |
10034 | ····AgrBi11TblGuidLeft ownVar; |
10035 | ····AgrBi11TblGuidRight otherVar; |
10036 | ····PersistenceManager pm; |
10037 | ····[SetUp] |
10038 | ····public void Setup() |
10039 | ····{ |
10040 | ········pm = PmFactory.NewPersistenceManager(); |
10041 | ········ownVar = new AgrBi11TblGuidLeft(); |
10042 | ········otherVar = new AgrBi11TblGuidRight(); |
10043 | ····} |
10044 | ····[TearDown] |
10045 | ····public void TearDown() |
10046 | ····{ |
10047 | ········try |
10048 | ········{ |
10049 | ············pm.UnloadCache(); |
10050 | ············var l = pm.Objects<AgrBi11TblGuidLeft>().ResultTable; |
10051 | ············pm.Delete(l); |
10052 | ············pm.Save(); |
10053 | ············pm.UnloadCache(); |
10054 | ············var m = pm.Objects<AgrBi11TblGuidRight>().ResultTable; |
10055 | ············pm.Delete(m); |
10056 | ············pm.Save(); |
10057 | ············pm.UnloadCache(); |
10058 | ············decimal count; |
10059 | ············count = (decimal) new NDOQuery<AgrBi11TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10060 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10061 | ············count = (decimal) new NDOQuery<AgrBi11TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10063 | ········} |
10064 | ········catch (Exception) |
10065 | ········{ |
10066 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10067 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10068 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10069 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10070 | ········} |
10071 | ····} |
10072 | ····[Test] |
10073 | ····public void TestSaveReload() |
10074 | ····{ |
10075 | ········CreateObjects(); |
10076 | ········QueryOwn(); |
10077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10078 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10079 | ····} |
10080 | ····[Test] |
10081 | ····public void TestSaveReloadNull() |
10082 | ····{ |
10083 | ········CreateObjects(); |
10084 | ········QueryOwn(); |
10085 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10086 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10087 | ········ownVar.RelField = null; |
10088 | ········pm.Save(); |
10089 | ········pm.UnloadCache(); |
10090 | ········QueryOwn(); |
10091 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10092 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10093 | ····} |
10094 | ····[Test] |
10095 | ····public void TestChangeKeyHolderLeft() |
10096 | ····{ |
10097 | ········CreateObjects(); |
10098 | ········QueryOwn(); |
10099 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10100 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10101 | ········int x = ownVar.RelField.Dummy; |
10102 | ········ownVar.Dummy = 4711; |
10103 | ········pm.Save(); |
10104 | ········pm.UnloadCache(); |
10105 | ········QueryOwn(); |
10106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10107 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10108 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10109 | ····} |
10110 | ····[Test] |
10111 | ····public void TestChangeKeyHolderRight() |
10112 | ····{ |
10113 | ········CreateObjects(); |
10114 | ········QueryOther(); |
10115 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10116 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10117 | ········int x = otherVar.RelField.Dummy; |
10118 | ········otherVar.Dummy = 4711; |
10119 | ········pm.Save(); |
10120 | ········pm.UnloadCache(); |
10121 | ········QueryOther(); |
10122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10125 | ····} |
10126 | ····[Test] |
10127 | ····public void TestChangeKeyHolderLeftNoTouch() |
10128 | ····{ |
10129 | ········CreateObjects(); |
10130 | ········QueryOwn(); |
10131 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10132 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10133 | ········ownVar.Dummy = 4711; |
10134 | ········pm.Save(); |
10135 | ········pm.UnloadCache(); |
10136 | ········QueryOwn(); |
10137 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10138 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10139 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10140 | ····} |
10141 | ····[Test] |
10142 | ····public void TestChangeKeyHolderRightNoTouch() |
10143 | ····{ |
10144 | ········CreateObjects(); |
10145 | ········QueryOther(); |
10146 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10147 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10148 | ········otherVar.Dummy = 4711; |
10149 | ········pm.Save(); |
10150 | ········pm.UnloadCache(); |
10151 | ········QueryOther(); |
10152 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10153 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10154 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10155 | ····} |
10156 | ····[Test] |
10157 | ····public void TestRelationHash() |
10158 | ····{ |
10159 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11TblGuidLeft)); |
10160 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10161 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11TblGuidRight)); |
10162 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10163 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10164 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10165 | ····} |
10166 | ····void CreateObjects() |
10167 | ····{ |
10168 | ········pm.MakePersistent(ownVar); |
10169 | ········pm.MakePersistent(otherVar); |
10170 | ········ownVar.AssignRelation(otherVar); |
10171 | ········pm.Save(); |
10172 | ········pm.UnloadCache(); |
10173 | ····} |
10174 | ····void QueryOwn() |
10175 | ····{ |
10176 | ········var q = new NDOQuery<AgrBi11TblGuidLeft>(pm); |
10177 | ········ownVar = q.ExecuteSingle(); |
10178 | ····} |
10179 | ····void QueryOther() |
10180 | ····{ |
10181 | ········var q = new NDOQuery<AgrBi11TblGuidRight>(pm); |
10182 | ········otherVar = q.ExecuteSingle(); |
10183 | ····} |
10184 | } |
10185 | |
10186 | |
10187 | [TestFixture] |
10188 | public class TestAgrDirnNoTblGuid : NDOTest |
10189 | { |
10190 | ····AgrDirnNoTblGuidLeft ownVar; |
10191 | ····AgrDirnNoTblGuidRight otherVar; |
10192 | ····PersistenceManager pm; |
10193 | ····[SetUp] |
10194 | ····public void Setup() |
10195 | ····{ |
10196 | ········pm = PmFactory.NewPersistenceManager(); |
10197 | ········ownVar = new AgrDirnNoTblGuidLeft(); |
10198 | ········otherVar = new AgrDirnNoTblGuidRight(); |
10199 | ····} |
10200 | ····[TearDown] |
10201 | ····public void TearDown() |
10202 | ····{ |
10203 | ········try |
10204 | ········{ |
10205 | ············pm.UnloadCache(); |
10206 | ············var l = pm.Objects<AgrDirnNoTblGuidLeft>().ResultTable; |
10207 | ············pm.Delete(l); |
10208 | ············pm.Save(); |
10209 | ············pm.UnloadCache(); |
10210 | ············var m = pm.Objects<AgrDirnNoTblGuidRight>().ResultTable; |
10211 | ············pm.Delete(m); |
10212 | ············pm.Save(); |
10213 | ············pm.UnloadCache(); |
10214 | ············decimal count; |
10215 | ············count = (decimal) new NDOQuery<AgrDirnNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10216 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10217 | ············count = (decimal) new NDOQuery<AgrDirnNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10218 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10219 | ········} |
10220 | ········catch (Exception) |
10221 | ········{ |
10222 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10223 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10224 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10225 | ········} |
10226 | ····} |
10227 | ····[Test] |
10228 | ····public void TestSaveReload() |
10229 | ····{ |
10230 | ········CreateObjects(); |
10231 | ········QueryOwn(); |
10232 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10233 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10234 | ····} |
10235 | ····[Test] |
10236 | ····public void TestSaveReloadNull() |
10237 | ····{ |
10238 | ········CreateObjects(); |
10239 | ········QueryOwn(); |
10240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10241 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10242 | ········ownVar.RelField = new List<AgrDirnNoTblGuidRight>(); |
10243 | ········pm.Save(); |
10244 | ········pm.UnloadCache(); |
10245 | ········QueryOwn(); |
10246 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10247 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10248 | ····} |
10249 | ····[Test] |
10250 | ····public void TestSaveReloadRemove() |
10251 | ····{ |
10252 | ········CreateObjects(); |
10253 | ········QueryOwn(); |
10254 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10255 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10256 | ········ownVar.RemoveRelatedObject(); |
10257 | ········pm.Save(); |
10258 | ········pm.UnloadCache(); |
10259 | ········QueryOwn(); |
10260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10261 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10262 | ····} |
10263 | ····void CreateObjects() |
10264 | ····{ |
10265 | ········pm.MakePersistent(ownVar); |
10266 | ········pm.MakePersistent(otherVar); |
10267 | ········ownVar.AssignRelation(otherVar); |
10268 | ········pm.Save(); |
10269 | ········pm.UnloadCache(); |
10270 | ····} |
10271 | ····void QueryOwn() |
10272 | ····{ |
10273 | ········var q = new NDOQuery<AgrDirnNoTblGuidLeft>(pm); |
10274 | ········ownVar = q.ExecuteSingle(); |
10275 | ····} |
10276 | ····void QueryOther() |
10277 | ····{ |
10278 | ········var q = new NDOQuery<AgrDirnNoTblGuidRight>(pm); |
10279 | ········otherVar = q.ExecuteSingle(); |
10280 | ····} |
10281 | } |
10282 | |
10283 | |
10284 | [TestFixture] |
10285 | public class TestAgrDirnTblGuid : NDOTest |
10286 | { |
10287 | ····AgrDirnTblGuidLeft ownVar; |
10288 | ····AgrDirnTblGuidRight otherVar; |
10289 | ····PersistenceManager pm; |
10290 | ····[SetUp] |
10291 | ····public void Setup() |
10292 | ····{ |
10293 | ········pm = PmFactory.NewPersistenceManager(); |
10294 | ········ownVar = new AgrDirnTblGuidLeft(); |
10295 | ········otherVar = new AgrDirnTblGuidRight(); |
10296 | ····} |
10297 | ····[TearDown] |
10298 | ····public void TearDown() |
10299 | ····{ |
10300 | ········try |
10301 | ········{ |
10302 | ············pm.UnloadCache(); |
10303 | ············var l = pm.Objects<AgrDirnTblGuidLeft>().ResultTable; |
10304 | ············pm.Delete(l); |
10305 | ············pm.Save(); |
10306 | ············pm.UnloadCache(); |
10307 | ············var m = pm.Objects<AgrDirnTblGuidRight>().ResultTable; |
10308 | ············pm.Delete(m); |
10309 | ············pm.Save(); |
10310 | ············pm.UnloadCache(); |
10311 | ············decimal count; |
10312 | ············count = (decimal) new NDOQuery<AgrDirnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10313 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10314 | ············count = (decimal) new NDOQuery<AgrDirnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10315 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10316 | ········} |
10317 | ········catch (Exception) |
10318 | ········{ |
10319 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10320 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10321 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10322 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10323 | ········} |
10324 | ····} |
10325 | ····[Test] |
10326 | ····public void TestSaveReload() |
10327 | ····{ |
10328 | ········CreateObjects(); |
10329 | ········QueryOwn(); |
10330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10331 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10332 | ····} |
10333 | ····[Test] |
10334 | ····public void TestSaveReloadNull() |
10335 | ····{ |
10336 | ········CreateObjects(); |
10337 | ········QueryOwn(); |
10338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10339 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10340 | ········ownVar.RelField = new List<AgrDirnTblGuidRight>(); |
10341 | ········pm.Save(); |
10342 | ········pm.UnloadCache(); |
10343 | ········QueryOwn(); |
10344 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10345 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10346 | ····} |
10347 | ····[Test] |
10348 | ····public void TestSaveReloadRemove() |
10349 | ····{ |
10350 | ········CreateObjects(); |
10351 | ········QueryOwn(); |
10352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10353 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10354 | ········ownVar.RemoveRelatedObject(); |
10355 | ········pm.Save(); |
10356 | ········pm.UnloadCache(); |
10357 | ········QueryOwn(); |
10358 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10359 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10360 | ····} |
10361 | ····void CreateObjects() |
10362 | ····{ |
10363 | ········pm.MakePersistent(ownVar); |
10364 | ········pm.MakePersistent(otherVar); |
10365 | ········ownVar.AssignRelation(otherVar); |
10366 | ········pm.Save(); |
10367 | ········pm.UnloadCache(); |
10368 | ····} |
10369 | ····void QueryOwn() |
10370 | ····{ |
10371 | ········var q = new NDOQuery<AgrDirnTblGuidLeft>(pm); |
10372 | ········ownVar = q.ExecuteSingle(); |
10373 | ····} |
10374 | ····void QueryOther() |
10375 | ····{ |
10376 | ········var q = new NDOQuery<AgrDirnTblGuidRight>(pm); |
10377 | ········otherVar = q.ExecuteSingle(); |
10378 | ····} |
10379 | } |
10380 | |
10381 | |
10382 | [TestFixture] |
10383 | public class TestAgrBin1NoTblGuid : NDOTest |
10384 | { |
10385 | ····AgrBin1NoTblGuidLeft ownVar; |
10386 | ····AgrBin1NoTblGuidRight otherVar; |
10387 | ····PersistenceManager pm; |
10388 | ····[SetUp] |
10389 | ····public void Setup() |
10390 | ····{ |
10391 | ········pm = PmFactory.NewPersistenceManager(); |
10392 | ········ownVar = new AgrBin1NoTblGuidLeft(); |
10393 | ········otherVar = new AgrBin1NoTblGuidRight(); |
10394 | ····} |
10395 | ····[TearDown] |
10396 | ····public void TearDown() |
10397 | ····{ |
10398 | ········try |
10399 | ········{ |
10400 | ············pm.UnloadCache(); |
10401 | ············var l = pm.Objects<AgrBin1NoTblGuidLeft>().ResultTable; |
10402 | ············pm.Delete(l); |
10403 | ············pm.Save(); |
10404 | ············pm.UnloadCache(); |
10405 | ············var m = pm.Objects<AgrBin1NoTblGuidRight>().ResultTable; |
10406 | ············pm.Delete(m); |
10407 | ············pm.Save(); |
10408 | ············pm.UnloadCache(); |
10409 | ············decimal count; |
10410 | ············count = (decimal) new NDOQuery<AgrBin1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10411 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10412 | ············count = (decimal) new NDOQuery<AgrBin1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10413 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10414 | ········} |
10415 | ········catch (Exception) |
10416 | ········{ |
10417 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10418 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10419 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10420 | ········} |
10421 | ····} |
10422 | ····[Test] |
10423 | ····public void TestSaveReload() |
10424 | ····{ |
10425 | ········CreateObjects(); |
10426 | ········QueryOwn(); |
10427 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10428 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10429 | ····} |
10430 | ····[Test] |
10431 | ····public void TestSaveReloadNull() |
10432 | ····{ |
10433 | ········CreateObjects(); |
10434 | ········QueryOwn(); |
10435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10436 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10437 | ········ownVar.RelField = new List<AgrBin1NoTblGuidRight>(); |
10438 | ········pm.Save(); |
10439 | ········pm.UnloadCache(); |
10440 | ········QueryOwn(); |
10441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10442 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10443 | ····} |
10444 | ····[Test] |
10445 | ····public void TestSaveReloadRemove() |
10446 | ····{ |
10447 | ········CreateObjects(); |
10448 | ········QueryOwn(); |
10449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10450 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10451 | ········ownVar.RemoveRelatedObject(); |
10452 | ········pm.Save(); |
10453 | ········pm.UnloadCache(); |
10454 | ········QueryOwn(); |
10455 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10456 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10457 | ····} |
10458 | ····[Test] |
10459 | ····public void TestChangeKeyHolderRight() |
10460 | ····{ |
10461 | ········CreateObjects(); |
10462 | ········QueryOther(); |
10463 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10464 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10465 | ········int x = otherVar.RelField.Dummy; |
10466 | ········otherVar.Dummy = 4711; |
10467 | ········pm.Save(); |
10468 | ········pm.UnloadCache(); |
10469 | ········QueryOther(); |
10470 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10471 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10472 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10473 | ····} |
10474 | ····[Test] |
10475 | ····public void TestChangeKeyHolderRightNoTouch() |
10476 | ····{ |
10477 | ········CreateObjects(); |
10478 | ········QueryOther(); |
10479 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10480 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10481 | ········otherVar.Dummy = 4711; |
10482 | ········pm.Save(); |
10483 | ········pm.UnloadCache(); |
10484 | ········QueryOther(); |
10485 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10486 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10487 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10488 | ····} |
10489 | ····[Test] |
10490 | ····public void TestRelationHash() |
10491 | ····{ |
10492 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblGuidLeft)); |
10493 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10494 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1NoTblGuidRight)); |
10495 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10496 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10497 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10498 | ····} |
10499 | ····void CreateObjects() |
10500 | ····{ |
10501 | ········pm.MakePersistent(ownVar); |
10502 | ········pm.MakePersistent(otherVar); |
10503 | ········ownVar.AssignRelation(otherVar); |
10504 | ········pm.Save(); |
10505 | ········pm.UnloadCache(); |
10506 | ····} |
10507 | ····void QueryOwn() |
10508 | ····{ |
10509 | ········var q = new NDOQuery<AgrBin1NoTblGuidLeft>(pm); |
10510 | ········ownVar = q.ExecuteSingle(); |
10511 | ····} |
10512 | ····void QueryOther() |
10513 | ····{ |
10514 | ········var q = new NDOQuery<AgrBin1NoTblGuidRight>(pm); |
10515 | ········otherVar = q.ExecuteSingle(); |
10516 | ····} |
10517 | } |
10518 | |
10519 | |
10520 | [TestFixture] |
10521 | public class TestAgrBin1TblGuid : NDOTest |
10522 | { |
10523 | ····AgrBin1TblGuidLeft ownVar; |
10524 | ····AgrBin1TblGuidRight otherVar; |
10525 | ····PersistenceManager pm; |
10526 | ····[SetUp] |
10527 | ····public void Setup() |
10528 | ····{ |
10529 | ········pm = PmFactory.NewPersistenceManager(); |
10530 | ········ownVar = new AgrBin1TblGuidLeft(); |
10531 | ········otherVar = new AgrBin1TblGuidRight(); |
10532 | ····} |
10533 | ····[TearDown] |
10534 | ····public void TearDown() |
10535 | ····{ |
10536 | ········try |
10537 | ········{ |
10538 | ············pm.UnloadCache(); |
10539 | ············var l = pm.Objects<AgrBin1TblGuidLeft>().ResultTable; |
10540 | ············pm.Delete(l); |
10541 | ············pm.Save(); |
10542 | ············pm.UnloadCache(); |
10543 | ············var m = pm.Objects<AgrBin1TblGuidRight>().ResultTable; |
10544 | ············pm.Delete(m); |
10545 | ············pm.Save(); |
10546 | ············pm.UnloadCache(); |
10547 | ············decimal count; |
10548 | ············count = (decimal) new NDOQuery<AgrBin1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10550 | ············count = (decimal) new NDOQuery<AgrBin1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10552 | ········} |
10553 | ········catch (Exception) |
10554 | ········{ |
10555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10559 | ········} |
10560 | ····} |
10561 | ····[Test] |
10562 | ····public void TestSaveReload() |
10563 | ····{ |
10564 | ········CreateObjects(); |
10565 | ········QueryOwn(); |
10566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10568 | ····} |
10569 | ····[Test] |
10570 | ····public void TestSaveReloadNull() |
10571 | ····{ |
10572 | ········CreateObjects(); |
10573 | ········QueryOwn(); |
10574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10576 | ········ownVar.RelField = new List<AgrBin1TblGuidRight>(); |
10577 | ········pm.Save(); |
10578 | ········pm.UnloadCache(); |
10579 | ········QueryOwn(); |
10580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10582 | ····} |
10583 | ····[Test] |
10584 | ····public void TestSaveReloadRemove() |
10585 | ····{ |
10586 | ········CreateObjects(); |
10587 | ········QueryOwn(); |
10588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10590 | ········ownVar.RemoveRelatedObject(); |
10591 | ········pm.Save(); |
10592 | ········pm.UnloadCache(); |
10593 | ········QueryOwn(); |
10594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10596 | ····} |
10597 | ····[Test] |
10598 | ····public void TestChangeKeyHolderRight() |
10599 | ····{ |
10600 | ········CreateObjects(); |
10601 | ········QueryOther(); |
10602 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10603 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10604 | ········int x = otherVar.RelField.Dummy; |
10605 | ········otherVar.Dummy = 4711; |
10606 | ········pm.Save(); |
10607 | ········pm.UnloadCache(); |
10608 | ········QueryOther(); |
10609 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10610 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10611 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10612 | ····} |
10613 | ····[Test] |
10614 | ····public void TestChangeKeyHolderRightNoTouch() |
10615 | ····{ |
10616 | ········CreateObjects(); |
10617 | ········QueryOther(); |
10618 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10619 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10620 | ········otherVar.Dummy = 4711; |
10621 | ········pm.Save(); |
10622 | ········pm.UnloadCache(); |
10623 | ········QueryOther(); |
10624 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
10625 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10626 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
10627 | ····} |
10628 | ····[Test] |
10629 | ····public void TestRelationHash() |
10630 | ····{ |
10631 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1TblGuidLeft)); |
10632 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10633 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1TblGuidRight)); |
10634 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10635 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10636 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10637 | ····} |
10638 | ····void CreateObjects() |
10639 | ····{ |
10640 | ········pm.MakePersistent(ownVar); |
10641 | ········pm.MakePersistent(otherVar); |
10642 | ········ownVar.AssignRelation(otherVar); |
10643 | ········pm.Save(); |
10644 | ········pm.UnloadCache(); |
10645 | ····} |
10646 | ····void QueryOwn() |
10647 | ····{ |
10648 | ········var q = new NDOQuery<AgrBin1TblGuidLeft>(pm); |
10649 | ········ownVar = q.ExecuteSingle(); |
10650 | ····} |
10651 | ····void QueryOther() |
10652 | ····{ |
10653 | ········var q = new NDOQuery<AgrBin1TblGuidRight>(pm); |
10654 | ········otherVar = q.ExecuteSingle(); |
10655 | ····} |
10656 | } |
10657 | |
10658 | |
10659 | [TestFixture] |
10660 | public class TestAgrBi1nNoTblGuid : NDOTest |
10661 | { |
10662 | ····AgrBi1nNoTblGuidLeft ownVar; |
10663 | ····AgrBi1nNoTblGuidRight otherVar; |
10664 | ····PersistenceManager pm; |
10665 | ····[SetUp] |
10666 | ····public void Setup() |
10667 | ····{ |
10668 | ········pm = PmFactory.NewPersistenceManager(); |
10669 | ········ownVar = new AgrBi1nNoTblGuidLeft(); |
10670 | ········otherVar = new AgrBi1nNoTblGuidRight(); |
10671 | ····} |
10672 | ····[TearDown] |
10673 | ····public void TearDown() |
10674 | ····{ |
10675 | ········try |
10676 | ········{ |
10677 | ············pm.UnloadCache(); |
10678 | ············var l = pm.Objects<AgrBi1nNoTblGuidLeft>().ResultTable; |
10679 | ············pm.Delete(l); |
10680 | ············pm.Save(); |
10681 | ············pm.UnloadCache(); |
10682 | ············var m = pm.Objects<AgrBi1nNoTblGuidRight>().ResultTable; |
10683 | ············pm.Delete(m); |
10684 | ············pm.Save(); |
10685 | ············pm.UnloadCache(); |
10686 | ············decimal count; |
10687 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10688 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10689 | ············count = (decimal) new NDOQuery<AgrBi1nNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10690 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10691 | ········} |
10692 | ········catch (Exception) |
10693 | ········{ |
10694 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10695 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10696 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10697 | ········} |
10698 | ····} |
10699 | ····[Test] |
10700 | ····public void TestSaveReload() |
10701 | ····{ |
10702 | ········CreateObjects(); |
10703 | ········QueryOwn(); |
10704 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10705 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10706 | ····} |
10707 | ····[Test] |
10708 | ····public void TestSaveReloadNull() |
10709 | ····{ |
10710 | ········CreateObjects(); |
10711 | ········QueryOwn(); |
10712 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10713 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10714 | ········ownVar.RelField = null; |
10715 | ········pm.Save(); |
10716 | ········pm.UnloadCache(); |
10717 | ········QueryOwn(); |
10718 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10719 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10720 | ····} |
10721 | ····[Test] |
10722 | ····public void TestChangeKeyHolderLeft() |
10723 | ····{ |
10724 | ········CreateObjects(); |
10725 | ········QueryOwn(); |
10726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10727 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10728 | ········int x = ownVar.RelField.Dummy; |
10729 | ········ownVar.Dummy = 4711; |
10730 | ········pm.Save(); |
10731 | ········pm.UnloadCache(); |
10732 | ········QueryOwn(); |
10733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10734 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10735 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10736 | ····} |
10737 | ····[Test] |
10738 | ····public void TestChangeKeyHolderLeftNoTouch() |
10739 | ····{ |
10740 | ········CreateObjects(); |
10741 | ········QueryOwn(); |
10742 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10744 | ········ownVar.Dummy = 4711; |
10745 | ········pm.Save(); |
10746 | ········pm.UnloadCache(); |
10747 | ········QueryOwn(); |
10748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10749 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10750 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10751 | ····} |
10752 | ····[Test] |
10753 | ····public void TestRelationHash() |
10754 | ····{ |
10755 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblGuidLeft)); |
10756 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10757 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nNoTblGuidRight)); |
10758 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10759 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10760 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10761 | ····} |
10762 | ····void CreateObjects() |
10763 | ····{ |
10764 | ········pm.MakePersistent(ownVar); |
10765 | ········pm.MakePersistent(otherVar); |
10766 | ········ownVar.AssignRelation(otherVar); |
10767 | ········pm.Save(); |
10768 | ········pm.UnloadCache(); |
10769 | ····} |
10770 | ····void QueryOwn() |
10771 | ····{ |
10772 | ········var q = new NDOQuery<AgrBi1nNoTblGuidLeft>(pm); |
10773 | ········ownVar = q.ExecuteSingle(); |
10774 | ····} |
10775 | ····void QueryOther() |
10776 | ····{ |
10777 | ········var q = new NDOQuery<AgrBi1nNoTblGuidRight>(pm); |
10778 | ········otherVar = q.ExecuteSingle(); |
10779 | ····} |
10780 | } |
10781 | |
10782 | |
10783 | [TestFixture] |
10784 | public class TestAgrBi1nTblGuid : NDOTest |
10785 | { |
10786 | ····AgrBi1nTblGuidLeft ownVar; |
10787 | ····AgrBi1nTblGuidRight otherVar; |
10788 | ····PersistenceManager pm; |
10789 | ····[SetUp] |
10790 | ····public void Setup() |
10791 | ····{ |
10792 | ········pm = PmFactory.NewPersistenceManager(); |
10793 | ········ownVar = new AgrBi1nTblGuidLeft(); |
10794 | ········otherVar = new AgrBi1nTblGuidRight(); |
10795 | ····} |
10796 | ····[TearDown] |
10797 | ····public void TearDown() |
10798 | ····{ |
10799 | ········try |
10800 | ········{ |
10801 | ············pm.UnloadCache(); |
10802 | ············var l = pm.Objects<AgrBi1nTblGuidLeft>().ResultTable; |
10803 | ············pm.Delete(l); |
10804 | ············pm.Save(); |
10805 | ············pm.UnloadCache(); |
10806 | ············var m = pm.Objects<AgrBi1nTblGuidRight>().ResultTable; |
10807 | ············pm.Delete(m); |
10808 | ············pm.Save(); |
10809 | ············pm.UnloadCache(); |
10810 | ············decimal count; |
10811 | ············count = (decimal) new NDOQuery<AgrBi1nTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10812 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10813 | ············count = (decimal) new NDOQuery<AgrBi1nTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10814 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10815 | ········} |
10816 | ········catch (Exception) |
10817 | ········{ |
10818 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10819 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10820 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10821 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10822 | ········} |
10823 | ····} |
10824 | ····[Test] |
10825 | ····public void TestSaveReload() |
10826 | ····{ |
10827 | ········CreateObjects(); |
10828 | ········QueryOwn(); |
10829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10830 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10831 | ····} |
10832 | ····[Test] |
10833 | ····public void TestSaveReloadNull() |
10834 | ····{ |
10835 | ········CreateObjects(); |
10836 | ········QueryOwn(); |
10837 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10838 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10839 | ········ownVar.RelField = null; |
10840 | ········pm.Save(); |
10841 | ········pm.UnloadCache(); |
10842 | ········QueryOwn(); |
10843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10844 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
10845 | ····} |
10846 | ····[Test] |
10847 | ····public void TestChangeKeyHolderLeft() |
10848 | ····{ |
10849 | ········CreateObjects(); |
10850 | ········QueryOwn(); |
10851 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10852 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10853 | ········int x = ownVar.RelField.Dummy; |
10854 | ········ownVar.Dummy = 4711; |
10855 | ········pm.Save(); |
10856 | ········pm.UnloadCache(); |
10857 | ········QueryOwn(); |
10858 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10859 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10861 | ····} |
10862 | ····[Test] |
10863 | ····public void TestChangeKeyHolderLeftNoTouch() |
10864 | ····{ |
10865 | ········CreateObjects(); |
10866 | ········QueryOwn(); |
10867 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10868 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10869 | ········ownVar.Dummy = 4711; |
10870 | ········pm.Save(); |
10871 | ········pm.UnloadCache(); |
10872 | ········QueryOwn(); |
10873 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10874 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
10875 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
10876 | ····} |
10877 | ····[Test] |
10878 | ····public void TestRelationHash() |
10879 | ····{ |
10880 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nTblGuidLeft)); |
10881 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10882 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nTblGuidRight)); |
10883 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10884 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10885 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10886 | ····} |
10887 | ····void CreateObjects() |
10888 | ····{ |
10889 | ········pm.MakePersistent(ownVar); |
10890 | ········pm.MakePersistent(otherVar); |
10891 | ········ownVar.AssignRelation(otherVar); |
10892 | ········pm.Save(); |
10893 | ········pm.UnloadCache(); |
10894 | ····} |
10895 | ····void QueryOwn() |
10896 | ····{ |
10897 | ········var q = new NDOQuery<AgrBi1nTblGuidLeft>(pm); |
10898 | ········ownVar = q.ExecuteSingle(); |
10899 | ····} |
10900 | ····void QueryOther() |
10901 | ····{ |
10902 | ········var q = new NDOQuery<AgrBi1nTblGuidRight>(pm); |
10903 | ········otherVar = q.ExecuteSingle(); |
10904 | ····} |
10905 | } |
10906 | |
10907 | |
10908 | [TestFixture] |
10909 | public class TestAgrBinnTblGuid : NDOTest |
10910 | { |
10911 | ····AgrBinnTblGuidLeft ownVar; |
10912 | ····AgrBinnTblGuidRight otherVar; |
10913 | ····PersistenceManager pm; |
10914 | ····[SetUp] |
10915 | ····public void Setup() |
10916 | ····{ |
10917 | ········pm = PmFactory.NewPersistenceManager(); |
10918 | ········ownVar = new AgrBinnTblGuidLeft(); |
10919 | ········otherVar = new AgrBinnTblGuidRight(); |
10920 | ····} |
10921 | ····[TearDown] |
10922 | ····public void TearDown() |
10923 | ····{ |
10924 | ········try |
10925 | ········{ |
10926 | ············pm.UnloadCache(); |
10927 | ············var l = pm.Objects<AgrBinnTblGuidLeft>().ResultTable; |
10928 | ············pm.Delete(l); |
10929 | ············pm.Save(); |
10930 | ············pm.UnloadCache(); |
10931 | ············var m = pm.Objects<AgrBinnTblGuidRight>().ResultTable; |
10932 | ············pm.Delete(m); |
10933 | ············pm.Save(); |
10934 | ············pm.UnloadCache(); |
10935 | ············decimal count; |
10936 | ············count = (decimal) new NDOQuery<AgrBinnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10937 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
10938 | ············count = (decimal) new NDOQuery<AgrBinnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
10939 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
10940 | ········} |
10941 | ········catch (Exception) |
10942 | ········{ |
10943 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
10944 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
10945 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
10946 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
10947 | ········} |
10948 | ····} |
10949 | ····[Test] |
10950 | ····public void TestSaveReload() |
10951 | ····{ |
10952 | ········CreateObjects(); |
10953 | ········QueryOwn(); |
10954 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10955 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10956 | ····} |
10957 | ····[Test] |
10958 | ····public void TestSaveReloadNull() |
10959 | ····{ |
10960 | ········CreateObjects(); |
10961 | ········QueryOwn(); |
10962 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10963 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10964 | ········ownVar.RelField = new List<AgrBinnTblGuidRight>(); |
10965 | ········pm.Save(); |
10966 | ········pm.UnloadCache(); |
10967 | ········QueryOwn(); |
10968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10969 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10970 | ····} |
10971 | ····[Test] |
10972 | ····public void TestSaveReloadRemove() |
10973 | ····{ |
10974 | ········CreateObjects(); |
10975 | ········QueryOwn(); |
10976 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10977 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10978 | ········ownVar.RemoveRelatedObject(); |
10979 | ········pm.Save(); |
10980 | ········pm.UnloadCache(); |
10981 | ········QueryOwn(); |
10982 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
10983 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
10984 | ····} |
10985 | ····[Test] |
10986 | ····public void TestRelationHash() |
10987 | ····{ |
10988 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnTblGuidLeft)); |
10989 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
10990 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnTblGuidRight)); |
10991 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
10992 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
10993 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
10994 | ····} |
10995 | ····void CreateObjects() |
10996 | ····{ |
10997 | ········pm.MakePersistent(ownVar); |
10998 | ········pm.MakePersistent(otherVar); |
10999 | ········ownVar.AssignRelation(otherVar); |
11000 | ········pm.Save(); |
11001 | ········pm.UnloadCache(); |
11002 | ····} |
11003 | ····void QueryOwn() |
11004 | ····{ |
11005 | ········var q = new NDOQuery<AgrBinnTblGuidLeft>(pm); |
11006 | ········ownVar = q.ExecuteSingle(); |
11007 | ····} |
11008 | ····void QueryOther() |
11009 | ····{ |
11010 | ········var q = new NDOQuery<AgrBinnTblGuidRight>(pm); |
11011 | ········otherVar = q.ExecuteSingle(); |
11012 | ····} |
11013 | } |
11014 | |
11015 | |
11016 | [TestFixture] |
11017 | public class TestCmpDir1NoTblGuid : NDOTest |
11018 | { |
11019 | ····CmpDir1NoTblGuidLeft ownVar; |
11020 | ····CmpDir1NoTblGuidRight otherVar; |
11021 | ····PersistenceManager pm; |
11022 | ····[SetUp] |
11023 | ····public void Setup() |
11024 | ····{ |
11025 | ········pm = PmFactory.NewPersistenceManager(); |
11026 | ········ownVar = new CmpDir1NoTblGuidLeft(); |
11027 | ········otherVar = new CmpDir1NoTblGuidRight(); |
11028 | ····} |
11029 | ····[TearDown] |
11030 | ····public void TearDown() |
11031 | ····{ |
11032 | ········try |
11033 | ········{ |
11034 | ············pm.UnloadCache(); |
11035 | ············var l = pm.Objects<CmpDir1NoTblGuidLeft>().ResultTable; |
11036 | ············pm.Delete(l); |
11037 | ············pm.Save(); |
11038 | ············pm.UnloadCache(); |
11039 | ············decimal count; |
11040 | ············count = (decimal) new NDOQuery<CmpDir1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11041 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11042 | ············count = (decimal) new NDOQuery<CmpDir1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11044 | ········} |
11045 | ········catch (Exception) |
11046 | ········{ |
11047 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11048 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11049 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11050 | ········} |
11051 | ····} |
11052 | ····[Test] |
11053 | ····public void TestSaveReload() |
11054 | ····{ |
11055 | ········CreateObjects(); |
11056 | ········QueryOwn(); |
11057 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11058 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11059 | ····} |
11060 | ····[Test] |
11061 | ····public void TestSaveReloadNull() |
11062 | ····{ |
11063 | ········CreateObjects(); |
11064 | ········QueryOwn(); |
11065 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11066 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11067 | ········ownVar.RelField = null; |
11068 | ········pm.Save(); |
11069 | ········pm.UnloadCache(); |
11070 | ········QueryOwn(); |
11071 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11072 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11073 | ····} |
11074 | ····[Test] |
11075 | ····public void TestChangeKeyHolderLeft() |
11076 | ····{ |
11077 | ········CreateObjects(); |
11078 | ········QueryOwn(); |
11079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11080 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11081 | ········int x = ownVar.RelField.Dummy; |
11082 | ········ownVar.Dummy = 4711; |
11083 | ········pm.Save(); |
11084 | ········pm.UnloadCache(); |
11085 | ········QueryOwn(); |
11086 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11087 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11088 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11089 | ····} |
11090 | ····[Test] |
11091 | ····public void TestChangeKeyHolderLeftNoTouch() |
11092 | ····{ |
11093 | ········CreateObjects(); |
11094 | ········QueryOwn(); |
11095 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11096 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11097 | ········ownVar.Dummy = 4711; |
11098 | ········pm.Save(); |
11099 | ········pm.UnloadCache(); |
11100 | ········QueryOwn(); |
11101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11102 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11103 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11104 | ····} |
11105 | ····void CreateObjects() |
11106 | ····{ |
11107 | ········pm.MakePersistent(ownVar); |
11108 | ········ownVar.AssignRelation(otherVar); |
11109 | ········pm.Save(); |
11110 | ········pm.UnloadCache(); |
11111 | ····} |
11112 | ····void QueryOwn() |
11113 | ····{ |
11114 | ········var q = new NDOQuery<CmpDir1NoTblGuidLeft>(pm); |
11115 | ········ownVar = q.ExecuteSingle(); |
11116 | ····} |
11117 | ····void QueryOther() |
11118 | ····{ |
11119 | ········var q = new NDOQuery<CmpDir1NoTblGuidRight>(pm); |
11120 | ········otherVar = q.ExecuteSingle(); |
11121 | ····} |
11122 | } |
11123 | |
11124 | |
11125 | [TestFixture] |
11126 | public class TestCmpDir1TblGuid : NDOTest |
11127 | { |
11128 | ····CmpDir1TblGuidLeft ownVar; |
11129 | ····CmpDir1TblGuidRight otherVar; |
11130 | ····PersistenceManager pm; |
11131 | ····[SetUp] |
11132 | ····public void Setup() |
11133 | ····{ |
11134 | ········pm = PmFactory.NewPersistenceManager(); |
11135 | ········ownVar = new CmpDir1TblGuidLeft(); |
11136 | ········otherVar = new CmpDir1TblGuidRight(); |
11137 | ····} |
11138 | ····[TearDown] |
11139 | ····public void TearDown() |
11140 | ····{ |
11141 | ········try |
11142 | ········{ |
11143 | ············pm.UnloadCache(); |
11144 | ············var l = pm.Objects<CmpDir1TblGuidLeft>().ResultTable; |
11145 | ············pm.Delete(l); |
11146 | ············pm.Save(); |
11147 | ············pm.UnloadCache(); |
11148 | ············decimal count; |
11149 | ············count = (decimal) new NDOQuery<CmpDir1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11150 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11151 | ············count = (decimal) new NDOQuery<CmpDir1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11152 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11153 | ········} |
11154 | ········catch (Exception) |
11155 | ········{ |
11156 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11158 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11159 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11160 | ········} |
11161 | ····} |
11162 | ····[Test] |
11163 | ····public void TestSaveReload() |
11164 | ····{ |
11165 | ········CreateObjects(); |
11166 | ········QueryOwn(); |
11167 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11168 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11169 | ····} |
11170 | ····[Test] |
11171 | ····public void TestSaveReloadNull() |
11172 | ····{ |
11173 | ········CreateObjects(); |
11174 | ········QueryOwn(); |
11175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11176 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11177 | ········ownVar.RelField = null; |
11178 | ········pm.Save(); |
11179 | ········pm.UnloadCache(); |
11180 | ········QueryOwn(); |
11181 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11182 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11183 | ····} |
11184 | ····[Test] |
11185 | ····public void TestChangeKeyHolderLeft() |
11186 | ····{ |
11187 | ········CreateObjects(); |
11188 | ········QueryOwn(); |
11189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11190 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11191 | ········int x = ownVar.RelField.Dummy; |
11192 | ········ownVar.Dummy = 4711; |
11193 | ········pm.Save(); |
11194 | ········pm.UnloadCache(); |
11195 | ········QueryOwn(); |
11196 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11197 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11198 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11199 | ····} |
11200 | ····[Test] |
11201 | ····public void TestChangeKeyHolderLeftNoTouch() |
11202 | ····{ |
11203 | ········CreateObjects(); |
11204 | ········QueryOwn(); |
11205 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11207 | ········ownVar.Dummy = 4711; |
11208 | ········pm.Save(); |
11209 | ········pm.UnloadCache(); |
11210 | ········QueryOwn(); |
11211 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11212 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11213 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11214 | ····} |
11215 | ····void CreateObjects() |
11216 | ····{ |
11217 | ········pm.MakePersistent(ownVar); |
11218 | ········ownVar.AssignRelation(otherVar); |
11219 | ········pm.Save(); |
11220 | ········pm.UnloadCache(); |
11221 | ····} |
11222 | ····void QueryOwn() |
11223 | ····{ |
11224 | ········var q = new NDOQuery<CmpDir1TblGuidLeft>(pm); |
11225 | ········ownVar = q.ExecuteSingle(); |
11226 | ····} |
11227 | ····void QueryOther() |
11228 | ····{ |
11229 | ········var q = new NDOQuery<CmpDir1TblGuidRight>(pm); |
11230 | ········otherVar = q.ExecuteSingle(); |
11231 | ····} |
11232 | } |
11233 | |
11234 | |
11235 | [TestFixture] |
11236 | public class TestCmpBi11NoTblGuid : NDOTest |
11237 | { |
11238 | ····CmpBi11NoTblGuidLeft ownVar; |
11239 | ····CmpBi11NoTblGuidRight otherVar; |
11240 | ····PersistenceManager pm; |
11241 | ····[SetUp] |
11242 | ····public void Setup() |
11243 | ····{ |
11244 | ········pm = PmFactory.NewPersistenceManager(); |
11245 | ········ownVar = new CmpBi11NoTblGuidLeft(); |
11246 | ········otherVar = new CmpBi11NoTblGuidRight(); |
11247 | ····} |
11248 | ····[TearDown] |
11249 | ····public void TearDown() |
11250 | ····{ |
11251 | ········try |
11252 | ········{ |
11253 | ············pm.UnloadCache(); |
11254 | ············var l = pm.Objects<CmpBi11NoTblGuidLeft>().ResultTable; |
11255 | ············pm.Delete(l); |
11256 | ············pm.Save(); |
11257 | ············pm.UnloadCache(); |
11258 | ············decimal count; |
11259 | ············count = (decimal) new NDOQuery<CmpBi11NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11260 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11261 | ············count = (decimal) new NDOQuery<CmpBi11NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11262 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11263 | ········} |
11264 | ········catch (Exception) |
11265 | ········{ |
11266 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11267 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11268 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11269 | ········} |
11270 | ····} |
11271 | ····[Test] |
11272 | ····public void TestSaveReload() |
11273 | ····{ |
11274 | ········CreateObjects(); |
11275 | ········QueryOwn(); |
11276 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11277 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11278 | ····} |
11279 | ····[Test] |
11280 | ····public void TestSaveReloadNull() |
11281 | ····{ |
11282 | ········CreateObjects(); |
11283 | ········QueryOwn(); |
11284 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11285 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11286 | ········ownVar.RelField = null; |
11287 | ········pm.Save(); |
11288 | ········pm.UnloadCache(); |
11289 | ········QueryOwn(); |
11290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11291 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11292 | ····} |
11293 | ····[Test] |
11294 | ····public void TestChangeKeyHolderLeft() |
11295 | ····{ |
11296 | ········CreateObjects(); |
11297 | ········QueryOwn(); |
11298 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11299 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11300 | ········int x = ownVar.RelField.Dummy; |
11301 | ········ownVar.Dummy = 4711; |
11302 | ········pm.Save(); |
11303 | ········pm.UnloadCache(); |
11304 | ········QueryOwn(); |
11305 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11306 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11307 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11308 | ····} |
11309 | ····[Test] |
11310 | ····public void TestChangeKeyHolderRight() |
11311 | ····{ |
11312 | ········CreateObjects(); |
11313 | ········QueryOther(); |
11314 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11315 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11316 | ········int x = otherVar.RelField.Dummy; |
11317 | ········otherVar.Dummy = 4711; |
11318 | ········pm.Save(); |
11319 | ········pm.UnloadCache(); |
11320 | ········QueryOther(); |
11321 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11322 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11323 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11324 | ····} |
11325 | ····[Test] |
11326 | ····public void TestChangeKeyHolderLeftNoTouch() |
11327 | ····{ |
11328 | ········CreateObjects(); |
11329 | ········QueryOwn(); |
11330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11332 | ········ownVar.Dummy = 4711; |
11333 | ········pm.Save(); |
11334 | ········pm.UnloadCache(); |
11335 | ········QueryOwn(); |
11336 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11337 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11338 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11339 | ····} |
11340 | ····[Test] |
11341 | ····public void TestChangeKeyHolderRightNoTouch() |
11342 | ····{ |
11343 | ········CreateObjects(); |
11344 | ········QueryOther(); |
11345 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11346 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11347 | ········otherVar.Dummy = 4711; |
11348 | ········pm.Save(); |
11349 | ········pm.UnloadCache(); |
11350 | ········QueryOther(); |
11351 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11352 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11353 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11354 | ····} |
11355 | ····[Test] |
11356 | ····public void TestRelationHash() |
11357 | ····{ |
11358 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblGuidLeft)); |
11359 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11360 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11NoTblGuidRight)); |
11361 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11362 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11363 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11364 | ····} |
11365 | ····void CreateObjects() |
11366 | ····{ |
11367 | ········pm.MakePersistent(ownVar); |
11368 | ········ownVar.AssignRelation(otherVar); |
11369 | ········pm.Save(); |
11370 | ········pm.UnloadCache(); |
11371 | ····} |
11372 | ····void QueryOwn() |
11373 | ····{ |
11374 | ········var q = new NDOQuery<CmpBi11NoTblGuidLeft>(pm); |
11375 | ········ownVar = q.ExecuteSingle(); |
11376 | ····} |
11377 | ····void QueryOther() |
11378 | ····{ |
11379 | ········var q = new NDOQuery<CmpBi11NoTblGuidRight>(pm); |
11380 | ········otherVar = q.ExecuteSingle(); |
11381 | ····} |
11382 | } |
11383 | |
11384 | |
11385 | [TestFixture] |
11386 | public class TestCmpBi11TblGuid : NDOTest |
11387 | { |
11388 | ····CmpBi11TblGuidLeft ownVar; |
11389 | ····CmpBi11TblGuidRight otherVar; |
11390 | ····PersistenceManager pm; |
11391 | ····[SetUp] |
11392 | ····public void Setup() |
11393 | ····{ |
11394 | ········pm = PmFactory.NewPersistenceManager(); |
11395 | ········ownVar = new CmpBi11TblGuidLeft(); |
11396 | ········otherVar = new CmpBi11TblGuidRight(); |
11397 | ····} |
11398 | ····[TearDown] |
11399 | ····public void TearDown() |
11400 | ····{ |
11401 | ········try |
11402 | ········{ |
11403 | ············pm.UnloadCache(); |
11404 | ············var l = pm.Objects<CmpBi11TblGuidLeft>().ResultTable; |
11405 | ············pm.Delete(l); |
11406 | ············pm.Save(); |
11407 | ············pm.UnloadCache(); |
11408 | ············decimal count; |
11409 | ············count = (decimal) new NDOQuery<CmpBi11TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11410 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11411 | ············count = (decimal) new NDOQuery<CmpBi11TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11412 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11413 | ········} |
11414 | ········catch (Exception) |
11415 | ········{ |
11416 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11417 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11418 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11419 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11420 | ········} |
11421 | ····} |
11422 | ····[Test] |
11423 | ····public void TestSaveReload() |
11424 | ····{ |
11425 | ········CreateObjects(); |
11426 | ········QueryOwn(); |
11427 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11428 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11429 | ····} |
11430 | ····[Test] |
11431 | ····public void TestSaveReloadNull() |
11432 | ····{ |
11433 | ········CreateObjects(); |
11434 | ········QueryOwn(); |
11435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11436 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11437 | ········ownVar.RelField = null; |
11438 | ········pm.Save(); |
11439 | ········pm.UnloadCache(); |
11440 | ········QueryOwn(); |
11441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11442 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
11443 | ····} |
11444 | ····[Test] |
11445 | ····public void TestChangeKeyHolderLeft() |
11446 | ····{ |
11447 | ········CreateObjects(); |
11448 | ········QueryOwn(); |
11449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11450 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11451 | ········int x = ownVar.RelField.Dummy; |
11452 | ········ownVar.Dummy = 4711; |
11453 | ········pm.Save(); |
11454 | ········pm.UnloadCache(); |
11455 | ········QueryOwn(); |
11456 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11457 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11458 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11459 | ····} |
11460 | ····[Test] |
11461 | ····public void TestChangeKeyHolderRight() |
11462 | ····{ |
11463 | ········CreateObjects(); |
11464 | ········QueryOther(); |
11465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11466 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11467 | ········int x = otherVar.RelField.Dummy; |
11468 | ········otherVar.Dummy = 4711; |
11469 | ········pm.Save(); |
11470 | ········pm.UnloadCache(); |
11471 | ········QueryOther(); |
11472 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11473 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11474 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11475 | ····} |
11476 | ····[Test] |
11477 | ····public void TestChangeKeyHolderLeftNoTouch() |
11478 | ····{ |
11479 | ········CreateObjects(); |
11480 | ········QueryOwn(); |
11481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11482 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11483 | ········ownVar.Dummy = 4711; |
11484 | ········pm.Save(); |
11485 | ········pm.UnloadCache(); |
11486 | ········QueryOwn(); |
11487 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11488 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11489 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
11490 | ····} |
11491 | ····[Test] |
11492 | ····public void TestChangeKeyHolderRightNoTouch() |
11493 | ····{ |
11494 | ········CreateObjects(); |
11495 | ········QueryOther(); |
11496 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11497 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11498 | ········otherVar.Dummy = 4711; |
11499 | ········pm.Save(); |
11500 | ········pm.UnloadCache(); |
11501 | ········QueryOther(); |
11502 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11503 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11504 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11505 | ····} |
11506 | ····[Test] |
11507 | ····public void TestRelationHash() |
11508 | ····{ |
11509 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11TblGuidLeft)); |
11510 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11511 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11TblGuidRight)); |
11512 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11513 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11514 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11515 | ····} |
11516 | ····void CreateObjects() |
11517 | ····{ |
11518 | ········pm.MakePersistent(ownVar); |
11519 | ········ownVar.AssignRelation(otherVar); |
11520 | ········pm.Save(); |
11521 | ········pm.UnloadCache(); |
11522 | ····} |
11523 | ····void QueryOwn() |
11524 | ····{ |
11525 | ········var q = new NDOQuery<CmpBi11TblGuidLeft>(pm); |
11526 | ········ownVar = q.ExecuteSingle(); |
11527 | ····} |
11528 | ····void QueryOther() |
11529 | ····{ |
11530 | ········var q = new NDOQuery<CmpBi11TblGuidRight>(pm); |
11531 | ········otherVar = q.ExecuteSingle(); |
11532 | ····} |
11533 | } |
11534 | |
11535 | |
11536 | [TestFixture] |
11537 | public class TestCmpDirnNoTblGuid : NDOTest |
11538 | { |
11539 | ····CmpDirnNoTblGuidLeft ownVar; |
11540 | ····CmpDirnNoTblGuidRight otherVar; |
11541 | ····PersistenceManager pm; |
11542 | ····[SetUp] |
11543 | ····public void Setup() |
11544 | ····{ |
11545 | ········pm = PmFactory.NewPersistenceManager(); |
11546 | ········ownVar = new CmpDirnNoTblGuidLeft(); |
11547 | ········otherVar = new CmpDirnNoTblGuidRight(); |
11548 | ····} |
11549 | ····[TearDown] |
11550 | ····public void TearDown() |
11551 | ····{ |
11552 | ········try |
11553 | ········{ |
11554 | ············pm.UnloadCache(); |
11555 | ············var l = pm.Objects<CmpDirnNoTblGuidLeft>().ResultTable; |
11556 | ············pm.Delete(l); |
11557 | ············pm.Save(); |
11558 | ············pm.UnloadCache(); |
11559 | ············decimal count; |
11560 | ············count = (decimal) new NDOQuery<CmpDirnNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11561 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11562 | ············count = (decimal) new NDOQuery<CmpDirnNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11563 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11564 | ········} |
11565 | ········catch (Exception) |
11566 | ········{ |
11567 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11568 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11569 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11570 | ········} |
11571 | ····} |
11572 | ····[Test] |
11573 | ····public void TestSaveReload() |
11574 | ····{ |
11575 | ········CreateObjects(); |
11576 | ········QueryOwn(); |
11577 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11578 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11579 | ····} |
11580 | ····[Test] |
11581 | ····public void TestSaveReloadNull() |
11582 | ····{ |
11583 | ········CreateObjects(); |
11584 | ········QueryOwn(); |
11585 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11586 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11587 | ········ownVar.RelField = new List<CmpDirnNoTblGuidRight>(); |
11588 | ········pm.Save(); |
11589 | ········pm.UnloadCache(); |
11590 | ········QueryOwn(); |
11591 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11592 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11593 | ····} |
11594 | ····[Test] |
11595 | ····public void TestSaveReloadRemove() |
11596 | ····{ |
11597 | ········CreateObjects(); |
11598 | ········QueryOwn(); |
11599 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11600 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11601 | ········ownVar.RemoveRelatedObject(); |
11602 | ········pm.Save(); |
11603 | ········pm.UnloadCache(); |
11604 | ········QueryOwn(); |
11605 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11606 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11607 | ····} |
11608 | ····void CreateObjects() |
11609 | ····{ |
11610 | ········pm.MakePersistent(ownVar); |
11611 | ········ownVar.AssignRelation(otherVar); |
11612 | ········pm.Save(); |
11613 | ········pm.UnloadCache(); |
11614 | ····} |
11615 | ····void QueryOwn() |
11616 | ····{ |
11617 | ········var q = new NDOQuery<CmpDirnNoTblGuidLeft>(pm); |
11618 | ········ownVar = q.ExecuteSingle(); |
11619 | ····} |
11620 | ····void QueryOther() |
11621 | ····{ |
11622 | ········var q = new NDOQuery<CmpDirnNoTblGuidRight>(pm); |
11623 | ········otherVar = q.ExecuteSingle(); |
11624 | ····} |
11625 | } |
11626 | |
11627 | |
11628 | [TestFixture] |
11629 | public class TestCmpDirnTblGuid : NDOTest |
11630 | { |
11631 | ····CmpDirnTblGuidLeft ownVar; |
11632 | ····CmpDirnTblGuidRight otherVar; |
11633 | ····PersistenceManager pm; |
11634 | ····[SetUp] |
11635 | ····public void Setup() |
11636 | ····{ |
11637 | ········pm = PmFactory.NewPersistenceManager(); |
11638 | ········ownVar = new CmpDirnTblGuidLeft(); |
11639 | ········otherVar = new CmpDirnTblGuidRight(); |
11640 | ····} |
11641 | ····[TearDown] |
11642 | ····public void TearDown() |
11643 | ····{ |
11644 | ········try |
11645 | ········{ |
11646 | ············pm.UnloadCache(); |
11647 | ············var l = pm.Objects<CmpDirnTblGuidLeft>().ResultTable; |
11648 | ············pm.Delete(l); |
11649 | ············pm.Save(); |
11650 | ············pm.UnloadCache(); |
11651 | ············decimal count; |
11652 | ············count = (decimal) new NDOQuery<CmpDirnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11653 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11654 | ············count = (decimal) new NDOQuery<CmpDirnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11655 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11656 | ········} |
11657 | ········catch (Exception) |
11658 | ········{ |
11659 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11660 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11661 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11662 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11663 | ········} |
11664 | ····} |
11665 | ····[Test] |
11666 | ····public void TestSaveReload() |
11667 | ····{ |
11668 | ········CreateObjects(); |
11669 | ········QueryOwn(); |
11670 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11671 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11672 | ····} |
11673 | ····[Test] |
11674 | ····public void TestSaveReloadNull() |
11675 | ····{ |
11676 | ········CreateObjects(); |
11677 | ········QueryOwn(); |
11678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11679 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11680 | ········ownVar.RelField = new List<CmpDirnTblGuidRight>(); |
11681 | ········pm.Save(); |
11682 | ········pm.UnloadCache(); |
11683 | ········QueryOwn(); |
11684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11685 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11686 | ····} |
11687 | ····[Test] |
11688 | ····public void TestSaveReloadRemove() |
11689 | ····{ |
11690 | ········CreateObjects(); |
11691 | ········QueryOwn(); |
11692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11693 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11694 | ········ownVar.RemoveRelatedObject(); |
11695 | ········pm.Save(); |
11696 | ········pm.UnloadCache(); |
11697 | ········QueryOwn(); |
11698 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11699 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11700 | ····} |
11701 | ····void CreateObjects() |
11702 | ····{ |
11703 | ········pm.MakePersistent(ownVar); |
11704 | ········ownVar.AssignRelation(otherVar); |
11705 | ········pm.Save(); |
11706 | ········pm.UnloadCache(); |
11707 | ····} |
11708 | ····void QueryOwn() |
11709 | ····{ |
11710 | ········var q = new NDOQuery<CmpDirnTblGuidLeft>(pm); |
11711 | ········ownVar = q.ExecuteSingle(); |
11712 | ····} |
11713 | ····void QueryOther() |
11714 | ····{ |
11715 | ········var q = new NDOQuery<CmpDirnTblGuidRight>(pm); |
11716 | ········otherVar = q.ExecuteSingle(); |
11717 | ····} |
11718 | } |
11719 | |
11720 | |
11721 | [TestFixture] |
11722 | public class TestCmpBin1NoTblGuid : NDOTest |
11723 | { |
11724 | ····CmpBin1NoTblGuidLeft ownVar; |
11725 | ····CmpBin1NoTblGuidRight otherVar; |
11726 | ····PersistenceManager pm; |
11727 | ····[SetUp] |
11728 | ····public void Setup() |
11729 | ····{ |
11730 | ········pm = PmFactory.NewPersistenceManager(); |
11731 | ········ownVar = new CmpBin1NoTblGuidLeft(); |
11732 | ········otherVar = new CmpBin1NoTblGuidRight(); |
11733 | ····} |
11734 | ····[TearDown] |
11735 | ····public void TearDown() |
11736 | ····{ |
11737 | ········try |
11738 | ········{ |
11739 | ············pm.UnloadCache(); |
11740 | ············var l = pm.Objects<CmpBin1NoTblGuidLeft>().ResultTable; |
11741 | ············pm.Delete(l); |
11742 | ············pm.Save(); |
11743 | ············pm.UnloadCache(); |
11744 | ············decimal count; |
11745 | ············count = (decimal) new NDOQuery<CmpBin1NoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11746 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11747 | ············count = (decimal) new NDOQuery<CmpBin1NoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11748 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11749 | ········} |
11750 | ········catch (Exception) |
11751 | ········{ |
11752 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11753 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11755 | ········} |
11756 | ····} |
11757 | ····[Test] |
11758 | ····public void TestSaveReload() |
11759 | ····{ |
11760 | ········CreateObjects(); |
11761 | ········QueryOwn(); |
11762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11763 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11764 | ····} |
11765 | ····[Test] |
11766 | ····public void TestSaveReloadNull() |
11767 | ····{ |
11768 | ········CreateObjects(); |
11769 | ········QueryOwn(); |
11770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11771 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11772 | ········ownVar.RelField = new List<CmpBin1NoTblGuidRight>(); |
11773 | ········pm.Save(); |
11774 | ········pm.UnloadCache(); |
11775 | ········QueryOwn(); |
11776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11777 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11778 | ····} |
11779 | ····[Test] |
11780 | ····public void TestSaveReloadRemove() |
11781 | ····{ |
11782 | ········CreateObjects(); |
11783 | ········QueryOwn(); |
11784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11785 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11786 | ········ownVar.RemoveRelatedObject(); |
11787 | ········pm.Save(); |
11788 | ········pm.UnloadCache(); |
11789 | ········QueryOwn(); |
11790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11791 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11792 | ····} |
11793 | ····[Test] |
11794 | ····public void TestChangeKeyHolderRight() |
11795 | ····{ |
11796 | ········CreateObjects(); |
11797 | ········QueryOther(); |
11798 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11799 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11800 | ········int x = otherVar.RelField.Dummy; |
11801 | ········otherVar.Dummy = 4711; |
11802 | ········pm.Save(); |
11803 | ········pm.UnloadCache(); |
11804 | ········QueryOther(); |
11805 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11806 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11807 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11808 | ····} |
11809 | ····[Test] |
11810 | ····public void TestChangeKeyHolderRightNoTouch() |
11811 | ····{ |
11812 | ········CreateObjects(); |
11813 | ········QueryOther(); |
11814 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11815 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11816 | ········otherVar.Dummy = 4711; |
11817 | ········pm.Save(); |
11818 | ········pm.UnloadCache(); |
11819 | ········QueryOther(); |
11820 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11821 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11822 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11823 | ····} |
11824 | ····[Test] |
11825 | ····public void TestRelationHash() |
11826 | ····{ |
11827 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblGuidLeft)); |
11828 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11829 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1NoTblGuidRight)); |
11830 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11831 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11832 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11833 | ····} |
11834 | ····void CreateObjects() |
11835 | ····{ |
11836 | ········pm.MakePersistent(ownVar); |
11837 | ········ownVar.AssignRelation(otherVar); |
11838 | ········pm.Save(); |
11839 | ········pm.UnloadCache(); |
11840 | ····} |
11841 | ····void QueryOwn() |
11842 | ····{ |
11843 | ········var q = new NDOQuery<CmpBin1NoTblGuidLeft>(pm); |
11844 | ········ownVar = q.ExecuteSingle(); |
11845 | ····} |
11846 | ····void QueryOther() |
11847 | ····{ |
11848 | ········var q = new NDOQuery<CmpBin1NoTblGuidRight>(pm); |
11849 | ········otherVar = q.ExecuteSingle(); |
11850 | ····} |
11851 | } |
11852 | |
11853 | |
11854 | [TestFixture] |
11855 | public class TestCmpBin1TblGuid : NDOTest |
11856 | { |
11857 | ····CmpBin1TblGuidLeft ownVar; |
11858 | ····CmpBin1TblGuidRight otherVar; |
11859 | ····PersistenceManager pm; |
11860 | ····[SetUp] |
11861 | ····public void Setup() |
11862 | ····{ |
11863 | ········pm = PmFactory.NewPersistenceManager(); |
11864 | ········ownVar = new CmpBin1TblGuidLeft(); |
11865 | ········otherVar = new CmpBin1TblGuidRight(); |
11866 | ····} |
11867 | ····[TearDown] |
11868 | ····public void TearDown() |
11869 | ····{ |
11870 | ········try |
11871 | ········{ |
11872 | ············pm.UnloadCache(); |
11873 | ············var l = pm.Objects<CmpBin1TblGuidLeft>().ResultTable; |
11874 | ············pm.Delete(l); |
11875 | ············pm.Save(); |
11876 | ············pm.UnloadCache(); |
11877 | ············decimal count; |
11878 | ············count = (decimal) new NDOQuery<CmpBin1TblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11879 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
11880 | ············count = (decimal) new NDOQuery<CmpBin1TblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
11881 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
11882 | ········} |
11883 | ········catch (Exception) |
11884 | ········{ |
11885 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
11886 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
11887 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
11888 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
11889 | ········} |
11890 | ····} |
11891 | ····[Test] |
11892 | ····public void TestSaveReload() |
11893 | ····{ |
11894 | ········CreateObjects(); |
11895 | ········QueryOwn(); |
11896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11897 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11898 | ····} |
11899 | ····[Test] |
11900 | ····public void TestSaveReloadNull() |
11901 | ····{ |
11902 | ········CreateObjects(); |
11903 | ········QueryOwn(); |
11904 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11905 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11906 | ········ownVar.RelField = new List<CmpBin1TblGuidRight>(); |
11907 | ········pm.Save(); |
11908 | ········pm.UnloadCache(); |
11909 | ········QueryOwn(); |
11910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11911 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11912 | ····} |
11913 | ····[Test] |
11914 | ····public void TestSaveReloadRemove() |
11915 | ····{ |
11916 | ········CreateObjects(); |
11917 | ········QueryOwn(); |
11918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11920 | ········ownVar.RemoveRelatedObject(); |
11921 | ········pm.Save(); |
11922 | ········pm.UnloadCache(); |
11923 | ········QueryOwn(); |
11924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
11925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
11926 | ····} |
11927 | ····[Test] |
11928 | ····public void TestChangeKeyHolderRight() |
11929 | ····{ |
11930 | ········CreateObjects(); |
11931 | ········QueryOther(); |
11932 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11933 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11934 | ········int x = otherVar.RelField.Dummy; |
11935 | ········otherVar.Dummy = 4711; |
11936 | ········pm.Save(); |
11937 | ········pm.UnloadCache(); |
11938 | ········QueryOther(); |
11939 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11940 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11941 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11942 | ····} |
11943 | ····[Test] |
11944 | ····public void TestChangeKeyHolderRightNoTouch() |
11945 | ····{ |
11946 | ········CreateObjects(); |
11947 | ········QueryOther(); |
11948 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11949 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11950 | ········otherVar.Dummy = 4711; |
11951 | ········pm.Save(); |
11952 | ········pm.UnloadCache(); |
11953 | ········QueryOther(); |
11954 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
11955 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
11956 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
11957 | ····} |
11958 | ····[Test] |
11959 | ····public void TestRelationHash() |
11960 | ····{ |
11961 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1TblGuidLeft)); |
11962 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
11963 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1TblGuidRight)); |
11964 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
11965 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
11966 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
11967 | ····} |
11968 | ····void CreateObjects() |
11969 | ····{ |
11970 | ········pm.MakePersistent(ownVar); |
11971 | ········ownVar.AssignRelation(otherVar); |
11972 | ········pm.Save(); |
11973 | ········pm.UnloadCache(); |
11974 | ····} |
11975 | ····void QueryOwn() |
11976 | ····{ |
11977 | ········var q = new NDOQuery<CmpBin1TblGuidLeft>(pm); |
11978 | ········ownVar = q.ExecuteSingle(); |
11979 | ····} |
11980 | ····void QueryOther() |
11981 | ····{ |
11982 | ········var q = new NDOQuery<CmpBin1TblGuidRight>(pm); |
11983 | ········otherVar = q.ExecuteSingle(); |
11984 | ····} |
11985 | } |
11986 | |
11987 | |
11988 | [TestFixture] |
11989 | public class TestCmpBi1nNoTblGuid : NDOTest |
11990 | { |
11991 | ····CmpBi1nNoTblGuidLeft ownVar; |
11992 | ····CmpBi1nNoTblGuidRight otherVar; |
11993 | ····PersistenceManager pm; |
11994 | ····[SetUp] |
11995 | ····public void Setup() |
11996 | ····{ |
11997 | ········pm = PmFactory.NewPersistenceManager(); |
11998 | ········ownVar = new CmpBi1nNoTblGuidLeft(); |
11999 | ········otherVar = new CmpBi1nNoTblGuidRight(); |
12000 | ····} |
12001 | ····[TearDown] |
12002 | ····public void TearDown() |
12003 | ····{ |
12004 | ········try |
12005 | ········{ |
12006 | ············pm.UnloadCache(); |
12007 | ············var l = pm.Objects<CmpBi1nNoTblGuidLeft>().ResultTable; |
12008 | ············pm.Delete(l); |
12009 | ············pm.Save(); |
12010 | ············pm.UnloadCache(); |
12011 | ············decimal count; |
12012 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12013 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12014 | ············count = (decimal) new NDOQuery<CmpBi1nNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12015 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12016 | ········} |
12017 | ········catch (Exception) |
12018 | ········{ |
12019 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12020 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12021 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12022 | ········} |
12023 | ····} |
12024 | ····[Test] |
12025 | ····public void TestSaveReload() |
12026 | ····{ |
12027 | ········CreateObjects(); |
12028 | ········QueryOwn(); |
12029 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12030 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12031 | ····} |
12032 | ····[Test] |
12033 | ····public void TestSaveReloadNull() |
12034 | ····{ |
12035 | ········CreateObjects(); |
12036 | ········QueryOwn(); |
12037 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12038 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12039 | ········ownVar.RelField = null; |
12040 | ········pm.Save(); |
12041 | ········pm.UnloadCache(); |
12042 | ········QueryOwn(); |
12043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12044 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12045 | ····} |
12046 | ····[Test] |
12047 | ····public void TestChangeKeyHolderLeft() |
12048 | ····{ |
12049 | ········CreateObjects(); |
12050 | ········QueryOwn(); |
12051 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12052 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12053 | ········int x = ownVar.RelField.Dummy; |
12054 | ········ownVar.Dummy = 4711; |
12055 | ········pm.Save(); |
12056 | ········pm.UnloadCache(); |
12057 | ········QueryOwn(); |
12058 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12059 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12060 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12061 | ····} |
12062 | ····[Test] |
12063 | ····public void TestChangeKeyHolderLeftNoTouch() |
12064 | ····{ |
12065 | ········CreateObjects(); |
12066 | ········QueryOwn(); |
12067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12068 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12069 | ········ownVar.Dummy = 4711; |
12070 | ········pm.Save(); |
12071 | ········pm.UnloadCache(); |
12072 | ········QueryOwn(); |
12073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12074 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12075 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12076 | ····} |
12077 | ····[Test] |
12078 | ····public void TestRelationHash() |
12079 | ····{ |
12080 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblGuidLeft)); |
12081 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12082 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nNoTblGuidRight)); |
12083 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12084 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12085 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12086 | ····} |
12087 | ····void CreateObjects() |
12088 | ····{ |
12089 | ········pm.MakePersistent(ownVar); |
12090 | ········ownVar.AssignRelation(otherVar); |
12091 | ········pm.Save(); |
12092 | ········pm.UnloadCache(); |
12093 | ····} |
12094 | ····void QueryOwn() |
12095 | ····{ |
12096 | ········var q = new NDOQuery<CmpBi1nNoTblGuidLeft>(pm); |
12097 | ········ownVar = q.ExecuteSingle(); |
12098 | ····} |
12099 | ····void QueryOther() |
12100 | ····{ |
12101 | ········var q = new NDOQuery<CmpBi1nNoTblGuidRight>(pm); |
12102 | ········otherVar = q.ExecuteSingle(); |
12103 | ····} |
12104 | } |
12105 | |
12106 | |
12107 | [TestFixture] |
12108 | public class TestCmpBi1nTblGuid : NDOTest |
12109 | { |
12110 | ····CmpBi1nTblGuidLeft ownVar; |
12111 | ····CmpBi1nTblGuidRight otherVar; |
12112 | ····PersistenceManager pm; |
12113 | ····[SetUp] |
12114 | ····public void Setup() |
12115 | ····{ |
12116 | ········pm = PmFactory.NewPersistenceManager(); |
12117 | ········ownVar = new CmpBi1nTblGuidLeft(); |
12118 | ········otherVar = new CmpBi1nTblGuidRight(); |
12119 | ····} |
12120 | ····[TearDown] |
12121 | ····public void TearDown() |
12122 | ····{ |
12123 | ········try |
12124 | ········{ |
12125 | ············pm.UnloadCache(); |
12126 | ············var l = pm.Objects<CmpBi1nTblGuidLeft>().ResultTable; |
12127 | ············pm.Delete(l); |
12128 | ············pm.Save(); |
12129 | ············pm.UnloadCache(); |
12130 | ············decimal count; |
12131 | ············count = (decimal) new NDOQuery<CmpBi1nTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12132 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12133 | ············count = (decimal) new NDOQuery<CmpBi1nTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12134 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12135 | ········} |
12136 | ········catch (Exception) |
12137 | ········{ |
12138 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12139 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12140 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12141 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12142 | ········} |
12143 | ····} |
12144 | ····[Test] |
12145 | ····public void TestSaveReload() |
12146 | ····{ |
12147 | ········CreateObjects(); |
12148 | ········QueryOwn(); |
12149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12151 | ····} |
12152 | ····[Test] |
12153 | ····public void TestSaveReloadNull() |
12154 | ····{ |
12155 | ········CreateObjects(); |
12156 | ········QueryOwn(); |
12157 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12158 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12159 | ········ownVar.RelField = null; |
12160 | ········pm.Save(); |
12161 | ········pm.UnloadCache(); |
12162 | ········QueryOwn(); |
12163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12164 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12165 | ····} |
12166 | ····[Test] |
12167 | ····public void TestChangeKeyHolderLeft() |
12168 | ····{ |
12169 | ········CreateObjects(); |
12170 | ········QueryOwn(); |
12171 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12172 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12173 | ········int x = ownVar.RelField.Dummy; |
12174 | ········ownVar.Dummy = 4711; |
12175 | ········pm.Save(); |
12176 | ········pm.UnloadCache(); |
12177 | ········QueryOwn(); |
12178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12179 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12181 | ····} |
12182 | ····[Test] |
12183 | ····public void TestChangeKeyHolderLeftNoTouch() |
12184 | ····{ |
12185 | ········CreateObjects(); |
12186 | ········QueryOwn(); |
12187 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12188 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12189 | ········ownVar.Dummy = 4711; |
12190 | ········pm.Save(); |
12191 | ········pm.UnloadCache(); |
12192 | ········QueryOwn(); |
12193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12194 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12195 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12196 | ····} |
12197 | ····[Test] |
12198 | ····public void TestRelationHash() |
12199 | ····{ |
12200 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nTblGuidLeft)); |
12201 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12202 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nTblGuidRight)); |
12203 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12204 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12205 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12206 | ····} |
12207 | ····void CreateObjects() |
12208 | ····{ |
12209 | ········pm.MakePersistent(ownVar); |
12210 | ········ownVar.AssignRelation(otherVar); |
12211 | ········pm.Save(); |
12212 | ········pm.UnloadCache(); |
12213 | ····} |
12214 | ····void QueryOwn() |
12215 | ····{ |
12216 | ········var q = new NDOQuery<CmpBi1nTblGuidLeft>(pm); |
12217 | ········ownVar = q.ExecuteSingle(); |
12218 | ····} |
12219 | ····void QueryOther() |
12220 | ····{ |
12221 | ········var q = new NDOQuery<CmpBi1nTblGuidRight>(pm); |
12222 | ········otherVar = q.ExecuteSingle(); |
12223 | ····} |
12224 | } |
12225 | |
12226 | |
12227 | [TestFixture] |
12228 | public class TestCmpBinnTblGuid : NDOTest |
12229 | { |
12230 | ····CmpBinnTblGuidLeft ownVar; |
12231 | ····CmpBinnTblGuidRight otherVar; |
12232 | ····PersistenceManager pm; |
12233 | ····[SetUp] |
12234 | ····public void Setup() |
12235 | ····{ |
12236 | ········pm = PmFactory.NewPersistenceManager(); |
12237 | ········ownVar = new CmpBinnTblGuidLeft(); |
12238 | ········otherVar = new CmpBinnTblGuidRight(); |
12239 | ····} |
12240 | ····[TearDown] |
12241 | ····public void TearDown() |
12242 | ····{ |
12243 | ········try |
12244 | ········{ |
12245 | ············pm.UnloadCache(); |
12246 | ············var l = pm.Objects<CmpBinnTblGuidLeft>().ResultTable; |
12247 | ············pm.Delete(l); |
12248 | ············pm.Save(); |
12249 | ············pm.UnloadCache(); |
12250 | ············decimal count; |
12251 | ············count = (decimal) new NDOQuery<CmpBinnTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12252 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12253 | ············count = (decimal) new NDOQuery<CmpBinnTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12254 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12255 | ········} |
12256 | ········catch (Exception) |
12257 | ········{ |
12258 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12259 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12260 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12261 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12262 | ········} |
12263 | ····} |
12264 | ····[Test] |
12265 | ····public void TestSaveReload() |
12266 | ····{ |
12267 | ········CreateObjects(); |
12268 | ········QueryOwn(); |
12269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12271 | ····} |
12272 | ····[Test] |
12273 | ····public void TestSaveReloadNull() |
12274 | ····{ |
12275 | ········CreateObjects(); |
12276 | ········QueryOwn(); |
12277 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12278 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12279 | ········ownVar.RelField = new List<CmpBinnTblGuidRight>(); |
12280 | ········pm.Save(); |
12281 | ········pm.UnloadCache(); |
12282 | ········QueryOwn(); |
12283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12284 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12285 | ····} |
12286 | ····[Test] |
12287 | ····public void TestSaveReloadRemove() |
12288 | ····{ |
12289 | ········CreateObjects(); |
12290 | ········QueryOwn(); |
12291 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12292 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12293 | ········ownVar.RemoveRelatedObject(); |
12294 | ········pm.Save(); |
12295 | ········pm.UnloadCache(); |
12296 | ········QueryOwn(); |
12297 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12298 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12299 | ····} |
12300 | ····[Test] |
12301 | ····public void TestRelationHash() |
12302 | ····{ |
12303 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnTblGuidLeft)); |
12304 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12305 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnTblGuidRight)); |
12306 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12307 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12308 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12309 | ····} |
12310 | ····void CreateObjects() |
12311 | ····{ |
12312 | ········pm.MakePersistent(ownVar); |
12313 | ········ownVar.AssignRelation(otherVar); |
12314 | ········pm.Save(); |
12315 | ········pm.UnloadCache(); |
12316 | ····} |
12317 | ····void QueryOwn() |
12318 | ····{ |
12319 | ········var q = new NDOQuery<CmpBinnTblGuidLeft>(pm); |
12320 | ········ownVar = q.ExecuteSingle(); |
12321 | ····} |
12322 | ····void QueryOther() |
12323 | ····{ |
12324 | ········var q = new NDOQuery<CmpBinnTblGuidRight>(pm); |
12325 | ········otherVar = q.ExecuteSingle(); |
12326 | ····} |
12327 | } |
12328 | |
12329 | |
12330 | [TestFixture] |
12331 | public class TestAgrDir1OwnpconNoTblGuid : NDOTest |
12332 | { |
12333 | ····AgrDir1OwnpconNoTblGuidLeftBase ownVar; |
12334 | ····AgrDir1OwnpconNoTblGuidRight otherVar; |
12335 | ····PersistenceManager pm; |
12336 | ····[SetUp] |
12337 | ····public void Setup() |
12338 | ····{ |
12339 | ········pm = PmFactory.NewPersistenceManager(); |
12340 | ········ownVar = new AgrDir1OwnpconNoTblGuidLeftDerived(); |
12341 | ········otherVar = new AgrDir1OwnpconNoTblGuidRight(); |
12342 | ····} |
12343 | ····[TearDown] |
12344 | ····public void TearDown() |
12345 | ····{ |
12346 | ········try |
12347 | ········{ |
12348 | ············pm.UnloadCache(); |
12349 | ············var l = pm.Objects<AgrDir1OwnpconNoTblGuidLeftBase>().ResultTable; |
12350 | ············pm.Delete(l); |
12351 | ············pm.Save(); |
12352 | ············pm.UnloadCache(); |
12353 | ············var m = pm.Objects<AgrDir1OwnpconNoTblGuidRight>().ResultTable; |
12354 | ············pm.Delete(m); |
12355 | ············pm.Save(); |
12356 | ············pm.UnloadCache(); |
12357 | ············decimal count; |
12358 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12359 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12360 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12361 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12362 | ········} |
12363 | ········catch (Exception) |
12364 | ········{ |
12365 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12366 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12367 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12368 | ········} |
12369 | ····} |
12370 | ····[Test] |
12371 | ····public void TestSaveReload() |
12372 | ····{ |
12373 | ········CreateObjects(); |
12374 | ········QueryOwn(); |
12375 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12376 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12377 | ····} |
12378 | ····[Test] |
12379 | ····public void TestSaveReloadNull() |
12380 | ····{ |
12381 | ········CreateObjects(); |
12382 | ········QueryOwn(); |
12383 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12384 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12385 | ········ownVar.RelField = null; |
12386 | ········pm.Save(); |
12387 | ········pm.UnloadCache(); |
12388 | ········QueryOwn(); |
12389 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12390 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12391 | ····} |
12392 | ····[Test] |
12393 | ····public void TestChangeKeyHolderLeft() |
12394 | ····{ |
12395 | ········CreateObjects(); |
12396 | ········QueryOwn(); |
12397 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12398 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12399 | ········int x = ownVar.RelField.Dummy; |
12400 | ········ownVar.Dummy = 4711; |
12401 | ········pm.Save(); |
12402 | ········pm.UnloadCache(); |
12403 | ········QueryOwn(); |
12404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12405 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12406 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12407 | ····} |
12408 | ····[Test] |
12409 | ····public void TestChangeKeyHolderLeftNoTouch() |
12410 | ····{ |
12411 | ········CreateObjects(); |
12412 | ········QueryOwn(); |
12413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12414 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12415 | ········ownVar.Dummy = 4711; |
12416 | ········pm.Save(); |
12417 | ········pm.UnloadCache(); |
12418 | ········QueryOwn(); |
12419 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12420 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12422 | ····} |
12423 | ····void CreateObjects() |
12424 | ····{ |
12425 | ········pm.MakePersistent(ownVar); |
12426 | ········pm.MakePersistent(otherVar); |
12427 | ········ownVar.AssignRelation(otherVar); |
12428 | ········pm.Save(); |
12429 | ········pm.UnloadCache(); |
12430 | ····} |
12431 | ····void QueryOwn() |
12432 | ····{ |
12433 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblGuidLeftBase>(pm); |
12434 | ········ownVar = q.ExecuteSingle(); |
12435 | ····} |
12436 | ····void QueryOther() |
12437 | ····{ |
12438 | ········var q = new NDOQuery<AgrDir1OwnpconNoTblGuidRight>(pm); |
12439 | ········otherVar = q.ExecuteSingle(); |
12440 | ····} |
12441 | } |
12442 | |
12443 | |
12444 | [TestFixture] |
12445 | public class TestAgrDir1OwnpconTblGuid : NDOTest |
12446 | { |
12447 | ····AgrDir1OwnpconTblGuidLeftBase ownVar; |
12448 | ····AgrDir1OwnpconTblGuidRight otherVar; |
12449 | ····PersistenceManager pm; |
12450 | ····[SetUp] |
12451 | ····public void Setup() |
12452 | ····{ |
12453 | ········pm = PmFactory.NewPersistenceManager(); |
12454 | ········ownVar = new AgrDir1OwnpconTblGuidLeftDerived(); |
12455 | ········otherVar = new AgrDir1OwnpconTblGuidRight(); |
12456 | ····} |
12457 | ····[TearDown] |
12458 | ····public void TearDown() |
12459 | ····{ |
12460 | ········try |
12461 | ········{ |
12462 | ············pm.UnloadCache(); |
12463 | ············var l = pm.Objects<AgrDir1OwnpconTblGuidLeftBase>().ResultTable; |
12464 | ············pm.Delete(l); |
12465 | ············pm.Save(); |
12466 | ············pm.UnloadCache(); |
12467 | ············var m = pm.Objects<AgrDir1OwnpconTblGuidRight>().ResultTable; |
12468 | ············pm.Delete(m); |
12469 | ············pm.Save(); |
12470 | ············pm.UnloadCache(); |
12471 | ············decimal count; |
12472 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12473 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12474 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12475 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12476 | ········} |
12477 | ········catch (Exception) |
12478 | ········{ |
12479 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12480 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12481 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12482 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12483 | ········} |
12484 | ····} |
12485 | ····[Test] |
12486 | ····public void TestSaveReload() |
12487 | ····{ |
12488 | ········CreateObjects(); |
12489 | ········QueryOwn(); |
12490 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12491 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12492 | ····} |
12493 | ····[Test] |
12494 | ····public void TestSaveReloadNull() |
12495 | ····{ |
12496 | ········CreateObjects(); |
12497 | ········QueryOwn(); |
12498 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12499 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12500 | ········ownVar.RelField = null; |
12501 | ········pm.Save(); |
12502 | ········pm.UnloadCache(); |
12503 | ········QueryOwn(); |
12504 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12505 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12506 | ····} |
12507 | ····[Test] |
12508 | ····public void TestChangeKeyHolderLeft() |
12509 | ····{ |
12510 | ········CreateObjects(); |
12511 | ········QueryOwn(); |
12512 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12513 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12514 | ········int x = ownVar.RelField.Dummy; |
12515 | ········ownVar.Dummy = 4711; |
12516 | ········pm.Save(); |
12517 | ········pm.UnloadCache(); |
12518 | ········QueryOwn(); |
12519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12520 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12521 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12522 | ····} |
12523 | ····[Test] |
12524 | ····public void TestChangeKeyHolderLeftNoTouch() |
12525 | ····{ |
12526 | ········CreateObjects(); |
12527 | ········QueryOwn(); |
12528 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12529 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12530 | ········ownVar.Dummy = 4711; |
12531 | ········pm.Save(); |
12532 | ········pm.UnloadCache(); |
12533 | ········QueryOwn(); |
12534 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12535 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12536 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12537 | ····} |
12538 | ····void CreateObjects() |
12539 | ····{ |
12540 | ········pm.MakePersistent(ownVar); |
12541 | ········pm.MakePersistent(otherVar); |
12542 | ········ownVar.AssignRelation(otherVar); |
12543 | ········pm.Save(); |
12544 | ········pm.UnloadCache(); |
12545 | ····} |
12546 | ····void QueryOwn() |
12547 | ····{ |
12548 | ········var q = new NDOQuery<AgrDir1OwnpconTblGuidLeftBase>(pm); |
12549 | ········ownVar = q.ExecuteSingle(); |
12550 | ····} |
12551 | ····void QueryOther() |
12552 | ····{ |
12553 | ········var q = new NDOQuery<AgrDir1OwnpconTblGuidRight>(pm); |
12554 | ········otherVar = q.ExecuteSingle(); |
12555 | ····} |
12556 | } |
12557 | |
12558 | |
12559 | [TestFixture] |
12560 | public class TestAgrBi11OwnpconNoTblGuid : NDOTest |
12561 | { |
12562 | ····AgrBi11OwnpconNoTblGuidLeftBase ownVar; |
12563 | ····AgrBi11OwnpconNoTblGuidRight otherVar; |
12564 | ····PersistenceManager pm; |
12565 | ····[SetUp] |
12566 | ····public void Setup() |
12567 | ····{ |
12568 | ········pm = PmFactory.NewPersistenceManager(); |
12569 | ········ownVar = new AgrBi11OwnpconNoTblGuidLeftDerived(); |
12570 | ········otherVar = new AgrBi11OwnpconNoTblGuidRight(); |
12571 | ····} |
12572 | ····[TearDown] |
12573 | ····public void TearDown() |
12574 | ····{ |
12575 | ········try |
12576 | ········{ |
12577 | ············pm.UnloadCache(); |
12578 | ············var l = pm.Objects<AgrBi11OwnpconNoTblGuidLeftBase>().ResultTable; |
12579 | ············pm.Delete(l); |
12580 | ············pm.Save(); |
12581 | ············pm.UnloadCache(); |
12582 | ············var m = pm.Objects<AgrBi11OwnpconNoTblGuidRight>().ResultTable; |
12583 | ············pm.Delete(m); |
12584 | ············pm.Save(); |
12585 | ············pm.UnloadCache(); |
12586 | ············decimal count; |
12587 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12588 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12589 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12590 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12591 | ········} |
12592 | ········catch (Exception) |
12593 | ········{ |
12594 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12595 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12596 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12597 | ········} |
12598 | ····} |
12599 | ····[Test] |
12600 | ····public void TestSaveReload() |
12601 | ····{ |
12602 | ········CreateObjects(); |
12603 | ········QueryOwn(); |
12604 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12605 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12606 | ····} |
12607 | ····[Test] |
12608 | ····public void TestSaveReloadNull() |
12609 | ····{ |
12610 | ········CreateObjects(); |
12611 | ········QueryOwn(); |
12612 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12613 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12614 | ········ownVar.RelField = null; |
12615 | ········pm.Save(); |
12616 | ········pm.UnloadCache(); |
12617 | ········QueryOwn(); |
12618 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12619 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12620 | ····} |
12621 | ····[Test] |
12622 | ····public void TestChangeKeyHolderLeft() |
12623 | ····{ |
12624 | ········CreateObjects(); |
12625 | ········QueryOwn(); |
12626 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12627 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12628 | ········int x = ownVar.RelField.Dummy; |
12629 | ········ownVar.Dummy = 4711; |
12630 | ········pm.Save(); |
12631 | ········pm.UnloadCache(); |
12632 | ········QueryOwn(); |
12633 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12634 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12635 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12636 | ····} |
12637 | ····[Test] |
12638 | ····public void TestChangeKeyHolderRight() |
12639 | ····{ |
12640 | ········CreateObjects(); |
12641 | ········QueryOther(); |
12642 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12643 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12644 | ········int x = otherVar.RelField.Dummy; |
12645 | ········otherVar.Dummy = 4711; |
12646 | ········pm.Save(); |
12647 | ········pm.UnloadCache(); |
12648 | ········QueryOther(); |
12649 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12650 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12651 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12652 | ····} |
12653 | ····[Test] |
12654 | ····public void TestChangeKeyHolderLeftNoTouch() |
12655 | ····{ |
12656 | ········CreateObjects(); |
12657 | ········QueryOwn(); |
12658 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12659 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12660 | ········ownVar.Dummy = 4711; |
12661 | ········pm.Save(); |
12662 | ········pm.UnloadCache(); |
12663 | ········QueryOwn(); |
12664 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12665 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12666 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12667 | ····} |
12668 | ····[Test] |
12669 | ····public void TestChangeKeyHolderRightNoTouch() |
12670 | ····{ |
12671 | ········CreateObjects(); |
12672 | ········QueryOther(); |
12673 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12674 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12675 | ········otherVar.Dummy = 4711; |
12676 | ········pm.Save(); |
12677 | ········pm.UnloadCache(); |
12678 | ········QueryOther(); |
12679 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12680 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12681 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12682 | ····} |
12683 | ····[Test] |
12684 | ····public void TestRelationHash() |
12685 | ····{ |
12686 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidLeftBase)); |
12687 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12688 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidRight)); |
12689 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12690 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12691 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12692 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconNoTblGuidLeftDerived)); |
12693 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
12694 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
12695 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
12696 | ····} |
12697 | ····void CreateObjects() |
12698 | ····{ |
12699 | ········pm.MakePersistent(ownVar); |
12700 | ········pm.MakePersistent(otherVar); |
12701 | ········ownVar.AssignRelation(otherVar); |
12702 | ········pm.Save(); |
12703 | ········pm.UnloadCache(); |
12704 | ····} |
12705 | ····void QueryOwn() |
12706 | ····{ |
12707 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblGuidLeftBase>(pm); |
12708 | ········ownVar = q.ExecuteSingle(); |
12709 | ····} |
12710 | ····void QueryOther() |
12711 | ····{ |
12712 | ········var q = new NDOQuery<AgrBi11OwnpconNoTblGuidRight>(pm); |
12713 | ········otherVar = q.ExecuteSingle(); |
12714 | ····} |
12715 | } |
12716 | |
12717 | |
12718 | [TestFixture] |
12719 | public class TestAgrBi11OwnpconTblGuid : NDOTest |
12720 | { |
12721 | ····AgrBi11OwnpconTblGuidLeftBase ownVar; |
12722 | ····AgrBi11OwnpconTblGuidRight otherVar; |
12723 | ····PersistenceManager pm; |
12724 | ····[SetUp] |
12725 | ····public void Setup() |
12726 | ····{ |
12727 | ········pm = PmFactory.NewPersistenceManager(); |
12728 | ········ownVar = new AgrBi11OwnpconTblGuidLeftDerived(); |
12729 | ········otherVar = new AgrBi11OwnpconTblGuidRight(); |
12730 | ····} |
12731 | ····[TearDown] |
12732 | ····public void TearDown() |
12733 | ····{ |
12734 | ········try |
12735 | ········{ |
12736 | ············pm.UnloadCache(); |
12737 | ············var l = pm.Objects<AgrBi11OwnpconTblGuidLeftBase>().ResultTable; |
12738 | ············pm.Delete(l); |
12739 | ············pm.Save(); |
12740 | ············pm.UnloadCache(); |
12741 | ············var m = pm.Objects<AgrBi11OwnpconTblGuidRight>().ResultTable; |
12742 | ············pm.Delete(m); |
12743 | ············pm.Save(); |
12744 | ············pm.UnloadCache(); |
12745 | ············decimal count; |
12746 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12747 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12748 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12749 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12750 | ········} |
12751 | ········catch (Exception) |
12752 | ········{ |
12753 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12755 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12756 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
12757 | ········} |
12758 | ····} |
12759 | ····[Test] |
12760 | ····public void TestSaveReload() |
12761 | ····{ |
12762 | ········CreateObjects(); |
12763 | ········QueryOwn(); |
12764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12765 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12766 | ····} |
12767 | ····[Test] |
12768 | ····public void TestSaveReloadNull() |
12769 | ····{ |
12770 | ········CreateObjects(); |
12771 | ········QueryOwn(); |
12772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12773 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12774 | ········ownVar.RelField = null; |
12775 | ········pm.Save(); |
12776 | ········pm.UnloadCache(); |
12777 | ········QueryOwn(); |
12778 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12779 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
12780 | ····} |
12781 | ····[Test] |
12782 | ····public void TestChangeKeyHolderLeft() |
12783 | ····{ |
12784 | ········CreateObjects(); |
12785 | ········QueryOwn(); |
12786 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12787 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12788 | ········int x = ownVar.RelField.Dummy; |
12789 | ········ownVar.Dummy = 4711; |
12790 | ········pm.Save(); |
12791 | ········pm.UnloadCache(); |
12792 | ········QueryOwn(); |
12793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12794 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12795 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12796 | ····} |
12797 | ····[Test] |
12798 | ····public void TestChangeKeyHolderRight() |
12799 | ····{ |
12800 | ········CreateObjects(); |
12801 | ········QueryOther(); |
12802 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12803 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12804 | ········int x = otherVar.RelField.Dummy; |
12805 | ········otherVar.Dummy = 4711; |
12806 | ········pm.Save(); |
12807 | ········pm.UnloadCache(); |
12808 | ········QueryOther(); |
12809 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12810 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12811 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12812 | ····} |
12813 | ····[Test] |
12814 | ····public void TestChangeKeyHolderLeftNoTouch() |
12815 | ····{ |
12816 | ········CreateObjects(); |
12817 | ········QueryOwn(); |
12818 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12819 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12820 | ········ownVar.Dummy = 4711; |
12821 | ········pm.Save(); |
12822 | ········pm.UnloadCache(); |
12823 | ········QueryOwn(); |
12824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12825 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12826 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
12827 | ····} |
12828 | ····[Test] |
12829 | ····public void TestChangeKeyHolderRightNoTouch() |
12830 | ····{ |
12831 | ········CreateObjects(); |
12832 | ········QueryOther(); |
12833 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12834 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12835 | ········otherVar.Dummy = 4711; |
12836 | ········pm.Save(); |
12837 | ········pm.UnloadCache(); |
12838 | ········QueryOther(); |
12839 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
12840 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
12841 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
12842 | ····} |
12843 | ····[Test] |
12844 | ····public void TestRelationHash() |
12845 | ····{ |
12846 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidLeftBase)); |
12847 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
12848 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidRight)); |
12849 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
12850 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
12851 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
12852 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconTblGuidLeftDerived)); |
12853 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
12854 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
12855 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
12856 | ····} |
12857 | ····void CreateObjects() |
12858 | ····{ |
12859 | ········pm.MakePersistent(ownVar); |
12860 | ········pm.MakePersistent(otherVar); |
12861 | ········ownVar.AssignRelation(otherVar); |
12862 | ········pm.Save(); |
12863 | ········pm.UnloadCache(); |
12864 | ····} |
12865 | ····void QueryOwn() |
12866 | ····{ |
12867 | ········var q = new NDOQuery<AgrBi11OwnpconTblGuidLeftBase>(pm); |
12868 | ········ownVar = q.ExecuteSingle(); |
12869 | ····} |
12870 | ····void QueryOther() |
12871 | ····{ |
12872 | ········var q = new NDOQuery<AgrBi11OwnpconTblGuidRight>(pm); |
12873 | ········otherVar = q.ExecuteSingle(); |
12874 | ····} |
12875 | } |
12876 | |
12877 | |
12878 | [TestFixture] |
12879 | public class TestAgrDirnOwnpconNoTblGuid : NDOTest |
12880 | { |
12881 | ····AgrDirnOwnpconNoTblGuidLeftBase ownVar; |
12882 | ····AgrDirnOwnpconNoTblGuidRight otherVar; |
12883 | ····PersistenceManager pm; |
12884 | ····[SetUp] |
12885 | ····public void Setup() |
12886 | ····{ |
12887 | ········pm = PmFactory.NewPersistenceManager(); |
12888 | ········ownVar = new AgrDirnOwnpconNoTblGuidLeftDerived(); |
12889 | ········otherVar = new AgrDirnOwnpconNoTblGuidRight(); |
12890 | ····} |
12891 | ····[TearDown] |
12892 | ····public void TearDown() |
12893 | ····{ |
12894 | ········try |
12895 | ········{ |
12896 | ············pm.UnloadCache(); |
12897 | ············var l = pm.Objects<AgrDirnOwnpconNoTblGuidLeftBase>().ResultTable; |
12898 | ············pm.Delete(l); |
12899 | ············pm.Save(); |
12900 | ············pm.UnloadCache(); |
12901 | ············var m = pm.Objects<AgrDirnOwnpconNoTblGuidRight>().ResultTable; |
12902 | ············pm.Delete(m); |
12903 | ············pm.Save(); |
12904 | ············pm.UnloadCache(); |
12905 | ············decimal count; |
12906 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12907 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
12908 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
12909 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
12910 | ········} |
12911 | ········catch (Exception) |
12912 | ········{ |
12913 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
12914 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
12915 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
12916 | ········} |
12917 | ····} |
12918 | ····[Test] |
12919 | ····public void TestSaveReload() |
12920 | ····{ |
12921 | ········CreateObjects(); |
12922 | ········QueryOwn(); |
12923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12924 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12925 | ····} |
12926 | ····[Test] |
12927 | ····public void TestSaveReloadNull() |
12928 | ····{ |
12929 | ········CreateObjects(); |
12930 | ········QueryOwn(); |
12931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12932 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12933 | ········ownVar.RelField = new List<AgrDirnOwnpconNoTblGuidRight>(); |
12934 | ········pm.Save(); |
12935 | ········pm.UnloadCache(); |
12936 | ········QueryOwn(); |
12937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12938 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12939 | ····} |
12940 | ····[Test] |
12941 | ····public void TestSaveReloadRemove() |
12942 | ····{ |
12943 | ········CreateObjects(); |
12944 | ········QueryOwn(); |
12945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12946 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12947 | ········ownVar.RemoveRelatedObject(); |
12948 | ········pm.Save(); |
12949 | ········pm.UnloadCache(); |
12950 | ········QueryOwn(); |
12951 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
12952 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
12953 | ····} |
12954 | ····void CreateObjects() |
12955 | ····{ |
12956 | ········pm.MakePersistent(ownVar); |
12957 | ········pm.MakePersistent(otherVar); |
12958 | ········ownVar.AssignRelation(otherVar); |
12959 | ········pm.Save(); |
12960 | ········pm.UnloadCache(); |
12961 | ····} |
12962 | ····void QueryOwn() |
12963 | ····{ |
12964 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblGuidLeftBase>(pm); |
12965 | ········ownVar = q.ExecuteSingle(); |
12966 | ····} |
12967 | ····void QueryOther() |
12968 | ····{ |
12969 | ········var q = new NDOQuery<AgrDirnOwnpconNoTblGuidRight>(pm); |
12970 | ········otherVar = q.ExecuteSingle(); |
12971 | ····} |
12972 | } |
12973 | |
12974 | |
12975 | [TestFixture] |
12976 | public class TestAgrDirnOwnpconTblGuid : NDOTest |
12977 | { |
12978 | ····AgrDirnOwnpconTblGuidLeftBase ownVar; |
12979 | ····AgrDirnOwnpconTblGuidRight otherVar; |
12980 | ····PersistenceManager pm; |
12981 | ····[SetUp] |
12982 | ····public void Setup() |
12983 | ····{ |
12984 | ········pm = PmFactory.NewPersistenceManager(); |
12985 | ········ownVar = new AgrDirnOwnpconTblGuidLeftDerived(); |
12986 | ········otherVar = new AgrDirnOwnpconTblGuidRight(); |
12987 | ····} |
12988 | ····[TearDown] |
12989 | ····public void TearDown() |
12990 | ····{ |
12991 | ········try |
12992 | ········{ |
12993 | ············pm.UnloadCache(); |
12994 | ············var l = pm.Objects<AgrDirnOwnpconTblGuidLeftBase>().ResultTable; |
12995 | ············pm.Delete(l); |
12996 | ············pm.Save(); |
12997 | ············pm.UnloadCache(); |
12998 | ············var m = pm.Objects<AgrDirnOwnpconTblGuidRight>().ResultTable; |
12999 | ············pm.Delete(m); |
13000 | ············pm.Save(); |
13001 | ············pm.UnloadCache(); |
13002 | ············decimal count; |
13003 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13004 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13005 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13006 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13007 | ········} |
13008 | ········catch (Exception) |
13009 | ········{ |
13010 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13011 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13012 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13013 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13014 | ········} |
13015 | ····} |
13016 | ····[Test] |
13017 | ····public void TestSaveReload() |
13018 | ····{ |
13019 | ········CreateObjects(); |
13020 | ········QueryOwn(); |
13021 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13022 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13023 | ····} |
13024 | ····[Test] |
13025 | ····public void TestSaveReloadNull() |
13026 | ····{ |
13027 | ········CreateObjects(); |
13028 | ········QueryOwn(); |
13029 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13030 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13031 | ········ownVar.RelField = new List<AgrDirnOwnpconTblGuidRight>(); |
13032 | ········pm.Save(); |
13033 | ········pm.UnloadCache(); |
13034 | ········QueryOwn(); |
13035 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13036 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13037 | ····} |
13038 | ····[Test] |
13039 | ····public void TestSaveReloadRemove() |
13040 | ····{ |
13041 | ········CreateObjects(); |
13042 | ········QueryOwn(); |
13043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13044 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13045 | ········ownVar.RemoveRelatedObject(); |
13046 | ········pm.Save(); |
13047 | ········pm.UnloadCache(); |
13048 | ········QueryOwn(); |
13049 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13050 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13051 | ····} |
13052 | ····void CreateObjects() |
13053 | ····{ |
13054 | ········pm.MakePersistent(ownVar); |
13055 | ········pm.MakePersistent(otherVar); |
13056 | ········ownVar.AssignRelation(otherVar); |
13057 | ········pm.Save(); |
13058 | ········pm.UnloadCache(); |
13059 | ····} |
13060 | ····void QueryOwn() |
13061 | ····{ |
13062 | ········var q = new NDOQuery<AgrDirnOwnpconTblGuidLeftBase>(pm); |
13063 | ········ownVar = q.ExecuteSingle(); |
13064 | ····} |
13065 | ····void QueryOther() |
13066 | ····{ |
13067 | ········var q = new NDOQuery<AgrDirnOwnpconTblGuidRight>(pm); |
13068 | ········otherVar = q.ExecuteSingle(); |
13069 | ····} |
13070 | } |
13071 | |
13072 | |
13073 | [TestFixture] |
13074 | public class TestAgrBin1OwnpconNoTblGuid : NDOTest |
13075 | { |
13076 | ····AgrBin1OwnpconNoTblGuidLeftBase ownVar; |
13077 | ····AgrBin1OwnpconNoTblGuidRight otherVar; |
13078 | ····PersistenceManager pm; |
13079 | ····[SetUp] |
13080 | ····public void Setup() |
13081 | ····{ |
13082 | ········pm = PmFactory.NewPersistenceManager(); |
13083 | ········ownVar = new AgrBin1OwnpconNoTblGuidLeftDerived(); |
13084 | ········otherVar = new AgrBin1OwnpconNoTblGuidRight(); |
13085 | ····} |
13086 | ····[TearDown] |
13087 | ····public void TearDown() |
13088 | ····{ |
13089 | ········try |
13090 | ········{ |
13091 | ············pm.UnloadCache(); |
13092 | ············var l = pm.Objects<AgrBin1OwnpconNoTblGuidLeftBase>().ResultTable; |
13093 | ············pm.Delete(l); |
13094 | ············pm.Save(); |
13095 | ············pm.UnloadCache(); |
13096 | ············var m = pm.Objects<AgrBin1OwnpconNoTblGuidRight>().ResultTable; |
13097 | ············pm.Delete(m); |
13098 | ············pm.Save(); |
13099 | ············pm.UnloadCache(); |
13100 | ············decimal count; |
13101 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13102 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13103 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13104 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13105 | ········} |
13106 | ········catch (Exception) |
13107 | ········{ |
13108 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13109 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13110 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13111 | ········} |
13112 | ····} |
13113 | ····[Test] |
13114 | ····public void TestSaveReload() |
13115 | ····{ |
13116 | ········CreateObjects(); |
13117 | ········QueryOwn(); |
13118 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13119 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13120 | ····} |
13121 | ····[Test] |
13122 | ····public void TestSaveReloadNull() |
13123 | ····{ |
13124 | ········CreateObjects(); |
13125 | ········QueryOwn(); |
13126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13127 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13128 | ········ownVar.RelField = new List<AgrBin1OwnpconNoTblGuidRight>(); |
13129 | ········pm.Save(); |
13130 | ········pm.UnloadCache(); |
13131 | ········QueryOwn(); |
13132 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13133 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13134 | ····} |
13135 | ····[Test] |
13136 | ····public void TestSaveReloadRemove() |
13137 | ····{ |
13138 | ········CreateObjects(); |
13139 | ········QueryOwn(); |
13140 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13141 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13142 | ········ownVar.RemoveRelatedObject(); |
13143 | ········pm.Save(); |
13144 | ········pm.UnloadCache(); |
13145 | ········QueryOwn(); |
13146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13147 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13148 | ····} |
13149 | ····[Test] |
13150 | ····public void TestChangeKeyHolderRight() |
13151 | ····{ |
13152 | ········CreateObjects(); |
13153 | ········QueryOther(); |
13154 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13155 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13156 | ········int x = otherVar.RelField.Dummy; |
13157 | ········otherVar.Dummy = 4711; |
13158 | ········pm.Save(); |
13159 | ········pm.UnloadCache(); |
13160 | ········QueryOther(); |
13161 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13162 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13163 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13164 | ····} |
13165 | ····[Test] |
13166 | ····public void TestChangeKeyHolderRightNoTouch() |
13167 | ····{ |
13168 | ········CreateObjects(); |
13169 | ········QueryOther(); |
13170 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13171 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13172 | ········otherVar.Dummy = 4711; |
13173 | ········pm.Save(); |
13174 | ········pm.UnloadCache(); |
13175 | ········QueryOther(); |
13176 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13177 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13178 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13179 | ····} |
13180 | ····[Test] |
13181 | ····public void TestRelationHash() |
13182 | ····{ |
13183 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidLeftBase)); |
13184 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13185 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidRight)); |
13186 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13187 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13188 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13189 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconNoTblGuidLeftDerived)); |
13190 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13191 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13192 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13193 | ····} |
13194 | ····void CreateObjects() |
13195 | ····{ |
13196 | ········pm.MakePersistent(ownVar); |
13197 | ········pm.MakePersistent(otherVar); |
13198 | ········ownVar.AssignRelation(otherVar); |
13199 | ········pm.Save(); |
13200 | ········pm.UnloadCache(); |
13201 | ····} |
13202 | ····void QueryOwn() |
13203 | ····{ |
13204 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblGuidLeftBase>(pm); |
13205 | ········ownVar = q.ExecuteSingle(); |
13206 | ····} |
13207 | ····void QueryOther() |
13208 | ····{ |
13209 | ········var q = new NDOQuery<AgrBin1OwnpconNoTblGuidRight>(pm); |
13210 | ········otherVar = q.ExecuteSingle(); |
13211 | ····} |
13212 | } |
13213 | |
13214 | |
13215 | [TestFixture] |
13216 | public class TestAgrBin1OwnpconTblGuid : NDOTest |
13217 | { |
13218 | ····AgrBin1OwnpconTblGuidLeftBase ownVar; |
13219 | ····AgrBin1OwnpconTblGuidRight otherVar; |
13220 | ····PersistenceManager pm; |
13221 | ····[SetUp] |
13222 | ····public void Setup() |
13223 | ····{ |
13224 | ········pm = PmFactory.NewPersistenceManager(); |
13225 | ········ownVar = new AgrBin1OwnpconTblGuidLeftDerived(); |
13226 | ········otherVar = new AgrBin1OwnpconTblGuidRight(); |
13227 | ····} |
13228 | ····[TearDown] |
13229 | ····public void TearDown() |
13230 | ····{ |
13231 | ········try |
13232 | ········{ |
13233 | ············pm.UnloadCache(); |
13234 | ············var l = pm.Objects<AgrBin1OwnpconTblGuidLeftBase>().ResultTable; |
13235 | ············pm.Delete(l); |
13236 | ············pm.Save(); |
13237 | ············pm.UnloadCache(); |
13238 | ············var m = pm.Objects<AgrBin1OwnpconTblGuidRight>().ResultTable; |
13239 | ············pm.Delete(m); |
13240 | ············pm.Save(); |
13241 | ············pm.UnloadCache(); |
13242 | ············decimal count; |
13243 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13245 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13247 | ········} |
13248 | ········catch (Exception) |
13249 | ········{ |
13250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13253 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13254 | ········} |
13255 | ····} |
13256 | ····[Test] |
13257 | ····public void TestSaveReload() |
13258 | ····{ |
13259 | ········CreateObjects(); |
13260 | ········QueryOwn(); |
13261 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13262 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13263 | ····} |
13264 | ····[Test] |
13265 | ····public void TestSaveReloadNull() |
13266 | ····{ |
13267 | ········CreateObjects(); |
13268 | ········QueryOwn(); |
13269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13271 | ········ownVar.RelField = new List<AgrBin1OwnpconTblGuidRight>(); |
13272 | ········pm.Save(); |
13273 | ········pm.UnloadCache(); |
13274 | ········QueryOwn(); |
13275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13276 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13277 | ····} |
13278 | ····[Test] |
13279 | ····public void TestSaveReloadRemove() |
13280 | ····{ |
13281 | ········CreateObjects(); |
13282 | ········QueryOwn(); |
13283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13284 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13285 | ········ownVar.RemoveRelatedObject(); |
13286 | ········pm.Save(); |
13287 | ········pm.UnloadCache(); |
13288 | ········QueryOwn(); |
13289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13290 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13291 | ····} |
13292 | ····[Test] |
13293 | ····public void TestChangeKeyHolderRight() |
13294 | ····{ |
13295 | ········CreateObjects(); |
13296 | ········QueryOther(); |
13297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13298 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13299 | ········int x = otherVar.RelField.Dummy; |
13300 | ········otherVar.Dummy = 4711; |
13301 | ········pm.Save(); |
13302 | ········pm.UnloadCache(); |
13303 | ········QueryOther(); |
13304 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13305 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13307 | ····} |
13308 | ····[Test] |
13309 | ····public void TestChangeKeyHolderRightNoTouch() |
13310 | ····{ |
13311 | ········CreateObjects(); |
13312 | ········QueryOther(); |
13313 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13314 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13315 | ········otherVar.Dummy = 4711; |
13316 | ········pm.Save(); |
13317 | ········pm.UnloadCache(); |
13318 | ········QueryOther(); |
13319 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13320 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13321 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13322 | ····} |
13323 | ····[Test] |
13324 | ····public void TestRelationHash() |
13325 | ····{ |
13326 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidLeftBase)); |
13327 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13328 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidRight)); |
13329 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13330 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13331 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13332 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconTblGuidLeftDerived)); |
13333 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13334 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13335 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13336 | ····} |
13337 | ····void CreateObjects() |
13338 | ····{ |
13339 | ········pm.MakePersistent(ownVar); |
13340 | ········pm.MakePersistent(otherVar); |
13341 | ········ownVar.AssignRelation(otherVar); |
13342 | ········pm.Save(); |
13343 | ········pm.UnloadCache(); |
13344 | ····} |
13345 | ····void QueryOwn() |
13346 | ····{ |
13347 | ········var q = new NDOQuery<AgrBin1OwnpconTblGuidLeftBase>(pm); |
13348 | ········ownVar = q.ExecuteSingle(); |
13349 | ····} |
13350 | ····void QueryOther() |
13351 | ····{ |
13352 | ········var q = new NDOQuery<AgrBin1OwnpconTblGuidRight>(pm); |
13353 | ········otherVar = q.ExecuteSingle(); |
13354 | ····} |
13355 | } |
13356 | |
13357 | |
13358 | [TestFixture] |
13359 | public class TestAgrBi1nOwnpconTblGuid : NDOTest |
13360 | { |
13361 | ····AgrBi1nOwnpconTblGuidLeftBase ownVar; |
13362 | ····AgrBi1nOwnpconTblGuidRight otherVar; |
13363 | ····PersistenceManager pm; |
13364 | ····[SetUp] |
13365 | ····public void Setup() |
13366 | ····{ |
13367 | ········pm = PmFactory.NewPersistenceManager(); |
13368 | ········ownVar = new AgrBi1nOwnpconTblGuidLeftDerived(); |
13369 | ········otherVar = new AgrBi1nOwnpconTblGuidRight(); |
13370 | ····} |
13371 | ····[TearDown] |
13372 | ····public void TearDown() |
13373 | ····{ |
13374 | ········try |
13375 | ········{ |
13376 | ············pm.UnloadCache(); |
13377 | ············var l = pm.Objects<AgrBi1nOwnpconTblGuidLeftBase>().ResultTable; |
13378 | ············pm.Delete(l); |
13379 | ············pm.Save(); |
13380 | ············pm.UnloadCache(); |
13381 | ············var m = pm.Objects<AgrBi1nOwnpconTblGuidRight>().ResultTable; |
13382 | ············pm.Delete(m); |
13383 | ············pm.Save(); |
13384 | ············pm.UnloadCache(); |
13385 | ············decimal count; |
13386 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13387 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13388 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13389 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13390 | ········} |
13391 | ········catch (Exception) |
13392 | ········{ |
13393 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13394 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13395 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13396 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13397 | ········} |
13398 | ····} |
13399 | ····[Test] |
13400 | ····public void TestSaveReload() |
13401 | ····{ |
13402 | ········CreateObjects(); |
13403 | ········QueryOwn(); |
13404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13405 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13406 | ····} |
13407 | ····[Test] |
13408 | ····public void TestSaveReloadNull() |
13409 | ····{ |
13410 | ········CreateObjects(); |
13411 | ········QueryOwn(); |
13412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13413 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13414 | ········ownVar.RelField = null; |
13415 | ········pm.Save(); |
13416 | ········pm.UnloadCache(); |
13417 | ········QueryOwn(); |
13418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13419 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13420 | ····} |
13421 | ····[Test] |
13422 | ····public void TestChangeKeyHolderLeft() |
13423 | ····{ |
13424 | ········CreateObjects(); |
13425 | ········QueryOwn(); |
13426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13427 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13428 | ········int x = ownVar.RelField.Dummy; |
13429 | ········ownVar.Dummy = 4711; |
13430 | ········pm.Save(); |
13431 | ········pm.UnloadCache(); |
13432 | ········QueryOwn(); |
13433 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13434 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13435 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13436 | ····} |
13437 | ····[Test] |
13438 | ····public void TestChangeKeyHolderLeftNoTouch() |
13439 | ····{ |
13440 | ········CreateObjects(); |
13441 | ········QueryOwn(); |
13442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13443 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13444 | ········ownVar.Dummy = 4711; |
13445 | ········pm.Save(); |
13446 | ········pm.UnloadCache(); |
13447 | ········QueryOwn(); |
13448 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13449 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13450 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13451 | ····} |
13452 | ····[Test] |
13453 | ····public void TestRelationHash() |
13454 | ····{ |
13455 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidLeftBase)); |
13456 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13457 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidRight)); |
13458 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13459 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13460 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13461 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconTblGuidLeftDerived)); |
13462 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13463 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13464 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13465 | ····} |
13466 | ····void CreateObjects() |
13467 | ····{ |
13468 | ········pm.MakePersistent(ownVar); |
13469 | ········pm.MakePersistent(otherVar); |
13470 | ········ownVar.AssignRelation(otherVar); |
13471 | ········pm.Save(); |
13472 | ········pm.UnloadCache(); |
13473 | ····} |
13474 | ····void QueryOwn() |
13475 | ····{ |
13476 | ········var q = new NDOQuery<AgrBi1nOwnpconTblGuidLeftBase>(pm); |
13477 | ········ownVar = q.ExecuteSingle(); |
13478 | ····} |
13479 | ····void QueryOther() |
13480 | ····{ |
13481 | ········var q = new NDOQuery<AgrBi1nOwnpconTblGuidRight>(pm); |
13482 | ········otherVar = q.ExecuteSingle(); |
13483 | ····} |
13484 | } |
13485 | |
13486 | |
13487 | [TestFixture] |
13488 | public class TestAgrBinnOwnpconTblGuid : NDOTest |
13489 | { |
13490 | ····AgrBinnOwnpconTblGuidLeftBase ownVar; |
13491 | ····AgrBinnOwnpconTblGuidRight otherVar; |
13492 | ····PersistenceManager pm; |
13493 | ····[SetUp] |
13494 | ····public void Setup() |
13495 | ····{ |
13496 | ········pm = PmFactory.NewPersistenceManager(); |
13497 | ········ownVar = new AgrBinnOwnpconTblGuidLeftDerived(); |
13498 | ········otherVar = new AgrBinnOwnpconTblGuidRight(); |
13499 | ····} |
13500 | ····[TearDown] |
13501 | ····public void TearDown() |
13502 | ····{ |
13503 | ········try |
13504 | ········{ |
13505 | ············pm.UnloadCache(); |
13506 | ············var l = pm.Objects<AgrBinnOwnpconTblGuidLeftBase>().ResultTable; |
13507 | ············pm.Delete(l); |
13508 | ············pm.Save(); |
13509 | ············pm.UnloadCache(); |
13510 | ············var m = pm.Objects<AgrBinnOwnpconTblGuidRight>().ResultTable; |
13511 | ············pm.Delete(m); |
13512 | ············pm.Save(); |
13513 | ············pm.UnloadCache(); |
13514 | ············decimal count; |
13515 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13516 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13517 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13518 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13519 | ········} |
13520 | ········catch (Exception) |
13521 | ········{ |
13522 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13523 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13524 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13525 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13526 | ········} |
13527 | ····} |
13528 | ····[Test] |
13529 | ····public void TestSaveReload() |
13530 | ····{ |
13531 | ········CreateObjects(); |
13532 | ········QueryOwn(); |
13533 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13534 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13535 | ····} |
13536 | ····[Test] |
13537 | ····public void TestSaveReloadNull() |
13538 | ····{ |
13539 | ········CreateObjects(); |
13540 | ········QueryOwn(); |
13541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13542 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13543 | ········ownVar.RelField = new List<AgrBinnOwnpconTblGuidRight>(); |
13544 | ········pm.Save(); |
13545 | ········pm.UnloadCache(); |
13546 | ········QueryOwn(); |
13547 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13548 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13549 | ····} |
13550 | ····[Test] |
13551 | ····public void TestSaveReloadRemove() |
13552 | ····{ |
13553 | ········CreateObjects(); |
13554 | ········QueryOwn(); |
13555 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13556 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13557 | ········ownVar.RemoveRelatedObject(); |
13558 | ········pm.Save(); |
13559 | ········pm.UnloadCache(); |
13560 | ········QueryOwn(); |
13561 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13562 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
13563 | ····} |
13564 | ····[Test] |
13565 | ····public void TestRelationHash() |
13566 | ····{ |
13567 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidLeftBase)); |
13568 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13569 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidRight)); |
13570 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13571 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13572 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13573 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconTblGuidLeftDerived)); |
13574 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13575 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13576 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13577 | ····} |
13578 | ····void CreateObjects() |
13579 | ····{ |
13580 | ········pm.MakePersistent(ownVar); |
13581 | ········pm.MakePersistent(otherVar); |
13582 | ········ownVar.AssignRelation(otherVar); |
13583 | ········pm.Save(); |
13584 | ········pm.UnloadCache(); |
13585 | ····} |
13586 | ····void QueryOwn() |
13587 | ····{ |
13588 | ········var q = new NDOQuery<AgrBinnOwnpconTblGuidLeftBase>(pm); |
13589 | ········ownVar = q.ExecuteSingle(); |
13590 | ····} |
13591 | ····void QueryOther() |
13592 | ····{ |
13593 | ········var q = new NDOQuery<AgrBinnOwnpconTblGuidRight>(pm); |
13594 | ········otherVar = q.ExecuteSingle(); |
13595 | ····} |
13596 | } |
13597 | |
13598 | |
13599 | [TestFixture] |
13600 | public class TestCmpDir1OwnpconNoTblGuid : NDOTest |
13601 | { |
13602 | ····CmpDir1OwnpconNoTblGuidLeftBase ownVar; |
13603 | ····CmpDir1OwnpconNoTblGuidRight otherVar; |
13604 | ····PersistenceManager pm; |
13605 | ····[SetUp] |
13606 | ····public void Setup() |
13607 | ····{ |
13608 | ········pm = PmFactory.NewPersistenceManager(); |
13609 | ········ownVar = new CmpDir1OwnpconNoTblGuidLeftDerived(); |
13610 | ········otherVar = new CmpDir1OwnpconNoTblGuidRight(); |
13611 | ····} |
13612 | ····[TearDown] |
13613 | ····public void TearDown() |
13614 | ····{ |
13615 | ········try |
13616 | ········{ |
13617 | ············pm.UnloadCache(); |
13618 | ············var l = pm.Objects<CmpDir1OwnpconNoTblGuidLeftBase>().ResultTable; |
13619 | ············pm.Delete(l); |
13620 | ············pm.Save(); |
13621 | ············pm.UnloadCache(); |
13622 | ············decimal count; |
13623 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13625 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13626 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13627 | ········} |
13628 | ········catch (Exception) |
13629 | ········{ |
13630 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13631 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13632 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13633 | ········} |
13634 | ····} |
13635 | ····[Test] |
13636 | ····public void TestSaveReload() |
13637 | ····{ |
13638 | ········CreateObjects(); |
13639 | ········QueryOwn(); |
13640 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13641 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13642 | ····} |
13643 | ····[Test] |
13644 | ····public void TestSaveReloadNull() |
13645 | ····{ |
13646 | ········CreateObjects(); |
13647 | ········QueryOwn(); |
13648 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13649 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13650 | ········ownVar.RelField = null; |
13651 | ········pm.Save(); |
13652 | ········pm.UnloadCache(); |
13653 | ········QueryOwn(); |
13654 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13655 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13656 | ····} |
13657 | ····[Test] |
13658 | ····public void TestChangeKeyHolderLeft() |
13659 | ····{ |
13660 | ········CreateObjects(); |
13661 | ········QueryOwn(); |
13662 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13663 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13664 | ········int x = ownVar.RelField.Dummy; |
13665 | ········ownVar.Dummy = 4711; |
13666 | ········pm.Save(); |
13667 | ········pm.UnloadCache(); |
13668 | ········QueryOwn(); |
13669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13670 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13671 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13672 | ····} |
13673 | ····[Test] |
13674 | ····public void TestChangeKeyHolderLeftNoTouch() |
13675 | ····{ |
13676 | ········CreateObjects(); |
13677 | ········QueryOwn(); |
13678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13679 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13680 | ········ownVar.Dummy = 4711; |
13681 | ········pm.Save(); |
13682 | ········pm.UnloadCache(); |
13683 | ········QueryOwn(); |
13684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13685 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13686 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13687 | ····} |
13688 | ····void CreateObjects() |
13689 | ····{ |
13690 | ········pm.MakePersistent(ownVar); |
13691 | ········ownVar.AssignRelation(otherVar); |
13692 | ········pm.Save(); |
13693 | ········pm.UnloadCache(); |
13694 | ····} |
13695 | ····void QueryOwn() |
13696 | ····{ |
13697 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblGuidLeftBase>(pm); |
13698 | ········ownVar = q.ExecuteSingle(); |
13699 | ····} |
13700 | ····void QueryOther() |
13701 | ····{ |
13702 | ········var q = new NDOQuery<CmpDir1OwnpconNoTblGuidRight>(pm); |
13703 | ········otherVar = q.ExecuteSingle(); |
13704 | ····} |
13705 | } |
13706 | |
13707 | |
13708 | [TestFixture] |
13709 | public class TestCmpDir1OwnpconTblGuid : NDOTest |
13710 | { |
13711 | ····CmpDir1OwnpconTblGuidLeftBase ownVar; |
13712 | ····CmpDir1OwnpconTblGuidRight otherVar; |
13713 | ····PersistenceManager pm; |
13714 | ····[SetUp] |
13715 | ····public void Setup() |
13716 | ····{ |
13717 | ········pm = PmFactory.NewPersistenceManager(); |
13718 | ········ownVar = new CmpDir1OwnpconTblGuidLeftDerived(); |
13719 | ········otherVar = new CmpDir1OwnpconTblGuidRight(); |
13720 | ····} |
13721 | ····[TearDown] |
13722 | ····public void TearDown() |
13723 | ····{ |
13724 | ········try |
13725 | ········{ |
13726 | ············pm.UnloadCache(); |
13727 | ············var l = pm.Objects<CmpDir1OwnpconTblGuidLeftBase>().ResultTable; |
13728 | ············pm.Delete(l); |
13729 | ············pm.Save(); |
13730 | ············pm.UnloadCache(); |
13731 | ············decimal count; |
13732 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13733 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13734 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13735 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13736 | ········} |
13737 | ········catch (Exception) |
13738 | ········{ |
13739 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13740 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13741 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13742 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
13743 | ········} |
13744 | ····} |
13745 | ····[Test] |
13746 | ····public void TestSaveReload() |
13747 | ····{ |
13748 | ········CreateObjects(); |
13749 | ········QueryOwn(); |
13750 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13751 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13752 | ····} |
13753 | ····[Test] |
13754 | ····public void TestSaveReloadNull() |
13755 | ····{ |
13756 | ········CreateObjects(); |
13757 | ········QueryOwn(); |
13758 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13759 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13760 | ········ownVar.RelField = null; |
13761 | ········pm.Save(); |
13762 | ········pm.UnloadCache(); |
13763 | ········QueryOwn(); |
13764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13765 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13766 | ····} |
13767 | ····[Test] |
13768 | ····public void TestChangeKeyHolderLeft() |
13769 | ····{ |
13770 | ········CreateObjects(); |
13771 | ········QueryOwn(); |
13772 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13773 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13774 | ········int x = ownVar.RelField.Dummy; |
13775 | ········ownVar.Dummy = 4711; |
13776 | ········pm.Save(); |
13777 | ········pm.UnloadCache(); |
13778 | ········QueryOwn(); |
13779 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13780 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13781 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13782 | ····} |
13783 | ····[Test] |
13784 | ····public void TestChangeKeyHolderLeftNoTouch() |
13785 | ····{ |
13786 | ········CreateObjects(); |
13787 | ········QueryOwn(); |
13788 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13789 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13790 | ········ownVar.Dummy = 4711; |
13791 | ········pm.Save(); |
13792 | ········pm.UnloadCache(); |
13793 | ········QueryOwn(); |
13794 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13795 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13796 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13797 | ····} |
13798 | ····void CreateObjects() |
13799 | ····{ |
13800 | ········pm.MakePersistent(ownVar); |
13801 | ········ownVar.AssignRelation(otherVar); |
13802 | ········pm.Save(); |
13803 | ········pm.UnloadCache(); |
13804 | ····} |
13805 | ····void QueryOwn() |
13806 | ····{ |
13807 | ········var q = new NDOQuery<CmpDir1OwnpconTblGuidLeftBase>(pm); |
13808 | ········ownVar = q.ExecuteSingle(); |
13809 | ····} |
13810 | ····void QueryOther() |
13811 | ····{ |
13812 | ········var q = new NDOQuery<CmpDir1OwnpconTblGuidRight>(pm); |
13813 | ········otherVar = q.ExecuteSingle(); |
13814 | ····} |
13815 | } |
13816 | |
13817 | |
13818 | [TestFixture] |
13819 | public class TestCmpBi11OwnpconNoTblGuid : NDOTest |
13820 | { |
13821 | ····CmpBi11OwnpconNoTblGuidLeftBase ownVar; |
13822 | ····CmpBi11OwnpconNoTblGuidRight otherVar; |
13823 | ····PersistenceManager pm; |
13824 | ····[SetUp] |
13825 | ····public void Setup() |
13826 | ····{ |
13827 | ········pm = PmFactory.NewPersistenceManager(); |
13828 | ········ownVar = new CmpBi11OwnpconNoTblGuidLeftDerived(); |
13829 | ········otherVar = new CmpBi11OwnpconNoTblGuidRight(); |
13830 | ····} |
13831 | ····[TearDown] |
13832 | ····public void TearDown() |
13833 | ····{ |
13834 | ········try |
13835 | ········{ |
13836 | ············pm.UnloadCache(); |
13837 | ············var l = pm.Objects<CmpBi11OwnpconNoTblGuidLeftBase>().ResultTable; |
13838 | ············pm.Delete(l); |
13839 | ············pm.Save(); |
13840 | ············pm.UnloadCache(); |
13841 | ············decimal count; |
13842 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13843 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13844 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13845 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
13846 | ········} |
13847 | ········catch (Exception) |
13848 | ········{ |
13849 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
13850 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
13851 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
13852 | ········} |
13853 | ····} |
13854 | ····[Test] |
13855 | ····public void TestSaveReload() |
13856 | ····{ |
13857 | ········CreateObjects(); |
13858 | ········QueryOwn(); |
13859 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13861 | ····} |
13862 | ····[Test] |
13863 | ····public void TestSaveReloadNull() |
13864 | ····{ |
13865 | ········CreateObjects(); |
13866 | ········QueryOwn(); |
13867 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13868 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13869 | ········ownVar.RelField = null; |
13870 | ········pm.Save(); |
13871 | ········pm.UnloadCache(); |
13872 | ········QueryOwn(); |
13873 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13874 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
13875 | ····} |
13876 | ····[Test] |
13877 | ····public void TestChangeKeyHolderLeft() |
13878 | ····{ |
13879 | ········CreateObjects(); |
13880 | ········QueryOwn(); |
13881 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13882 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13883 | ········int x = ownVar.RelField.Dummy; |
13884 | ········ownVar.Dummy = 4711; |
13885 | ········pm.Save(); |
13886 | ········pm.UnloadCache(); |
13887 | ········QueryOwn(); |
13888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13889 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13890 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13891 | ····} |
13892 | ····[Test] |
13893 | ····public void TestChangeKeyHolderRight() |
13894 | ····{ |
13895 | ········CreateObjects(); |
13896 | ········QueryOther(); |
13897 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13898 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13899 | ········int x = otherVar.RelField.Dummy; |
13900 | ········otherVar.Dummy = 4711; |
13901 | ········pm.Save(); |
13902 | ········pm.UnloadCache(); |
13903 | ········QueryOther(); |
13904 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13905 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13906 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13907 | ····} |
13908 | ····[Test] |
13909 | ····public void TestChangeKeyHolderLeftNoTouch() |
13910 | ····{ |
13911 | ········CreateObjects(); |
13912 | ········QueryOwn(); |
13913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13915 | ········ownVar.Dummy = 4711; |
13916 | ········pm.Save(); |
13917 | ········pm.UnloadCache(); |
13918 | ········QueryOwn(); |
13919 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
13920 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13921 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
13922 | ····} |
13923 | ····[Test] |
13924 | ····public void TestChangeKeyHolderRightNoTouch() |
13925 | ····{ |
13926 | ········CreateObjects(); |
13927 | ········QueryOther(); |
13928 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13929 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13930 | ········otherVar.Dummy = 4711; |
13931 | ········pm.Save(); |
13932 | ········pm.UnloadCache(); |
13933 | ········QueryOther(); |
13934 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
13935 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
13936 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
13937 | ····} |
13938 | ····[Test] |
13939 | ····public void TestRelationHash() |
13940 | ····{ |
13941 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidLeftBase)); |
13942 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
13943 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidRight)); |
13944 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
13945 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
13946 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
13947 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconNoTblGuidLeftDerived)); |
13948 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
13949 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
13950 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
13951 | ····} |
13952 | ····void CreateObjects() |
13953 | ····{ |
13954 | ········pm.MakePersistent(ownVar); |
13955 | ········ownVar.AssignRelation(otherVar); |
13956 | ········pm.Save(); |
13957 | ········pm.UnloadCache(); |
13958 | ····} |
13959 | ····void QueryOwn() |
13960 | ····{ |
13961 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblGuidLeftBase>(pm); |
13962 | ········ownVar = q.ExecuteSingle(); |
13963 | ····} |
13964 | ····void QueryOther() |
13965 | ····{ |
13966 | ········var q = new NDOQuery<CmpBi11OwnpconNoTblGuidRight>(pm); |
13967 | ········otherVar = q.ExecuteSingle(); |
13968 | ····} |
13969 | } |
13970 | |
13971 | |
13972 | [TestFixture] |
13973 | public class TestCmpBi11OwnpconTblGuid : NDOTest |
13974 | { |
13975 | ····CmpBi11OwnpconTblGuidLeftBase ownVar; |
13976 | ····CmpBi11OwnpconTblGuidRight otherVar; |
13977 | ····PersistenceManager pm; |
13978 | ····[SetUp] |
13979 | ····public void Setup() |
13980 | ····{ |
13981 | ········pm = PmFactory.NewPersistenceManager(); |
13982 | ········ownVar = new CmpBi11OwnpconTblGuidLeftDerived(); |
13983 | ········otherVar = new CmpBi11OwnpconTblGuidRight(); |
13984 | ····} |
13985 | ····[TearDown] |
13986 | ····public void TearDown() |
13987 | ····{ |
13988 | ········try |
13989 | ········{ |
13990 | ············pm.UnloadCache(); |
13991 | ············var l = pm.Objects<CmpBi11OwnpconTblGuidLeftBase>().ResultTable; |
13992 | ············pm.Delete(l); |
13993 | ············pm.Save(); |
13994 | ············pm.UnloadCache(); |
13995 | ············decimal count; |
13996 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13997 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
13998 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
13999 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14000 | ········} |
14001 | ········catch (Exception) |
14002 | ········{ |
14003 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14004 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14005 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14006 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14007 | ········} |
14008 | ····} |
14009 | ····[Test] |
14010 | ····public void TestSaveReload() |
14011 | ····{ |
14012 | ········CreateObjects(); |
14013 | ········QueryOwn(); |
14014 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14015 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14016 | ····} |
14017 | ····[Test] |
14018 | ····public void TestSaveReloadNull() |
14019 | ····{ |
14020 | ········CreateObjects(); |
14021 | ········QueryOwn(); |
14022 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14023 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14024 | ········ownVar.RelField = null; |
14025 | ········pm.Save(); |
14026 | ········pm.UnloadCache(); |
14027 | ········QueryOwn(); |
14028 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14029 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14030 | ····} |
14031 | ····[Test] |
14032 | ····public void TestChangeKeyHolderLeft() |
14033 | ····{ |
14034 | ········CreateObjects(); |
14035 | ········QueryOwn(); |
14036 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14037 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14038 | ········int x = ownVar.RelField.Dummy; |
14039 | ········ownVar.Dummy = 4711; |
14040 | ········pm.Save(); |
14041 | ········pm.UnloadCache(); |
14042 | ········QueryOwn(); |
14043 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14044 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14045 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14046 | ····} |
14047 | ····[Test] |
14048 | ····public void TestChangeKeyHolderRight() |
14049 | ····{ |
14050 | ········CreateObjects(); |
14051 | ········QueryOther(); |
14052 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14053 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14054 | ········int x = otherVar.RelField.Dummy; |
14055 | ········otherVar.Dummy = 4711; |
14056 | ········pm.Save(); |
14057 | ········pm.UnloadCache(); |
14058 | ········QueryOther(); |
14059 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14060 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14061 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14062 | ····} |
14063 | ····[Test] |
14064 | ····public void TestChangeKeyHolderLeftNoTouch() |
14065 | ····{ |
14066 | ········CreateObjects(); |
14067 | ········QueryOwn(); |
14068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14070 | ········ownVar.Dummy = 4711; |
14071 | ········pm.Save(); |
14072 | ········pm.UnloadCache(); |
14073 | ········QueryOwn(); |
14074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14075 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14076 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14077 | ····} |
14078 | ····[Test] |
14079 | ····public void TestChangeKeyHolderRightNoTouch() |
14080 | ····{ |
14081 | ········CreateObjects(); |
14082 | ········QueryOther(); |
14083 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14084 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14085 | ········otherVar.Dummy = 4711; |
14086 | ········pm.Save(); |
14087 | ········pm.UnloadCache(); |
14088 | ········QueryOther(); |
14089 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14090 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14091 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14092 | ····} |
14093 | ····[Test] |
14094 | ····public void TestRelationHash() |
14095 | ····{ |
14096 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidLeftBase)); |
14097 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14098 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidRight)); |
14099 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14100 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14101 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14102 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconTblGuidLeftDerived)); |
14103 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14104 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14105 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14106 | ····} |
14107 | ····void CreateObjects() |
14108 | ····{ |
14109 | ········pm.MakePersistent(ownVar); |
14110 | ········ownVar.AssignRelation(otherVar); |
14111 | ········pm.Save(); |
14112 | ········pm.UnloadCache(); |
14113 | ····} |
14114 | ····void QueryOwn() |
14115 | ····{ |
14116 | ········var q = new NDOQuery<CmpBi11OwnpconTblGuidLeftBase>(pm); |
14117 | ········ownVar = q.ExecuteSingle(); |
14118 | ····} |
14119 | ····void QueryOther() |
14120 | ····{ |
14121 | ········var q = new NDOQuery<CmpBi11OwnpconTblGuidRight>(pm); |
14122 | ········otherVar = q.ExecuteSingle(); |
14123 | ····} |
14124 | } |
14125 | |
14126 | |
14127 | [TestFixture] |
14128 | public class TestCmpDirnOwnpconNoTblGuid : NDOTest |
14129 | { |
14130 | ····CmpDirnOwnpconNoTblGuidLeftBase ownVar; |
14131 | ····CmpDirnOwnpconNoTblGuidRight otherVar; |
14132 | ····PersistenceManager pm; |
14133 | ····[SetUp] |
14134 | ····public void Setup() |
14135 | ····{ |
14136 | ········pm = PmFactory.NewPersistenceManager(); |
14137 | ········ownVar = new CmpDirnOwnpconNoTblGuidLeftDerived(); |
14138 | ········otherVar = new CmpDirnOwnpconNoTblGuidRight(); |
14139 | ····} |
14140 | ····[TearDown] |
14141 | ····public void TearDown() |
14142 | ····{ |
14143 | ········try |
14144 | ········{ |
14145 | ············pm.UnloadCache(); |
14146 | ············var l = pm.Objects<CmpDirnOwnpconNoTblGuidLeftBase>().ResultTable; |
14147 | ············pm.Delete(l); |
14148 | ············pm.Save(); |
14149 | ············pm.UnloadCache(); |
14150 | ············decimal count; |
14151 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14152 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14153 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14154 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14155 | ········} |
14156 | ········catch (Exception) |
14157 | ········{ |
14158 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14159 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14160 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14161 | ········} |
14162 | ····} |
14163 | ····[Test] |
14164 | ····public void TestSaveReload() |
14165 | ····{ |
14166 | ········CreateObjects(); |
14167 | ········QueryOwn(); |
14168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14169 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14170 | ····} |
14171 | ····[Test] |
14172 | ····public void TestSaveReloadNull() |
14173 | ····{ |
14174 | ········CreateObjects(); |
14175 | ········QueryOwn(); |
14176 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14177 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14178 | ········ownVar.RelField = new List<CmpDirnOwnpconNoTblGuidRight>(); |
14179 | ········pm.Save(); |
14180 | ········pm.UnloadCache(); |
14181 | ········QueryOwn(); |
14182 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14183 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14184 | ····} |
14185 | ····[Test] |
14186 | ····public void TestSaveReloadRemove() |
14187 | ····{ |
14188 | ········CreateObjects(); |
14189 | ········QueryOwn(); |
14190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14191 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14192 | ········ownVar.RemoveRelatedObject(); |
14193 | ········pm.Save(); |
14194 | ········pm.UnloadCache(); |
14195 | ········QueryOwn(); |
14196 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14197 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14198 | ····} |
14199 | ····void CreateObjects() |
14200 | ····{ |
14201 | ········pm.MakePersistent(ownVar); |
14202 | ········ownVar.AssignRelation(otherVar); |
14203 | ········pm.Save(); |
14204 | ········pm.UnloadCache(); |
14205 | ····} |
14206 | ····void QueryOwn() |
14207 | ····{ |
14208 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblGuidLeftBase>(pm); |
14209 | ········ownVar = q.ExecuteSingle(); |
14210 | ····} |
14211 | ····void QueryOther() |
14212 | ····{ |
14213 | ········var q = new NDOQuery<CmpDirnOwnpconNoTblGuidRight>(pm); |
14214 | ········otherVar = q.ExecuteSingle(); |
14215 | ····} |
14216 | } |
14217 | |
14218 | |
14219 | [TestFixture] |
14220 | public class TestCmpDirnOwnpconTblGuid : NDOTest |
14221 | { |
14222 | ····CmpDirnOwnpconTblGuidLeftBase ownVar; |
14223 | ····CmpDirnOwnpconTblGuidRight otherVar; |
14224 | ····PersistenceManager pm; |
14225 | ····[SetUp] |
14226 | ····public void Setup() |
14227 | ····{ |
14228 | ········pm = PmFactory.NewPersistenceManager(); |
14229 | ········ownVar = new CmpDirnOwnpconTblGuidLeftDerived(); |
14230 | ········otherVar = new CmpDirnOwnpconTblGuidRight(); |
14231 | ····} |
14232 | ····[TearDown] |
14233 | ····public void TearDown() |
14234 | ····{ |
14235 | ········try |
14236 | ········{ |
14237 | ············pm.UnloadCache(); |
14238 | ············var l = pm.Objects<CmpDirnOwnpconTblGuidLeftBase>().ResultTable; |
14239 | ············pm.Delete(l); |
14240 | ············pm.Save(); |
14241 | ············pm.UnloadCache(); |
14242 | ············decimal count; |
14243 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14245 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14247 | ········} |
14248 | ········catch (Exception) |
14249 | ········{ |
14250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14253 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14254 | ········} |
14255 | ····} |
14256 | ····[Test] |
14257 | ····public void TestSaveReload() |
14258 | ····{ |
14259 | ········CreateObjects(); |
14260 | ········QueryOwn(); |
14261 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14262 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14263 | ····} |
14264 | ····[Test] |
14265 | ····public void TestSaveReloadNull() |
14266 | ····{ |
14267 | ········CreateObjects(); |
14268 | ········QueryOwn(); |
14269 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14270 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14271 | ········ownVar.RelField = new List<CmpDirnOwnpconTblGuidRight>(); |
14272 | ········pm.Save(); |
14273 | ········pm.UnloadCache(); |
14274 | ········QueryOwn(); |
14275 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14276 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14277 | ····} |
14278 | ····[Test] |
14279 | ····public void TestSaveReloadRemove() |
14280 | ····{ |
14281 | ········CreateObjects(); |
14282 | ········QueryOwn(); |
14283 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14284 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14285 | ········ownVar.RemoveRelatedObject(); |
14286 | ········pm.Save(); |
14287 | ········pm.UnloadCache(); |
14288 | ········QueryOwn(); |
14289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14290 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14291 | ····} |
14292 | ····void CreateObjects() |
14293 | ····{ |
14294 | ········pm.MakePersistent(ownVar); |
14295 | ········ownVar.AssignRelation(otherVar); |
14296 | ········pm.Save(); |
14297 | ········pm.UnloadCache(); |
14298 | ····} |
14299 | ····void QueryOwn() |
14300 | ····{ |
14301 | ········var q = new NDOQuery<CmpDirnOwnpconTblGuidLeftBase>(pm); |
14302 | ········ownVar = q.ExecuteSingle(); |
14303 | ····} |
14304 | ····void QueryOther() |
14305 | ····{ |
14306 | ········var q = new NDOQuery<CmpDirnOwnpconTblGuidRight>(pm); |
14307 | ········otherVar = q.ExecuteSingle(); |
14308 | ····} |
14309 | } |
14310 | |
14311 | |
14312 | [TestFixture] |
14313 | public class TestCmpBin1OwnpconNoTblGuid : NDOTest |
14314 | { |
14315 | ····CmpBin1OwnpconNoTblGuidLeftBase ownVar; |
14316 | ····CmpBin1OwnpconNoTblGuidRight otherVar; |
14317 | ····PersistenceManager pm; |
14318 | ····[SetUp] |
14319 | ····public void Setup() |
14320 | ····{ |
14321 | ········pm = PmFactory.NewPersistenceManager(); |
14322 | ········ownVar = new CmpBin1OwnpconNoTblGuidLeftDerived(); |
14323 | ········otherVar = new CmpBin1OwnpconNoTblGuidRight(); |
14324 | ····} |
14325 | ····[TearDown] |
14326 | ····public void TearDown() |
14327 | ····{ |
14328 | ········try |
14329 | ········{ |
14330 | ············pm.UnloadCache(); |
14331 | ············var l = pm.Objects<CmpBin1OwnpconNoTblGuidLeftBase>().ResultTable; |
14332 | ············pm.Delete(l); |
14333 | ············pm.Save(); |
14334 | ············pm.UnloadCache(); |
14335 | ············decimal count; |
14336 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14337 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14338 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14339 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14340 | ········} |
14341 | ········catch (Exception) |
14342 | ········{ |
14343 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14344 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14345 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14346 | ········} |
14347 | ····} |
14348 | ····[Test] |
14349 | ····public void TestSaveReload() |
14350 | ····{ |
14351 | ········CreateObjects(); |
14352 | ········QueryOwn(); |
14353 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14354 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14355 | ····} |
14356 | ····[Test] |
14357 | ····public void TestSaveReloadNull() |
14358 | ····{ |
14359 | ········CreateObjects(); |
14360 | ········QueryOwn(); |
14361 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14362 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14363 | ········ownVar.RelField = new List<CmpBin1OwnpconNoTblGuidRight>(); |
14364 | ········pm.Save(); |
14365 | ········pm.UnloadCache(); |
14366 | ········QueryOwn(); |
14367 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14368 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14369 | ····} |
14370 | ····[Test] |
14371 | ····public void TestSaveReloadRemove() |
14372 | ····{ |
14373 | ········CreateObjects(); |
14374 | ········QueryOwn(); |
14375 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14376 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14377 | ········ownVar.RemoveRelatedObject(); |
14378 | ········pm.Save(); |
14379 | ········pm.UnloadCache(); |
14380 | ········QueryOwn(); |
14381 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14382 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14383 | ····} |
14384 | ····[Test] |
14385 | ····public void TestChangeKeyHolderRight() |
14386 | ····{ |
14387 | ········CreateObjects(); |
14388 | ········QueryOther(); |
14389 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14390 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14391 | ········int x = otherVar.RelField.Dummy; |
14392 | ········otherVar.Dummy = 4711; |
14393 | ········pm.Save(); |
14394 | ········pm.UnloadCache(); |
14395 | ········QueryOther(); |
14396 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14397 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14398 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14399 | ····} |
14400 | ····[Test] |
14401 | ····public void TestChangeKeyHolderRightNoTouch() |
14402 | ····{ |
14403 | ········CreateObjects(); |
14404 | ········QueryOther(); |
14405 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14406 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14407 | ········otherVar.Dummy = 4711; |
14408 | ········pm.Save(); |
14409 | ········pm.UnloadCache(); |
14410 | ········QueryOther(); |
14411 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14412 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14413 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14414 | ····} |
14415 | ····[Test] |
14416 | ····public void TestRelationHash() |
14417 | ····{ |
14418 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidLeftBase)); |
14419 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14420 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidRight)); |
14421 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14422 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14423 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14424 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconNoTblGuidLeftDerived)); |
14425 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14426 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14427 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14428 | ····} |
14429 | ····void CreateObjects() |
14430 | ····{ |
14431 | ········pm.MakePersistent(ownVar); |
14432 | ········ownVar.AssignRelation(otherVar); |
14433 | ········pm.Save(); |
14434 | ········pm.UnloadCache(); |
14435 | ····} |
14436 | ····void QueryOwn() |
14437 | ····{ |
14438 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblGuidLeftBase>(pm); |
14439 | ········ownVar = q.ExecuteSingle(); |
14440 | ····} |
14441 | ····void QueryOther() |
14442 | ····{ |
14443 | ········var q = new NDOQuery<CmpBin1OwnpconNoTblGuidRight>(pm); |
14444 | ········otherVar = q.ExecuteSingle(); |
14445 | ····} |
14446 | } |
14447 | |
14448 | |
14449 | [TestFixture] |
14450 | public class TestCmpBin1OwnpconTblGuid : NDOTest |
14451 | { |
14452 | ····CmpBin1OwnpconTblGuidLeftBase ownVar; |
14453 | ····CmpBin1OwnpconTblGuidRight otherVar; |
14454 | ····PersistenceManager pm; |
14455 | ····[SetUp] |
14456 | ····public void Setup() |
14457 | ····{ |
14458 | ········pm = PmFactory.NewPersistenceManager(); |
14459 | ········ownVar = new CmpBin1OwnpconTblGuidLeftDerived(); |
14460 | ········otherVar = new CmpBin1OwnpconTblGuidRight(); |
14461 | ····} |
14462 | ····[TearDown] |
14463 | ····public void TearDown() |
14464 | ····{ |
14465 | ········try |
14466 | ········{ |
14467 | ············pm.UnloadCache(); |
14468 | ············var l = pm.Objects<CmpBin1OwnpconTblGuidLeftBase>().ResultTable; |
14469 | ············pm.Delete(l); |
14470 | ············pm.Save(); |
14471 | ············pm.UnloadCache(); |
14472 | ············decimal count; |
14473 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14474 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14475 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14476 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14477 | ········} |
14478 | ········catch (Exception) |
14479 | ········{ |
14480 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14481 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14482 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14483 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14484 | ········} |
14485 | ····} |
14486 | ····[Test] |
14487 | ····public void TestSaveReload() |
14488 | ····{ |
14489 | ········CreateObjects(); |
14490 | ········QueryOwn(); |
14491 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14492 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14493 | ····} |
14494 | ····[Test] |
14495 | ····public void TestSaveReloadNull() |
14496 | ····{ |
14497 | ········CreateObjects(); |
14498 | ········QueryOwn(); |
14499 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14500 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14501 | ········ownVar.RelField = new List<CmpBin1OwnpconTblGuidRight>(); |
14502 | ········pm.Save(); |
14503 | ········pm.UnloadCache(); |
14504 | ········QueryOwn(); |
14505 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14506 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14507 | ····} |
14508 | ····[Test] |
14509 | ····public void TestSaveReloadRemove() |
14510 | ····{ |
14511 | ········CreateObjects(); |
14512 | ········QueryOwn(); |
14513 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14514 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14515 | ········ownVar.RemoveRelatedObject(); |
14516 | ········pm.Save(); |
14517 | ········pm.UnloadCache(); |
14518 | ········QueryOwn(); |
14519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14520 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14521 | ····} |
14522 | ····[Test] |
14523 | ····public void TestChangeKeyHolderRight() |
14524 | ····{ |
14525 | ········CreateObjects(); |
14526 | ········QueryOther(); |
14527 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14528 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14529 | ········int x = otherVar.RelField.Dummy; |
14530 | ········otherVar.Dummy = 4711; |
14531 | ········pm.Save(); |
14532 | ········pm.UnloadCache(); |
14533 | ········QueryOther(); |
14534 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14535 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14536 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14537 | ····} |
14538 | ····[Test] |
14539 | ····public void TestChangeKeyHolderRightNoTouch() |
14540 | ····{ |
14541 | ········CreateObjects(); |
14542 | ········QueryOther(); |
14543 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14544 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14545 | ········otherVar.Dummy = 4711; |
14546 | ········pm.Save(); |
14547 | ········pm.UnloadCache(); |
14548 | ········QueryOther(); |
14549 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
14550 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14551 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
14552 | ····} |
14553 | ····[Test] |
14554 | ····public void TestRelationHash() |
14555 | ····{ |
14556 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidLeftBase)); |
14557 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14558 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidRight)); |
14559 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14560 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14561 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14562 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconTblGuidLeftDerived)); |
14563 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14564 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14565 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14566 | ····} |
14567 | ····void CreateObjects() |
14568 | ····{ |
14569 | ········pm.MakePersistent(ownVar); |
14570 | ········ownVar.AssignRelation(otherVar); |
14571 | ········pm.Save(); |
14572 | ········pm.UnloadCache(); |
14573 | ····} |
14574 | ····void QueryOwn() |
14575 | ····{ |
14576 | ········var q = new NDOQuery<CmpBin1OwnpconTblGuidLeftBase>(pm); |
14577 | ········ownVar = q.ExecuteSingle(); |
14578 | ····} |
14579 | ····void QueryOther() |
14580 | ····{ |
14581 | ········var q = new NDOQuery<CmpBin1OwnpconTblGuidRight>(pm); |
14582 | ········otherVar = q.ExecuteSingle(); |
14583 | ····} |
14584 | } |
14585 | |
14586 | |
14587 | [TestFixture] |
14588 | public class TestCmpBi1nOwnpconTblGuid : NDOTest |
14589 | { |
14590 | ····CmpBi1nOwnpconTblGuidLeftBase ownVar; |
14591 | ····CmpBi1nOwnpconTblGuidRight otherVar; |
14592 | ····PersistenceManager pm; |
14593 | ····[SetUp] |
14594 | ····public void Setup() |
14595 | ····{ |
14596 | ········pm = PmFactory.NewPersistenceManager(); |
14597 | ········ownVar = new CmpBi1nOwnpconTblGuidLeftDerived(); |
14598 | ········otherVar = new CmpBi1nOwnpconTblGuidRight(); |
14599 | ····} |
14600 | ····[TearDown] |
14601 | ····public void TearDown() |
14602 | ····{ |
14603 | ········try |
14604 | ········{ |
14605 | ············pm.UnloadCache(); |
14606 | ············var l = pm.Objects<CmpBi1nOwnpconTblGuidLeftBase>().ResultTable; |
14607 | ············pm.Delete(l); |
14608 | ············pm.Save(); |
14609 | ············pm.UnloadCache(); |
14610 | ············decimal count; |
14611 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14612 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14613 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14614 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14615 | ········} |
14616 | ········catch (Exception) |
14617 | ········{ |
14618 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14619 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14620 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14621 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14622 | ········} |
14623 | ····} |
14624 | ····[Test] |
14625 | ····public void TestSaveReload() |
14626 | ····{ |
14627 | ········CreateObjects(); |
14628 | ········QueryOwn(); |
14629 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14630 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14631 | ····} |
14632 | ····[Test] |
14633 | ····public void TestSaveReloadNull() |
14634 | ····{ |
14635 | ········CreateObjects(); |
14636 | ········QueryOwn(); |
14637 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14638 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14639 | ········ownVar.RelField = null; |
14640 | ········pm.Save(); |
14641 | ········pm.UnloadCache(); |
14642 | ········QueryOwn(); |
14643 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14644 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14645 | ····} |
14646 | ····[Test] |
14647 | ····public void TestChangeKeyHolderLeft() |
14648 | ····{ |
14649 | ········CreateObjects(); |
14650 | ········QueryOwn(); |
14651 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14652 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14653 | ········int x = ownVar.RelField.Dummy; |
14654 | ········ownVar.Dummy = 4711; |
14655 | ········pm.Save(); |
14656 | ········pm.UnloadCache(); |
14657 | ········QueryOwn(); |
14658 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14659 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14660 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14661 | ····} |
14662 | ····[Test] |
14663 | ····public void TestChangeKeyHolderLeftNoTouch() |
14664 | ····{ |
14665 | ········CreateObjects(); |
14666 | ········QueryOwn(); |
14667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14669 | ········ownVar.Dummy = 4711; |
14670 | ········pm.Save(); |
14671 | ········pm.UnloadCache(); |
14672 | ········QueryOwn(); |
14673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14674 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14676 | ····} |
14677 | ····[Test] |
14678 | ····public void TestRelationHash() |
14679 | ····{ |
14680 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidLeftBase)); |
14681 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14682 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidRight)); |
14683 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14684 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14685 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14686 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconTblGuidLeftDerived)); |
14687 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14688 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14689 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14690 | ····} |
14691 | ····void CreateObjects() |
14692 | ····{ |
14693 | ········pm.MakePersistent(ownVar); |
14694 | ········ownVar.AssignRelation(otherVar); |
14695 | ········pm.Save(); |
14696 | ········pm.UnloadCache(); |
14697 | ····} |
14698 | ····void QueryOwn() |
14699 | ····{ |
14700 | ········var q = new NDOQuery<CmpBi1nOwnpconTblGuidLeftBase>(pm); |
14701 | ········ownVar = q.ExecuteSingle(); |
14702 | ····} |
14703 | ····void QueryOther() |
14704 | ····{ |
14705 | ········var q = new NDOQuery<CmpBi1nOwnpconTblGuidRight>(pm); |
14706 | ········otherVar = q.ExecuteSingle(); |
14707 | ····} |
14708 | } |
14709 | |
14710 | |
14711 | [TestFixture] |
14712 | public class TestCmpBinnOwnpconTblGuid : NDOTest |
14713 | { |
14714 | ····CmpBinnOwnpconTblGuidLeftBase ownVar; |
14715 | ····CmpBinnOwnpconTblGuidRight otherVar; |
14716 | ····PersistenceManager pm; |
14717 | ····[SetUp] |
14718 | ····public void Setup() |
14719 | ····{ |
14720 | ········pm = PmFactory.NewPersistenceManager(); |
14721 | ········ownVar = new CmpBinnOwnpconTblGuidLeftDerived(); |
14722 | ········otherVar = new CmpBinnOwnpconTblGuidRight(); |
14723 | ····} |
14724 | ····[TearDown] |
14725 | ····public void TearDown() |
14726 | ····{ |
14727 | ········try |
14728 | ········{ |
14729 | ············pm.UnloadCache(); |
14730 | ············var l = pm.Objects<CmpBinnOwnpconTblGuidLeftBase>().ResultTable; |
14731 | ············pm.Delete(l); |
14732 | ············pm.Save(); |
14733 | ············pm.UnloadCache(); |
14734 | ············decimal count; |
14735 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14736 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14737 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14738 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14739 | ········} |
14740 | ········catch (Exception) |
14741 | ········{ |
14742 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14743 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14744 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14745 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14746 | ········} |
14747 | ····} |
14748 | ····[Test] |
14749 | ····public void TestSaveReload() |
14750 | ····{ |
14751 | ········CreateObjects(); |
14752 | ········QueryOwn(); |
14753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14754 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14755 | ····} |
14756 | ····[Test] |
14757 | ····public void TestSaveReloadNull() |
14758 | ····{ |
14759 | ········CreateObjects(); |
14760 | ········QueryOwn(); |
14761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14762 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14763 | ········ownVar.RelField = new List<CmpBinnOwnpconTblGuidRight>(); |
14764 | ········pm.Save(); |
14765 | ········pm.UnloadCache(); |
14766 | ········QueryOwn(); |
14767 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14768 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14769 | ····} |
14770 | ····[Test] |
14771 | ····public void TestSaveReloadRemove() |
14772 | ····{ |
14773 | ········CreateObjects(); |
14774 | ········QueryOwn(); |
14775 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14776 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14777 | ········ownVar.RemoveRelatedObject(); |
14778 | ········pm.Save(); |
14779 | ········pm.UnloadCache(); |
14780 | ········QueryOwn(); |
14781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14782 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
14783 | ····} |
14784 | ····[Test] |
14785 | ····public void TestRelationHash() |
14786 | ····{ |
14787 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidLeftBase)); |
14788 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
14789 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidRight)); |
14790 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
14791 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
14792 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
14793 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconTblGuidLeftDerived)); |
14794 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
14795 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
14796 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
14797 | ····} |
14798 | ····void CreateObjects() |
14799 | ····{ |
14800 | ········pm.MakePersistent(ownVar); |
14801 | ········ownVar.AssignRelation(otherVar); |
14802 | ········pm.Save(); |
14803 | ········pm.UnloadCache(); |
14804 | ····} |
14805 | ····void QueryOwn() |
14806 | ····{ |
14807 | ········var q = new NDOQuery<CmpBinnOwnpconTblGuidLeftBase>(pm); |
14808 | ········ownVar = q.ExecuteSingle(); |
14809 | ····} |
14810 | ····void QueryOther() |
14811 | ····{ |
14812 | ········var q = new NDOQuery<CmpBinnOwnpconTblGuidRight>(pm); |
14813 | ········otherVar = q.ExecuteSingle(); |
14814 | ····} |
14815 | } |
14816 | |
14817 | |
14818 | [TestFixture] |
14819 | public class TestAgrDir1OthpconNoTblGuid : NDOTest |
14820 | { |
14821 | ····AgrDir1OthpconNoTblGuidLeft ownVar; |
14822 | ····AgrDir1OthpconNoTblGuidRightBase otherVar; |
14823 | ····PersistenceManager pm; |
14824 | ····[SetUp] |
14825 | ····public void Setup() |
14826 | ····{ |
14827 | ········pm = PmFactory.NewPersistenceManager(); |
14828 | ········ownVar = new AgrDir1OthpconNoTblGuidLeft(); |
14829 | ········otherVar = new AgrDir1OthpconNoTblGuidRightDerived(); |
14830 | ····} |
14831 | ····[TearDown] |
14832 | ····public void TearDown() |
14833 | ····{ |
14834 | ········try |
14835 | ········{ |
14836 | ············pm.UnloadCache(); |
14837 | ············var l = pm.Objects<AgrDir1OthpconNoTblGuidLeft>().ResultTable; |
14838 | ············pm.Delete(l); |
14839 | ············pm.Save(); |
14840 | ············pm.UnloadCache(); |
14841 | ············var m = pm.Objects<AgrDir1OthpconNoTblGuidRightBase>().ResultTable; |
14842 | ············pm.Delete(m); |
14843 | ············pm.Save(); |
14844 | ············pm.UnloadCache(); |
14845 | ············decimal count; |
14846 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14847 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14848 | ············count = (decimal) new NDOQuery<AgrDir1OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14849 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14850 | ········} |
14851 | ········catch (Exception) |
14852 | ········{ |
14853 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14854 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14855 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14856 | ········} |
14857 | ····} |
14858 | ····[Test] |
14859 | ····public void TestSaveReload() |
14860 | ····{ |
14861 | ········CreateObjects(); |
14862 | ········QueryOwn(); |
14863 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14864 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14865 | ····} |
14866 | ····[Test] |
14867 | ····public void TestSaveReloadNull() |
14868 | ····{ |
14869 | ········CreateObjects(); |
14870 | ········QueryOwn(); |
14871 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14872 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14873 | ········ownVar.RelField = null; |
14874 | ········pm.Save(); |
14875 | ········pm.UnloadCache(); |
14876 | ········QueryOwn(); |
14877 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14878 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14879 | ····} |
14880 | ····[Test] |
14881 | ····public void TestChangeKeyHolderLeft() |
14882 | ····{ |
14883 | ········CreateObjects(); |
14884 | ········QueryOwn(); |
14885 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14886 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14887 | ········int x = ownVar.RelField.Dummy; |
14888 | ········ownVar.Dummy = 4711; |
14889 | ········pm.Save(); |
14890 | ········pm.UnloadCache(); |
14891 | ········QueryOwn(); |
14892 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14893 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14894 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14895 | ····} |
14896 | ····[Test] |
14897 | ····public void TestChangeKeyHolderLeftNoTouch() |
14898 | ····{ |
14899 | ········CreateObjects(); |
14900 | ········QueryOwn(); |
14901 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14902 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14903 | ········ownVar.Dummy = 4711; |
14904 | ········pm.Save(); |
14905 | ········pm.UnloadCache(); |
14906 | ········QueryOwn(); |
14907 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14908 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
14909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14910 | ····} |
14911 | ····void CreateObjects() |
14912 | ····{ |
14913 | ········pm.MakePersistent(ownVar); |
14914 | ········pm.MakePersistent(otherVar); |
14915 | ········ownVar.AssignRelation(otherVar); |
14916 | ········pm.Save(); |
14917 | ········pm.UnloadCache(); |
14918 | ····} |
14919 | ····void QueryOwn() |
14920 | ····{ |
14921 | ········var q = new NDOQuery<AgrDir1OthpconNoTblGuidLeft>(pm); |
14922 | ········ownVar = q.ExecuteSingle(); |
14923 | ····} |
14924 | ····void QueryOther() |
14925 | ····{ |
14926 | ········var q = new NDOQuery<AgrDir1OthpconNoTblGuidRightBase>(pm); |
14927 | ········otherVar = q.ExecuteSingle(); |
14928 | ····} |
14929 | } |
14930 | |
14931 | |
14932 | [TestFixture] |
14933 | public class TestAgrDir1OthpconTblGuid : NDOTest |
14934 | { |
14935 | ····AgrDir1OthpconTblGuidLeft ownVar; |
14936 | ····AgrDir1OthpconTblGuidRightBase otherVar; |
14937 | ····PersistenceManager pm; |
14938 | ····[SetUp] |
14939 | ····public void Setup() |
14940 | ····{ |
14941 | ········pm = PmFactory.NewPersistenceManager(); |
14942 | ········ownVar = new AgrDir1OthpconTblGuidLeft(); |
14943 | ········otherVar = new AgrDir1OthpconTblGuidRightDerived(); |
14944 | ····} |
14945 | ····[TearDown] |
14946 | ····public void TearDown() |
14947 | ····{ |
14948 | ········try |
14949 | ········{ |
14950 | ············pm.UnloadCache(); |
14951 | ············var l = pm.Objects<AgrDir1OthpconTblGuidLeft>().ResultTable; |
14952 | ············pm.Delete(l); |
14953 | ············pm.Save(); |
14954 | ············pm.UnloadCache(); |
14955 | ············var m = pm.Objects<AgrDir1OthpconTblGuidRightBase>().ResultTable; |
14956 | ············pm.Delete(m); |
14957 | ············pm.Save(); |
14958 | ············pm.UnloadCache(); |
14959 | ············decimal count; |
14960 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14961 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
14962 | ············count = (decimal) new NDOQuery<AgrDir1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
14963 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
14964 | ········} |
14965 | ········catch (Exception) |
14966 | ········{ |
14967 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
14968 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
14969 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
14970 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
14971 | ········} |
14972 | ····} |
14973 | ····[Test] |
14974 | ····public void TestSaveReload() |
14975 | ····{ |
14976 | ········CreateObjects(); |
14977 | ········QueryOwn(); |
14978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14979 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14980 | ····} |
14981 | ····[Test] |
14982 | ····public void TestSaveReloadNull() |
14983 | ····{ |
14984 | ········CreateObjects(); |
14985 | ········QueryOwn(); |
14986 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14987 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
14988 | ········ownVar.RelField = null; |
14989 | ········pm.Save(); |
14990 | ········pm.UnloadCache(); |
14991 | ········QueryOwn(); |
14992 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
14993 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
14994 | ····} |
14995 | ····[Test] |
14996 | ····public void TestChangeKeyHolderLeft() |
14997 | ····{ |
14998 | ········CreateObjects(); |
14999 | ········QueryOwn(); |
15000 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15001 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15002 | ········int x = ownVar.RelField.Dummy; |
15003 | ········ownVar.Dummy = 4711; |
15004 | ········pm.Save(); |
15005 | ········pm.UnloadCache(); |
15006 | ········QueryOwn(); |
15007 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15008 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15009 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15010 | ····} |
15011 | ····[Test] |
15012 | ····public void TestChangeKeyHolderLeftNoTouch() |
15013 | ····{ |
15014 | ········CreateObjects(); |
15015 | ········QueryOwn(); |
15016 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15017 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15018 | ········ownVar.Dummy = 4711; |
15019 | ········pm.Save(); |
15020 | ········pm.UnloadCache(); |
15021 | ········QueryOwn(); |
15022 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15023 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15024 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15025 | ····} |
15026 | ····void CreateObjects() |
15027 | ····{ |
15028 | ········pm.MakePersistent(ownVar); |
15029 | ········pm.MakePersistent(otherVar); |
15030 | ········ownVar.AssignRelation(otherVar); |
15031 | ········pm.Save(); |
15032 | ········pm.UnloadCache(); |
15033 | ····} |
15034 | ····void QueryOwn() |
15035 | ····{ |
15036 | ········var q = new NDOQuery<AgrDir1OthpconTblGuidLeft>(pm); |
15037 | ········ownVar = q.ExecuteSingle(); |
15038 | ····} |
15039 | ····void QueryOther() |
15040 | ····{ |
15041 | ········var q = new NDOQuery<AgrDir1OthpconTblGuidRightBase>(pm); |
15042 | ········otherVar = q.ExecuteSingle(); |
15043 | ····} |
15044 | } |
15045 | |
15046 | |
15047 | [TestFixture] |
15048 | public class TestAgrBi11OthpconNoTblGuid : NDOTest |
15049 | { |
15050 | ····AgrBi11OthpconNoTblGuidLeft ownVar; |
15051 | ····AgrBi11OthpconNoTblGuidRightBase otherVar; |
15052 | ····PersistenceManager pm; |
15053 | ····[SetUp] |
15054 | ····public void Setup() |
15055 | ····{ |
15056 | ········pm = PmFactory.NewPersistenceManager(); |
15057 | ········ownVar = new AgrBi11OthpconNoTblGuidLeft(); |
15058 | ········otherVar = new AgrBi11OthpconNoTblGuidRightDerived(); |
15059 | ····} |
15060 | ····[TearDown] |
15061 | ····public void TearDown() |
15062 | ····{ |
15063 | ········try |
15064 | ········{ |
15065 | ············pm.UnloadCache(); |
15066 | ············var l = pm.Objects<AgrBi11OthpconNoTblGuidLeft>().ResultTable; |
15067 | ············pm.Delete(l); |
15068 | ············pm.Save(); |
15069 | ············pm.UnloadCache(); |
15070 | ············var m = pm.Objects<AgrBi11OthpconNoTblGuidRightBase>().ResultTable; |
15071 | ············pm.Delete(m); |
15072 | ············pm.Save(); |
15073 | ············pm.UnloadCache(); |
15074 | ············decimal count; |
15075 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15076 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15077 | ············count = (decimal) new NDOQuery<AgrBi11OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15078 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15079 | ········} |
15080 | ········catch (Exception) |
15081 | ········{ |
15082 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15083 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15084 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15085 | ········} |
15086 | ····} |
15087 | ····[Test] |
15088 | ····public void TestSaveReload() |
15089 | ····{ |
15090 | ········CreateObjects(); |
15091 | ········QueryOwn(); |
15092 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15093 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15094 | ····} |
15095 | ····[Test] |
15096 | ····public void TestSaveReloadNull() |
15097 | ····{ |
15098 | ········CreateObjects(); |
15099 | ········QueryOwn(); |
15100 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15101 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15102 | ········ownVar.RelField = null; |
15103 | ········pm.Save(); |
15104 | ········pm.UnloadCache(); |
15105 | ········QueryOwn(); |
15106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15107 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15108 | ····} |
15109 | ····[Test] |
15110 | ····public void TestChangeKeyHolderLeft() |
15111 | ····{ |
15112 | ········CreateObjects(); |
15113 | ········QueryOwn(); |
15114 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15115 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15116 | ········int x = ownVar.RelField.Dummy; |
15117 | ········ownVar.Dummy = 4711; |
15118 | ········pm.Save(); |
15119 | ········pm.UnloadCache(); |
15120 | ········QueryOwn(); |
15121 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15122 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15123 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15124 | ····} |
15125 | ····[Test] |
15126 | ····public void TestChangeKeyHolderRight() |
15127 | ····{ |
15128 | ········CreateObjects(); |
15129 | ········QueryOther(); |
15130 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15131 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15132 | ········int x = otherVar.RelField.Dummy; |
15133 | ········otherVar.Dummy = 4711; |
15134 | ········pm.Save(); |
15135 | ········pm.UnloadCache(); |
15136 | ········QueryOther(); |
15137 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15138 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15139 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15140 | ····} |
15141 | ····[Test] |
15142 | ····public void TestChangeKeyHolderLeftNoTouch() |
15143 | ····{ |
15144 | ········CreateObjects(); |
15145 | ········QueryOwn(); |
15146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15148 | ········ownVar.Dummy = 4711; |
15149 | ········pm.Save(); |
15150 | ········pm.UnloadCache(); |
15151 | ········QueryOwn(); |
15152 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15153 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15154 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15155 | ····} |
15156 | ····[Test] |
15157 | ····public void TestChangeKeyHolderRightNoTouch() |
15158 | ····{ |
15159 | ········CreateObjects(); |
15160 | ········QueryOther(); |
15161 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15162 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15163 | ········otherVar.Dummy = 4711; |
15164 | ········pm.Save(); |
15165 | ········pm.UnloadCache(); |
15166 | ········QueryOther(); |
15167 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15168 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15169 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15170 | ····} |
15171 | ····[Test] |
15172 | ····public void TestRelationHash() |
15173 | ····{ |
15174 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidLeft)); |
15175 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15176 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidRightBase)); |
15177 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15178 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15179 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15180 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconNoTblGuidRightDerived)); |
15181 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15182 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15183 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15184 | ····} |
15185 | ····void CreateObjects() |
15186 | ····{ |
15187 | ········pm.MakePersistent(ownVar); |
15188 | ········pm.MakePersistent(otherVar); |
15189 | ········ownVar.AssignRelation(otherVar); |
15190 | ········pm.Save(); |
15191 | ········pm.UnloadCache(); |
15192 | ····} |
15193 | ····void QueryOwn() |
15194 | ····{ |
15195 | ········var q = new NDOQuery<AgrBi11OthpconNoTblGuidLeft>(pm); |
15196 | ········ownVar = q.ExecuteSingle(); |
15197 | ····} |
15198 | ····void QueryOther() |
15199 | ····{ |
15200 | ········var q = new NDOQuery<AgrBi11OthpconNoTblGuidRightBase>(pm); |
15201 | ········otherVar = q.ExecuteSingle(); |
15202 | ····} |
15203 | } |
15204 | |
15205 | |
15206 | [TestFixture] |
15207 | public class TestAgrBi11OthpconTblGuid : NDOTest |
15208 | { |
15209 | ····AgrBi11OthpconTblGuidLeft ownVar; |
15210 | ····AgrBi11OthpconTblGuidRightBase otherVar; |
15211 | ····PersistenceManager pm; |
15212 | ····[SetUp] |
15213 | ····public void Setup() |
15214 | ····{ |
15215 | ········pm = PmFactory.NewPersistenceManager(); |
15216 | ········ownVar = new AgrBi11OthpconTblGuidLeft(); |
15217 | ········otherVar = new AgrBi11OthpconTblGuidRightDerived(); |
15218 | ····} |
15219 | ····[TearDown] |
15220 | ····public void TearDown() |
15221 | ····{ |
15222 | ········try |
15223 | ········{ |
15224 | ············pm.UnloadCache(); |
15225 | ············var l = pm.Objects<AgrBi11OthpconTblGuidLeft>().ResultTable; |
15226 | ············pm.Delete(l); |
15227 | ············pm.Save(); |
15228 | ············pm.UnloadCache(); |
15229 | ············var m = pm.Objects<AgrBi11OthpconTblGuidRightBase>().ResultTable; |
15230 | ············pm.Delete(m); |
15231 | ············pm.Save(); |
15232 | ············pm.UnloadCache(); |
15233 | ············decimal count; |
15234 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15235 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15236 | ············count = (decimal) new NDOQuery<AgrBi11OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15237 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15238 | ········} |
15239 | ········catch (Exception) |
15240 | ········{ |
15241 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15242 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15243 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15244 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15245 | ········} |
15246 | ····} |
15247 | ····[Test] |
15248 | ····public void TestSaveReload() |
15249 | ····{ |
15250 | ········CreateObjects(); |
15251 | ········QueryOwn(); |
15252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15254 | ····} |
15255 | ····[Test] |
15256 | ····public void TestSaveReloadNull() |
15257 | ····{ |
15258 | ········CreateObjects(); |
15259 | ········QueryOwn(); |
15260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15262 | ········ownVar.RelField = null; |
15263 | ········pm.Save(); |
15264 | ········pm.UnloadCache(); |
15265 | ········QueryOwn(); |
15266 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15267 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15268 | ····} |
15269 | ····[Test] |
15270 | ····public void TestChangeKeyHolderLeft() |
15271 | ····{ |
15272 | ········CreateObjects(); |
15273 | ········QueryOwn(); |
15274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15275 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15276 | ········int x = ownVar.RelField.Dummy; |
15277 | ········ownVar.Dummy = 4711; |
15278 | ········pm.Save(); |
15279 | ········pm.UnloadCache(); |
15280 | ········QueryOwn(); |
15281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15282 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15284 | ····} |
15285 | ····[Test] |
15286 | ····public void TestChangeKeyHolderRight() |
15287 | ····{ |
15288 | ········CreateObjects(); |
15289 | ········QueryOther(); |
15290 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15291 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15292 | ········int x = otherVar.RelField.Dummy; |
15293 | ········otherVar.Dummy = 4711; |
15294 | ········pm.Save(); |
15295 | ········pm.UnloadCache(); |
15296 | ········QueryOther(); |
15297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15298 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15299 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15300 | ····} |
15301 | ····[Test] |
15302 | ····public void TestChangeKeyHolderLeftNoTouch() |
15303 | ····{ |
15304 | ········CreateObjects(); |
15305 | ········QueryOwn(); |
15306 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15307 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15308 | ········ownVar.Dummy = 4711; |
15309 | ········pm.Save(); |
15310 | ········pm.UnloadCache(); |
15311 | ········QueryOwn(); |
15312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15313 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15315 | ····} |
15316 | ····[Test] |
15317 | ····public void TestChangeKeyHolderRightNoTouch() |
15318 | ····{ |
15319 | ········CreateObjects(); |
15320 | ········QueryOther(); |
15321 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15322 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15323 | ········otherVar.Dummy = 4711; |
15324 | ········pm.Save(); |
15325 | ········pm.UnloadCache(); |
15326 | ········QueryOther(); |
15327 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15328 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15329 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15330 | ····} |
15331 | ····[Test] |
15332 | ····public void TestRelationHash() |
15333 | ····{ |
15334 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidLeft)); |
15335 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15336 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidRightBase)); |
15337 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15338 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15339 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15340 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpconTblGuidRightDerived)); |
15341 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15342 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15343 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15344 | ····} |
15345 | ····void CreateObjects() |
15346 | ····{ |
15347 | ········pm.MakePersistent(ownVar); |
15348 | ········pm.MakePersistent(otherVar); |
15349 | ········ownVar.AssignRelation(otherVar); |
15350 | ········pm.Save(); |
15351 | ········pm.UnloadCache(); |
15352 | ····} |
15353 | ····void QueryOwn() |
15354 | ····{ |
15355 | ········var q = new NDOQuery<AgrBi11OthpconTblGuidLeft>(pm); |
15356 | ········ownVar = q.ExecuteSingle(); |
15357 | ····} |
15358 | ····void QueryOther() |
15359 | ····{ |
15360 | ········var q = new NDOQuery<AgrBi11OthpconTblGuidRightBase>(pm); |
15361 | ········otherVar = q.ExecuteSingle(); |
15362 | ····} |
15363 | } |
15364 | |
15365 | |
15366 | [TestFixture] |
15367 | public class TestAgrDirnOthpconTblGuid : NDOTest |
15368 | { |
15369 | ····AgrDirnOthpconTblGuidLeft ownVar; |
15370 | ····AgrDirnOthpconTblGuidRightBase otherVar; |
15371 | ····PersistenceManager pm; |
15372 | ····[SetUp] |
15373 | ····public void Setup() |
15374 | ····{ |
15375 | ········pm = PmFactory.NewPersistenceManager(); |
15376 | ········ownVar = new AgrDirnOthpconTblGuidLeft(); |
15377 | ········otherVar = new AgrDirnOthpconTblGuidRightDerived(); |
15378 | ····} |
15379 | ····[TearDown] |
15380 | ····public void TearDown() |
15381 | ····{ |
15382 | ········try |
15383 | ········{ |
15384 | ············pm.UnloadCache(); |
15385 | ············var l = pm.Objects<AgrDirnOthpconTblGuidLeft>().ResultTable; |
15386 | ············pm.Delete(l); |
15387 | ············pm.Save(); |
15388 | ············pm.UnloadCache(); |
15389 | ············var m = pm.Objects<AgrDirnOthpconTblGuidRightBase>().ResultTable; |
15390 | ············pm.Delete(m); |
15391 | ············pm.Save(); |
15392 | ············pm.UnloadCache(); |
15393 | ············decimal count; |
15394 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15395 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15396 | ············count = (decimal) new NDOQuery<AgrDirnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15397 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15398 | ········} |
15399 | ········catch (Exception) |
15400 | ········{ |
15401 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15402 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15403 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15404 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15405 | ········} |
15406 | ····} |
15407 | ····[Test] |
15408 | ····public void TestSaveReload() |
15409 | ····{ |
15410 | ········CreateObjects(); |
15411 | ········QueryOwn(); |
15412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15413 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15414 | ····} |
15415 | ····[Test] |
15416 | ····public void TestSaveReloadNull() |
15417 | ····{ |
15418 | ········CreateObjects(); |
15419 | ········QueryOwn(); |
15420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15421 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15422 | ········ownVar.RelField = new List<AgrDirnOthpconTblGuidRightBase>(); |
15423 | ········pm.Save(); |
15424 | ········pm.UnloadCache(); |
15425 | ········QueryOwn(); |
15426 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15427 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15428 | ····} |
15429 | ····[Test] |
15430 | ····public void TestSaveReloadRemove() |
15431 | ····{ |
15432 | ········CreateObjects(); |
15433 | ········QueryOwn(); |
15434 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15435 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15436 | ········ownVar.RemoveRelatedObject(); |
15437 | ········pm.Save(); |
15438 | ········pm.UnloadCache(); |
15439 | ········QueryOwn(); |
15440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15441 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15442 | ····} |
15443 | ····void CreateObjects() |
15444 | ····{ |
15445 | ········pm.MakePersistent(ownVar); |
15446 | ········pm.MakePersistent(otherVar); |
15447 | ········ownVar.AssignRelation(otherVar); |
15448 | ········pm.Save(); |
15449 | ········pm.UnloadCache(); |
15450 | ····} |
15451 | ····void QueryOwn() |
15452 | ····{ |
15453 | ········var q = new NDOQuery<AgrDirnOthpconTblGuidLeft>(pm); |
15454 | ········ownVar = q.ExecuteSingle(); |
15455 | ····} |
15456 | ····void QueryOther() |
15457 | ····{ |
15458 | ········var q = new NDOQuery<AgrDirnOthpconTblGuidRightBase>(pm); |
15459 | ········otherVar = q.ExecuteSingle(); |
15460 | ····} |
15461 | } |
15462 | |
15463 | |
15464 | [TestFixture] |
15465 | public class TestAgrBin1OthpconTblGuid : NDOTest |
15466 | { |
15467 | ····AgrBin1OthpconTblGuidLeft ownVar; |
15468 | ····AgrBin1OthpconTblGuidRightBase otherVar; |
15469 | ····PersistenceManager pm; |
15470 | ····[SetUp] |
15471 | ····public void Setup() |
15472 | ····{ |
15473 | ········pm = PmFactory.NewPersistenceManager(); |
15474 | ········ownVar = new AgrBin1OthpconTblGuidLeft(); |
15475 | ········otherVar = new AgrBin1OthpconTblGuidRightDerived(); |
15476 | ····} |
15477 | ····[TearDown] |
15478 | ····public void TearDown() |
15479 | ····{ |
15480 | ········try |
15481 | ········{ |
15482 | ············pm.UnloadCache(); |
15483 | ············var l = pm.Objects<AgrBin1OthpconTblGuidLeft>().ResultTable; |
15484 | ············pm.Delete(l); |
15485 | ············pm.Save(); |
15486 | ············pm.UnloadCache(); |
15487 | ············var m = pm.Objects<AgrBin1OthpconTblGuidRightBase>().ResultTable; |
15488 | ············pm.Delete(m); |
15489 | ············pm.Save(); |
15490 | ············pm.UnloadCache(); |
15491 | ············decimal count; |
15492 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15493 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15494 | ············count = (decimal) new NDOQuery<AgrBin1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15495 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15496 | ········} |
15497 | ········catch (Exception) |
15498 | ········{ |
15499 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15500 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15501 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15502 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15503 | ········} |
15504 | ····} |
15505 | ····[Test] |
15506 | ····public void TestSaveReload() |
15507 | ····{ |
15508 | ········CreateObjects(); |
15509 | ········QueryOwn(); |
15510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15511 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15512 | ····} |
15513 | ····[Test] |
15514 | ····public void TestSaveReloadNull() |
15515 | ····{ |
15516 | ········CreateObjects(); |
15517 | ········QueryOwn(); |
15518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15519 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15520 | ········ownVar.RelField = new List<AgrBin1OthpconTblGuidRightBase>(); |
15521 | ········pm.Save(); |
15522 | ········pm.UnloadCache(); |
15523 | ········QueryOwn(); |
15524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15525 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15526 | ····} |
15527 | ····[Test] |
15528 | ····public void TestSaveReloadRemove() |
15529 | ····{ |
15530 | ········CreateObjects(); |
15531 | ········QueryOwn(); |
15532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15533 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15534 | ········ownVar.RemoveRelatedObject(); |
15535 | ········pm.Save(); |
15536 | ········pm.UnloadCache(); |
15537 | ········QueryOwn(); |
15538 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15539 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15540 | ····} |
15541 | ····[Test] |
15542 | ····public void TestChangeKeyHolderRight() |
15543 | ····{ |
15544 | ········CreateObjects(); |
15545 | ········QueryOther(); |
15546 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15547 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15548 | ········int x = otherVar.RelField.Dummy; |
15549 | ········otherVar.Dummy = 4711; |
15550 | ········pm.Save(); |
15551 | ········pm.UnloadCache(); |
15552 | ········QueryOther(); |
15553 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15554 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15555 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15556 | ····} |
15557 | ····[Test] |
15558 | ····public void TestChangeKeyHolderRightNoTouch() |
15559 | ····{ |
15560 | ········CreateObjects(); |
15561 | ········QueryOther(); |
15562 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15563 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15564 | ········otherVar.Dummy = 4711; |
15565 | ········pm.Save(); |
15566 | ········pm.UnloadCache(); |
15567 | ········QueryOther(); |
15568 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
15569 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15570 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
15571 | ····} |
15572 | ····[Test] |
15573 | ····public void TestRelationHash() |
15574 | ····{ |
15575 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidLeft)); |
15576 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15577 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidRightBase)); |
15578 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15579 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15580 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15581 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpconTblGuidRightDerived)); |
15582 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15583 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15584 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15585 | ····} |
15586 | ····void CreateObjects() |
15587 | ····{ |
15588 | ········pm.MakePersistent(ownVar); |
15589 | ········pm.MakePersistent(otherVar); |
15590 | ········ownVar.AssignRelation(otherVar); |
15591 | ········pm.Save(); |
15592 | ········pm.UnloadCache(); |
15593 | ····} |
15594 | ····void QueryOwn() |
15595 | ····{ |
15596 | ········var q = new NDOQuery<AgrBin1OthpconTblGuidLeft>(pm); |
15597 | ········ownVar = q.ExecuteSingle(); |
15598 | ····} |
15599 | ····void QueryOther() |
15600 | ····{ |
15601 | ········var q = new NDOQuery<AgrBin1OthpconTblGuidRightBase>(pm); |
15602 | ········otherVar = q.ExecuteSingle(); |
15603 | ····} |
15604 | } |
15605 | |
15606 | |
15607 | [TestFixture] |
15608 | public class TestAgrBi1nOthpconNoTblGuid : NDOTest |
15609 | { |
15610 | ····AgrBi1nOthpconNoTblGuidLeft ownVar; |
15611 | ····AgrBi1nOthpconNoTblGuidRightBase otherVar; |
15612 | ····PersistenceManager pm; |
15613 | ····[SetUp] |
15614 | ····public void Setup() |
15615 | ····{ |
15616 | ········pm = PmFactory.NewPersistenceManager(); |
15617 | ········ownVar = new AgrBi1nOthpconNoTblGuidLeft(); |
15618 | ········otherVar = new AgrBi1nOthpconNoTblGuidRightDerived(); |
15619 | ····} |
15620 | ····[TearDown] |
15621 | ····public void TearDown() |
15622 | ····{ |
15623 | ········try |
15624 | ········{ |
15625 | ············pm.UnloadCache(); |
15626 | ············var l = pm.Objects<AgrBi1nOthpconNoTblGuidLeft>().ResultTable; |
15627 | ············pm.Delete(l); |
15628 | ············pm.Save(); |
15629 | ············pm.UnloadCache(); |
15630 | ············var m = pm.Objects<AgrBi1nOthpconNoTblGuidRightBase>().ResultTable; |
15631 | ············pm.Delete(m); |
15632 | ············pm.Save(); |
15633 | ············pm.UnloadCache(); |
15634 | ············decimal count; |
15635 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15636 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15637 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15638 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15639 | ········} |
15640 | ········catch (Exception) |
15641 | ········{ |
15642 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15644 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15645 | ········} |
15646 | ····} |
15647 | ····[Test] |
15648 | ····public void TestSaveReload() |
15649 | ····{ |
15650 | ········CreateObjects(); |
15651 | ········QueryOwn(); |
15652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15654 | ····} |
15655 | ····[Test] |
15656 | ····public void TestSaveReloadNull() |
15657 | ····{ |
15658 | ········CreateObjects(); |
15659 | ········QueryOwn(); |
15660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15662 | ········ownVar.RelField = null; |
15663 | ········pm.Save(); |
15664 | ········pm.UnloadCache(); |
15665 | ········QueryOwn(); |
15666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15667 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15668 | ····} |
15669 | ····[Test] |
15670 | ····public void TestChangeKeyHolderLeft() |
15671 | ····{ |
15672 | ········CreateObjects(); |
15673 | ········QueryOwn(); |
15674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15676 | ········int x = ownVar.RelField.Dummy; |
15677 | ········ownVar.Dummy = 4711; |
15678 | ········pm.Save(); |
15679 | ········pm.UnloadCache(); |
15680 | ········QueryOwn(); |
15681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15682 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15683 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15684 | ····} |
15685 | ····[Test] |
15686 | ····public void TestChangeKeyHolderLeftNoTouch() |
15687 | ····{ |
15688 | ········CreateObjects(); |
15689 | ········QueryOwn(); |
15690 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15691 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15692 | ········ownVar.Dummy = 4711; |
15693 | ········pm.Save(); |
15694 | ········pm.UnloadCache(); |
15695 | ········QueryOwn(); |
15696 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15697 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15698 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15699 | ····} |
15700 | ····[Test] |
15701 | ····public void TestRelationHash() |
15702 | ····{ |
15703 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidLeft)); |
15704 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15705 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidRightBase)); |
15706 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15707 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15708 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15709 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconNoTblGuidRightDerived)); |
15710 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15711 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15712 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15713 | ····} |
15714 | ····void CreateObjects() |
15715 | ····{ |
15716 | ········pm.MakePersistent(ownVar); |
15717 | ········pm.MakePersistent(otherVar); |
15718 | ········ownVar.AssignRelation(otherVar); |
15719 | ········pm.Save(); |
15720 | ········pm.UnloadCache(); |
15721 | ····} |
15722 | ····void QueryOwn() |
15723 | ····{ |
15724 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblGuidLeft>(pm); |
15725 | ········ownVar = q.ExecuteSingle(); |
15726 | ····} |
15727 | ····void QueryOther() |
15728 | ····{ |
15729 | ········var q = new NDOQuery<AgrBi1nOthpconNoTblGuidRightBase>(pm); |
15730 | ········otherVar = q.ExecuteSingle(); |
15731 | ····} |
15732 | } |
15733 | |
15734 | |
15735 | [TestFixture] |
15736 | public class TestAgrBi1nOthpconTblGuid : NDOTest |
15737 | { |
15738 | ····AgrBi1nOthpconTblGuidLeft ownVar; |
15739 | ····AgrBi1nOthpconTblGuidRightBase otherVar; |
15740 | ····PersistenceManager pm; |
15741 | ····[SetUp] |
15742 | ····public void Setup() |
15743 | ····{ |
15744 | ········pm = PmFactory.NewPersistenceManager(); |
15745 | ········ownVar = new AgrBi1nOthpconTblGuidLeft(); |
15746 | ········otherVar = new AgrBi1nOthpconTblGuidRightDerived(); |
15747 | ····} |
15748 | ····[TearDown] |
15749 | ····public void TearDown() |
15750 | ····{ |
15751 | ········try |
15752 | ········{ |
15753 | ············pm.UnloadCache(); |
15754 | ············var l = pm.Objects<AgrBi1nOthpconTblGuidLeft>().ResultTable; |
15755 | ············pm.Delete(l); |
15756 | ············pm.Save(); |
15757 | ············pm.UnloadCache(); |
15758 | ············var m = pm.Objects<AgrBi1nOthpconTblGuidRightBase>().ResultTable; |
15759 | ············pm.Delete(m); |
15760 | ············pm.Save(); |
15761 | ············pm.UnloadCache(); |
15762 | ············decimal count; |
15763 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15764 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15765 | ············count = (decimal) new NDOQuery<AgrBi1nOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15766 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15767 | ········} |
15768 | ········catch (Exception) |
15769 | ········{ |
15770 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15771 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15772 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15773 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15774 | ········} |
15775 | ····} |
15776 | ····[Test] |
15777 | ····public void TestSaveReload() |
15778 | ····{ |
15779 | ········CreateObjects(); |
15780 | ········QueryOwn(); |
15781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15782 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15783 | ····} |
15784 | ····[Test] |
15785 | ····public void TestSaveReloadNull() |
15786 | ····{ |
15787 | ········CreateObjects(); |
15788 | ········QueryOwn(); |
15789 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15790 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15791 | ········ownVar.RelField = null; |
15792 | ········pm.Save(); |
15793 | ········pm.UnloadCache(); |
15794 | ········QueryOwn(); |
15795 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15796 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
15797 | ····} |
15798 | ····[Test] |
15799 | ····public void TestChangeKeyHolderLeft() |
15800 | ····{ |
15801 | ········CreateObjects(); |
15802 | ········QueryOwn(); |
15803 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15804 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15805 | ········int x = ownVar.RelField.Dummy; |
15806 | ········ownVar.Dummy = 4711; |
15807 | ········pm.Save(); |
15808 | ········pm.UnloadCache(); |
15809 | ········QueryOwn(); |
15810 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15811 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15812 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15813 | ····} |
15814 | ····[Test] |
15815 | ····public void TestChangeKeyHolderLeftNoTouch() |
15816 | ····{ |
15817 | ········CreateObjects(); |
15818 | ········QueryOwn(); |
15819 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15820 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15821 | ········ownVar.Dummy = 4711; |
15822 | ········pm.Save(); |
15823 | ········pm.UnloadCache(); |
15824 | ········QueryOwn(); |
15825 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15826 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
15827 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
15828 | ····} |
15829 | ····[Test] |
15830 | ····public void TestRelationHash() |
15831 | ····{ |
15832 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidLeft)); |
15833 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15834 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidRightBase)); |
15835 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15836 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15837 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15838 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpconTblGuidRightDerived)); |
15839 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15840 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15841 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15842 | ····} |
15843 | ····void CreateObjects() |
15844 | ····{ |
15845 | ········pm.MakePersistent(ownVar); |
15846 | ········pm.MakePersistent(otherVar); |
15847 | ········ownVar.AssignRelation(otherVar); |
15848 | ········pm.Save(); |
15849 | ········pm.UnloadCache(); |
15850 | ····} |
15851 | ····void QueryOwn() |
15852 | ····{ |
15853 | ········var q = new NDOQuery<AgrBi1nOthpconTblGuidLeft>(pm); |
15854 | ········ownVar = q.ExecuteSingle(); |
15855 | ····} |
15856 | ····void QueryOther() |
15857 | ····{ |
15858 | ········var q = new NDOQuery<AgrBi1nOthpconTblGuidRightBase>(pm); |
15859 | ········otherVar = q.ExecuteSingle(); |
15860 | ····} |
15861 | } |
15862 | |
15863 | |
15864 | [TestFixture] |
15865 | public class TestAgrBinnOthpconTblGuid : NDOTest |
15866 | { |
15867 | ····AgrBinnOthpconTblGuidLeft ownVar; |
15868 | ····AgrBinnOthpconTblGuidRightBase otherVar; |
15869 | ····PersistenceManager pm; |
15870 | ····[SetUp] |
15871 | ····public void Setup() |
15872 | ····{ |
15873 | ········pm = PmFactory.NewPersistenceManager(); |
15874 | ········ownVar = new AgrBinnOthpconTblGuidLeft(); |
15875 | ········otherVar = new AgrBinnOthpconTblGuidRightDerived(); |
15876 | ····} |
15877 | ····[TearDown] |
15878 | ····public void TearDown() |
15879 | ····{ |
15880 | ········try |
15881 | ········{ |
15882 | ············pm.UnloadCache(); |
15883 | ············var l = pm.Objects<AgrBinnOthpconTblGuidLeft>().ResultTable; |
15884 | ············pm.Delete(l); |
15885 | ············pm.Save(); |
15886 | ············pm.UnloadCache(); |
15887 | ············var m = pm.Objects<AgrBinnOthpconTblGuidRightBase>().ResultTable; |
15888 | ············pm.Delete(m); |
15889 | ············pm.Save(); |
15890 | ············pm.UnloadCache(); |
15891 | ············decimal count; |
15892 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15893 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
15894 | ············count = (decimal) new NDOQuery<AgrBinnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
15895 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
15896 | ········} |
15897 | ········catch (Exception) |
15898 | ········{ |
15899 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
15900 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
15901 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
15902 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
15903 | ········} |
15904 | ····} |
15905 | ····[Test] |
15906 | ····public void TestSaveReload() |
15907 | ····{ |
15908 | ········CreateObjects(); |
15909 | ········QueryOwn(); |
15910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15911 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15912 | ····} |
15913 | ····[Test] |
15914 | ····public void TestSaveReloadNull() |
15915 | ····{ |
15916 | ········CreateObjects(); |
15917 | ········QueryOwn(); |
15918 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15919 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15920 | ········ownVar.RelField = new List<AgrBinnOthpconTblGuidRightBase>(); |
15921 | ········pm.Save(); |
15922 | ········pm.UnloadCache(); |
15923 | ········QueryOwn(); |
15924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15925 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15926 | ····} |
15927 | ····[Test] |
15928 | ····public void TestSaveReloadRemove() |
15929 | ····{ |
15930 | ········CreateObjects(); |
15931 | ········QueryOwn(); |
15932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15933 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15934 | ········ownVar.RemoveRelatedObject(); |
15935 | ········pm.Save(); |
15936 | ········pm.UnloadCache(); |
15937 | ········QueryOwn(); |
15938 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
15939 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
15940 | ····} |
15941 | ····[Test] |
15942 | ····public void TestRelationHash() |
15943 | ····{ |
15944 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidLeft)); |
15945 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
15946 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidRightBase)); |
15947 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
15948 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
15949 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
15950 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpconTblGuidRightDerived)); |
15951 | ········Relation relderRight = clderRight.FindRelation("relField"); |
15952 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
15953 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
15954 | ····} |
15955 | ····void CreateObjects() |
15956 | ····{ |
15957 | ········pm.MakePersistent(ownVar); |
15958 | ········pm.MakePersistent(otherVar); |
15959 | ········ownVar.AssignRelation(otherVar); |
15960 | ········pm.Save(); |
15961 | ········pm.UnloadCache(); |
15962 | ····} |
15963 | ····void QueryOwn() |
15964 | ····{ |
15965 | ········var q = new NDOQuery<AgrBinnOthpconTblGuidLeft>(pm); |
15966 | ········ownVar = q.ExecuteSingle(); |
15967 | ····} |
15968 | ····void QueryOther() |
15969 | ····{ |
15970 | ········var q = new NDOQuery<AgrBinnOthpconTblGuidRightBase>(pm); |
15971 | ········otherVar = q.ExecuteSingle(); |
15972 | ····} |
15973 | } |
15974 | |
15975 | |
15976 | [TestFixture] |
15977 | public class TestCmpDir1OthpconNoTblGuid : NDOTest |
15978 | { |
15979 | ····CmpDir1OthpconNoTblGuidLeft ownVar; |
15980 | ····CmpDir1OthpconNoTblGuidRightBase otherVar; |
15981 | ····PersistenceManager pm; |
15982 | ····[SetUp] |
15983 | ····public void Setup() |
15984 | ····{ |
15985 | ········pm = PmFactory.NewPersistenceManager(); |
15986 | ········ownVar = new CmpDir1OthpconNoTblGuidLeft(); |
15987 | ········otherVar = new CmpDir1OthpconNoTblGuidRightDerived(); |
15988 | ····} |
15989 | ····[TearDown] |
15990 | ····public void TearDown() |
15991 | ····{ |
15992 | ········try |
15993 | ········{ |
15994 | ············pm.UnloadCache(); |
15995 | ············var l = pm.Objects<CmpDir1OthpconNoTblGuidLeft>().ResultTable; |
15996 | ············pm.Delete(l); |
15997 | ············pm.Save(); |
15998 | ············pm.UnloadCache(); |
15999 | ············decimal count; |
16000 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16001 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16002 | ············count = (decimal) new NDOQuery<CmpDir1OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16003 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16004 | ········} |
16005 | ········catch (Exception) |
16006 | ········{ |
16007 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16008 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16009 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16010 | ········} |
16011 | ····} |
16012 | ····[Test] |
16013 | ····public void TestSaveReload() |
16014 | ····{ |
16015 | ········CreateObjects(); |
16016 | ········QueryOwn(); |
16017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16018 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16019 | ····} |
16020 | ····[Test] |
16021 | ····public void TestSaveReloadNull() |
16022 | ····{ |
16023 | ········CreateObjects(); |
16024 | ········QueryOwn(); |
16025 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16026 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16027 | ········ownVar.RelField = null; |
16028 | ········pm.Save(); |
16029 | ········pm.UnloadCache(); |
16030 | ········QueryOwn(); |
16031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16032 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16033 | ····} |
16034 | ····[Test] |
16035 | ····public void TestChangeKeyHolderLeft() |
16036 | ····{ |
16037 | ········CreateObjects(); |
16038 | ········QueryOwn(); |
16039 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16040 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16041 | ········int x = ownVar.RelField.Dummy; |
16042 | ········ownVar.Dummy = 4711; |
16043 | ········pm.Save(); |
16044 | ········pm.UnloadCache(); |
16045 | ········QueryOwn(); |
16046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16047 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16048 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16049 | ····} |
16050 | ····[Test] |
16051 | ····public void TestChangeKeyHolderLeftNoTouch() |
16052 | ····{ |
16053 | ········CreateObjects(); |
16054 | ········QueryOwn(); |
16055 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16056 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16057 | ········ownVar.Dummy = 4711; |
16058 | ········pm.Save(); |
16059 | ········pm.UnloadCache(); |
16060 | ········QueryOwn(); |
16061 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16062 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16063 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16064 | ····} |
16065 | ····void CreateObjects() |
16066 | ····{ |
16067 | ········pm.MakePersistent(ownVar); |
16068 | ········ownVar.AssignRelation(otherVar); |
16069 | ········pm.Save(); |
16070 | ········pm.UnloadCache(); |
16071 | ····} |
16072 | ····void QueryOwn() |
16073 | ····{ |
16074 | ········var q = new NDOQuery<CmpDir1OthpconNoTblGuidLeft>(pm); |
16075 | ········ownVar = q.ExecuteSingle(); |
16076 | ····} |
16077 | ····void QueryOther() |
16078 | ····{ |
16079 | ········var q = new NDOQuery<CmpDir1OthpconNoTblGuidRightBase>(pm); |
16080 | ········otherVar = q.ExecuteSingle(); |
16081 | ····} |
16082 | } |
16083 | |
16084 | |
16085 | [TestFixture] |
16086 | public class TestCmpDir1OthpconTblGuid : NDOTest |
16087 | { |
16088 | ····CmpDir1OthpconTblGuidLeft ownVar; |
16089 | ····CmpDir1OthpconTblGuidRightBase otherVar; |
16090 | ····PersistenceManager pm; |
16091 | ····[SetUp] |
16092 | ····public void Setup() |
16093 | ····{ |
16094 | ········pm = PmFactory.NewPersistenceManager(); |
16095 | ········ownVar = new CmpDir1OthpconTblGuidLeft(); |
16096 | ········otherVar = new CmpDir1OthpconTblGuidRightDerived(); |
16097 | ····} |
16098 | ····[TearDown] |
16099 | ····public void TearDown() |
16100 | ····{ |
16101 | ········try |
16102 | ········{ |
16103 | ············pm.UnloadCache(); |
16104 | ············var l = pm.Objects<CmpDir1OthpconTblGuidLeft>().ResultTable; |
16105 | ············pm.Delete(l); |
16106 | ············pm.Save(); |
16107 | ············pm.UnloadCache(); |
16108 | ············decimal count; |
16109 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16110 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16111 | ············count = (decimal) new NDOQuery<CmpDir1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16112 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16113 | ········} |
16114 | ········catch (Exception) |
16115 | ········{ |
16116 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16117 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16118 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16119 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16120 | ········} |
16121 | ····} |
16122 | ····[Test] |
16123 | ····public void TestSaveReload() |
16124 | ····{ |
16125 | ········CreateObjects(); |
16126 | ········QueryOwn(); |
16127 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16128 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16129 | ····} |
16130 | ····[Test] |
16131 | ····public void TestSaveReloadNull() |
16132 | ····{ |
16133 | ········CreateObjects(); |
16134 | ········QueryOwn(); |
16135 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16136 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16137 | ········ownVar.RelField = null; |
16138 | ········pm.Save(); |
16139 | ········pm.UnloadCache(); |
16140 | ········QueryOwn(); |
16141 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16142 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16143 | ····} |
16144 | ····[Test] |
16145 | ····public void TestChangeKeyHolderLeft() |
16146 | ····{ |
16147 | ········CreateObjects(); |
16148 | ········QueryOwn(); |
16149 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16150 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16151 | ········int x = ownVar.RelField.Dummy; |
16152 | ········ownVar.Dummy = 4711; |
16153 | ········pm.Save(); |
16154 | ········pm.UnloadCache(); |
16155 | ········QueryOwn(); |
16156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16157 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16158 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16159 | ····} |
16160 | ····[Test] |
16161 | ····public void TestChangeKeyHolderLeftNoTouch() |
16162 | ····{ |
16163 | ········CreateObjects(); |
16164 | ········QueryOwn(); |
16165 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16166 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16167 | ········ownVar.Dummy = 4711; |
16168 | ········pm.Save(); |
16169 | ········pm.UnloadCache(); |
16170 | ········QueryOwn(); |
16171 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16172 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16174 | ····} |
16175 | ····void CreateObjects() |
16176 | ····{ |
16177 | ········pm.MakePersistent(ownVar); |
16178 | ········ownVar.AssignRelation(otherVar); |
16179 | ········pm.Save(); |
16180 | ········pm.UnloadCache(); |
16181 | ····} |
16182 | ····void QueryOwn() |
16183 | ····{ |
16184 | ········var q = new NDOQuery<CmpDir1OthpconTblGuidLeft>(pm); |
16185 | ········ownVar = q.ExecuteSingle(); |
16186 | ····} |
16187 | ····void QueryOther() |
16188 | ····{ |
16189 | ········var q = new NDOQuery<CmpDir1OthpconTblGuidRightBase>(pm); |
16190 | ········otherVar = q.ExecuteSingle(); |
16191 | ····} |
16192 | } |
16193 | |
16194 | |
16195 | [TestFixture] |
16196 | public class TestCmpBi11OthpconNoTblGuid : NDOTest |
16197 | { |
16198 | ····CmpBi11OthpconNoTblGuidLeft ownVar; |
16199 | ····CmpBi11OthpconNoTblGuidRightBase otherVar; |
16200 | ····PersistenceManager pm; |
16201 | ····[SetUp] |
16202 | ····public void Setup() |
16203 | ····{ |
16204 | ········pm = PmFactory.NewPersistenceManager(); |
16205 | ········ownVar = new CmpBi11OthpconNoTblGuidLeft(); |
16206 | ········otherVar = new CmpBi11OthpconNoTblGuidRightDerived(); |
16207 | ····} |
16208 | ····[TearDown] |
16209 | ····public void TearDown() |
16210 | ····{ |
16211 | ········try |
16212 | ········{ |
16213 | ············pm.UnloadCache(); |
16214 | ············var l = pm.Objects<CmpBi11OthpconNoTblGuidLeft>().ResultTable; |
16215 | ············pm.Delete(l); |
16216 | ············pm.Save(); |
16217 | ············pm.UnloadCache(); |
16218 | ············decimal count; |
16219 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16220 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16221 | ············count = (decimal) new NDOQuery<CmpBi11OthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16222 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16223 | ········} |
16224 | ········catch (Exception) |
16225 | ········{ |
16226 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16227 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16228 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16229 | ········} |
16230 | ····} |
16231 | ····[Test] |
16232 | ····public void TestSaveReload() |
16233 | ····{ |
16234 | ········CreateObjects(); |
16235 | ········QueryOwn(); |
16236 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16237 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16238 | ····} |
16239 | ····[Test] |
16240 | ····public void TestSaveReloadNull() |
16241 | ····{ |
16242 | ········CreateObjects(); |
16243 | ········QueryOwn(); |
16244 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16245 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16246 | ········ownVar.RelField = null; |
16247 | ········pm.Save(); |
16248 | ········pm.UnloadCache(); |
16249 | ········QueryOwn(); |
16250 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16251 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16252 | ····} |
16253 | ····[Test] |
16254 | ····public void TestChangeKeyHolderLeft() |
16255 | ····{ |
16256 | ········CreateObjects(); |
16257 | ········QueryOwn(); |
16258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16259 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16260 | ········int x = ownVar.RelField.Dummy; |
16261 | ········ownVar.Dummy = 4711; |
16262 | ········pm.Save(); |
16263 | ········pm.UnloadCache(); |
16264 | ········QueryOwn(); |
16265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16266 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16267 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16268 | ····} |
16269 | ····[Test] |
16270 | ····public void TestChangeKeyHolderRight() |
16271 | ····{ |
16272 | ········CreateObjects(); |
16273 | ········QueryOther(); |
16274 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16275 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16276 | ········int x = otherVar.RelField.Dummy; |
16277 | ········otherVar.Dummy = 4711; |
16278 | ········pm.Save(); |
16279 | ········pm.UnloadCache(); |
16280 | ········QueryOther(); |
16281 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16282 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16283 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16284 | ····} |
16285 | ····[Test] |
16286 | ····public void TestChangeKeyHolderLeftNoTouch() |
16287 | ····{ |
16288 | ········CreateObjects(); |
16289 | ········QueryOwn(); |
16290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16291 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16292 | ········ownVar.Dummy = 4711; |
16293 | ········pm.Save(); |
16294 | ········pm.UnloadCache(); |
16295 | ········QueryOwn(); |
16296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16297 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16298 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16299 | ····} |
16300 | ····[Test] |
16301 | ····public void TestChangeKeyHolderRightNoTouch() |
16302 | ····{ |
16303 | ········CreateObjects(); |
16304 | ········QueryOther(); |
16305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16307 | ········otherVar.Dummy = 4711; |
16308 | ········pm.Save(); |
16309 | ········pm.UnloadCache(); |
16310 | ········QueryOther(); |
16311 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16312 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16313 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16314 | ····} |
16315 | ····[Test] |
16316 | ····public void TestRelationHash() |
16317 | ····{ |
16318 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidLeft)); |
16319 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16320 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidRightBase)); |
16321 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16322 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16323 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16324 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconNoTblGuidRightDerived)); |
16325 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16326 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16327 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16328 | ····} |
16329 | ····void CreateObjects() |
16330 | ····{ |
16331 | ········pm.MakePersistent(ownVar); |
16332 | ········ownVar.AssignRelation(otherVar); |
16333 | ········pm.Save(); |
16334 | ········pm.UnloadCache(); |
16335 | ····} |
16336 | ····void QueryOwn() |
16337 | ····{ |
16338 | ········var q = new NDOQuery<CmpBi11OthpconNoTblGuidLeft>(pm); |
16339 | ········ownVar = q.ExecuteSingle(); |
16340 | ····} |
16341 | ····void QueryOther() |
16342 | ····{ |
16343 | ········var q = new NDOQuery<CmpBi11OthpconNoTblGuidRightBase>(pm); |
16344 | ········otherVar = q.ExecuteSingle(); |
16345 | ····} |
16346 | } |
16347 | |
16348 | |
16349 | [TestFixture] |
16350 | public class TestCmpBi11OthpconTblGuid : NDOTest |
16351 | { |
16352 | ····CmpBi11OthpconTblGuidLeft ownVar; |
16353 | ····CmpBi11OthpconTblGuidRightBase otherVar; |
16354 | ····PersistenceManager pm; |
16355 | ····[SetUp] |
16356 | ····public void Setup() |
16357 | ····{ |
16358 | ········pm = PmFactory.NewPersistenceManager(); |
16359 | ········ownVar = new CmpBi11OthpconTblGuidLeft(); |
16360 | ········otherVar = new CmpBi11OthpconTblGuidRightDerived(); |
16361 | ····} |
16362 | ····[TearDown] |
16363 | ····public void TearDown() |
16364 | ····{ |
16365 | ········try |
16366 | ········{ |
16367 | ············pm.UnloadCache(); |
16368 | ············var l = pm.Objects<CmpBi11OthpconTblGuidLeft>().ResultTable; |
16369 | ············pm.Delete(l); |
16370 | ············pm.Save(); |
16371 | ············pm.UnloadCache(); |
16372 | ············decimal count; |
16373 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16374 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16375 | ············count = (decimal) new NDOQuery<CmpBi11OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16376 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16377 | ········} |
16378 | ········catch (Exception) |
16379 | ········{ |
16380 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16382 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16383 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16384 | ········} |
16385 | ····} |
16386 | ····[Test] |
16387 | ····public void TestSaveReload() |
16388 | ····{ |
16389 | ········CreateObjects(); |
16390 | ········QueryOwn(); |
16391 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16392 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16393 | ····} |
16394 | ····[Test] |
16395 | ····public void TestSaveReloadNull() |
16396 | ····{ |
16397 | ········CreateObjects(); |
16398 | ········QueryOwn(); |
16399 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16400 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16401 | ········ownVar.RelField = null; |
16402 | ········pm.Save(); |
16403 | ········pm.UnloadCache(); |
16404 | ········QueryOwn(); |
16405 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16406 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16407 | ····} |
16408 | ····[Test] |
16409 | ····public void TestChangeKeyHolderLeft() |
16410 | ····{ |
16411 | ········CreateObjects(); |
16412 | ········QueryOwn(); |
16413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16414 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16415 | ········int x = ownVar.RelField.Dummy; |
16416 | ········ownVar.Dummy = 4711; |
16417 | ········pm.Save(); |
16418 | ········pm.UnloadCache(); |
16419 | ········QueryOwn(); |
16420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16421 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16422 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16423 | ····} |
16424 | ····[Test] |
16425 | ····public void TestChangeKeyHolderRight() |
16426 | ····{ |
16427 | ········CreateObjects(); |
16428 | ········QueryOther(); |
16429 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16430 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16431 | ········int x = otherVar.RelField.Dummy; |
16432 | ········otherVar.Dummy = 4711; |
16433 | ········pm.Save(); |
16434 | ········pm.UnloadCache(); |
16435 | ········QueryOther(); |
16436 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16437 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16438 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16439 | ····} |
16440 | ····[Test] |
16441 | ····public void TestChangeKeyHolderLeftNoTouch() |
16442 | ····{ |
16443 | ········CreateObjects(); |
16444 | ········QueryOwn(); |
16445 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16447 | ········ownVar.Dummy = 4711; |
16448 | ········pm.Save(); |
16449 | ········pm.UnloadCache(); |
16450 | ········QueryOwn(); |
16451 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16452 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16453 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16454 | ····} |
16455 | ····[Test] |
16456 | ····public void TestChangeKeyHolderRightNoTouch() |
16457 | ····{ |
16458 | ········CreateObjects(); |
16459 | ········QueryOther(); |
16460 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16461 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16462 | ········otherVar.Dummy = 4711; |
16463 | ········pm.Save(); |
16464 | ········pm.UnloadCache(); |
16465 | ········QueryOther(); |
16466 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16467 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16468 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16469 | ····} |
16470 | ····[Test] |
16471 | ····public void TestRelationHash() |
16472 | ····{ |
16473 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidLeft)); |
16474 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16475 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidRightBase)); |
16476 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16477 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16478 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16479 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpconTblGuidRightDerived)); |
16480 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16481 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16482 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16483 | ····} |
16484 | ····void CreateObjects() |
16485 | ····{ |
16486 | ········pm.MakePersistent(ownVar); |
16487 | ········ownVar.AssignRelation(otherVar); |
16488 | ········pm.Save(); |
16489 | ········pm.UnloadCache(); |
16490 | ····} |
16491 | ····void QueryOwn() |
16492 | ····{ |
16493 | ········var q = new NDOQuery<CmpBi11OthpconTblGuidLeft>(pm); |
16494 | ········ownVar = q.ExecuteSingle(); |
16495 | ····} |
16496 | ····void QueryOther() |
16497 | ····{ |
16498 | ········var q = new NDOQuery<CmpBi11OthpconTblGuidRightBase>(pm); |
16499 | ········otherVar = q.ExecuteSingle(); |
16500 | ····} |
16501 | } |
16502 | |
16503 | |
16504 | [TestFixture] |
16505 | public class TestCmpDirnOthpconTblGuid : NDOTest |
16506 | { |
16507 | ····CmpDirnOthpconTblGuidLeft ownVar; |
16508 | ····CmpDirnOthpconTblGuidRightBase otherVar; |
16509 | ····PersistenceManager pm; |
16510 | ····[SetUp] |
16511 | ····public void Setup() |
16512 | ····{ |
16513 | ········pm = PmFactory.NewPersistenceManager(); |
16514 | ········ownVar = new CmpDirnOthpconTblGuidLeft(); |
16515 | ········otherVar = new CmpDirnOthpconTblGuidRightDerived(); |
16516 | ····} |
16517 | ····[TearDown] |
16518 | ····public void TearDown() |
16519 | ····{ |
16520 | ········try |
16521 | ········{ |
16522 | ············pm.UnloadCache(); |
16523 | ············var l = pm.Objects<CmpDirnOthpconTblGuidLeft>().ResultTable; |
16524 | ············pm.Delete(l); |
16525 | ············pm.Save(); |
16526 | ············pm.UnloadCache(); |
16527 | ············decimal count; |
16528 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16529 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16530 | ············count = (decimal) new NDOQuery<CmpDirnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16532 | ········} |
16533 | ········catch (Exception) |
16534 | ········{ |
16535 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16536 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16537 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16538 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16539 | ········} |
16540 | ····} |
16541 | ····[Test] |
16542 | ····public void TestSaveReload() |
16543 | ····{ |
16544 | ········CreateObjects(); |
16545 | ········QueryOwn(); |
16546 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16547 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16548 | ····} |
16549 | ····[Test] |
16550 | ····public void TestSaveReloadNull() |
16551 | ····{ |
16552 | ········CreateObjects(); |
16553 | ········QueryOwn(); |
16554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16555 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16556 | ········ownVar.RelField = new List<CmpDirnOthpconTblGuidRightBase>(); |
16557 | ········pm.Save(); |
16558 | ········pm.UnloadCache(); |
16559 | ········QueryOwn(); |
16560 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16561 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16562 | ····} |
16563 | ····[Test] |
16564 | ····public void TestSaveReloadRemove() |
16565 | ····{ |
16566 | ········CreateObjects(); |
16567 | ········QueryOwn(); |
16568 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16569 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16570 | ········ownVar.RemoveRelatedObject(); |
16571 | ········pm.Save(); |
16572 | ········pm.UnloadCache(); |
16573 | ········QueryOwn(); |
16574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16575 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16576 | ····} |
16577 | ····void CreateObjects() |
16578 | ····{ |
16579 | ········pm.MakePersistent(ownVar); |
16580 | ········ownVar.AssignRelation(otherVar); |
16581 | ········pm.Save(); |
16582 | ········pm.UnloadCache(); |
16583 | ····} |
16584 | ····void QueryOwn() |
16585 | ····{ |
16586 | ········var q = new NDOQuery<CmpDirnOthpconTblGuidLeft>(pm); |
16587 | ········ownVar = q.ExecuteSingle(); |
16588 | ····} |
16589 | ····void QueryOther() |
16590 | ····{ |
16591 | ········var q = new NDOQuery<CmpDirnOthpconTblGuidRightBase>(pm); |
16592 | ········otherVar = q.ExecuteSingle(); |
16593 | ····} |
16594 | } |
16595 | |
16596 | |
16597 | [TestFixture] |
16598 | public class TestCmpBin1OthpconTblGuid : NDOTest |
16599 | { |
16600 | ····CmpBin1OthpconTblGuidLeft ownVar; |
16601 | ····CmpBin1OthpconTblGuidRightBase otherVar; |
16602 | ····PersistenceManager pm; |
16603 | ····[SetUp] |
16604 | ····public void Setup() |
16605 | ····{ |
16606 | ········pm = PmFactory.NewPersistenceManager(); |
16607 | ········ownVar = new CmpBin1OthpconTblGuidLeft(); |
16608 | ········otherVar = new CmpBin1OthpconTblGuidRightDerived(); |
16609 | ····} |
16610 | ····[TearDown] |
16611 | ····public void TearDown() |
16612 | ····{ |
16613 | ········try |
16614 | ········{ |
16615 | ············pm.UnloadCache(); |
16616 | ············var l = pm.Objects<CmpBin1OthpconTblGuidLeft>().ResultTable; |
16617 | ············pm.Delete(l); |
16618 | ············pm.Save(); |
16619 | ············pm.UnloadCache(); |
16620 | ············decimal count; |
16621 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16622 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16623 | ············count = (decimal) new NDOQuery<CmpBin1OthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16625 | ········} |
16626 | ········catch (Exception) |
16627 | ········{ |
16628 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16629 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16630 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16631 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16632 | ········} |
16633 | ····} |
16634 | ····[Test] |
16635 | ····public void TestSaveReload() |
16636 | ····{ |
16637 | ········CreateObjects(); |
16638 | ········QueryOwn(); |
16639 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16640 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16641 | ····} |
16642 | ····[Test] |
16643 | ····public void TestSaveReloadNull() |
16644 | ····{ |
16645 | ········CreateObjects(); |
16646 | ········QueryOwn(); |
16647 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16648 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16649 | ········ownVar.RelField = new List<CmpBin1OthpconTblGuidRightBase>(); |
16650 | ········pm.Save(); |
16651 | ········pm.UnloadCache(); |
16652 | ········QueryOwn(); |
16653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16654 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16655 | ····} |
16656 | ····[Test] |
16657 | ····public void TestSaveReloadRemove() |
16658 | ····{ |
16659 | ········CreateObjects(); |
16660 | ········QueryOwn(); |
16661 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16662 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16663 | ········ownVar.RemoveRelatedObject(); |
16664 | ········pm.Save(); |
16665 | ········pm.UnloadCache(); |
16666 | ········QueryOwn(); |
16667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16668 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
16669 | ····} |
16670 | ····[Test] |
16671 | ····public void TestChangeKeyHolderRight() |
16672 | ····{ |
16673 | ········CreateObjects(); |
16674 | ········QueryOther(); |
16675 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16676 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16677 | ········int x = otherVar.RelField.Dummy; |
16678 | ········otherVar.Dummy = 4711; |
16679 | ········pm.Save(); |
16680 | ········pm.UnloadCache(); |
16681 | ········QueryOther(); |
16682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16683 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16684 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16685 | ····} |
16686 | ····[Test] |
16687 | ····public void TestChangeKeyHolderRightNoTouch() |
16688 | ····{ |
16689 | ········CreateObjects(); |
16690 | ········QueryOther(); |
16691 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16692 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16693 | ········otherVar.Dummy = 4711; |
16694 | ········pm.Save(); |
16695 | ········pm.UnloadCache(); |
16696 | ········QueryOther(); |
16697 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
16698 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16699 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
16700 | ····} |
16701 | ····[Test] |
16702 | ····public void TestRelationHash() |
16703 | ····{ |
16704 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidLeft)); |
16705 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16706 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidRightBase)); |
16707 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16708 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16709 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16710 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpconTblGuidRightDerived)); |
16711 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16712 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16713 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16714 | ····} |
16715 | ····void CreateObjects() |
16716 | ····{ |
16717 | ········pm.MakePersistent(ownVar); |
16718 | ········ownVar.AssignRelation(otherVar); |
16719 | ········pm.Save(); |
16720 | ········pm.UnloadCache(); |
16721 | ····} |
16722 | ····void QueryOwn() |
16723 | ····{ |
16724 | ········var q = new NDOQuery<CmpBin1OthpconTblGuidLeft>(pm); |
16725 | ········ownVar = q.ExecuteSingle(); |
16726 | ····} |
16727 | ····void QueryOther() |
16728 | ····{ |
16729 | ········var q = new NDOQuery<CmpBin1OthpconTblGuidRightBase>(pm); |
16730 | ········otherVar = q.ExecuteSingle(); |
16731 | ····} |
16732 | } |
16733 | |
16734 | |
16735 | [TestFixture] |
16736 | public class TestCmpBi1nOthpconNoTblGuid : NDOTest |
16737 | { |
16738 | ····CmpBi1nOthpconNoTblGuidLeft ownVar; |
16739 | ····CmpBi1nOthpconNoTblGuidRightBase otherVar; |
16740 | ····PersistenceManager pm; |
16741 | ····[SetUp] |
16742 | ····public void Setup() |
16743 | ····{ |
16744 | ········pm = PmFactory.NewPersistenceManager(); |
16745 | ········ownVar = new CmpBi1nOthpconNoTblGuidLeft(); |
16746 | ········otherVar = new CmpBi1nOthpconNoTblGuidRightDerived(); |
16747 | ····} |
16748 | ····[TearDown] |
16749 | ····public void TearDown() |
16750 | ····{ |
16751 | ········try |
16752 | ········{ |
16753 | ············pm.UnloadCache(); |
16754 | ············var l = pm.Objects<CmpBi1nOthpconNoTblGuidLeft>().ResultTable; |
16755 | ············pm.Delete(l); |
16756 | ············pm.Save(); |
16757 | ············pm.UnloadCache(); |
16758 | ············decimal count; |
16759 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16761 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16762 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16763 | ········} |
16764 | ········catch (Exception) |
16765 | ········{ |
16766 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16767 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16768 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16769 | ········} |
16770 | ····} |
16771 | ····[Test] |
16772 | ····public void TestSaveReload() |
16773 | ····{ |
16774 | ········CreateObjects(); |
16775 | ········QueryOwn(); |
16776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16777 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16778 | ····} |
16779 | ····[Test] |
16780 | ····public void TestSaveReloadNull() |
16781 | ····{ |
16782 | ········CreateObjects(); |
16783 | ········QueryOwn(); |
16784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16785 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16786 | ········ownVar.RelField = null; |
16787 | ········pm.Save(); |
16788 | ········pm.UnloadCache(); |
16789 | ········QueryOwn(); |
16790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16791 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16792 | ····} |
16793 | ····[Test] |
16794 | ····public void TestChangeKeyHolderLeft() |
16795 | ····{ |
16796 | ········CreateObjects(); |
16797 | ········QueryOwn(); |
16798 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16799 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16800 | ········int x = ownVar.RelField.Dummy; |
16801 | ········ownVar.Dummy = 4711; |
16802 | ········pm.Save(); |
16803 | ········pm.UnloadCache(); |
16804 | ········QueryOwn(); |
16805 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16806 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16807 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16808 | ····} |
16809 | ····[Test] |
16810 | ····public void TestChangeKeyHolderLeftNoTouch() |
16811 | ····{ |
16812 | ········CreateObjects(); |
16813 | ········QueryOwn(); |
16814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16815 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16816 | ········ownVar.Dummy = 4711; |
16817 | ········pm.Save(); |
16818 | ········pm.UnloadCache(); |
16819 | ········QueryOwn(); |
16820 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16821 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16823 | ····} |
16824 | ····[Test] |
16825 | ····public void TestRelationHash() |
16826 | ····{ |
16827 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidLeft)); |
16828 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16829 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidRightBase)); |
16830 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16831 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16832 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16833 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconNoTblGuidRightDerived)); |
16834 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16835 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16836 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16837 | ····} |
16838 | ····void CreateObjects() |
16839 | ····{ |
16840 | ········pm.MakePersistent(ownVar); |
16841 | ········ownVar.AssignRelation(otherVar); |
16842 | ········pm.Save(); |
16843 | ········pm.UnloadCache(); |
16844 | ····} |
16845 | ····void QueryOwn() |
16846 | ····{ |
16847 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblGuidLeft>(pm); |
16848 | ········ownVar = q.ExecuteSingle(); |
16849 | ····} |
16850 | ····void QueryOther() |
16851 | ····{ |
16852 | ········var q = new NDOQuery<CmpBi1nOthpconNoTblGuidRightBase>(pm); |
16853 | ········otherVar = q.ExecuteSingle(); |
16854 | ····} |
16855 | } |
16856 | |
16857 | |
16858 | [TestFixture] |
16859 | public class TestCmpBi1nOthpconTblGuid : NDOTest |
16860 | { |
16861 | ····CmpBi1nOthpconTblGuidLeft ownVar; |
16862 | ····CmpBi1nOthpconTblGuidRightBase otherVar; |
16863 | ····PersistenceManager pm; |
16864 | ····[SetUp] |
16865 | ····public void Setup() |
16866 | ····{ |
16867 | ········pm = PmFactory.NewPersistenceManager(); |
16868 | ········ownVar = new CmpBi1nOthpconTblGuidLeft(); |
16869 | ········otherVar = new CmpBi1nOthpconTblGuidRightDerived(); |
16870 | ····} |
16871 | ····[TearDown] |
16872 | ····public void TearDown() |
16873 | ····{ |
16874 | ········try |
16875 | ········{ |
16876 | ············pm.UnloadCache(); |
16877 | ············var l = pm.Objects<CmpBi1nOthpconTblGuidLeft>().ResultTable; |
16878 | ············pm.Delete(l); |
16879 | ············pm.Save(); |
16880 | ············pm.UnloadCache(); |
16881 | ············decimal count; |
16882 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16883 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
16884 | ············count = (decimal) new NDOQuery<CmpBi1nOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
16885 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
16886 | ········} |
16887 | ········catch (Exception) |
16888 | ········{ |
16889 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
16890 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
16891 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
16892 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
16893 | ········} |
16894 | ····} |
16895 | ····[Test] |
16896 | ····public void TestSaveReload() |
16897 | ····{ |
16898 | ········CreateObjects(); |
16899 | ········QueryOwn(); |
16900 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16901 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16902 | ····} |
16903 | ····[Test] |
16904 | ····public void TestSaveReloadNull() |
16905 | ····{ |
16906 | ········CreateObjects(); |
16907 | ········QueryOwn(); |
16908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16910 | ········ownVar.RelField = null; |
16911 | ········pm.Save(); |
16912 | ········pm.UnloadCache(); |
16913 | ········QueryOwn(); |
16914 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16915 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
16916 | ····} |
16917 | ····[Test] |
16918 | ····public void TestChangeKeyHolderLeft() |
16919 | ····{ |
16920 | ········CreateObjects(); |
16921 | ········QueryOwn(); |
16922 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16923 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16924 | ········int x = ownVar.RelField.Dummy; |
16925 | ········ownVar.Dummy = 4711; |
16926 | ········pm.Save(); |
16927 | ········pm.UnloadCache(); |
16928 | ········QueryOwn(); |
16929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16930 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16931 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16932 | ····} |
16933 | ····[Test] |
16934 | ····public void TestChangeKeyHolderLeftNoTouch() |
16935 | ····{ |
16936 | ········CreateObjects(); |
16937 | ········QueryOwn(); |
16938 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16939 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16940 | ········ownVar.Dummy = 4711; |
16941 | ········pm.Save(); |
16942 | ········pm.UnloadCache(); |
16943 | ········QueryOwn(); |
16944 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
16945 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
16946 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
16947 | ····} |
16948 | ····[Test] |
16949 | ····public void TestRelationHash() |
16950 | ····{ |
16951 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidLeft)); |
16952 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
16953 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidRightBase)); |
16954 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
16955 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
16956 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
16957 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpconTblGuidRightDerived)); |
16958 | ········Relation relderRight = clderRight.FindRelation("relField"); |
16959 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
16960 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
16961 | ····} |
16962 | ····void CreateObjects() |
16963 | ····{ |
16964 | ········pm.MakePersistent(ownVar); |
16965 | ········ownVar.AssignRelation(otherVar); |
16966 | ········pm.Save(); |
16967 | ········pm.UnloadCache(); |
16968 | ····} |
16969 | ····void QueryOwn() |
16970 | ····{ |
16971 | ········var q = new NDOQuery<CmpBi1nOthpconTblGuidLeft>(pm); |
16972 | ········ownVar = q.ExecuteSingle(); |
16973 | ····} |
16974 | ····void QueryOther() |
16975 | ····{ |
16976 | ········var q = new NDOQuery<CmpBi1nOthpconTblGuidRightBase>(pm); |
16977 | ········otherVar = q.ExecuteSingle(); |
16978 | ····} |
16979 | } |
16980 | |
16981 | |
16982 | [TestFixture] |
16983 | public class TestCmpBinnOthpconTblGuid : NDOTest |
16984 | { |
16985 | ····CmpBinnOthpconTblGuidLeft ownVar; |
16986 | ····CmpBinnOthpconTblGuidRightBase otherVar; |
16987 | ····PersistenceManager pm; |
16988 | ····[SetUp] |
16989 | ····public void Setup() |
16990 | ····{ |
16991 | ········pm = PmFactory.NewPersistenceManager(); |
16992 | ········ownVar = new CmpBinnOthpconTblGuidLeft(); |
16993 | ········otherVar = new CmpBinnOthpconTblGuidRightDerived(); |
16994 | ····} |
16995 | ····[TearDown] |
16996 | ····public void TearDown() |
16997 | ····{ |
16998 | ········try |
16999 | ········{ |
17000 | ············pm.UnloadCache(); |
17001 | ············var l = pm.Objects<CmpBinnOthpconTblGuidLeft>().ResultTable; |
17002 | ············pm.Delete(l); |
17003 | ············pm.Save(); |
17004 | ············pm.UnloadCache(); |
17005 | ············decimal count; |
17006 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17007 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17008 | ············count = (decimal) new NDOQuery<CmpBinnOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17009 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17010 | ········} |
17011 | ········catch (Exception) |
17012 | ········{ |
17013 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17014 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17015 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17016 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17017 | ········} |
17018 | ····} |
17019 | ····[Test] |
17020 | ····public void TestSaveReload() |
17021 | ····{ |
17022 | ········CreateObjects(); |
17023 | ········QueryOwn(); |
17024 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17025 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17026 | ····} |
17027 | ····[Test] |
17028 | ····public void TestSaveReloadNull() |
17029 | ····{ |
17030 | ········CreateObjects(); |
17031 | ········QueryOwn(); |
17032 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17033 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17034 | ········ownVar.RelField = new List<CmpBinnOthpconTblGuidRightBase>(); |
17035 | ········pm.Save(); |
17036 | ········pm.UnloadCache(); |
17037 | ········QueryOwn(); |
17038 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17039 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17040 | ····} |
17041 | ····[Test] |
17042 | ····public void TestSaveReloadRemove() |
17043 | ····{ |
17044 | ········CreateObjects(); |
17045 | ········QueryOwn(); |
17046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17047 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17048 | ········ownVar.RemoveRelatedObject(); |
17049 | ········pm.Save(); |
17050 | ········pm.UnloadCache(); |
17051 | ········QueryOwn(); |
17052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17053 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17054 | ····} |
17055 | ····[Test] |
17056 | ····public void TestRelationHash() |
17057 | ····{ |
17058 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidLeft)); |
17059 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17060 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidRightBase)); |
17061 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17062 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17063 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17064 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpconTblGuidRightDerived)); |
17065 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17066 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17067 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17068 | ····} |
17069 | ····void CreateObjects() |
17070 | ····{ |
17071 | ········pm.MakePersistent(ownVar); |
17072 | ········ownVar.AssignRelation(otherVar); |
17073 | ········pm.Save(); |
17074 | ········pm.UnloadCache(); |
17075 | ····} |
17076 | ····void QueryOwn() |
17077 | ····{ |
17078 | ········var q = new NDOQuery<CmpBinnOthpconTblGuidLeft>(pm); |
17079 | ········ownVar = q.ExecuteSingle(); |
17080 | ····} |
17081 | ····void QueryOther() |
17082 | ····{ |
17083 | ········var q = new NDOQuery<CmpBinnOthpconTblGuidRightBase>(pm); |
17084 | ········otherVar = q.ExecuteSingle(); |
17085 | ····} |
17086 | } |
17087 | |
17088 | |
17089 | [TestFixture] |
17090 | public class TestAgrDir1OwnpconOthpconNoTblGuid : NDOTest |
17091 | { |
17092 | ····AgrDir1OwnpconOthpconNoTblGuidLeftBase ownVar; |
17093 | ····AgrDir1OwnpconOthpconNoTblGuidRightBase otherVar; |
17094 | ····PersistenceManager pm; |
17095 | ····[SetUp] |
17096 | ····public void Setup() |
17097 | ····{ |
17098 | ········pm = PmFactory.NewPersistenceManager(); |
17099 | ········ownVar = new AgrDir1OwnpconOthpconNoTblGuidLeftDerived(); |
17100 | ········otherVar = new AgrDir1OwnpconOthpconNoTblGuidRightDerived(); |
17101 | ····} |
17102 | ····[TearDown] |
17103 | ····public void TearDown() |
17104 | ····{ |
17105 | ········try |
17106 | ········{ |
17107 | ············pm.UnloadCache(); |
17108 | ············var l = pm.Objects<AgrDir1OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
17109 | ············pm.Delete(l); |
17110 | ············pm.Save(); |
17111 | ············pm.UnloadCache(); |
17112 | ············var m = pm.Objects<AgrDir1OwnpconOthpconNoTblGuidRightBase>().ResultTable; |
17113 | ············pm.Delete(m); |
17114 | ············pm.Save(); |
17115 | ············pm.UnloadCache(); |
17116 | ············decimal count; |
17117 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17118 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17119 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17120 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17121 | ········} |
17122 | ········catch (Exception) |
17123 | ········{ |
17124 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17125 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17126 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17127 | ········} |
17128 | ····} |
17129 | ····[Test] |
17130 | ····public void TestSaveReload() |
17131 | ····{ |
17132 | ········CreateObjects(); |
17133 | ········QueryOwn(); |
17134 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17135 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17136 | ····} |
17137 | ····[Test] |
17138 | ····public void TestSaveReloadNull() |
17139 | ····{ |
17140 | ········CreateObjects(); |
17141 | ········QueryOwn(); |
17142 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17143 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17144 | ········ownVar.RelField = null; |
17145 | ········pm.Save(); |
17146 | ········pm.UnloadCache(); |
17147 | ········QueryOwn(); |
17148 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17149 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17150 | ····} |
17151 | ····[Test] |
17152 | ····public void TestChangeKeyHolderLeft() |
17153 | ····{ |
17154 | ········CreateObjects(); |
17155 | ········QueryOwn(); |
17156 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17157 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17158 | ········int x = ownVar.RelField.Dummy; |
17159 | ········ownVar.Dummy = 4711; |
17160 | ········pm.Save(); |
17161 | ········pm.UnloadCache(); |
17162 | ········QueryOwn(); |
17163 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17164 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17165 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17166 | ····} |
17167 | ····[Test] |
17168 | ····public void TestChangeKeyHolderLeftNoTouch() |
17169 | ····{ |
17170 | ········CreateObjects(); |
17171 | ········QueryOwn(); |
17172 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17174 | ········ownVar.Dummy = 4711; |
17175 | ········pm.Save(); |
17176 | ········pm.UnloadCache(); |
17177 | ········QueryOwn(); |
17178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17179 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17180 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17181 | ····} |
17182 | ····void CreateObjects() |
17183 | ····{ |
17184 | ········pm.MakePersistent(ownVar); |
17185 | ········pm.MakePersistent(otherVar); |
17186 | ········ownVar.AssignRelation(otherVar); |
17187 | ········pm.Save(); |
17188 | ········pm.UnloadCache(); |
17189 | ····} |
17190 | ····void QueryOwn() |
17191 | ····{ |
17192 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidLeftBase>(pm); |
17193 | ········ownVar = q.ExecuteSingle(); |
17194 | ····} |
17195 | ····void QueryOther() |
17196 | ····{ |
17197 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconNoTblGuidRightBase>(pm); |
17198 | ········otherVar = q.ExecuteSingle(); |
17199 | ····} |
17200 | } |
17201 | |
17202 | |
17203 | [TestFixture] |
17204 | public class TestAgrDir1OwnpconOthpconTblGuid : NDOTest |
17205 | { |
17206 | ····AgrDir1OwnpconOthpconTblGuidLeftBase ownVar; |
17207 | ····AgrDir1OwnpconOthpconTblGuidRightBase otherVar; |
17208 | ····PersistenceManager pm; |
17209 | ····[SetUp] |
17210 | ····public void Setup() |
17211 | ····{ |
17212 | ········pm = PmFactory.NewPersistenceManager(); |
17213 | ········ownVar = new AgrDir1OwnpconOthpconTblGuidLeftDerived(); |
17214 | ········otherVar = new AgrDir1OwnpconOthpconTblGuidRightDerived(); |
17215 | ····} |
17216 | ····[TearDown] |
17217 | ····public void TearDown() |
17218 | ····{ |
17219 | ········try |
17220 | ········{ |
17221 | ············pm.UnloadCache(); |
17222 | ············var l = pm.Objects<AgrDir1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17223 | ············pm.Delete(l); |
17224 | ············pm.Save(); |
17225 | ············pm.UnloadCache(); |
17226 | ············var m = pm.Objects<AgrDir1OwnpconOthpconTblGuidRightBase>().ResultTable; |
17227 | ············pm.Delete(m); |
17228 | ············pm.Save(); |
17229 | ············pm.UnloadCache(); |
17230 | ············decimal count; |
17231 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17232 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17233 | ············count = (decimal) new NDOQuery<AgrDir1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17234 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17235 | ········} |
17236 | ········catch (Exception) |
17237 | ········{ |
17238 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17239 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17240 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17241 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17242 | ········} |
17243 | ····} |
17244 | ····[Test] |
17245 | ····public void TestSaveReload() |
17246 | ····{ |
17247 | ········CreateObjects(); |
17248 | ········QueryOwn(); |
17249 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17250 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17251 | ····} |
17252 | ····[Test] |
17253 | ····public void TestSaveReloadNull() |
17254 | ····{ |
17255 | ········CreateObjects(); |
17256 | ········QueryOwn(); |
17257 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17258 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17259 | ········ownVar.RelField = null; |
17260 | ········pm.Save(); |
17261 | ········pm.UnloadCache(); |
17262 | ········QueryOwn(); |
17263 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17264 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17265 | ····} |
17266 | ····[Test] |
17267 | ····public void TestChangeKeyHolderLeft() |
17268 | ····{ |
17269 | ········CreateObjects(); |
17270 | ········QueryOwn(); |
17271 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17272 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17273 | ········int x = ownVar.RelField.Dummy; |
17274 | ········ownVar.Dummy = 4711; |
17275 | ········pm.Save(); |
17276 | ········pm.UnloadCache(); |
17277 | ········QueryOwn(); |
17278 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17279 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17280 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17281 | ····} |
17282 | ····[Test] |
17283 | ····public void TestChangeKeyHolderLeftNoTouch() |
17284 | ····{ |
17285 | ········CreateObjects(); |
17286 | ········QueryOwn(); |
17287 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17288 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17289 | ········ownVar.Dummy = 4711; |
17290 | ········pm.Save(); |
17291 | ········pm.UnloadCache(); |
17292 | ········QueryOwn(); |
17293 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17294 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17295 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17296 | ····} |
17297 | ····void CreateObjects() |
17298 | ····{ |
17299 | ········pm.MakePersistent(ownVar); |
17300 | ········pm.MakePersistent(otherVar); |
17301 | ········ownVar.AssignRelation(otherVar); |
17302 | ········pm.Save(); |
17303 | ········pm.UnloadCache(); |
17304 | ····} |
17305 | ····void QueryOwn() |
17306 | ····{ |
17307 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblGuidLeftBase>(pm); |
17308 | ········ownVar = q.ExecuteSingle(); |
17309 | ····} |
17310 | ····void QueryOther() |
17311 | ····{ |
17312 | ········var q = new NDOQuery<AgrDir1OwnpconOthpconTblGuidRightBase>(pm); |
17313 | ········otherVar = q.ExecuteSingle(); |
17314 | ····} |
17315 | } |
17316 | |
17317 | |
17318 | [TestFixture] |
17319 | public class TestAgrBi11OwnpconOthpconNoTblGuid : NDOTest |
17320 | { |
17321 | ····AgrBi11OwnpconOthpconNoTblGuidLeftBase ownVar; |
17322 | ····AgrBi11OwnpconOthpconNoTblGuidRightBase otherVar; |
17323 | ····PersistenceManager pm; |
17324 | ····[SetUp] |
17325 | ····public void Setup() |
17326 | ····{ |
17327 | ········pm = PmFactory.NewPersistenceManager(); |
17328 | ········ownVar = new AgrBi11OwnpconOthpconNoTblGuidLeftDerived(); |
17329 | ········otherVar = new AgrBi11OwnpconOthpconNoTblGuidRightDerived(); |
17330 | ····} |
17331 | ····[TearDown] |
17332 | ····public void TearDown() |
17333 | ····{ |
17334 | ········try |
17335 | ········{ |
17336 | ············pm.UnloadCache(); |
17337 | ············var l = pm.Objects<AgrBi11OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
17338 | ············pm.Delete(l); |
17339 | ············pm.Save(); |
17340 | ············pm.UnloadCache(); |
17341 | ············var m = pm.Objects<AgrBi11OwnpconOthpconNoTblGuidRightBase>().ResultTable; |
17342 | ············pm.Delete(m); |
17343 | ············pm.Save(); |
17344 | ············pm.UnloadCache(); |
17345 | ············decimal count; |
17346 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17347 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17348 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17349 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17350 | ········} |
17351 | ········catch (Exception) |
17352 | ········{ |
17353 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17354 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17355 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17356 | ········} |
17357 | ····} |
17358 | ····[Test] |
17359 | ····public void TestSaveReload() |
17360 | ····{ |
17361 | ········CreateObjects(); |
17362 | ········QueryOwn(); |
17363 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17364 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17365 | ····} |
17366 | ····[Test] |
17367 | ····public void TestSaveReloadNull() |
17368 | ····{ |
17369 | ········CreateObjects(); |
17370 | ········QueryOwn(); |
17371 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17372 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17373 | ········ownVar.RelField = null; |
17374 | ········pm.Save(); |
17375 | ········pm.UnloadCache(); |
17376 | ········QueryOwn(); |
17377 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17378 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17379 | ····} |
17380 | ····[Test] |
17381 | ····public void TestChangeKeyHolderLeft() |
17382 | ····{ |
17383 | ········CreateObjects(); |
17384 | ········QueryOwn(); |
17385 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17386 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17387 | ········int x = ownVar.RelField.Dummy; |
17388 | ········ownVar.Dummy = 4711; |
17389 | ········pm.Save(); |
17390 | ········pm.UnloadCache(); |
17391 | ········QueryOwn(); |
17392 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17393 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17394 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17395 | ····} |
17396 | ····[Test] |
17397 | ····public void TestChangeKeyHolderRight() |
17398 | ····{ |
17399 | ········CreateObjects(); |
17400 | ········QueryOther(); |
17401 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17402 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17403 | ········int x = otherVar.RelField.Dummy; |
17404 | ········otherVar.Dummy = 4711; |
17405 | ········pm.Save(); |
17406 | ········pm.UnloadCache(); |
17407 | ········QueryOther(); |
17408 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17409 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17410 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17411 | ····} |
17412 | ····[Test] |
17413 | ····public void TestChangeKeyHolderLeftNoTouch() |
17414 | ····{ |
17415 | ········CreateObjects(); |
17416 | ········QueryOwn(); |
17417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17419 | ········ownVar.Dummy = 4711; |
17420 | ········pm.Save(); |
17421 | ········pm.UnloadCache(); |
17422 | ········QueryOwn(); |
17423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17424 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17425 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17426 | ····} |
17427 | ····[Test] |
17428 | ····public void TestChangeKeyHolderRightNoTouch() |
17429 | ····{ |
17430 | ········CreateObjects(); |
17431 | ········QueryOther(); |
17432 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17433 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17434 | ········otherVar.Dummy = 4711; |
17435 | ········pm.Save(); |
17436 | ········pm.UnloadCache(); |
17437 | ········QueryOther(); |
17438 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17439 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17440 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17441 | ····} |
17442 | ····[Test] |
17443 | ····public void TestRelationHash() |
17444 | ····{ |
17445 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidLeftBase)); |
17446 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17447 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidRightBase)); |
17448 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17449 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17450 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17451 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidLeftDerived)); |
17452 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17453 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17454 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17455 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconNoTblGuidRightDerived)); |
17456 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17457 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17458 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17459 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17460 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17461 | ····} |
17462 | ····void CreateObjects() |
17463 | ····{ |
17464 | ········pm.MakePersistent(ownVar); |
17465 | ········pm.MakePersistent(otherVar); |
17466 | ········ownVar.AssignRelation(otherVar); |
17467 | ········pm.Save(); |
17468 | ········pm.UnloadCache(); |
17469 | ····} |
17470 | ····void QueryOwn() |
17471 | ····{ |
17472 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidLeftBase>(pm); |
17473 | ········ownVar = q.ExecuteSingle(); |
17474 | ····} |
17475 | ····void QueryOther() |
17476 | ····{ |
17477 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconNoTblGuidRightBase>(pm); |
17478 | ········otherVar = q.ExecuteSingle(); |
17479 | ····} |
17480 | } |
17481 | |
17482 | |
17483 | [TestFixture] |
17484 | public class TestAgrBi11OwnpconOthpconTblGuid : NDOTest |
17485 | { |
17486 | ····AgrBi11OwnpconOthpconTblGuidLeftBase ownVar; |
17487 | ····AgrBi11OwnpconOthpconTblGuidRightBase otherVar; |
17488 | ····PersistenceManager pm; |
17489 | ····[SetUp] |
17490 | ····public void Setup() |
17491 | ····{ |
17492 | ········pm = PmFactory.NewPersistenceManager(); |
17493 | ········ownVar = new AgrBi11OwnpconOthpconTblGuidLeftDerived(); |
17494 | ········otherVar = new AgrBi11OwnpconOthpconTblGuidRightDerived(); |
17495 | ····} |
17496 | ····[TearDown] |
17497 | ····public void TearDown() |
17498 | ····{ |
17499 | ········try |
17500 | ········{ |
17501 | ············pm.UnloadCache(); |
17502 | ············var l = pm.Objects<AgrBi11OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17503 | ············pm.Delete(l); |
17504 | ············pm.Save(); |
17505 | ············pm.UnloadCache(); |
17506 | ············var m = pm.Objects<AgrBi11OwnpconOthpconTblGuidRightBase>().ResultTable; |
17507 | ············pm.Delete(m); |
17508 | ············pm.Save(); |
17509 | ············pm.UnloadCache(); |
17510 | ············decimal count; |
17511 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17512 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17513 | ············count = (decimal) new NDOQuery<AgrBi11OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17514 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17515 | ········} |
17516 | ········catch (Exception) |
17517 | ········{ |
17518 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17519 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17520 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17521 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17522 | ········} |
17523 | ····} |
17524 | ····[Test] |
17525 | ····public void TestSaveReload() |
17526 | ····{ |
17527 | ········CreateObjects(); |
17528 | ········QueryOwn(); |
17529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17530 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17531 | ····} |
17532 | ····[Test] |
17533 | ····public void TestSaveReloadNull() |
17534 | ····{ |
17535 | ········CreateObjects(); |
17536 | ········QueryOwn(); |
17537 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17538 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17539 | ········ownVar.RelField = null; |
17540 | ········pm.Save(); |
17541 | ········pm.UnloadCache(); |
17542 | ········QueryOwn(); |
17543 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17544 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17545 | ····} |
17546 | ····[Test] |
17547 | ····public void TestChangeKeyHolderLeft() |
17548 | ····{ |
17549 | ········CreateObjects(); |
17550 | ········QueryOwn(); |
17551 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17552 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17553 | ········int x = ownVar.RelField.Dummy; |
17554 | ········ownVar.Dummy = 4711; |
17555 | ········pm.Save(); |
17556 | ········pm.UnloadCache(); |
17557 | ········QueryOwn(); |
17558 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17559 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17560 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17561 | ····} |
17562 | ····[Test] |
17563 | ····public void TestChangeKeyHolderRight() |
17564 | ····{ |
17565 | ········CreateObjects(); |
17566 | ········QueryOther(); |
17567 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17568 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17569 | ········int x = otherVar.RelField.Dummy; |
17570 | ········otherVar.Dummy = 4711; |
17571 | ········pm.Save(); |
17572 | ········pm.UnloadCache(); |
17573 | ········QueryOther(); |
17574 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17575 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17576 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17577 | ····} |
17578 | ····[Test] |
17579 | ····public void TestChangeKeyHolderLeftNoTouch() |
17580 | ····{ |
17581 | ········CreateObjects(); |
17582 | ········QueryOwn(); |
17583 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17584 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17585 | ········ownVar.Dummy = 4711; |
17586 | ········pm.Save(); |
17587 | ········pm.UnloadCache(); |
17588 | ········QueryOwn(); |
17589 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17590 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17591 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17592 | ····} |
17593 | ····[Test] |
17594 | ····public void TestChangeKeyHolderRightNoTouch() |
17595 | ····{ |
17596 | ········CreateObjects(); |
17597 | ········QueryOther(); |
17598 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17599 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17600 | ········otherVar.Dummy = 4711; |
17601 | ········pm.Save(); |
17602 | ········pm.UnloadCache(); |
17603 | ········QueryOther(); |
17604 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17605 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17606 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17607 | ····} |
17608 | ····[Test] |
17609 | ····public void TestRelationHash() |
17610 | ····{ |
17611 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidLeftBase)); |
17612 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17613 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidRightBase)); |
17614 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17615 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17616 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17617 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidLeftDerived)); |
17618 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17619 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17620 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17621 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpconOthpconTblGuidRightDerived)); |
17622 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17623 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17624 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17625 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17626 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17627 | ····} |
17628 | ····void CreateObjects() |
17629 | ····{ |
17630 | ········pm.MakePersistent(ownVar); |
17631 | ········pm.MakePersistent(otherVar); |
17632 | ········ownVar.AssignRelation(otherVar); |
17633 | ········pm.Save(); |
17634 | ········pm.UnloadCache(); |
17635 | ····} |
17636 | ····void QueryOwn() |
17637 | ····{ |
17638 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblGuidLeftBase>(pm); |
17639 | ········ownVar = q.ExecuteSingle(); |
17640 | ····} |
17641 | ····void QueryOther() |
17642 | ····{ |
17643 | ········var q = new NDOQuery<AgrBi11OwnpconOthpconTblGuidRightBase>(pm); |
17644 | ········otherVar = q.ExecuteSingle(); |
17645 | ····} |
17646 | } |
17647 | |
17648 | |
17649 | [TestFixture] |
17650 | public class TestAgrDirnOwnpconOthpconTblGuid : NDOTest |
17651 | { |
17652 | ····AgrDirnOwnpconOthpconTblGuidLeftBase ownVar; |
17653 | ····AgrDirnOwnpconOthpconTblGuidRightBase otherVar; |
17654 | ····PersistenceManager pm; |
17655 | ····[SetUp] |
17656 | ····public void Setup() |
17657 | ····{ |
17658 | ········pm = PmFactory.NewPersistenceManager(); |
17659 | ········ownVar = new AgrDirnOwnpconOthpconTblGuidLeftDerived(); |
17660 | ········otherVar = new AgrDirnOwnpconOthpconTblGuidRightDerived(); |
17661 | ····} |
17662 | ····[TearDown] |
17663 | ····public void TearDown() |
17664 | ····{ |
17665 | ········try |
17666 | ········{ |
17667 | ············pm.UnloadCache(); |
17668 | ············var l = pm.Objects<AgrDirnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
17669 | ············pm.Delete(l); |
17670 | ············pm.Save(); |
17671 | ············pm.UnloadCache(); |
17672 | ············var m = pm.Objects<AgrDirnOwnpconOthpconTblGuidRightBase>().ResultTable; |
17673 | ············pm.Delete(m); |
17674 | ············pm.Save(); |
17675 | ············pm.UnloadCache(); |
17676 | ············decimal count; |
17677 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17678 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17679 | ············count = (decimal) new NDOQuery<AgrDirnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17680 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17681 | ········} |
17682 | ········catch (Exception) |
17683 | ········{ |
17684 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17685 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17686 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17687 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17688 | ········} |
17689 | ····} |
17690 | ····[Test] |
17691 | ····public void TestSaveReload() |
17692 | ····{ |
17693 | ········CreateObjects(); |
17694 | ········QueryOwn(); |
17695 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17696 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17697 | ····} |
17698 | ····[Test] |
17699 | ····public void TestSaveReloadNull() |
17700 | ····{ |
17701 | ········CreateObjects(); |
17702 | ········QueryOwn(); |
17703 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17704 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17705 | ········ownVar.RelField = new List<AgrDirnOwnpconOthpconTblGuidRightBase>(); |
17706 | ········pm.Save(); |
17707 | ········pm.UnloadCache(); |
17708 | ········QueryOwn(); |
17709 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17710 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17711 | ····} |
17712 | ····[Test] |
17713 | ····public void TestSaveReloadRemove() |
17714 | ····{ |
17715 | ········CreateObjects(); |
17716 | ········QueryOwn(); |
17717 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17718 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17719 | ········ownVar.RemoveRelatedObject(); |
17720 | ········pm.Save(); |
17721 | ········pm.UnloadCache(); |
17722 | ········QueryOwn(); |
17723 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17724 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17725 | ····} |
17726 | ····void CreateObjects() |
17727 | ····{ |
17728 | ········pm.MakePersistent(ownVar); |
17729 | ········pm.MakePersistent(otherVar); |
17730 | ········ownVar.AssignRelation(otherVar); |
17731 | ········pm.Save(); |
17732 | ········pm.UnloadCache(); |
17733 | ····} |
17734 | ····void QueryOwn() |
17735 | ····{ |
17736 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblGuidLeftBase>(pm); |
17737 | ········ownVar = q.ExecuteSingle(); |
17738 | ····} |
17739 | ····void QueryOther() |
17740 | ····{ |
17741 | ········var q = new NDOQuery<AgrDirnOwnpconOthpconTblGuidRightBase>(pm); |
17742 | ········otherVar = q.ExecuteSingle(); |
17743 | ····} |
17744 | } |
17745 | |
17746 | |
17747 | [TestFixture] |
17748 | public class TestAgrBin1OwnpconOthpconTblGuid : NDOTest |
17749 | { |
17750 | ····AgrBin1OwnpconOthpconTblGuidLeftBase ownVar; |
17751 | ····AgrBin1OwnpconOthpconTblGuidRightBase otherVar; |
17752 | ····PersistenceManager pm; |
17753 | ····[SetUp] |
17754 | ····public void Setup() |
17755 | ····{ |
17756 | ········pm = PmFactory.NewPersistenceManager(); |
17757 | ········ownVar = new AgrBin1OwnpconOthpconTblGuidLeftDerived(); |
17758 | ········otherVar = new AgrBin1OwnpconOthpconTblGuidRightDerived(); |
17759 | ····} |
17760 | ····[TearDown] |
17761 | ····public void TearDown() |
17762 | ····{ |
17763 | ········try |
17764 | ········{ |
17765 | ············pm.UnloadCache(); |
17766 | ············var l = pm.Objects<AgrBin1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
17767 | ············pm.Delete(l); |
17768 | ············pm.Save(); |
17769 | ············pm.UnloadCache(); |
17770 | ············var m = pm.Objects<AgrBin1OwnpconOthpconTblGuidRightBase>().ResultTable; |
17771 | ············pm.Delete(m); |
17772 | ············pm.Save(); |
17773 | ············pm.UnloadCache(); |
17774 | ············decimal count; |
17775 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17776 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17777 | ············count = (decimal) new NDOQuery<AgrBin1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17778 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17779 | ········} |
17780 | ········catch (Exception) |
17781 | ········{ |
17782 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17783 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17784 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17785 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17786 | ········} |
17787 | ····} |
17788 | ····[Test] |
17789 | ····public void TestSaveReload() |
17790 | ····{ |
17791 | ········CreateObjects(); |
17792 | ········QueryOwn(); |
17793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17794 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17795 | ····} |
17796 | ····[Test] |
17797 | ····public void TestSaveReloadNull() |
17798 | ····{ |
17799 | ········CreateObjects(); |
17800 | ········QueryOwn(); |
17801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17802 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17803 | ········ownVar.RelField = new List<AgrBin1OwnpconOthpconTblGuidRightBase>(); |
17804 | ········pm.Save(); |
17805 | ········pm.UnloadCache(); |
17806 | ········QueryOwn(); |
17807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17808 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17809 | ····} |
17810 | ····[Test] |
17811 | ····public void TestSaveReloadRemove() |
17812 | ····{ |
17813 | ········CreateObjects(); |
17814 | ········QueryOwn(); |
17815 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17816 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17817 | ········ownVar.RemoveRelatedObject(); |
17818 | ········pm.Save(); |
17819 | ········pm.UnloadCache(); |
17820 | ········QueryOwn(); |
17821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17822 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
17823 | ····} |
17824 | ····[Test] |
17825 | ····public void TestChangeKeyHolderRight() |
17826 | ····{ |
17827 | ········CreateObjects(); |
17828 | ········QueryOther(); |
17829 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17830 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17831 | ········int x = otherVar.RelField.Dummy; |
17832 | ········otherVar.Dummy = 4711; |
17833 | ········pm.Save(); |
17834 | ········pm.UnloadCache(); |
17835 | ········QueryOther(); |
17836 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17837 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17838 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17839 | ····} |
17840 | ····[Test] |
17841 | ····public void TestChangeKeyHolderRightNoTouch() |
17842 | ····{ |
17843 | ········CreateObjects(); |
17844 | ········QueryOther(); |
17845 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17846 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17847 | ········otherVar.Dummy = 4711; |
17848 | ········pm.Save(); |
17849 | ········pm.UnloadCache(); |
17850 | ········QueryOther(); |
17851 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
17852 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17853 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
17854 | ····} |
17855 | ····[Test] |
17856 | ····public void TestRelationHash() |
17857 | ····{ |
17858 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidLeftBase)); |
17859 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17860 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidRightBase)); |
17861 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17862 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17863 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17864 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidLeftDerived)); |
17865 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
17866 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
17867 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
17868 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpconOthpconTblGuidRightDerived)); |
17869 | ········Relation relderRight = clderRight.FindRelation("relField"); |
17870 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
17871 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
17872 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
17873 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
17874 | ····} |
17875 | ····void CreateObjects() |
17876 | ····{ |
17877 | ········pm.MakePersistent(ownVar); |
17878 | ········pm.MakePersistent(otherVar); |
17879 | ········ownVar.AssignRelation(otherVar); |
17880 | ········pm.Save(); |
17881 | ········pm.UnloadCache(); |
17882 | ····} |
17883 | ····void QueryOwn() |
17884 | ····{ |
17885 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblGuidLeftBase>(pm); |
17886 | ········ownVar = q.ExecuteSingle(); |
17887 | ····} |
17888 | ····void QueryOther() |
17889 | ····{ |
17890 | ········var q = new NDOQuery<AgrBin1OwnpconOthpconTblGuidRightBase>(pm); |
17891 | ········otherVar = q.ExecuteSingle(); |
17892 | ····} |
17893 | } |
17894 | |
17895 | |
17896 | [TestFixture] |
17897 | public class TestAgrBi1nOwnpconOthpconTblGuid : NDOTest |
17898 | { |
17899 | ····AgrBi1nOwnpconOthpconTblGuidLeftBase ownVar; |
17900 | ····AgrBi1nOwnpconOthpconTblGuidRightBase otherVar; |
17901 | ····PersistenceManager pm; |
17902 | ····[SetUp] |
17903 | ····public void Setup() |
17904 | ····{ |
17905 | ········pm = PmFactory.NewPersistenceManager(); |
17906 | ········ownVar = new AgrBi1nOwnpconOthpconTblGuidLeftDerived(); |
17907 | ········otherVar = new AgrBi1nOwnpconOthpconTblGuidRightDerived(); |
17908 | ····} |
17909 | ····[TearDown] |
17910 | ····public void TearDown() |
17911 | ····{ |
17912 | ········try |
17913 | ········{ |
17914 | ············pm.UnloadCache(); |
17915 | ············var l = pm.Objects<AgrBi1nOwnpconOthpconTblGuidLeftBase>().ResultTable; |
17916 | ············pm.Delete(l); |
17917 | ············pm.Save(); |
17918 | ············pm.UnloadCache(); |
17919 | ············var m = pm.Objects<AgrBi1nOwnpconOthpconTblGuidRightBase>().ResultTable; |
17920 | ············pm.Delete(m); |
17921 | ············pm.Save(); |
17922 | ············pm.UnloadCache(); |
17923 | ············decimal count; |
17924 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17925 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
17926 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
17927 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
17928 | ········} |
17929 | ········catch (Exception) |
17930 | ········{ |
17931 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
17932 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
17933 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
17934 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
17935 | ········} |
17936 | ····} |
17937 | ····[Test] |
17938 | ····public void TestSaveReload() |
17939 | ····{ |
17940 | ········CreateObjects(); |
17941 | ········QueryOwn(); |
17942 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17943 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17944 | ····} |
17945 | ····[Test] |
17946 | ····public void TestSaveReloadNull() |
17947 | ····{ |
17948 | ········CreateObjects(); |
17949 | ········QueryOwn(); |
17950 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17951 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17952 | ········ownVar.RelField = null; |
17953 | ········pm.Save(); |
17954 | ········pm.UnloadCache(); |
17955 | ········QueryOwn(); |
17956 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17957 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
17958 | ····} |
17959 | ····[Test] |
17960 | ····public void TestChangeKeyHolderLeft() |
17961 | ····{ |
17962 | ········CreateObjects(); |
17963 | ········QueryOwn(); |
17964 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17965 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17966 | ········int x = ownVar.RelField.Dummy; |
17967 | ········ownVar.Dummy = 4711; |
17968 | ········pm.Save(); |
17969 | ········pm.UnloadCache(); |
17970 | ········QueryOwn(); |
17971 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17972 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17973 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17974 | ····} |
17975 | ····[Test] |
17976 | ····public void TestChangeKeyHolderLeftNoTouch() |
17977 | ····{ |
17978 | ········CreateObjects(); |
17979 | ········QueryOwn(); |
17980 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17981 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17982 | ········ownVar.Dummy = 4711; |
17983 | ········pm.Save(); |
17984 | ········pm.UnloadCache(); |
17985 | ········QueryOwn(); |
17986 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
17987 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
17988 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
17989 | ····} |
17990 | ····[Test] |
17991 | ····public void TestRelationHash() |
17992 | ····{ |
17993 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidLeftBase)); |
17994 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
17995 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidRightBase)); |
17996 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
17997 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
17998 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
17999 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidLeftDerived)); |
18000 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18001 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18002 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18003 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpconOthpconTblGuidRightDerived)); |
18004 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18005 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18006 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18007 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18008 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18009 | ····} |
18010 | ····void CreateObjects() |
18011 | ····{ |
18012 | ········pm.MakePersistent(ownVar); |
18013 | ········pm.MakePersistent(otherVar); |
18014 | ········ownVar.AssignRelation(otherVar); |
18015 | ········pm.Save(); |
18016 | ········pm.UnloadCache(); |
18017 | ····} |
18018 | ····void QueryOwn() |
18019 | ····{ |
18020 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblGuidLeftBase>(pm); |
18021 | ········ownVar = q.ExecuteSingle(); |
18022 | ····} |
18023 | ····void QueryOther() |
18024 | ····{ |
18025 | ········var q = new NDOQuery<AgrBi1nOwnpconOthpconTblGuidRightBase>(pm); |
18026 | ········otherVar = q.ExecuteSingle(); |
18027 | ····} |
18028 | } |
18029 | |
18030 | |
18031 | [TestFixture] |
18032 | public class TestAgrBinnOwnpconOthpconTblGuid : NDOTest |
18033 | { |
18034 | ····AgrBinnOwnpconOthpconTblGuidLeftBase ownVar; |
18035 | ····AgrBinnOwnpconOthpconTblGuidRightBase otherVar; |
18036 | ····PersistenceManager pm; |
18037 | ····[SetUp] |
18038 | ····public void Setup() |
18039 | ····{ |
18040 | ········pm = PmFactory.NewPersistenceManager(); |
18041 | ········ownVar = new AgrBinnOwnpconOthpconTblGuidLeftDerived(); |
18042 | ········otherVar = new AgrBinnOwnpconOthpconTblGuidRightDerived(); |
18043 | ····} |
18044 | ····[TearDown] |
18045 | ····public void TearDown() |
18046 | ····{ |
18047 | ········try |
18048 | ········{ |
18049 | ············pm.UnloadCache(); |
18050 | ············var l = pm.Objects<AgrBinnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18051 | ············pm.Delete(l); |
18052 | ············pm.Save(); |
18053 | ············pm.UnloadCache(); |
18054 | ············var m = pm.Objects<AgrBinnOwnpconOthpconTblGuidRightBase>().ResultTable; |
18055 | ············pm.Delete(m); |
18056 | ············pm.Save(); |
18057 | ············pm.UnloadCache(); |
18058 | ············decimal count; |
18059 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18060 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18061 | ············count = (decimal) new NDOQuery<AgrBinnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18062 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18063 | ········} |
18064 | ········catch (Exception) |
18065 | ········{ |
18066 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18067 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18068 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18069 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18070 | ········} |
18071 | ····} |
18072 | ····[Test] |
18073 | ····public void TestSaveReload() |
18074 | ····{ |
18075 | ········CreateObjects(); |
18076 | ········QueryOwn(); |
18077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18078 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18079 | ····} |
18080 | ····[Test] |
18081 | ····public void TestSaveReloadNull() |
18082 | ····{ |
18083 | ········CreateObjects(); |
18084 | ········QueryOwn(); |
18085 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18086 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18087 | ········ownVar.RelField = new List<AgrBinnOwnpconOthpconTblGuidRightBase>(); |
18088 | ········pm.Save(); |
18089 | ········pm.UnloadCache(); |
18090 | ········QueryOwn(); |
18091 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18092 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18093 | ····} |
18094 | ····[Test] |
18095 | ····public void TestSaveReloadRemove() |
18096 | ····{ |
18097 | ········CreateObjects(); |
18098 | ········QueryOwn(); |
18099 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18100 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18101 | ········ownVar.RemoveRelatedObject(); |
18102 | ········pm.Save(); |
18103 | ········pm.UnloadCache(); |
18104 | ········QueryOwn(); |
18105 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18106 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18107 | ····} |
18108 | ····[Test] |
18109 | ····public void TestRelationHash() |
18110 | ····{ |
18111 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidLeftBase)); |
18112 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18113 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidRightBase)); |
18114 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18115 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18116 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18117 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidLeftDerived)); |
18118 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18119 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18120 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18121 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpconOthpconTblGuidRightDerived)); |
18122 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18123 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18124 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18125 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18126 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18127 | ····} |
18128 | ····void CreateObjects() |
18129 | ····{ |
18130 | ········pm.MakePersistent(ownVar); |
18131 | ········pm.MakePersistent(otherVar); |
18132 | ········ownVar.AssignRelation(otherVar); |
18133 | ········pm.Save(); |
18134 | ········pm.UnloadCache(); |
18135 | ····} |
18136 | ····void QueryOwn() |
18137 | ····{ |
18138 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblGuidLeftBase>(pm); |
18139 | ········ownVar = q.ExecuteSingle(); |
18140 | ····} |
18141 | ····void QueryOther() |
18142 | ····{ |
18143 | ········var q = new NDOQuery<AgrBinnOwnpconOthpconTblGuidRightBase>(pm); |
18144 | ········otherVar = q.ExecuteSingle(); |
18145 | ····} |
18146 | } |
18147 | |
18148 | |
18149 | [TestFixture] |
18150 | public class TestCmpDir1OwnpconOthpconNoTblGuid : NDOTest |
18151 | { |
18152 | ····CmpDir1OwnpconOthpconNoTblGuidLeftBase ownVar; |
18153 | ····CmpDir1OwnpconOthpconNoTblGuidRightBase otherVar; |
18154 | ····PersistenceManager pm; |
18155 | ····[SetUp] |
18156 | ····public void Setup() |
18157 | ····{ |
18158 | ········pm = PmFactory.NewPersistenceManager(); |
18159 | ········ownVar = new CmpDir1OwnpconOthpconNoTblGuidLeftDerived(); |
18160 | ········otherVar = new CmpDir1OwnpconOthpconNoTblGuidRightDerived(); |
18161 | ····} |
18162 | ····[TearDown] |
18163 | ····public void TearDown() |
18164 | ····{ |
18165 | ········try |
18166 | ········{ |
18167 | ············pm.UnloadCache(); |
18168 | ············var l = pm.Objects<CmpDir1OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
18169 | ············pm.Delete(l); |
18170 | ············pm.Save(); |
18171 | ············pm.UnloadCache(); |
18172 | ············decimal count; |
18173 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18174 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18175 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18176 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18177 | ········} |
18178 | ········catch (Exception) |
18179 | ········{ |
18180 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18181 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18182 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18183 | ········} |
18184 | ····} |
18185 | ····[Test] |
18186 | ····public void TestSaveReload() |
18187 | ····{ |
18188 | ········CreateObjects(); |
18189 | ········QueryOwn(); |
18190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18191 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18192 | ····} |
18193 | ····[Test] |
18194 | ····public void TestSaveReloadNull() |
18195 | ····{ |
18196 | ········CreateObjects(); |
18197 | ········QueryOwn(); |
18198 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18199 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18200 | ········ownVar.RelField = null; |
18201 | ········pm.Save(); |
18202 | ········pm.UnloadCache(); |
18203 | ········QueryOwn(); |
18204 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18205 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18206 | ····} |
18207 | ····[Test] |
18208 | ····public void TestChangeKeyHolderLeft() |
18209 | ····{ |
18210 | ········CreateObjects(); |
18211 | ········QueryOwn(); |
18212 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18213 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18214 | ········int x = ownVar.RelField.Dummy; |
18215 | ········ownVar.Dummy = 4711; |
18216 | ········pm.Save(); |
18217 | ········pm.UnloadCache(); |
18218 | ········QueryOwn(); |
18219 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18220 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18221 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18222 | ····} |
18223 | ····[Test] |
18224 | ····public void TestChangeKeyHolderLeftNoTouch() |
18225 | ····{ |
18226 | ········CreateObjects(); |
18227 | ········QueryOwn(); |
18228 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18229 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18230 | ········ownVar.Dummy = 4711; |
18231 | ········pm.Save(); |
18232 | ········pm.UnloadCache(); |
18233 | ········QueryOwn(); |
18234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18235 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18236 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18237 | ····} |
18238 | ····void CreateObjects() |
18239 | ····{ |
18240 | ········pm.MakePersistent(ownVar); |
18241 | ········ownVar.AssignRelation(otherVar); |
18242 | ········pm.Save(); |
18243 | ········pm.UnloadCache(); |
18244 | ····} |
18245 | ····void QueryOwn() |
18246 | ····{ |
18247 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidLeftBase>(pm); |
18248 | ········ownVar = q.ExecuteSingle(); |
18249 | ····} |
18250 | ····void QueryOther() |
18251 | ····{ |
18252 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconNoTblGuidRightBase>(pm); |
18253 | ········otherVar = q.ExecuteSingle(); |
18254 | ····} |
18255 | } |
18256 | |
18257 | |
18258 | [TestFixture] |
18259 | public class TestCmpDir1OwnpconOthpconTblGuid : NDOTest |
18260 | { |
18261 | ····CmpDir1OwnpconOthpconTblGuidLeftBase ownVar; |
18262 | ····CmpDir1OwnpconOthpconTblGuidRightBase otherVar; |
18263 | ····PersistenceManager pm; |
18264 | ····[SetUp] |
18265 | ····public void Setup() |
18266 | ····{ |
18267 | ········pm = PmFactory.NewPersistenceManager(); |
18268 | ········ownVar = new CmpDir1OwnpconOthpconTblGuidLeftDerived(); |
18269 | ········otherVar = new CmpDir1OwnpconOthpconTblGuidRightDerived(); |
18270 | ····} |
18271 | ····[TearDown] |
18272 | ····public void TearDown() |
18273 | ····{ |
18274 | ········try |
18275 | ········{ |
18276 | ············pm.UnloadCache(); |
18277 | ············var l = pm.Objects<CmpDir1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18278 | ············pm.Delete(l); |
18279 | ············pm.Save(); |
18280 | ············pm.UnloadCache(); |
18281 | ············decimal count; |
18282 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18283 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18284 | ············count = (decimal) new NDOQuery<CmpDir1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18285 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18286 | ········} |
18287 | ········catch (Exception) |
18288 | ········{ |
18289 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18290 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18291 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18292 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18293 | ········} |
18294 | ····} |
18295 | ····[Test] |
18296 | ····public void TestSaveReload() |
18297 | ····{ |
18298 | ········CreateObjects(); |
18299 | ········QueryOwn(); |
18300 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18301 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18302 | ····} |
18303 | ····[Test] |
18304 | ····public void TestSaveReloadNull() |
18305 | ····{ |
18306 | ········CreateObjects(); |
18307 | ········QueryOwn(); |
18308 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18309 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18310 | ········ownVar.RelField = null; |
18311 | ········pm.Save(); |
18312 | ········pm.UnloadCache(); |
18313 | ········QueryOwn(); |
18314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18315 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18316 | ····} |
18317 | ····[Test] |
18318 | ····public void TestChangeKeyHolderLeft() |
18319 | ····{ |
18320 | ········CreateObjects(); |
18321 | ········QueryOwn(); |
18322 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18323 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18324 | ········int x = ownVar.RelField.Dummy; |
18325 | ········ownVar.Dummy = 4711; |
18326 | ········pm.Save(); |
18327 | ········pm.UnloadCache(); |
18328 | ········QueryOwn(); |
18329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18330 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18332 | ····} |
18333 | ····[Test] |
18334 | ····public void TestChangeKeyHolderLeftNoTouch() |
18335 | ····{ |
18336 | ········CreateObjects(); |
18337 | ········QueryOwn(); |
18338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18340 | ········ownVar.Dummy = 4711; |
18341 | ········pm.Save(); |
18342 | ········pm.UnloadCache(); |
18343 | ········QueryOwn(); |
18344 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18345 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18346 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18347 | ····} |
18348 | ····void CreateObjects() |
18349 | ····{ |
18350 | ········pm.MakePersistent(ownVar); |
18351 | ········ownVar.AssignRelation(otherVar); |
18352 | ········pm.Save(); |
18353 | ········pm.UnloadCache(); |
18354 | ····} |
18355 | ····void QueryOwn() |
18356 | ····{ |
18357 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblGuidLeftBase>(pm); |
18358 | ········ownVar = q.ExecuteSingle(); |
18359 | ····} |
18360 | ····void QueryOther() |
18361 | ····{ |
18362 | ········var q = new NDOQuery<CmpDir1OwnpconOthpconTblGuidRightBase>(pm); |
18363 | ········otherVar = q.ExecuteSingle(); |
18364 | ····} |
18365 | } |
18366 | |
18367 | |
18368 | [TestFixture] |
18369 | public class TestCmpBi11OwnpconOthpconNoTblGuid : NDOTest |
18370 | { |
18371 | ····CmpBi11OwnpconOthpconNoTblGuidLeftBase ownVar; |
18372 | ····CmpBi11OwnpconOthpconNoTblGuidRightBase otherVar; |
18373 | ····PersistenceManager pm; |
18374 | ····[SetUp] |
18375 | ····public void Setup() |
18376 | ····{ |
18377 | ········pm = PmFactory.NewPersistenceManager(); |
18378 | ········ownVar = new CmpBi11OwnpconOthpconNoTblGuidLeftDerived(); |
18379 | ········otherVar = new CmpBi11OwnpconOthpconNoTblGuidRightDerived(); |
18380 | ····} |
18381 | ····[TearDown] |
18382 | ····public void TearDown() |
18383 | ····{ |
18384 | ········try |
18385 | ········{ |
18386 | ············pm.UnloadCache(); |
18387 | ············var l = pm.Objects<CmpBi11OwnpconOthpconNoTblGuidLeftBase>().ResultTable; |
18388 | ············pm.Delete(l); |
18389 | ············pm.Save(); |
18390 | ············pm.UnloadCache(); |
18391 | ············decimal count; |
18392 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18393 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18394 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18395 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18396 | ········} |
18397 | ········catch (Exception) |
18398 | ········{ |
18399 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18400 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18401 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18402 | ········} |
18403 | ····} |
18404 | ····[Test] |
18405 | ····public void TestSaveReload() |
18406 | ····{ |
18407 | ········CreateObjects(); |
18408 | ········QueryOwn(); |
18409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18410 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18411 | ····} |
18412 | ····[Test] |
18413 | ····public void TestSaveReloadNull() |
18414 | ····{ |
18415 | ········CreateObjects(); |
18416 | ········QueryOwn(); |
18417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18419 | ········ownVar.RelField = null; |
18420 | ········pm.Save(); |
18421 | ········pm.UnloadCache(); |
18422 | ········QueryOwn(); |
18423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18424 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18425 | ····} |
18426 | ····[Test] |
18427 | ····public void TestChangeKeyHolderLeft() |
18428 | ····{ |
18429 | ········CreateObjects(); |
18430 | ········QueryOwn(); |
18431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18432 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18433 | ········int x = ownVar.RelField.Dummy; |
18434 | ········ownVar.Dummy = 4711; |
18435 | ········pm.Save(); |
18436 | ········pm.UnloadCache(); |
18437 | ········QueryOwn(); |
18438 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18439 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18440 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18441 | ····} |
18442 | ····[Test] |
18443 | ····public void TestChangeKeyHolderRight() |
18444 | ····{ |
18445 | ········CreateObjects(); |
18446 | ········QueryOther(); |
18447 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18448 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18449 | ········int x = otherVar.RelField.Dummy; |
18450 | ········otherVar.Dummy = 4711; |
18451 | ········pm.Save(); |
18452 | ········pm.UnloadCache(); |
18453 | ········QueryOther(); |
18454 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18455 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18456 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18457 | ····} |
18458 | ····[Test] |
18459 | ····public void TestChangeKeyHolderLeftNoTouch() |
18460 | ····{ |
18461 | ········CreateObjects(); |
18462 | ········QueryOwn(); |
18463 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18464 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18465 | ········ownVar.Dummy = 4711; |
18466 | ········pm.Save(); |
18467 | ········pm.UnloadCache(); |
18468 | ········QueryOwn(); |
18469 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18470 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18471 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18472 | ····} |
18473 | ····[Test] |
18474 | ····public void TestChangeKeyHolderRightNoTouch() |
18475 | ····{ |
18476 | ········CreateObjects(); |
18477 | ········QueryOther(); |
18478 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18479 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18480 | ········otherVar.Dummy = 4711; |
18481 | ········pm.Save(); |
18482 | ········pm.UnloadCache(); |
18483 | ········QueryOther(); |
18484 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18485 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18486 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18487 | ····} |
18488 | ····[Test] |
18489 | ····public void TestRelationHash() |
18490 | ····{ |
18491 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidLeftBase)); |
18492 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18493 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidRightBase)); |
18494 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18495 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18496 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18497 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidLeftDerived)); |
18498 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18499 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18500 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18501 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconNoTblGuidRightDerived)); |
18502 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18503 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18504 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18505 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18506 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18507 | ····} |
18508 | ····void CreateObjects() |
18509 | ····{ |
18510 | ········pm.MakePersistent(ownVar); |
18511 | ········ownVar.AssignRelation(otherVar); |
18512 | ········pm.Save(); |
18513 | ········pm.UnloadCache(); |
18514 | ····} |
18515 | ····void QueryOwn() |
18516 | ····{ |
18517 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidLeftBase>(pm); |
18518 | ········ownVar = q.ExecuteSingle(); |
18519 | ····} |
18520 | ····void QueryOther() |
18521 | ····{ |
18522 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconNoTblGuidRightBase>(pm); |
18523 | ········otherVar = q.ExecuteSingle(); |
18524 | ····} |
18525 | } |
18526 | |
18527 | |
18528 | [TestFixture] |
18529 | public class TestCmpBi11OwnpconOthpconTblGuid : NDOTest |
18530 | { |
18531 | ····CmpBi11OwnpconOthpconTblGuidLeftBase ownVar; |
18532 | ····CmpBi11OwnpconOthpconTblGuidRightBase otherVar; |
18533 | ····PersistenceManager pm; |
18534 | ····[SetUp] |
18535 | ····public void Setup() |
18536 | ····{ |
18537 | ········pm = PmFactory.NewPersistenceManager(); |
18538 | ········ownVar = new CmpBi11OwnpconOthpconTblGuidLeftDerived(); |
18539 | ········otherVar = new CmpBi11OwnpconOthpconTblGuidRightDerived(); |
18540 | ····} |
18541 | ····[TearDown] |
18542 | ····public void TearDown() |
18543 | ····{ |
18544 | ········try |
18545 | ········{ |
18546 | ············pm.UnloadCache(); |
18547 | ············var l = pm.Objects<CmpBi11OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18548 | ············pm.Delete(l); |
18549 | ············pm.Save(); |
18550 | ············pm.UnloadCache(); |
18551 | ············decimal count; |
18552 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18553 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18554 | ············count = (decimal) new NDOQuery<CmpBi11OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18555 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18556 | ········} |
18557 | ········catch (Exception) |
18558 | ········{ |
18559 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18560 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18561 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18562 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18563 | ········} |
18564 | ····} |
18565 | ····[Test] |
18566 | ····public void TestSaveReload() |
18567 | ····{ |
18568 | ········CreateObjects(); |
18569 | ········QueryOwn(); |
18570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18571 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18572 | ····} |
18573 | ····[Test] |
18574 | ····public void TestSaveReloadNull() |
18575 | ····{ |
18576 | ········CreateObjects(); |
18577 | ········QueryOwn(); |
18578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18579 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18580 | ········ownVar.RelField = null; |
18581 | ········pm.Save(); |
18582 | ········pm.UnloadCache(); |
18583 | ········QueryOwn(); |
18584 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18585 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18586 | ····} |
18587 | ····[Test] |
18588 | ····public void TestChangeKeyHolderLeft() |
18589 | ····{ |
18590 | ········CreateObjects(); |
18591 | ········QueryOwn(); |
18592 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18593 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18594 | ········int x = ownVar.RelField.Dummy; |
18595 | ········ownVar.Dummy = 4711; |
18596 | ········pm.Save(); |
18597 | ········pm.UnloadCache(); |
18598 | ········QueryOwn(); |
18599 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18600 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18601 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18602 | ····} |
18603 | ····[Test] |
18604 | ····public void TestChangeKeyHolderRight() |
18605 | ····{ |
18606 | ········CreateObjects(); |
18607 | ········QueryOther(); |
18608 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18609 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18610 | ········int x = otherVar.RelField.Dummy; |
18611 | ········otherVar.Dummy = 4711; |
18612 | ········pm.Save(); |
18613 | ········pm.UnloadCache(); |
18614 | ········QueryOther(); |
18615 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18616 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18617 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18618 | ····} |
18619 | ····[Test] |
18620 | ····public void TestChangeKeyHolderLeftNoTouch() |
18621 | ····{ |
18622 | ········CreateObjects(); |
18623 | ········QueryOwn(); |
18624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18625 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18626 | ········ownVar.Dummy = 4711; |
18627 | ········pm.Save(); |
18628 | ········pm.UnloadCache(); |
18629 | ········QueryOwn(); |
18630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18631 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18632 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18633 | ····} |
18634 | ····[Test] |
18635 | ····public void TestChangeKeyHolderRightNoTouch() |
18636 | ····{ |
18637 | ········CreateObjects(); |
18638 | ········QueryOther(); |
18639 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18640 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18641 | ········otherVar.Dummy = 4711; |
18642 | ········pm.Save(); |
18643 | ········pm.UnloadCache(); |
18644 | ········QueryOther(); |
18645 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18646 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18647 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18648 | ····} |
18649 | ····[Test] |
18650 | ····public void TestRelationHash() |
18651 | ····{ |
18652 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidLeftBase)); |
18653 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18654 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidRightBase)); |
18655 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18656 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18657 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18658 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidLeftDerived)); |
18659 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18660 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18661 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18662 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpconOthpconTblGuidRightDerived)); |
18663 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18664 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18665 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18666 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18667 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18668 | ····} |
18669 | ····void CreateObjects() |
18670 | ····{ |
18671 | ········pm.MakePersistent(ownVar); |
18672 | ········ownVar.AssignRelation(otherVar); |
18673 | ········pm.Save(); |
18674 | ········pm.UnloadCache(); |
18675 | ····} |
18676 | ····void QueryOwn() |
18677 | ····{ |
18678 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblGuidLeftBase>(pm); |
18679 | ········ownVar = q.ExecuteSingle(); |
18680 | ····} |
18681 | ····void QueryOther() |
18682 | ····{ |
18683 | ········var q = new NDOQuery<CmpBi11OwnpconOthpconTblGuidRightBase>(pm); |
18684 | ········otherVar = q.ExecuteSingle(); |
18685 | ····} |
18686 | } |
18687 | |
18688 | |
18689 | [TestFixture] |
18690 | public class TestCmpDirnOwnpconOthpconTblGuid : NDOTest |
18691 | { |
18692 | ····CmpDirnOwnpconOthpconTblGuidLeftBase ownVar; |
18693 | ····CmpDirnOwnpconOthpconTblGuidRightBase otherVar; |
18694 | ····PersistenceManager pm; |
18695 | ····[SetUp] |
18696 | ····public void Setup() |
18697 | ····{ |
18698 | ········pm = PmFactory.NewPersistenceManager(); |
18699 | ········ownVar = new CmpDirnOwnpconOthpconTblGuidLeftDerived(); |
18700 | ········otherVar = new CmpDirnOwnpconOthpconTblGuidRightDerived(); |
18701 | ····} |
18702 | ····[TearDown] |
18703 | ····public void TearDown() |
18704 | ····{ |
18705 | ········try |
18706 | ········{ |
18707 | ············pm.UnloadCache(); |
18708 | ············var l = pm.Objects<CmpDirnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18709 | ············pm.Delete(l); |
18710 | ············pm.Save(); |
18711 | ············pm.UnloadCache(); |
18712 | ············decimal count; |
18713 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18714 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18715 | ············count = (decimal) new NDOQuery<CmpDirnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18716 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18717 | ········} |
18718 | ········catch (Exception) |
18719 | ········{ |
18720 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18721 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18722 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18723 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18724 | ········} |
18725 | ····} |
18726 | ····[Test] |
18727 | ····public void TestSaveReload() |
18728 | ····{ |
18729 | ········CreateObjects(); |
18730 | ········QueryOwn(); |
18731 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18732 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18733 | ····} |
18734 | ····[Test] |
18735 | ····public void TestSaveReloadNull() |
18736 | ····{ |
18737 | ········CreateObjects(); |
18738 | ········QueryOwn(); |
18739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18740 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18741 | ········ownVar.RelField = new List<CmpDirnOwnpconOthpconTblGuidRightBase>(); |
18742 | ········pm.Save(); |
18743 | ········pm.UnloadCache(); |
18744 | ········QueryOwn(); |
18745 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18746 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18747 | ····} |
18748 | ····[Test] |
18749 | ····public void TestSaveReloadRemove() |
18750 | ····{ |
18751 | ········CreateObjects(); |
18752 | ········QueryOwn(); |
18753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18754 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18755 | ········ownVar.RemoveRelatedObject(); |
18756 | ········pm.Save(); |
18757 | ········pm.UnloadCache(); |
18758 | ········QueryOwn(); |
18759 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18760 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18761 | ····} |
18762 | ····void CreateObjects() |
18763 | ····{ |
18764 | ········pm.MakePersistent(ownVar); |
18765 | ········ownVar.AssignRelation(otherVar); |
18766 | ········pm.Save(); |
18767 | ········pm.UnloadCache(); |
18768 | ····} |
18769 | ····void QueryOwn() |
18770 | ····{ |
18771 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblGuidLeftBase>(pm); |
18772 | ········ownVar = q.ExecuteSingle(); |
18773 | ····} |
18774 | ····void QueryOther() |
18775 | ····{ |
18776 | ········var q = new NDOQuery<CmpDirnOwnpconOthpconTblGuidRightBase>(pm); |
18777 | ········otherVar = q.ExecuteSingle(); |
18778 | ····} |
18779 | } |
18780 | |
18781 | |
18782 | [TestFixture] |
18783 | public class TestCmpBin1OwnpconOthpconTblGuid : NDOTest |
18784 | { |
18785 | ····CmpBin1OwnpconOthpconTblGuidLeftBase ownVar; |
18786 | ····CmpBin1OwnpconOthpconTblGuidRightBase otherVar; |
18787 | ····PersistenceManager pm; |
18788 | ····[SetUp] |
18789 | ····public void Setup() |
18790 | ····{ |
18791 | ········pm = PmFactory.NewPersistenceManager(); |
18792 | ········ownVar = new CmpBin1OwnpconOthpconTblGuidLeftDerived(); |
18793 | ········otherVar = new CmpBin1OwnpconOthpconTblGuidRightDerived(); |
18794 | ····} |
18795 | ····[TearDown] |
18796 | ····public void TearDown() |
18797 | ····{ |
18798 | ········try |
18799 | ········{ |
18800 | ············pm.UnloadCache(); |
18801 | ············var l = pm.Objects<CmpBin1OwnpconOthpconTblGuidLeftBase>().ResultTable; |
18802 | ············pm.Delete(l); |
18803 | ············pm.Save(); |
18804 | ············pm.UnloadCache(); |
18805 | ············decimal count; |
18806 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18807 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18808 | ············count = (decimal) new NDOQuery<CmpBin1OwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18809 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18810 | ········} |
18811 | ········catch (Exception) |
18812 | ········{ |
18813 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18814 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18815 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18816 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18817 | ········} |
18818 | ····} |
18819 | ····[Test] |
18820 | ····public void TestSaveReload() |
18821 | ····{ |
18822 | ········CreateObjects(); |
18823 | ········QueryOwn(); |
18824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18825 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18826 | ····} |
18827 | ····[Test] |
18828 | ····public void TestSaveReloadNull() |
18829 | ····{ |
18830 | ········CreateObjects(); |
18831 | ········QueryOwn(); |
18832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18833 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18834 | ········ownVar.RelField = new List<CmpBin1OwnpconOthpconTblGuidRightBase>(); |
18835 | ········pm.Save(); |
18836 | ········pm.UnloadCache(); |
18837 | ········QueryOwn(); |
18838 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18839 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18840 | ····} |
18841 | ····[Test] |
18842 | ····public void TestSaveReloadRemove() |
18843 | ····{ |
18844 | ········CreateObjects(); |
18845 | ········QueryOwn(); |
18846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18847 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18848 | ········ownVar.RemoveRelatedObject(); |
18849 | ········pm.Save(); |
18850 | ········pm.UnloadCache(); |
18851 | ········QueryOwn(); |
18852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18853 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
18854 | ····} |
18855 | ····[Test] |
18856 | ····public void TestChangeKeyHolderRight() |
18857 | ····{ |
18858 | ········CreateObjects(); |
18859 | ········QueryOther(); |
18860 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18861 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18862 | ········int x = otherVar.RelField.Dummy; |
18863 | ········otherVar.Dummy = 4711; |
18864 | ········pm.Save(); |
18865 | ········pm.UnloadCache(); |
18866 | ········QueryOther(); |
18867 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18868 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18869 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18870 | ····} |
18871 | ····[Test] |
18872 | ····public void TestChangeKeyHolderRightNoTouch() |
18873 | ····{ |
18874 | ········CreateObjects(); |
18875 | ········QueryOther(); |
18876 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18877 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18878 | ········otherVar.Dummy = 4711; |
18879 | ········pm.Save(); |
18880 | ········pm.UnloadCache(); |
18881 | ········QueryOther(); |
18882 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
18883 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18884 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
18885 | ····} |
18886 | ····[Test] |
18887 | ····public void TestRelationHash() |
18888 | ····{ |
18889 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidLeftBase)); |
18890 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
18891 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidRightBase)); |
18892 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
18893 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
18894 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
18895 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidLeftDerived)); |
18896 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
18897 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
18898 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
18899 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpconOthpconTblGuidRightDerived)); |
18900 | ········Relation relderRight = clderRight.FindRelation("relField"); |
18901 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
18902 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
18903 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
18904 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
18905 | ····} |
18906 | ····void CreateObjects() |
18907 | ····{ |
18908 | ········pm.MakePersistent(ownVar); |
18909 | ········ownVar.AssignRelation(otherVar); |
18910 | ········pm.Save(); |
18911 | ········pm.UnloadCache(); |
18912 | ····} |
18913 | ····void QueryOwn() |
18914 | ····{ |
18915 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblGuidLeftBase>(pm); |
18916 | ········ownVar = q.ExecuteSingle(); |
18917 | ····} |
18918 | ····void QueryOther() |
18919 | ····{ |
18920 | ········var q = new NDOQuery<CmpBin1OwnpconOthpconTblGuidRightBase>(pm); |
18921 | ········otherVar = q.ExecuteSingle(); |
18922 | ····} |
18923 | } |
18924 | |
18925 | |
18926 | [TestFixture] |
18927 | public class TestCmpBi1nOwnpconOthpconTblGuid : NDOTest |
18928 | { |
18929 | ····CmpBi1nOwnpconOthpconTblGuidLeftBase ownVar; |
18930 | ····CmpBi1nOwnpconOthpconTblGuidRightBase otherVar; |
18931 | ····PersistenceManager pm; |
18932 | ····[SetUp] |
18933 | ····public void Setup() |
18934 | ····{ |
18935 | ········pm = PmFactory.NewPersistenceManager(); |
18936 | ········ownVar = new CmpBi1nOwnpconOthpconTblGuidLeftDerived(); |
18937 | ········otherVar = new CmpBi1nOwnpconOthpconTblGuidRightDerived(); |
18938 | ····} |
18939 | ····[TearDown] |
18940 | ····public void TearDown() |
18941 | ····{ |
18942 | ········try |
18943 | ········{ |
18944 | ············pm.UnloadCache(); |
18945 | ············var l = pm.Objects<CmpBi1nOwnpconOthpconTblGuidLeftBase>().ResultTable; |
18946 | ············pm.Delete(l); |
18947 | ············pm.Save(); |
18948 | ············pm.UnloadCache(); |
18949 | ············decimal count; |
18950 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18951 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
18952 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
18953 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
18954 | ········} |
18955 | ········catch (Exception) |
18956 | ········{ |
18957 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
18958 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
18959 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
18960 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
18961 | ········} |
18962 | ····} |
18963 | ····[Test] |
18964 | ····public void TestSaveReload() |
18965 | ····{ |
18966 | ········CreateObjects(); |
18967 | ········QueryOwn(); |
18968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18969 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18970 | ····} |
18971 | ····[Test] |
18972 | ····public void TestSaveReloadNull() |
18973 | ····{ |
18974 | ········CreateObjects(); |
18975 | ········QueryOwn(); |
18976 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18977 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18978 | ········ownVar.RelField = null; |
18979 | ········pm.Save(); |
18980 | ········pm.UnloadCache(); |
18981 | ········QueryOwn(); |
18982 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18983 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
18984 | ····} |
18985 | ····[Test] |
18986 | ····public void TestChangeKeyHolderLeft() |
18987 | ····{ |
18988 | ········CreateObjects(); |
18989 | ········QueryOwn(); |
18990 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18991 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
18992 | ········int x = ownVar.RelField.Dummy; |
18993 | ········ownVar.Dummy = 4711; |
18994 | ········pm.Save(); |
18995 | ········pm.UnloadCache(); |
18996 | ········QueryOwn(); |
18997 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
18998 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
18999 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19000 | ····} |
19001 | ····[Test] |
19002 | ····public void TestChangeKeyHolderLeftNoTouch() |
19003 | ····{ |
19004 | ········CreateObjects(); |
19005 | ········QueryOwn(); |
19006 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19007 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19008 | ········ownVar.Dummy = 4711; |
19009 | ········pm.Save(); |
19010 | ········pm.UnloadCache(); |
19011 | ········QueryOwn(); |
19012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19013 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19014 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19015 | ····} |
19016 | ····[Test] |
19017 | ····public void TestRelationHash() |
19018 | ····{ |
19019 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidLeftBase)); |
19020 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19021 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidRightBase)); |
19022 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19023 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19024 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19025 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidLeftDerived)); |
19026 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19027 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19028 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19029 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpconOthpconTblGuidRightDerived)); |
19030 | ········Relation relderRight = clderRight.FindRelation("relField"); |
19031 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
19032 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
19033 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
19034 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
19035 | ····} |
19036 | ····void CreateObjects() |
19037 | ····{ |
19038 | ········pm.MakePersistent(ownVar); |
19039 | ········ownVar.AssignRelation(otherVar); |
19040 | ········pm.Save(); |
19041 | ········pm.UnloadCache(); |
19042 | ····} |
19043 | ····void QueryOwn() |
19044 | ····{ |
19045 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblGuidLeftBase>(pm); |
19046 | ········ownVar = q.ExecuteSingle(); |
19047 | ····} |
19048 | ····void QueryOther() |
19049 | ····{ |
19050 | ········var q = new NDOQuery<CmpBi1nOwnpconOthpconTblGuidRightBase>(pm); |
19051 | ········otherVar = q.ExecuteSingle(); |
19052 | ····} |
19053 | } |
19054 | |
19055 | |
19056 | [TestFixture] |
19057 | public class TestCmpBinnOwnpconOthpconTblGuid : NDOTest |
19058 | { |
19059 | ····CmpBinnOwnpconOthpconTblGuidLeftBase ownVar; |
19060 | ····CmpBinnOwnpconOthpconTblGuidRightBase otherVar; |
19061 | ····PersistenceManager pm; |
19062 | ····[SetUp] |
19063 | ····public void Setup() |
19064 | ····{ |
19065 | ········pm = PmFactory.NewPersistenceManager(); |
19066 | ········ownVar = new CmpBinnOwnpconOthpconTblGuidLeftDerived(); |
19067 | ········otherVar = new CmpBinnOwnpconOthpconTblGuidRightDerived(); |
19068 | ····} |
19069 | ····[TearDown] |
19070 | ····public void TearDown() |
19071 | ····{ |
19072 | ········try |
19073 | ········{ |
19074 | ············pm.UnloadCache(); |
19075 | ············var l = pm.Objects<CmpBinnOwnpconOthpconTblGuidLeftBase>().ResultTable; |
19076 | ············pm.Delete(l); |
19077 | ············pm.Save(); |
19078 | ············pm.UnloadCache(); |
19079 | ············decimal count; |
19080 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19081 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19082 | ············count = (decimal) new NDOQuery<CmpBinnOwnpconOthpconTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19083 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19084 | ········} |
19085 | ········catch (Exception) |
19086 | ········{ |
19087 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19088 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19089 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19090 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19091 | ········} |
19092 | ····} |
19093 | ····[Test] |
19094 | ····public void TestSaveReload() |
19095 | ····{ |
19096 | ········CreateObjects(); |
19097 | ········QueryOwn(); |
19098 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19099 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19100 | ····} |
19101 | ····[Test] |
19102 | ····public void TestSaveReloadNull() |
19103 | ····{ |
19104 | ········CreateObjects(); |
19105 | ········QueryOwn(); |
19106 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19107 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19108 | ········ownVar.RelField = new List<CmpBinnOwnpconOthpconTblGuidRightBase>(); |
19109 | ········pm.Save(); |
19110 | ········pm.UnloadCache(); |
19111 | ········QueryOwn(); |
19112 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19113 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19114 | ····} |
19115 | ····[Test] |
19116 | ····public void TestSaveReloadRemove() |
19117 | ····{ |
19118 | ········CreateObjects(); |
19119 | ········QueryOwn(); |
19120 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19121 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19122 | ········ownVar.RemoveRelatedObject(); |
19123 | ········pm.Save(); |
19124 | ········pm.UnloadCache(); |
19125 | ········QueryOwn(); |
19126 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19127 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19128 | ····} |
19129 | ····[Test] |
19130 | ····public void TestRelationHash() |
19131 | ····{ |
19132 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidLeftBase)); |
19133 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19134 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidRightBase)); |
19135 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19136 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19137 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19138 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidLeftDerived)); |
19139 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19140 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19141 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19142 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpconOthpconTblGuidRightDerived)); |
19143 | ········Relation relderRight = clderRight.FindRelation("relField"); |
19144 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
19145 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
19146 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
19147 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
19148 | ····} |
19149 | ····void CreateObjects() |
19150 | ····{ |
19151 | ········pm.MakePersistent(ownVar); |
19152 | ········ownVar.AssignRelation(otherVar); |
19153 | ········pm.Save(); |
19154 | ········pm.UnloadCache(); |
19155 | ····} |
19156 | ····void QueryOwn() |
19157 | ····{ |
19158 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblGuidLeftBase>(pm); |
19159 | ········ownVar = q.ExecuteSingle(); |
19160 | ····} |
19161 | ····void QueryOther() |
19162 | ····{ |
19163 | ········var q = new NDOQuery<CmpBinnOwnpconOthpconTblGuidRightBase>(pm); |
19164 | ········otherVar = q.ExecuteSingle(); |
19165 | ····} |
19166 | } |
19167 | |
19168 | |
19169 | [TestFixture] |
19170 | public class TestAgrDir1OwnpabsNoTblAuto : NDOTest |
19171 | { |
19172 | ····AgrDir1OwnpabsNoTblAutoLeftBase ownVar; |
19173 | ····AgrDir1OwnpabsNoTblAutoRight otherVar; |
19174 | ····PersistenceManager pm; |
19175 | ····[SetUp] |
19176 | ····public void Setup() |
19177 | ····{ |
19178 | ········pm = PmFactory.NewPersistenceManager(); |
19179 | ········ownVar = new AgrDir1OwnpabsNoTblAutoLeftDerived(); |
19180 | ········otherVar = new AgrDir1OwnpabsNoTblAutoRight(); |
19181 | ····} |
19182 | ····[TearDown] |
19183 | ····public void TearDown() |
19184 | ····{ |
19185 | ········try |
19186 | ········{ |
19187 | ············pm.UnloadCache(); |
19188 | ············var l = pm.Objects<AgrDir1OwnpabsNoTblAutoLeftBase>().ResultTable; |
19189 | ············pm.Delete(l); |
19190 | ············pm.Save(); |
19191 | ············pm.UnloadCache(); |
19192 | ············var m = pm.Objects<AgrDir1OwnpabsNoTblAutoRight>().ResultTable; |
19193 | ············pm.Delete(m); |
19194 | ············pm.Save(); |
19195 | ············pm.UnloadCache(); |
19196 | ············decimal count; |
19197 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19198 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19199 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19200 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19201 | ········} |
19202 | ········catch (Exception) |
19203 | ········{ |
19204 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19205 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19206 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19207 | ········} |
19208 | ····} |
19209 | ····[Test] |
19210 | ····public void TestSaveReload() |
19211 | ····{ |
19212 | ········CreateObjects(); |
19213 | ········QueryOwn(); |
19214 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19215 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19216 | ····} |
19217 | ····[Test] |
19218 | ····public void TestSaveReloadNull() |
19219 | ····{ |
19220 | ········CreateObjects(); |
19221 | ········QueryOwn(); |
19222 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19223 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19224 | ········ownVar.RelField = null; |
19225 | ········pm.Save(); |
19226 | ········pm.UnloadCache(); |
19227 | ········QueryOwn(); |
19228 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19229 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19230 | ····} |
19231 | ····[Test] |
19232 | ····public void TestChangeKeyHolderLeft() |
19233 | ····{ |
19234 | ········CreateObjects(); |
19235 | ········QueryOwn(); |
19236 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19237 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19238 | ········int x = ownVar.RelField.Dummy; |
19239 | ········ownVar.Dummy = 4711; |
19240 | ········pm.Save(); |
19241 | ········pm.UnloadCache(); |
19242 | ········QueryOwn(); |
19243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19244 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19245 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19246 | ····} |
19247 | ····[Test] |
19248 | ····public void TestChangeKeyHolderLeftNoTouch() |
19249 | ····{ |
19250 | ········CreateObjects(); |
19251 | ········QueryOwn(); |
19252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19254 | ········ownVar.Dummy = 4711; |
19255 | ········pm.Save(); |
19256 | ········pm.UnloadCache(); |
19257 | ········QueryOwn(); |
19258 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19259 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19261 | ····} |
19262 | ····[Test] |
19263 | ····public void TestUpdateOrder() |
19264 | ····{ |
19265 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
19266 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
19267 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsNoTblAutoLeftDerived)})) |
19268 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
19269 | ········Debug.WriteLine("AgrDir1OwnpabsNoTblAutoLeftBase"); |
19270 | ····} |
19271 | ····void CreateObjects() |
19272 | ····{ |
19273 | ········pm.MakePersistent(ownVar); |
19274 | ········pm.MakePersistent(otherVar); |
19275 | ········ownVar.AssignRelation(otherVar); |
19276 | ········pm.Save(); |
19277 | ········pm.UnloadCache(); |
19278 | ····} |
19279 | ····void QueryOwn() |
19280 | ····{ |
19281 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblAutoLeftBase>(pm); |
19282 | ········ownVar = q.ExecuteSingle(); |
19283 | ····} |
19284 | ····void QueryOther() |
19285 | ····{ |
19286 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblAutoRight>(pm); |
19287 | ········otherVar = q.ExecuteSingle(); |
19288 | ····} |
19289 | } |
19290 | |
19291 | |
19292 | [TestFixture] |
19293 | public class TestAgrDir1OwnpabsTblAuto : NDOTest |
19294 | { |
19295 | ····AgrDir1OwnpabsTblAutoLeftBase ownVar; |
19296 | ····AgrDir1OwnpabsTblAutoRight otherVar; |
19297 | ····PersistenceManager pm; |
19298 | ····[SetUp] |
19299 | ····public void Setup() |
19300 | ····{ |
19301 | ········pm = PmFactory.NewPersistenceManager(); |
19302 | ········ownVar = new AgrDir1OwnpabsTblAutoLeftDerived(); |
19303 | ········otherVar = new AgrDir1OwnpabsTblAutoRight(); |
19304 | ····} |
19305 | ····[TearDown] |
19306 | ····public void TearDown() |
19307 | ····{ |
19308 | ········try |
19309 | ········{ |
19310 | ············pm.UnloadCache(); |
19311 | ············var l = pm.Objects<AgrDir1OwnpabsTblAutoLeftBase>().ResultTable; |
19312 | ············pm.Delete(l); |
19313 | ············pm.Save(); |
19314 | ············pm.UnloadCache(); |
19315 | ············var m = pm.Objects<AgrDir1OwnpabsTblAutoRight>().ResultTable; |
19316 | ············pm.Delete(m); |
19317 | ············pm.Save(); |
19318 | ············pm.UnloadCache(); |
19319 | ············decimal count; |
19320 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19321 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19322 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19323 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19324 | ········} |
19325 | ········catch (Exception) |
19326 | ········{ |
19327 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19328 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19329 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19330 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19331 | ········} |
19332 | ····} |
19333 | ····[Test] |
19334 | ····public void TestSaveReload() |
19335 | ····{ |
19336 | ········CreateObjects(); |
19337 | ········QueryOwn(); |
19338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19340 | ····} |
19341 | ····[Test] |
19342 | ····public void TestSaveReloadNull() |
19343 | ····{ |
19344 | ········CreateObjects(); |
19345 | ········QueryOwn(); |
19346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19347 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19348 | ········ownVar.RelField = null; |
19349 | ········pm.Save(); |
19350 | ········pm.UnloadCache(); |
19351 | ········QueryOwn(); |
19352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19353 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19354 | ····} |
19355 | ····[Test] |
19356 | ····public void TestChangeKeyHolderLeft() |
19357 | ····{ |
19358 | ········CreateObjects(); |
19359 | ········QueryOwn(); |
19360 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19361 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19362 | ········int x = ownVar.RelField.Dummy; |
19363 | ········ownVar.Dummy = 4711; |
19364 | ········pm.Save(); |
19365 | ········pm.UnloadCache(); |
19366 | ········QueryOwn(); |
19367 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19368 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19369 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19370 | ····} |
19371 | ····[Test] |
19372 | ····public void TestChangeKeyHolderLeftNoTouch() |
19373 | ····{ |
19374 | ········CreateObjects(); |
19375 | ········QueryOwn(); |
19376 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19377 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19378 | ········ownVar.Dummy = 4711; |
19379 | ········pm.Save(); |
19380 | ········pm.UnloadCache(); |
19381 | ········QueryOwn(); |
19382 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19383 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19384 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19385 | ····} |
19386 | ····void CreateObjects() |
19387 | ····{ |
19388 | ········pm.MakePersistent(ownVar); |
19389 | ········pm.MakePersistent(otherVar); |
19390 | ········ownVar.AssignRelation(otherVar); |
19391 | ········pm.Save(); |
19392 | ········pm.UnloadCache(); |
19393 | ····} |
19394 | ····void QueryOwn() |
19395 | ····{ |
19396 | ········var q = new NDOQuery<AgrDir1OwnpabsTblAutoLeftBase>(pm); |
19397 | ········ownVar = q.ExecuteSingle(); |
19398 | ····} |
19399 | ····void QueryOther() |
19400 | ····{ |
19401 | ········var q = new NDOQuery<AgrDir1OwnpabsTblAutoRight>(pm); |
19402 | ········otherVar = q.ExecuteSingle(); |
19403 | ····} |
19404 | } |
19405 | |
19406 | |
19407 | [TestFixture] |
19408 | public class TestAgrBi11OwnpabsNoTblAuto : NDOTest |
19409 | { |
19410 | ····AgrBi11OwnpabsNoTblAutoLeftBase ownVar; |
19411 | ····AgrBi11OwnpabsNoTblAutoRight otherVar; |
19412 | ····PersistenceManager pm; |
19413 | ····[SetUp] |
19414 | ····public void Setup() |
19415 | ····{ |
19416 | ········pm = PmFactory.NewPersistenceManager(); |
19417 | ········ownVar = new AgrBi11OwnpabsNoTblAutoLeftDerived(); |
19418 | ········otherVar = new AgrBi11OwnpabsNoTblAutoRight(); |
19419 | ····} |
19420 | ····[TearDown] |
19421 | ····public void TearDown() |
19422 | ····{ |
19423 | ········try |
19424 | ········{ |
19425 | ············pm.UnloadCache(); |
19426 | ············var l = pm.Objects<AgrBi11OwnpabsNoTblAutoLeftBase>().ResultTable; |
19427 | ············pm.Delete(l); |
19428 | ············pm.Save(); |
19429 | ············pm.UnloadCache(); |
19430 | ············var m = pm.Objects<AgrBi11OwnpabsNoTblAutoRight>().ResultTable; |
19431 | ············pm.Delete(m); |
19432 | ············pm.Save(); |
19433 | ············pm.UnloadCache(); |
19434 | ············decimal count; |
19435 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19436 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19437 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19438 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19439 | ········} |
19440 | ········catch (Exception) |
19441 | ········{ |
19442 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19443 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19444 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19445 | ········} |
19446 | ····} |
19447 | ····[Test] |
19448 | ····public void TestSaveReload() |
19449 | ····{ |
19450 | ········CreateObjects(); |
19451 | ········QueryOwn(); |
19452 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19453 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19454 | ····} |
19455 | ····[Test] |
19456 | ····public void TestSaveReloadNull() |
19457 | ····{ |
19458 | ········CreateObjects(); |
19459 | ········QueryOwn(); |
19460 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19462 | ········ownVar.RelField = null; |
19463 | ········pm.Save(); |
19464 | ········pm.UnloadCache(); |
19465 | ········QueryOwn(); |
19466 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19467 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19468 | ····} |
19469 | ····[Test] |
19470 | ····public void TestChangeKeyHolderLeft() |
19471 | ····{ |
19472 | ········CreateObjects(); |
19473 | ········QueryOwn(); |
19474 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19475 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19476 | ········int x = ownVar.RelField.Dummy; |
19477 | ········ownVar.Dummy = 4711; |
19478 | ········pm.Save(); |
19479 | ········pm.UnloadCache(); |
19480 | ········QueryOwn(); |
19481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19482 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19483 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19484 | ····} |
19485 | ····[Test] |
19486 | ····public void TestChangeKeyHolderRight() |
19487 | ····{ |
19488 | ········CreateObjects(); |
19489 | ········QueryOther(); |
19490 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19491 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19492 | ········int x = otherVar.RelField.Dummy; |
19493 | ········otherVar.Dummy = 4711; |
19494 | ········pm.Save(); |
19495 | ········pm.UnloadCache(); |
19496 | ········QueryOther(); |
19497 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19498 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19499 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19500 | ····} |
19501 | ····[Test] |
19502 | ····public void TestChangeKeyHolderLeftNoTouch() |
19503 | ····{ |
19504 | ········CreateObjects(); |
19505 | ········QueryOwn(); |
19506 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19507 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19508 | ········ownVar.Dummy = 4711; |
19509 | ········pm.Save(); |
19510 | ········pm.UnloadCache(); |
19511 | ········QueryOwn(); |
19512 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19513 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19514 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19515 | ····} |
19516 | ····[Test] |
19517 | ····public void TestChangeKeyHolderRightNoTouch() |
19518 | ····{ |
19519 | ········CreateObjects(); |
19520 | ········QueryOther(); |
19521 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19522 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19523 | ········otherVar.Dummy = 4711; |
19524 | ········pm.Save(); |
19525 | ········pm.UnloadCache(); |
19526 | ········QueryOther(); |
19527 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19528 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19529 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19530 | ····} |
19531 | ····[Test] |
19532 | ····public void TestRelationHash() |
19533 | ····{ |
19534 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoLeftBase)); |
19535 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19536 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoRight)); |
19537 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19538 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19539 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19540 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblAutoLeftDerived)); |
19541 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19542 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19543 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19544 | ····} |
19545 | ····void CreateObjects() |
19546 | ····{ |
19547 | ········pm.MakePersistent(ownVar); |
19548 | ········pm.MakePersistent(otherVar); |
19549 | ········pm.Save(); |
19550 | ········ownVar.AssignRelation(otherVar); |
19551 | ········pm.Save(); |
19552 | ········pm.UnloadCache(); |
19553 | ····} |
19554 | ····void QueryOwn() |
19555 | ····{ |
19556 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblAutoLeftBase>(pm); |
19557 | ········ownVar = q.ExecuteSingle(); |
19558 | ····} |
19559 | ····void QueryOther() |
19560 | ····{ |
19561 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblAutoRight>(pm); |
19562 | ········otherVar = q.ExecuteSingle(); |
19563 | ····} |
19564 | } |
19565 | |
19566 | |
19567 | [TestFixture] |
19568 | public class TestAgrBi11OwnpabsTblAuto : NDOTest |
19569 | { |
19570 | ····AgrBi11OwnpabsTblAutoLeftBase ownVar; |
19571 | ····AgrBi11OwnpabsTblAutoRight otherVar; |
19572 | ····PersistenceManager pm; |
19573 | ····[SetUp] |
19574 | ····public void Setup() |
19575 | ····{ |
19576 | ········pm = PmFactory.NewPersistenceManager(); |
19577 | ········ownVar = new AgrBi11OwnpabsTblAutoLeftDerived(); |
19578 | ········otherVar = new AgrBi11OwnpabsTblAutoRight(); |
19579 | ····} |
19580 | ····[TearDown] |
19581 | ····public void TearDown() |
19582 | ····{ |
19583 | ········try |
19584 | ········{ |
19585 | ············pm.UnloadCache(); |
19586 | ············var l = pm.Objects<AgrBi11OwnpabsTblAutoLeftBase>().ResultTable; |
19587 | ············pm.Delete(l); |
19588 | ············pm.Save(); |
19589 | ············pm.UnloadCache(); |
19590 | ············var m = pm.Objects<AgrBi11OwnpabsTblAutoRight>().ResultTable; |
19591 | ············pm.Delete(m); |
19592 | ············pm.Save(); |
19593 | ············pm.UnloadCache(); |
19594 | ············decimal count; |
19595 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19596 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19597 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19598 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19599 | ········} |
19600 | ········catch (Exception) |
19601 | ········{ |
19602 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19603 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19604 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19605 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19606 | ········} |
19607 | ····} |
19608 | ····[Test] |
19609 | ····public void TestSaveReload() |
19610 | ····{ |
19611 | ········CreateObjects(); |
19612 | ········QueryOwn(); |
19613 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19614 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19615 | ····} |
19616 | ····[Test] |
19617 | ····public void TestSaveReloadNull() |
19618 | ····{ |
19619 | ········CreateObjects(); |
19620 | ········QueryOwn(); |
19621 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19622 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19623 | ········ownVar.RelField = null; |
19624 | ········pm.Save(); |
19625 | ········pm.UnloadCache(); |
19626 | ········QueryOwn(); |
19627 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19628 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
19629 | ····} |
19630 | ····[Test] |
19631 | ····public void TestChangeKeyHolderLeft() |
19632 | ····{ |
19633 | ········CreateObjects(); |
19634 | ········QueryOwn(); |
19635 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19636 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19637 | ········int x = ownVar.RelField.Dummy; |
19638 | ········ownVar.Dummy = 4711; |
19639 | ········pm.Save(); |
19640 | ········pm.UnloadCache(); |
19641 | ········QueryOwn(); |
19642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19643 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19644 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19645 | ····} |
19646 | ····[Test] |
19647 | ····public void TestChangeKeyHolderRight() |
19648 | ····{ |
19649 | ········CreateObjects(); |
19650 | ········QueryOther(); |
19651 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19652 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19653 | ········int x = otherVar.RelField.Dummy; |
19654 | ········otherVar.Dummy = 4711; |
19655 | ········pm.Save(); |
19656 | ········pm.UnloadCache(); |
19657 | ········QueryOther(); |
19658 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19659 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19660 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19661 | ····} |
19662 | ····[Test] |
19663 | ····public void TestChangeKeyHolderLeftNoTouch() |
19664 | ····{ |
19665 | ········CreateObjects(); |
19666 | ········QueryOwn(); |
19667 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19668 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19669 | ········ownVar.Dummy = 4711; |
19670 | ········pm.Save(); |
19671 | ········pm.UnloadCache(); |
19672 | ········QueryOwn(); |
19673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19674 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19675 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
19676 | ····} |
19677 | ····[Test] |
19678 | ····public void TestChangeKeyHolderRightNoTouch() |
19679 | ····{ |
19680 | ········CreateObjects(); |
19681 | ········QueryOther(); |
19682 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19683 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19684 | ········otherVar.Dummy = 4711; |
19685 | ········pm.Save(); |
19686 | ········pm.UnloadCache(); |
19687 | ········QueryOther(); |
19688 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
19689 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
19690 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
19691 | ····} |
19692 | ····[Test] |
19693 | ····public void TestRelationHash() |
19694 | ····{ |
19695 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoLeftBase)); |
19696 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
19697 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoRight)); |
19698 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
19699 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
19700 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
19701 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblAutoLeftDerived)); |
19702 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
19703 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
19704 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
19705 | ····} |
19706 | ····void CreateObjects() |
19707 | ····{ |
19708 | ········pm.MakePersistent(ownVar); |
19709 | ········pm.MakePersistent(otherVar); |
19710 | ········pm.Save(); |
19711 | ········ownVar.AssignRelation(otherVar); |
19712 | ········pm.Save(); |
19713 | ········pm.UnloadCache(); |
19714 | ····} |
19715 | ····void QueryOwn() |
19716 | ····{ |
19717 | ········var q = new NDOQuery<AgrBi11OwnpabsTblAutoLeftBase>(pm); |
19718 | ········ownVar = q.ExecuteSingle(); |
19719 | ····} |
19720 | ····void QueryOther() |
19721 | ····{ |
19722 | ········var q = new NDOQuery<AgrBi11OwnpabsTblAutoRight>(pm); |
19723 | ········otherVar = q.ExecuteSingle(); |
19724 | ····} |
19725 | } |
19726 | |
19727 | |
19728 | [TestFixture] |
19729 | public class TestAgrDirnOwnpabsNoTblAuto : NDOTest |
19730 | { |
19731 | ····AgrDirnOwnpabsNoTblAutoLeftBase ownVar; |
19732 | ····AgrDirnOwnpabsNoTblAutoRight otherVar; |
19733 | ····PersistenceManager pm; |
19734 | ····[SetUp] |
19735 | ····public void Setup() |
19736 | ····{ |
19737 | ········pm = PmFactory.NewPersistenceManager(); |
19738 | ········ownVar = new AgrDirnOwnpabsNoTblAutoLeftDerived(); |
19739 | ········otherVar = new AgrDirnOwnpabsNoTblAutoRight(); |
19740 | ····} |
19741 | ····[TearDown] |
19742 | ····public void TearDown() |
19743 | ····{ |
19744 | ········try |
19745 | ········{ |
19746 | ············pm.UnloadCache(); |
19747 | ············var l = pm.Objects<AgrDirnOwnpabsNoTblAutoLeftBase>().ResultTable; |
19748 | ············pm.Delete(l); |
19749 | ············pm.Save(); |
19750 | ············pm.UnloadCache(); |
19751 | ············var m = pm.Objects<AgrDirnOwnpabsNoTblAutoRight>().ResultTable; |
19752 | ············pm.Delete(m); |
19753 | ············pm.Save(); |
19754 | ············pm.UnloadCache(); |
19755 | ············decimal count; |
19756 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19757 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19758 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19759 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19760 | ········} |
19761 | ········catch (Exception) |
19762 | ········{ |
19763 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19764 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19765 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19766 | ········} |
19767 | ····} |
19768 | ····[Test] |
19769 | ····public void TestSaveReload() |
19770 | ····{ |
19771 | ········CreateObjects(); |
19772 | ········QueryOwn(); |
19773 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19774 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19775 | ····} |
19776 | ····[Test] |
19777 | ····public void TestSaveReloadNull() |
19778 | ····{ |
19779 | ········CreateObjects(); |
19780 | ········QueryOwn(); |
19781 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19782 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19783 | ········ownVar.RelField = new List<AgrDirnOwnpabsNoTblAutoRight>(); |
19784 | ········pm.Save(); |
19785 | ········pm.UnloadCache(); |
19786 | ········QueryOwn(); |
19787 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19788 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19789 | ····} |
19790 | ····[Test] |
19791 | ····public void TestSaveReloadRemove() |
19792 | ····{ |
19793 | ········CreateObjects(); |
19794 | ········QueryOwn(); |
19795 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19796 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19797 | ········ownVar.RemoveRelatedObject(); |
19798 | ········pm.Save(); |
19799 | ········pm.UnloadCache(); |
19800 | ········QueryOwn(); |
19801 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19802 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19803 | ····} |
19804 | ····[Test] |
19805 | ····public void TestUpdateOrder() |
19806 | ····{ |
19807 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
19808 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
19809 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpabsNoTblAutoLeftDerived)})) |
19810 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrDirnOwnpabsNoTblAutoRight)})), "Wrong order #2"); |
19811 | ········Debug.WriteLine("AgrDirnOwnpabsNoTblAutoLeftBase"); |
19812 | ····} |
19813 | ····void CreateObjects() |
19814 | ····{ |
19815 | ········pm.MakePersistent(ownVar); |
19816 | ········pm.MakePersistent(otherVar); |
19817 | ········ownVar.AssignRelation(otherVar); |
19818 | ········pm.Save(); |
19819 | ········pm.UnloadCache(); |
19820 | ····} |
19821 | ····void QueryOwn() |
19822 | ····{ |
19823 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblAutoLeftBase>(pm); |
19824 | ········ownVar = q.ExecuteSingle(); |
19825 | ····} |
19826 | ····void QueryOther() |
19827 | ····{ |
19828 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblAutoRight>(pm); |
19829 | ········otherVar = q.ExecuteSingle(); |
19830 | ····} |
19831 | } |
19832 | |
19833 | |
19834 | [TestFixture] |
19835 | public class TestAgrDirnOwnpabsTblAuto : NDOTest |
19836 | { |
19837 | ····AgrDirnOwnpabsTblAutoLeftBase ownVar; |
19838 | ····AgrDirnOwnpabsTblAutoRight otherVar; |
19839 | ····PersistenceManager pm; |
19840 | ····[SetUp] |
19841 | ····public void Setup() |
19842 | ····{ |
19843 | ········pm = PmFactory.NewPersistenceManager(); |
19844 | ········ownVar = new AgrDirnOwnpabsTblAutoLeftDerived(); |
19845 | ········otherVar = new AgrDirnOwnpabsTblAutoRight(); |
19846 | ····} |
19847 | ····[TearDown] |
19848 | ····public void TearDown() |
19849 | ····{ |
19850 | ········try |
19851 | ········{ |
19852 | ············pm.UnloadCache(); |
19853 | ············var l = pm.Objects<AgrDirnOwnpabsTblAutoLeftBase>().ResultTable; |
19854 | ············pm.Delete(l); |
19855 | ············pm.Save(); |
19856 | ············pm.UnloadCache(); |
19857 | ············var m = pm.Objects<AgrDirnOwnpabsTblAutoRight>().ResultTable; |
19858 | ············pm.Delete(m); |
19859 | ············pm.Save(); |
19860 | ············pm.UnloadCache(); |
19861 | ············decimal count; |
19862 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19863 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19864 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19866 | ········} |
19867 | ········catch (Exception) |
19868 | ········{ |
19869 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19870 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19871 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19872 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
19873 | ········} |
19874 | ····} |
19875 | ····[Test] |
19876 | ····public void TestSaveReload() |
19877 | ····{ |
19878 | ········CreateObjects(); |
19879 | ········QueryOwn(); |
19880 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19881 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19882 | ····} |
19883 | ····[Test] |
19884 | ····public void TestSaveReloadNull() |
19885 | ····{ |
19886 | ········CreateObjects(); |
19887 | ········QueryOwn(); |
19888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19889 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19890 | ········ownVar.RelField = new List<AgrDirnOwnpabsTblAutoRight>(); |
19891 | ········pm.Save(); |
19892 | ········pm.UnloadCache(); |
19893 | ········QueryOwn(); |
19894 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19895 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19896 | ····} |
19897 | ····[Test] |
19898 | ····public void TestSaveReloadRemove() |
19899 | ····{ |
19900 | ········CreateObjects(); |
19901 | ········QueryOwn(); |
19902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19903 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19904 | ········ownVar.RemoveRelatedObject(); |
19905 | ········pm.Save(); |
19906 | ········pm.UnloadCache(); |
19907 | ········QueryOwn(); |
19908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19909 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19910 | ····} |
19911 | ····void CreateObjects() |
19912 | ····{ |
19913 | ········pm.MakePersistent(ownVar); |
19914 | ········pm.MakePersistent(otherVar); |
19915 | ········ownVar.AssignRelation(otherVar); |
19916 | ········pm.Save(); |
19917 | ········pm.UnloadCache(); |
19918 | ····} |
19919 | ····void QueryOwn() |
19920 | ····{ |
19921 | ········var q = new NDOQuery<AgrDirnOwnpabsTblAutoLeftBase>(pm); |
19922 | ········ownVar = q.ExecuteSingle(); |
19923 | ····} |
19924 | ····void QueryOther() |
19925 | ····{ |
19926 | ········var q = new NDOQuery<AgrDirnOwnpabsTblAutoRight>(pm); |
19927 | ········otherVar = q.ExecuteSingle(); |
19928 | ····} |
19929 | } |
19930 | |
19931 | |
19932 | [TestFixture] |
19933 | public class TestAgrBin1OwnpabsNoTblAuto : NDOTest |
19934 | { |
19935 | ····AgrBin1OwnpabsNoTblAutoLeftBase ownVar; |
19936 | ····AgrBin1OwnpabsNoTblAutoRight otherVar; |
19937 | ····PersistenceManager pm; |
19938 | ····[SetUp] |
19939 | ····public void Setup() |
19940 | ····{ |
19941 | ········pm = PmFactory.NewPersistenceManager(); |
19942 | ········ownVar = new AgrBin1OwnpabsNoTblAutoLeftDerived(); |
19943 | ········otherVar = new AgrBin1OwnpabsNoTblAutoRight(); |
19944 | ····} |
19945 | ····[TearDown] |
19946 | ····public void TearDown() |
19947 | ····{ |
19948 | ········try |
19949 | ········{ |
19950 | ············pm.UnloadCache(); |
19951 | ············var l = pm.Objects<AgrBin1OwnpabsNoTblAutoLeftBase>().ResultTable; |
19952 | ············pm.Delete(l); |
19953 | ············pm.Save(); |
19954 | ············pm.UnloadCache(); |
19955 | ············var m = pm.Objects<AgrBin1OwnpabsNoTblAutoRight>().ResultTable; |
19956 | ············pm.Delete(m); |
19957 | ············pm.Save(); |
19958 | ············pm.UnloadCache(); |
19959 | ············decimal count; |
19960 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19961 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
19962 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
19963 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
19964 | ········} |
19965 | ········catch (Exception) |
19966 | ········{ |
19967 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
19968 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
19969 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
19970 | ········} |
19971 | ····} |
19972 | ····[Test] |
19973 | ····public void TestSaveReload() |
19974 | ····{ |
19975 | ········CreateObjects(); |
19976 | ········QueryOwn(); |
19977 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19978 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19979 | ····} |
19980 | ····[Test] |
19981 | ····public void TestSaveReloadNull() |
19982 | ····{ |
19983 | ········CreateObjects(); |
19984 | ········QueryOwn(); |
19985 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19986 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19987 | ········ownVar.RelField = new List<AgrBin1OwnpabsNoTblAutoRight>(); |
19988 | ········pm.Save(); |
19989 | ········pm.UnloadCache(); |
19990 | ········QueryOwn(); |
19991 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
19992 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
19993 | ····} |
19994 | ····[Test] |
19995 | ····public void TestSaveReloadRemove() |
19996 | ····{ |
19997 | ········CreateObjects(); |
19998 | ········QueryOwn(); |
19999 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20000 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20001 | ········ownVar.RemoveRelatedObject(); |
20002 | ········pm.Save(); |
20003 | ········pm.UnloadCache(); |
20004 | ········QueryOwn(); |
20005 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20006 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20007 | ····} |
20008 | ····[Test] |
20009 | ····public void TestChangeKeyHolderRight() |
20010 | ····{ |
20011 | ········CreateObjects(); |
20012 | ········QueryOther(); |
20013 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20014 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20015 | ········int x = otherVar.RelField.Dummy; |
20016 | ········otherVar.Dummy = 4711; |
20017 | ········pm.Save(); |
20018 | ········pm.UnloadCache(); |
20019 | ········QueryOther(); |
20020 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20021 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20022 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20023 | ····} |
20024 | ····[Test] |
20025 | ····public void TestChangeKeyHolderRightNoTouch() |
20026 | ····{ |
20027 | ········CreateObjects(); |
20028 | ········QueryOther(); |
20029 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20030 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20031 | ········otherVar.Dummy = 4711; |
20032 | ········pm.Save(); |
20033 | ········pm.UnloadCache(); |
20034 | ········QueryOther(); |
20035 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20036 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20037 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20038 | ····} |
20039 | ····[Test] |
20040 | ····public void TestUpdateOrder() |
20041 | ····{ |
20042 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
20043 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
20044 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpabsNoTblAutoLeftDerived)})) |
20045 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(AgrBin1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
20046 | ········Debug.WriteLine("AgrBin1OwnpabsNoTblAutoLeftBase"); |
20047 | ····} |
20048 | ····[Test] |
20049 | ····public void TestRelationHash() |
20050 | ····{ |
20051 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoLeftBase)); |
20052 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20053 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoRight)); |
20054 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20055 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20056 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20057 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblAutoLeftDerived)); |
20058 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20059 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20060 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20061 | ····} |
20062 | ····void CreateObjects() |
20063 | ····{ |
20064 | ········pm.MakePersistent(ownVar); |
20065 | ········pm.MakePersistent(otherVar); |
20066 | ········pm.Save(); |
20067 | ········ownVar.AssignRelation(otherVar); |
20068 | ········pm.Save(); |
20069 | ········pm.UnloadCache(); |
20070 | ····} |
20071 | ····void QueryOwn() |
20072 | ····{ |
20073 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblAutoLeftBase>(pm); |
20074 | ········ownVar = q.ExecuteSingle(); |
20075 | ····} |
20076 | ····void QueryOther() |
20077 | ····{ |
20078 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblAutoRight>(pm); |
20079 | ········otherVar = q.ExecuteSingle(); |
20080 | ····} |
20081 | } |
20082 | |
20083 | |
20084 | [TestFixture] |
20085 | public class TestAgrBin1OwnpabsTblAuto : NDOTest |
20086 | { |
20087 | ····AgrBin1OwnpabsTblAutoLeftBase ownVar; |
20088 | ····AgrBin1OwnpabsTblAutoRight otherVar; |
20089 | ····PersistenceManager pm; |
20090 | ····[SetUp] |
20091 | ····public void Setup() |
20092 | ····{ |
20093 | ········pm = PmFactory.NewPersistenceManager(); |
20094 | ········ownVar = new AgrBin1OwnpabsTblAutoLeftDerived(); |
20095 | ········otherVar = new AgrBin1OwnpabsTblAutoRight(); |
20096 | ····} |
20097 | ····[TearDown] |
20098 | ····public void TearDown() |
20099 | ····{ |
20100 | ········try |
20101 | ········{ |
20102 | ············pm.UnloadCache(); |
20103 | ············var l = pm.Objects<AgrBin1OwnpabsTblAutoLeftBase>().ResultTable; |
20104 | ············pm.Delete(l); |
20105 | ············pm.Save(); |
20106 | ············pm.UnloadCache(); |
20107 | ············var m = pm.Objects<AgrBin1OwnpabsTblAutoRight>().ResultTable; |
20108 | ············pm.Delete(m); |
20109 | ············pm.Save(); |
20110 | ············pm.UnloadCache(); |
20111 | ············decimal count; |
20112 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20113 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20114 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20115 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20116 | ········} |
20117 | ········catch (Exception) |
20118 | ········{ |
20119 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20120 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20121 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20122 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20123 | ········} |
20124 | ····} |
20125 | ····[Test] |
20126 | ····public void TestSaveReload() |
20127 | ····{ |
20128 | ········CreateObjects(); |
20129 | ········QueryOwn(); |
20130 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20131 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20132 | ····} |
20133 | ····[Test] |
20134 | ····public void TestSaveReloadNull() |
20135 | ····{ |
20136 | ········CreateObjects(); |
20137 | ········QueryOwn(); |
20138 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20139 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20140 | ········ownVar.RelField = new List<AgrBin1OwnpabsTblAutoRight>(); |
20141 | ········pm.Save(); |
20142 | ········pm.UnloadCache(); |
20143 | ········QueryOwn(); |
20144 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20145 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20146 | ····} |
20147 | ····[Test] |
20148 | ····public void TestSaveReloadRemove() |
20149 | ····{ |
20150 | ········CreateObjects(); |
20151 | ········QueryOwn(); |
20152 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20153 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20154 | ········ownVar.RemoveRelatedObject(); |
20155 | ········pm.Save(); |
20156 | ········pm.UnloadCache(); |
20157 | ········QueryOwn(); |
20158 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20159 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20160 | ····} |
20161 | ····[Test] |
20162 | ····public void TestChangeKeyHolderRight() |
20163 | ····{ |
20164 | ········CreateObjects(); |
20165 | ········QueryOther(); |
20166 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20167 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20168 | ········int x = otherVar.RelField.Dummy; |
20169 | ········otherVar.Dummy = 4711; |
20170 | ········pm.Save(); |
20171 | ········pm.UnloadCache(); |
20172 | ········QueryOther(); |
20173 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20174 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20175 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20176 | ····} |
20177 | ····[Test] |
20178 | ····public void TestChangeKeyHolderRightNoTouch() |
20179 | ····{ |
20180 | ········CreateObjects(); |
20181 | ········QueryOther(); |
20182 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20183 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20184 | ········otherVar.Dummy = 4711; |
20185 | ········pm.Save(); |
20186 | ········pm.UnloadCache(); |
20187 | ········QueryOther(); |
20188 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20189 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20190 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20191 | ····} |
20192 | ····[Test] |
20193 | ····public void TestRelationHash() |
20194 | ····{ |
20195 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoLeftBase)); |
20196 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20197 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoRight)); |
20198 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20199 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20200 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20201 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblAutoLeftDerived)); |
20202 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20203 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20204 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20205 | ····} |
20206 | ····void CreateObjects() |
20207 | ····{ |
20208 | ········pm.MakePersistent(ownVar); |
20209 | ········pm.MakePersistent(otherVar); |
20210 | ········pm.Save(); |
20211 | ········ownVar.AssignRelation(otherVar); |
20212 | ········pm.Save(); |
20213 | ········pm.UnloadCache(); |
20214 | ····} |
20215 | ····void QueryOwn() |
20216 | ····{ |
20217 | ········var q = new NDOQuery<AgrBin1OwnpabsTblAutoLeftBase>(pm); |
20218 | ········ownVar = q.ExecuteSingle(); |
20219 | ····} |
20220 | ····void QueryOther() |
20221 | ····{ |
20222 | ········var q = new NDOQuery<AgrBin1OwnpabsTblAutoRight>(pm); |
20223 | ········otherVar = q.ExecuteSingle(); |
20224 | ····} |
20225 | } |
20226 | |
20227 | |
20228 | [TestFixture] |
20229 | public class TestAgrBi1nOwnpabsTblAuto : NDOTest |
20230 | { |
20231 | ····AgrBi1nOwnpabsTblAutoLeftBase ownVar; |
20232 | ····AgrBi1nOwnpabsTblAutoRight otherVar; |
20233 | ····PersistenceManager pm; |
20234 | ····[SetUp] |
20235 | ····public void Setup() |
20236 | ····{ |
20237 | ········pm = PmFactory.NewPersistenceManager(); |
20238 | ········ownVar = new AgrBi1nOwnpabsTblAutoLeftDerived(); |
20239 | ········otherVar = new AgrBi1nOwnpabsTblAutoRight(); |
20240 | ····} |
20241 | ····[TearDown] |
20242 | ····public void TearDown() |
20243 | ····{ |
20244 | ········try |
20245 | ········{ |
20246 | ············pm.UnloadCache(); |
20247 | ············var l = pm.Objects<AgrBi1nOwnpabsTblAutoLeftBase>().ResultTable; |
20248 | ············pm.Delete(l); |
20249 | ············pm.Save(); |
20250 | ············pm.UnloadCache(); |
20251 | ············var m = pm.Objects<AgrBi1nOwnpabsTblAutoRight>().ResultTable; |
20252 | ············pm.Delete(m); |
20253 | ············pm.Save(); |
20254 | ············pm.UnloadCache(); |
20255 | ············decimal count; |
20256 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20257 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20258 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20259 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20260 | ········} |
20261 | ········catch (Exception) |
20262 | ········{ |
20263 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20264 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20265 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20266 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20267 | ········} |
20268 | ····} |
20269 | ····[Test] |
20270 | ····public void TestSaveReload() |
20271 | ····{ |
20272 | ········CreateObjects(); |
20273 | ········QueryOwn(); |
20274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20275 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20276 | ····} |
20277 | ····[Test] |
20278 | ····public void TestSaveReloadNull() |
20279 | ····{ |
20280 | ········CreateObjects(); |
20281 | ········QueryOwn(); |
20282 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20284 | ········ownVar.RelField = null; |
20285 | ········pm.Save(); |
20286 | ········pm.UnloadCache(); |
20287 | ········QueryOwn(); |
20288 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20289 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20290 | ····} |
20291 | ····[Test] |
20292 | ····public void TestChangeKeyHolderLeft() |
20293 | ····{ |
20294 | ········CreateObjects(); |
20295 | ········QueryOwn(); |
20296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20297 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20298 | ········int x = ownVar.RelField.Dummy; |
20299 | ········ownVar.Dummy = 4711; |
20300 | ········pm.Save(); |
20301 | ········pm.UnloadCache(); |
20302 | ········QueryOwn(); |
20303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20304 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20305 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20306 | ····} |
20307 | ····[Test] |
20308 | ····public void TestChangeKeyHolderLeftNoTouch() |
20309 | ····{ |
20310 | ········CreateObjects(); |
20311 | ········QueryOwn(); |
20312 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20313 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20314 | ········ownVar.Dummy = 4711; |
20315 | ········pm.Save(); |
20316 | ········pm.UnloadCache(); |
20317 | ········QueryOwn(); |
20318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20319 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20320 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20321 | ····} |
20322 | ····[Test] |
20323 | ····public void TestRelationHash() |
20324 | ····{ |
20325 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoLeftBase)); |
20326 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20327 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoRight)); |
20328 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20329 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20330 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20331 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblAutoLeftDerived)); |
20332 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20333 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20334 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20335 | ····} |
20336 | ····void CreateObjects() |
20337 | ····{ |
20338 | ········pm.MakePersistent(ownVar); |
20339 | ········pm.MakePersistent(otherVar); |
20340 | ········ownVar.AssignRelation(otherVar); |
20341 | ········pm.Save(); |
20342 | ········pm.UnloadCache(); |
20343 | ····} |
20344 | ····void QueryOwn() |
20345 | ····{ |
20346 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblAutoLeftBase>(pm); |
20347 | ········ownVar = q.ExecuteSingle(); |
20348 | ····} |
20349 | ····void QueryOther() |
20350 | ····{ |
20351 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblAutoRight>(pm); |
20352 | ········otherVar = q.ExecuteSingle(); |
20353 | ····} |
20354 | } |
20355 | |
20356 | |
20357 | [TestFixture] |
20358 | public class TestAgrBinnOwnpabsTblAuto : NDOTest |
20359 | { |
20360 | ····AgrBinnOwnpabsTblAutoLeftBase ownVar; |
20361 | ····AgrBinnOwnpabsTblAutoRight otherVar; |
20362 | ····PersistenceManager pm; |
20363 | ····[SetUp] |
20364 | ····public void Setup() |
20365 | ····{ |
20366 | ········pm = PmFactory.NewPersistenceManager(); |
20367 | ········ownVar = new AgrBinnOwnpabsTblAutoLeftDerived(); |
20368 | ········otherVar = new AgrBinnOwnpabsTblAutoRight(); |
20369 | ····} |
20370 | ····[TearDown] |
20371 | ····public void TearDown() |
20372 | ····{ |
20373 | ········try |
20374 | ········{ |
20375 | ············pm.UnloadCache(); |
20376 | ············var l = pm.Objects<AgrBinnOwnpabsTblAutoLeftBase>().ResultTable; |
20377 | ············pm.Delete(l); |
20378 | ············pm.Save(); |
20379 | ············pm.UnloadCache(); |
20380 | ············var m = pm.Objects<AgrBinnOwnpabsTblAutoRight>().ResultTable; |
20381 | ············pm.Delete(m); |
20382 | ············pm.Save(); |
20383 | ············pm.UnloadCache(); |
20384 | ············decimal count; |
20385 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20386 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20387 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20388 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20389 | ········} |
20390 | ········catch (Exception) |
20391 | ········{ |
20392 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20393 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20394 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20395 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20396 | ········} |
20397 | ····} |
20398 | ····[Test] |
20399 | ····public void TestSaveReload() |
20400 | ····{ |
20401 | ········CreateObjects(); |
20402 | ········QueryOwn(); |
20403 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20404 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20405 | ····} |
20406 | ····[Test] |
20407 | ····public void TestSaveReloadNull() |
20408 | ····{ |
20409 | ········CreateObjects(); |
20410 | ········QueryOwn(); |
20411 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20412 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20413 | ········ownVar.RelField = new List<AgrBinnOwnpabsTblAutoRight>(); |
20414 | ········pm.Save(); |
20415 | ········pm.UnloadCache(); |
20416 | ········QueryOwn(); |
20417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20418 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20419 | ····} |
20420 | ····[Test] |
20421 | ····public void TestSaveReloadRemove() |
20422 | ····{ |
20423 | ········CreateObjects(); |
20424 | ········QueryOwn(); |
20425 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20426 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20427 | ········ownVar.RemoveRelatedObject(); |
20428 | ········pm.Save(); |
20429 | ········pm.UnloadCache(); |
20430 | ········QueryOwn(); |
20431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20432 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
20433 | ····} |
20434 | ····[Test] |
20435 | ····public void TestRelationHash() |
20436 | ····{ |
20437 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoLeftBase)); |
20438 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20439 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoRight)); |
20440 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20441 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20442 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20443 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblAutoLeftDerived)); |
20444 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20445 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20446 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20447 | ····} |
20448 | ····void CreateObjects() |
20449 | ····{ |
20450 | ········pm.MakePersistent(ownVar); |
20451 | ········pm.MakePersistent(otherVar); |
20452 | ········ownVar.AssignRelation(otherVar); |
20453 | ········pm.Save(); |
20454 | ········pm.UnloadCache(); |
20455 | ····} |
20456 | ····void QueryOwn() |
20457 | ····{ |
20458 | ········var q = new NDOQuery<AgrBinnOwnpabsTblAutoLeftBase>(pm); |
20459 | ········ownVar = q.ExecuteSingle(); |
20460 | ····} |
20461 | ····void QueryOther() |
20462 | ····{ |
20463 | ········var q = new NDOQuery<AgrBinnOwnpabsTblAutoRight>(pm); |
20464 | ········otherVar = q.ExecuteSingle(); |
20465 | ····} |
20466 | } |
20467 | |
20468 | |
20469 | [TestFixture] |
20470 | public class TestCmpDir1OwnpabsNoTblAuto : NDOTest |
20471 | { |
20472 | ····CmpDir1OwnpabsNoTblAutoLeftBase ownVar; |
20473 | ····CmpDir1OwnpabsNoTblAutoRight otherVar; |
20474 | ····PersistenceManager pm; |
20475 | ····[SetUp] |
20476 | ····public void Setup() |
20477 | ····{ |
20478 | ········pm = PmFactory.NewPersistenceManager(); |
20479 | ········ownVar = new CmpDir1OwnpabsNoTblAutoLeftDerived(); |
20480 | ········otherVar = new CmpDir1OwnpabsNoTblAutoRight(); |
20481 | ····} |
20482 | ····[TearDown] |
20483 | ····public void TearDown() |
20484 | ····{ |
20485 | ········try |
20486 | ········{ |
20487 | ············pm.UnloadCache(); |
20488 | ············var l = pm.Objects<CmpDir1OwnpabsNoTblAutoLeftBase>().ResultTable; |
20489 | ············pm.Delete(l); |
20490 | ············pm.Save(); |
20491 | ············pm.UnloadCache(); |
20492 | ············decimal count; |
20493 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20494 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20495 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20496 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20497 | ········} |
20498 | ········catch (Exception) |
20499 | ········{ |
20500 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20501 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20502 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20503 | ········} |
20504 | ····} |
20505 | ····[Test] |
20506 | ····public void TestSaveReload() |
20507 | ····{ |
20508 | ········CreateObjects(); |
20509 | ········QueryOwn(); |
20510 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20511 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20512 | ····} |
20513 | ····[Test] |
20514 | ····public void TestSaveReloadNull() |
20515 | ····{ |
20516 | ········CreateObjects(); |
20517 | ········QueryOwn(); |
20518 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20519 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20520 | ········ownVar.RelField = null; |
20521 | ········pm.Save(); |
20522 | ········pm.UnloadCache(); |
20523 | ········QueryOwn(); |
20524 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20525 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20526 | ····} |
20527 | ····[Test] |
20528 | ····public void TestChangeKeyHolderLeft() |
20529 | ····{ |
20530 | ········CreateObjects(); |
20531 | ········QueryOwn(); |
20532 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20533 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20534 | ········int x = ownVar.RelField.Dummy; |
20535 | ········ownVar.Dummy = 4711; |
20536 | ········pm.Save(); |
20537 | ········pm.UnloadCache(); |
20538 | ········QueryOwn(); |
20539 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20540 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20541 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20542 | ····} |
20543 | ····[Test] |
20544 | ····public void TestChangeKeyHolderLeftNoTouch() |
20545 | ····{ |
20546 | ········CreateObjects(); |
20547 | ········QueryOwn(); |
20548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20549 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20550 | ········ownVar.Dummy = 4711; |
20551 | ········pm.Save(); |
20552 | ········pm.UnloadCache(); |
20553 | ········QueryOwn(); |
20554 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20555 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20556 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20557 | ····} |
20558 | ····[Test] |
20559 | ····public void TestUpdateOrder() |
20560 | ····{ |
20561 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
20562 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
20563 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpabsNoTblAutoLeftDerived)})) |
20564 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(CmpDir1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
20565 | ········Debug.WriteLine("CmpDir1OwnpabsNoTblAutoLeftBase"); |
20566 | ····} |
20567 | ····void CreateObjects() |
20568 | ····{ |
20569 | ········pm.MakePersistent(ownVar); |
20570 | ········pm.Save(); |
20571 | ········ownVar.AssignRelation(otherVar); |
20572 | ········pm.Save(); |
20573 | ········pm.UnloadCache(); |
20574 | ····} |
20575 | ····void QueryOwn() |
20576 | ····{ |
20577 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblAutoLeftBase>(pm); |
20578 | ········ownVar = q.ExecuteSingle(); |
20579 | ····} |
20580 | ····void QueryOther() |
20581 | ····{ |
20582 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblAutoRight>(pm); |
20583 | ········otherVar = q.ExecuteSingle(); |
20584 | ····} |
20585 | } |
20586 | |
20587 | |
20588 | [TestFixture] |
20589 | public class TestCmpDir1OwnpabsTblAuto : NDOTest |
20590 | { |
20591 | ····CmpDir1OwnpabsTblAutoLeftBase ownVar; |
20592 | ····CmpDir1OwnpabsTblAutoRight otherVar; |
20593 | ····PersistenceManager pm; |
20594 | ····[SetUp] |
20595 | ····public void Setup() |
20596 | ····{ |
20597 | ········pm = PmFactory.NewPersistenceManager(); |
20598 | ········ownVar = new CmpDir1OwnpabsTblAutoLeftDerived(); |
20599 | ········otherVar = new CmpDir1OwnpabsTblAutoRight(); |
20600 | ····} |
20601 | ····[TearDown] |
20602 | ····public void TearDown() |
20603 | ····{ |
20604 | ········try |
20605 | ········{ |
20606 | ············pm.UnloadCache(); |
20607 | ············var l = pm.Objects<CmpDir1OwnpabsTblAutoLeftBase>().ResultTable; |
20608 | ············pm.Delete(l); |
20609 | ············pm.Save(); |
20610 | ············pm.UnloadCache(); |
20611 | ············decimal count; |
20612 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20613 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20614 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20615 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20616 | ········} |
20617 | ········catch (Exception) |
20618 | ········{ |
20619 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20620 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20621 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20622 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20623 | ········} |
20624 | ····} |
20625 | ····[Test] |
20626 | ····public void TestSaveReload() |
20627 | ····{ |
20628 | ········CreateObjects(); |
20629 | ········QueryOwn(); |
20630 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20631 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20632 | ····} |
20633 | ····[Test] |
20634 | ····public void TestSaveReloadNull() |
20635 | ····{ |
20636 | ········CreateObjects(); |
20637 | ········QueryOwn(); |
20638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20639 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20640 | ········ownVar.RelField = null; |
20641 | ········pm.Save(); |
20642 | ········pm.UnloadCache(); |
20643 | ········QueryOwn(); |
20644 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20645 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20646 | ····} |
20647 | ····[Test] |
20648 | ····public void TestChangeKeyHolderLeft() |
20649 | ····{ |
20650 | ········CreateObjects(); |
20651 | ········QueryOwn(); |
20652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20653 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20654 | ········int x = ownVar.RelField.Dummy; |
20655 | ········ownVar.Dummy = 4711; |
20656 | ········pm.Save(); |
20657 | ········pm.UnloadCache(); |
20658 | ········QueryOwn(); |
20659 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20660 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20661 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20662 | ····} |
20663 | ····[Test] |
20664 | ····public void TestChangeKeyHolderLeftNoTouch() |
20665 | ····{ |
20666 | ········CreateObjects(); |
20667 | ········QueryOwn(); |
20668 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20669 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20670 | ········ownVar.Dummy = 4711; |
20671 | ········pm.Save(); |
20672 | ········pm.UnloadCache(); |
20673 | ········QueryOwn(); |
20674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20675 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20676 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20677 | ····} |
20678 | ····void CreateObjects() |
20679 | ····{ |
20680 | ········pm.MakePersistent(ownVar); |
20681 | ········ownVar.AssignRelation(otherVar); |
20682 | ········pm.Save(); |
20683 | ········pm.UnloadCache(); |
20684 | ····} |
20685 | ····void QueryOwn() |
20686 | ····{ |
20687 | ········var q = new NDOQuery<CmpDir1OwnpabsTblAutoLeftBase>(pm); |
20688 | ········ownVar = q.ExecuteSingle(); |
20689 | ····} |
20690 | ····void QueryOther() |
20691 | ····{ |
20692 | ········var q = new NDOQuery<CmpDir1OwnpabsTblAutoRight>(pm); |
20693 | ········otherVar = q.ExecuteSingle(); |
20694 | ····} |
20695 | } |
20696 | |
20697 | |
20698 | [TestFixture] |
20699 | public class TestCmpBi11OwnpabsNoTblAuto : NDOTest |
20700 | { |
20701 | ····CmpBi11OwnpabsNoTblAutoLeftBase ownVar; |
20702 | ····CmpBi11OwnpabsNoTblAutoRight otherVar; |
20703 | ····PersistenceManager pm; |
20704 | ····[SetUp] |
20705 | ····public void Setup() |
20706 | ····{ |
20707 | ········pm = PmFactory.NewPersistenceManager(); |
20708 | ········ownVar = new CmpBi11OwnpabsNoTblAutoLeftDerived(); |
20709 | ········otherVar = new CmpBi11OwnpabsNoTblAutoRight(); |
20710 | ····} |
20711 | ····[TearDown] |
20712 | ····public void TearDown() |
20713 | ····{ |
20714 | ········try |
20715 | ········{ |
20716 | ············pm.UnloadCache(); |
20717 | ············var l = pm.Objects<CmpBi11OwnpabsNoTblAutoLeftBase>().ResultTable; |
20718 | ············pm.Delete(l); |
20719 | ············pm.Save(); |
20720 | ············pm.UnloadCache(); |
20721 | ············decimal count; |
20722 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20723 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20724 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20725 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20726 | ········} |
20727 | ········catch (Exception) |
20728 | ········{ |
20729 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20730 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20731 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20732 | ········} |
20733 | ····} |
20734 | ····[Test] |
20735 | ····public void TestSaveReload() |
20736 | ····{ |
20737 | ········CreateObjects(); |
20738 | ········QueryOwn(); |
20739 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20740 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20741 | ····} |
20742 | ····[Test] |
20743 | ····public void TestSaveReloadNull() |
20744 | ····{ |
20745 | ········CreateObjects(); |
20746 | ········QueryOwn(); |
20747 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20748 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20749 | ········ownVar.RelField = null; |
20750 | ········pm.Save(); |
20751 | ········pm.UnloadCache(); |
20752 | ········QueryOwn(); |
20753 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20754 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20755 | ····} |
20756 | ····[Test] |
20757 | ····public void TestChangeKeyHolderLeft() |
20758 | ····{ |
20759 | ········CreateObjects(); |
20760 | ········QueryOwn(); |
20761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20762 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20763 | ········int x = ownVar.RelField.Dummy; |
20764 | ········ownVar.Dummy = 4711; |
20765 | ········pm.Save(); |
20766 | ········pm.UnloadCache(); |
20767 | ········QueryOwn(); |
20768 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20769 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20770 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20771 | ····} |
20772 | ····[Test] |
20773 | ····public void TestChangeKeyHolderRight() |
20774 | ····{ |
20775 | ········CreateObjects(); |
20776 | ········QueryOther(); |
20777 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20778 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20779 | ········int x = otherVar.RelField.Dummy; |
20780 | ········otherVar.Dummy = 4711; |
20781 | ········pm.Save(); |
20782 | ········pm.UnloadCache(); |
20783 | ········QueryOther(); |
20784 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20785 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20786 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20787 | ····} |
20788 | ····[Test] |
20789 | ····public void TestChangeKeyHolderLeftNoTouch() |
20790 | ····{ |
20791 | ········CreateObjects(); |
20792 | ········QueryOwn(); |
20793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20794 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20795 | ········ownVar.Dummy = 4711; |
20796 | ········pm.Save(); |
20797 | ········pm.UnloadCache(); |
20798 | ········QueryOwn(); |
20799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20800 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20801 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20802 | ····} |
20803 | ····[Test] |
20804 | ····public void TestChangeKeyHolderRightNoTouch() |
20805 | ····{ |
20806 | ········CreateObjects(); |
20807 | ········QueryOther(); |
20808 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20809 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20810 | ········otherVar.Dummy = 4711; |
20811 | ········pm.Save(); |
20812 | ········pm.UnloadCache(); |
20813 | ········QueryOther(); |
20814 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20815 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20816 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20817 | ····} |
20818 | ····[Test] |
20819 | ····public void TestRelationHash() |
20820 | ····{ |
20821 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoLeftBase)); |
20822 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20823 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoRight)); |
20824 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20825 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20826 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20827 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblAutoLeftDerived)); |
20828 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20829 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20830 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20831 | ····} |
20832 | ····void CreateObjects() |
20833 | ····{ |
20834 | ········pm.MakePersistent(ownVar); |
20835 | ········pm.Save(); |
20836 | ········ownVar.AssignRelation(otherVar); |
20837 | ········pm.Save(); |
20838 | ········pm.UnloadCache(); |
20839 | ····} |
20840 | ····void QueryOwn() |
20841 | ····{ |
20842 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblAutoLeftBase>(pm); |
20843 | ········ownVar = q.ExecuteSingle(); |
20844 | ····} |
20845 | ····void QueryOther() |
20846 | ····{ |
20847 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblAutoRight>(pm); |
20848 | ········otherVar = q.ExecuteSingle(); |
20849 | ····} |
20850 | } |
20851 | |
20852 | |
20853 | [TestFixture] |
20854 | public class TestCmpBi11OwnpabsTblAuto : NDOTest |
20855 | { |
20856 | ····CmpBi11OwnpabsTblAutoLeftBase ownVar; |
20857 | ····CmpBi11OwnpabsTblAutoRight otherVar; |
20858 | ····PersistenceManager pm; |
20859 | ····[SetUp] |
20860 | ····public void Setup() |
20861 | ····{ |
20862 | ········pm = PmFactory.NewPersistenceManager(); |
20863 | ········ownVar = new CmpBi11OwnpabsTblAutoLeftDerived(); |
20864 | ········otherVar = new CmpBi11OwnpabsTblAutoRight(); |
20865 | ····} |
20866 | ····[TearDown] |
20867 | ····public void TearDown() |
20868 | ····{ |
20869 | ········try |
20870 | ········{ |
20871 | ············pm.UnloadCache(); |
20872 | ············var l = pm.Objects<CmpBi11OwnpabsTblAutoLeftBase>().ResultTable; |
20873 | ············pm.Delete(l); |
20874 | ············pm.Save(); |
20875 | ············pm.UnloadCache(); |
20876 | ············decimal count; |
20877 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20878 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
20879 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
20880 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
20881 | ········} |
20882 | ········catch (Exception) |
20883 | ········{ |
20884 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
20885 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
20886 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
20887 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
20888 | ········} |
20889 | ····} |
20890 | ····[Test] |
20891 | ····public void TestSaveReload() |
20892 | ····{ |
20893 | ········CreateObjects(); |
20894 | ········QueryOwn(); |
20895 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20896 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20897 | ····} |
20898 | ····[Test] |
20899 | ····public void TestSaveReloadNull() |
20900 | ····{ |
20901 | ········CreateObjects(); |
20902 | ········QueryOwn(); |
20903 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20904 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20905 | ········ownVar.RelField = null; |
20906 | ········pm.Save(); |
20907 | ········pm.UnloadCache(); |
20908 | ········QueryOwn(); |
20909 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20910 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
20911 | ····} |
20912 | ····[Test] |
20913 | ····public void TestChangeKeyHolderLeft() |
20914 | ····{ |
20915 | ········CreateObjects(); |
20916 | ········QueryOwn(); |
20917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20918 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20919 | ········int x = ownVar.RelField.Dummy; |
20920 | ········ownVar.Dummy = 4711; |
20921 | ········pm.Save(); |
20922 | ········pm.UnloadCache(); |
20923 | ········QueryOwn(); |
20924 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20925 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20926 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20927 | ····} |
20928 | ····[Test] |
20929 | ····public void TestChangeKeyHolderRight() |
20930 | ····{ |
20931 | ········CreateObjects(); |
20932 | ········QueryOther(); |
20933 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20934 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20935 | ········int x = otherVar.RelField.Dummy; |
20936 | ········otherVar.Dummy = 4711; |
20937 | ········pm.Save(); |
20938 | ········pm.UnloadCache(); |
20939 | ········QueryOther(); |
20940 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20941 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20942 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20943 | ····} |
20944 | ····[Test] |
20945 | ····public void TestChangeKeyHolderLeftNoTouch() |
20946 | ····{ |
20947 | ········CreateObjects(); |
20948 | ········QueryOwn(); |
20949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20950 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20951 | ········ownVar.Dummy = 4711; |
20952 | ········pm.Save(); |
20953 | ········pm.UnloadCache(); |
20954 | ········QueryOwn(); |
20955 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
20956 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20957 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
20958 | ····} |
20959 | ····[Test] |
20960 | ····public void TestChangeKeyHolderRightNoTouch() |
20961 | ····{ |
20962 | ········CreateObjects(); |
20963 | ········QueryOther(); |
20964 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20965 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20966 | ········otherVar.Dummy = 4711; |
20967 | ········pm.Save(); |
20968 | ········pm.UnloadCache(); |
20969 | ········QueryOther(); |
20970 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
20971 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
20972 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
20973 | ····} |
20974 | ····[Test] |
20975 | ····public void TestRelationHash() |
20976 | ····{ |
20977 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoLeftBase)); |
20978 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
20979 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoRight)); |
20980 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
20981 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
20982 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
20983 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblAutoLeftDerived)); |
20984 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
20985 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
20986 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
20987 | ····} |
20988 | ····void CreateObjects() |
20989 | ····{ |
20990 | ········pm.MakePersistent(ownVar); |
20991 | ········ownVar.AssignRelation(otherVar); |
20992 | ········pm.Save(); |
20993 | ········pm.UnloadCache(); |
20994 | ····} |
20995 | ····void QueryOwn() |
20996 | ····{ |
20997 | ········var q = new NDOQuery<CmpBi11OwnpabsTblAutoLeftBase>(pm); |
20998 | ········ownVar = q.ExecuteSingle(); |
20999 | ····} |
21000 | ····void QueryOther() |
21001 | ····{ |
21002 | ········var q = new NDOQuery<CmpBi11OwnpabsTblAutoRight>(pm); |
21003 | ········otherVar = q.ExecuteSingle(); |
21004 | ····} |
21005 | } |
21006 | |
21007 | |
21008 | [TestFixture] |
21009 | public class TestCmpDirnOwnpabsNoTblAuto : NDOTest |
21010 | { |
21011 | ····CmpDirnOwnpabsNoTblAutoLeftBase ownVar; |
21012 | ····CmpDirnOwnpabsNoTblAutoRight otherVar; |
21013 | ····PersistenceManager pm; |
21014 | ····[SetUp] |
21015 | ····public void Setup() |
21016 | ····{ |
21017 | ········pm = PmFactory.NewPersistenceManager(); |
21018 | ········ownVar = new CmpDirnOwnpabsNoTblAutoLeftDerived(); |
21019 | ········otherVar = new CmpDirnOwnpabsNoTblAutoRight(); |
21020 | ····} |
21021 | ····[TearDown] |
21022 | ····public void TearDown() |
21023 | ····{ |
21024 | ········try |
21025 | ········{ |
21026 | ············pm.UnloadCache(); |
21027 | ············var l = pm.Objects<CmpDirnOwnpabsNoTblAutoLeftBase>().ResultTable; |
21028 | ············pm.Delete(l); |
21029 | ············pm.Save(); |
21030 | ············pm.UnloadCache(); |
21031 | ············decimal count; |
21032 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21033 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21034 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21035 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21036 | ········} |
21037 | ········catch (Exception) |
21038 | ········{ |
21039 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21040 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21041 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21042 | ········} |
21043 | ····} |
21044 | ····[Test] |
21045 | ····public void TestSaveReload() |
21046 | ····{ |
21047 | ········CreateObjects(); |
21048 | ········QueryOwn(); |
21049 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21050 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21051 | ····} |
21052 | ····[Test] |
21053 | ····public void TestSaveReloadNull() |
21054 | ····{ |
21055 | ········CreateObjects(); |
21056 | ········QueryOwn(); |
21057 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21058 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21059 | ········ownVar.RelField = new List<CmpDirnOwnpabsNoTblAutoRight>(); |
21060 | ········pm.Save(); |
21061 | ········pm.UnloadCache(); |
21062 | ········QueryOwn(); |
21063 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21064 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21065 | ····} |
21066 | ····[Test] |
21067 | ····public void TestSaveReloadRemove() |
21068 | ····{ |
21069 | ········CreateObjects(); |
21070 | ········QueryOwn(); |
21071 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21072 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21073 | ········ownVar.RemoveRelatedObject(); |
21074 | ········pm.Save(); |
21075 | ········pm.UnloadCache(); |
21076 | ········QueryOwn(); |
21077 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21078 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21079 | ····} |
21080 | ····[Test] |
21081 | ····public void TestUpdateOrder() |
21082 | ····{ |
21083 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21084 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21085 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpabsNoTblAutoLeftDerived)})) |
21086 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpDirnOwnpabsNoTblAutoRight)})), "Wrong order #2"); |
21087 | ········Debug.WriteLine("CmpDirnOwnpabsNoTblAutoLeftBase"); |
21088 | ····} |
21089 | ····void CreateObjects() |
21090 | ····{ |
21091 | ········pm.MakePersistent(ownVar); |
21092 | ········ownVar.AssignRelation(otherVar); |
21093 | ········pm.Save(); |
21094 | ········pm.UnloadCache(); |
21095 | ····} |
21096 | ····void QueryOwn() |
21097 | ····{ |
21098 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblAutoLeftBase>(pm); |
21099 | ········ownVar = q.ExecuteSingle(); |
21100 | ····} |
21101 | ····void QueryOther() |
21102 | ····{ |
21103 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblAutoRight>(pm); |
21104 | ········otherVar = q.ExecuteSingle(); |
21105 | ····} |
21106 | } |
21107 | |
21108 | |
21109 | [TestFixture] |
21110 | public class TestCmpDirnOwnpabsTblAuto : NDOTest |
21111 | { |
21112 | ····CmpDirnOwnpabsTblAutoLeftBase ownVar; |
21113 | ····CmpDirnOwnpabsTblAutoRight otherVar; |
21114 | ····PersistenceManager pm; |
21115 | ····[SetUp] |
21116 | ····public void Setup() |
21117 | ····{ |
21118 | ········pm = PmFactory.NewPersistenceManager(); |
21119 | ········ownVar = new CmpDirnOwnpabsTblAutoLeftDerived(); |
21120 | ········otherVar = new CmpDirnOwnpabsTblAutoRight(); |
21121 | ····} |
21122 | ····[TearDown] |
21123 | ····public void TearDown() |
21124 | ····{ |
21125 | ········try |
21126 | ········{ |
21127 | ············pm.UnloadCache(); |
21128 | ············var l = pm.Objects<CmpDirnOwnpabsTblAutoLeftBase>().ResultTable; |
21129 | ············pm.Delete(l); |
21130 | ············pm.Save(); |
21131 | ············pm.UnloadCache(); |
21132 | ············decimal count; |
21133 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21134 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21135 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21136 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21137 | ········} |
21138 | ········catch (Exception) |
21139 | ········{ |
21140 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21141 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21142 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21143 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21144 | ········} |
21145 | ····} |
21146 | ····[Test] |
21147 | ····public void TestSaveReload() |
21148 | ····{ |
21149 | ········CreateObjects(); |
21150 | ········QueryOwn(); |
21151 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21152 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21153 | ····} |
21154 | ····[Test] |
21155 | ····public void TestSaveReloadNull() |
21156 | ····{ |
21157 | ········CreateObjects(); |
21158 | ········QueryOwn(); |
21159 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21160 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21161 | ········ownVar.RelField = new List<CmpDirnOwnpabsTblAutoRight>(); |
21162 | ········pm.Save(); |
21163 | ········pm.UnloadCache(); |
21164 | ········QueryOwn(); |
21165 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21166 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21167 | ····} |
21168 | ····[Test] |
21169 | ····public void TestSaveReloadRemove() |
21170 | ····{ |
21171 | ········CreateObjects(); |
21172 | ········QueryOwn(); |
21173 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21174 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21175 | ········ownVar.RemoveRelatedObject(); |
21176 | ········pm.Save(); |
21177 | ········pm.UnloadCache(); |
21178 | ········QueryOwn(); |
21179 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21180 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21181 | ····} |
21182 | ····void CreateObjects() |
21183 | ····{ |
21184 | ········pm.MakePersistent(ownVar); |
21185 | ········ownVar.AssignRelation(otherVar); |
21186 | ········pm.Save(); |
21187 | ········pm.UnloadCache(); |
21188 | ····} |
21189 | ····void QueryOwn() |
21190 | ····{ |
21191 | ········var q = new NDOQuery<CmpDirnOwnpabsTblAutoLeftBase>(pm); |
21192 | ········ownVar = q.ExecuteSingle(); |
21193 | ····} |
21194 | ····void QueryOther() |
21195 | ····{ |
21196 | ········var q = new NDOQuery<CmpDirnOwnpabsTblAutoRight>(pm); |
21197 | ········otherVar = q.ExecuteSingle(); |
21198 | ····} |
21199 | } |
21200 | |
21201 | |
21202 | [TestFixture] |
21203 | public class TestCmpBin1OwnpabsNoTblAuto : NDOTest |
21204 | { |
21205 | ····CmpBin1OwnpabsNoTblAutoLeftBase ownVar; |
21206 | ····CmpBin1OwnpabsNoTblAutoRight otherVar; |
21207 | ····PersistenceManager pm; |
21208 | ····[SetUp] |
21209 | ····public void Setup() |
21210 | ····{ |
21211 | ········pm = PmFactory.NewPersistenceManager(); |
21212 | ········ownVar = new CmpBin1OwnpabsNoTblAutoLeftDerived(); |
21213 | ········otherVar = new CmpBin1OwnpabsNoTblAutoRight(); |
21214 | ····} |
21215 | ····[TearDown] |
21216 | ····public void TearDown() |
21217 | ····{ |
21218 | ········try |
21219 | ········{ |
21220 | ············pm.UnloadCache(); |
21221 | ············var l = pm.Objects<CmpBin1OwnpabsNoTblAutoLeftBase>().ResultTable; |
21222 | ············pm.Delete(l); |
21223 | ············pm.Save(); |
21224 | ············pm.UnloadCache(); |
21225 | ············decimal count; |
21226 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21227 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21228 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21229 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21230 | ········} |
21231 | ········catch (Exception) |
21232 | ········{ |
21233 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21234 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21235 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21236 | ········} |
21237 | ····} |
21238 | ····[Test] |
21239 | ····public void TestSaveReload() |
21240 | ····{ |
21241 | ········CreateObjects(); |
21242 | ········QueryOwn(); |
21243 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21244 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21245 | ····} |
21246 | ····[Test] |
21247 | ····public void TestSaveReloadNull() |
21248 | ····{ |
21249 | ········CreateObjects(); |
21250 | ········QueryOwn(); |
21251 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21252 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21253 | ········ownVar.RelField = new List<CmpBin1OwnpabsNoTblAutoRight>(); |
21254 | ········pm.Save(); |
21255 | ········pm.UnloadCache(); |
21256 | ········QueryOwn(); |
21257 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21258 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21259 | ····} |
21260 | ····[Test] |
21261 | ····public void TestSaveReloadRemove() |
21262 | ····{ |
21263 | ········CreateObjects(); |
21264 | ········QueryOwn(); |
21265 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21266 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21267 | ········ownVar.RemoveRelatedObject(); |
21268 | ········pm.Save(); |
21269 | ········pm.UnloadCache(); |
21270 | ········QueryOwn(); |
21271 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21272 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21273 | ····} |
21274 | ····[Test] |
21275 | ····public void TestChangeKeyHolderRight() |
21276 | ····{ |
21277 | ········CreateObjects(); |
21278 | ········QueryOther(); |
21279 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21280 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21281 | ········int x = otherVar.RelField.Dummy; |
21282 | ········otherVar.Dummy = 4711; |
21283 | ········pm.Save(); |
21284 | ········pm.UnloadCache(); |
21285 | ········QueryOther(); |
21286 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21287 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21288 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21289 | ····} |
21290 | ····[Test] |
21291 | ····public void TestChangeKeyHolderRightNoTouch() |
21292 | ····{ |
21293 | ········CreateObjects(); |
21294 | ········QueryOther(); |
21295 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21296 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21297 | ········otherVar.Dummy = 4711; |
21298 | ········pm.Save(); |
21299 | ········pm.UnloadCache(); |
21300 | ········QueryOther(); |
21301 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21302 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21303 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21304 | ····} |
21305 | ····[Test] |
21306 | ····public void TestUpdateOrder() |
21307 | ····{ |
21308 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21309 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21310 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpabsNoTblAutoLeftDerived)})) |
21311 | ················< ((int)mi.Invoke(mapping, new object[]{typeof(CmpBin1OwnpabsNoTblAutoRight)})), "Wrong order #2"); |
21312 | ········Debug.WriteLine("CmpBin1OwnpabsNoTblAutoLeftBase"); |
21313 | ····} |
21314 | ····[Test] |
21315 | ····public void TestRelationHash() |
21316 | ····{ |
21317 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoLeftBase)); |
21318 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21319 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoRight)); |
21320 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21321 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21322 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21323 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblAutoLeftDerived)); |
21324 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21325 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21326 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21327 | ····} |
21328 | ····void CreateObjects() |
21329 | ····{ |
21330 | ········pm.MakePersistent(ownVar); |
21331 | ········ownVar.AssignRelation(otherVar); |
21332 | ········pm.Save(); |
21333 | ········pm.UnloadCache(); |
21334 | ····} |
21335 | ····void QueryOwn() |
21336 | ····{ |
21337 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblAutoLeftBase>(pm); |
21338 | ········ownVar = q.ExecuteSingle(); |
21339 | ····} |
21340 | ····void QueryOther() |
21341 | ····{ |
21342 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblAutoRight>(pm); |
21343 | ········otherVar = q.ExecuteSingle(); |
21344 | ····} |
21345 | } |
21346 | |
21347 | |
21348 | [TestFixture] |
21349 | public class TestCmpBin1OwnpabsTblAuto : NDOTest |
21350 | { |
21351 | ····CmpBin1OwnpabsTblAutoLeftBase ownVar; |
21352 | ····CmpBin1OwnpabsTblAutoRight otherVar; |
21353 | ····PersistenceManager pm; |
21354 | ····[SetUp] |
21355 | ····public void Setup() |
21356 | ····{ |
21357 | ········pm = PmFactory.NewPersistenceManager(); |
21358 | ········ownVar = new CmpBin1OwnpabsTblAutoLeftDerived(); |
21359 | ········otherVar = new CmpBin1OwnpabsTblAutoRight(); |
21360 | ····} |
21361 | ····[TearDown] |
21362 | ····public void TearDown() |
21363 | ····{ |
21364 | ········try |
21365 | ········{ |
21366 | ············pm.UnloadCache(); |
21367 | ············var l = pm.Objects<CmpBin1OwnpabsTblAutoLeftBase>().ResultTable; |
21368 | ············pm.Delete(l); |
21369 | ············pm.Save(); |
21370 | ············pm.UnloadCache(); |
21371 | ············decimal count; |
21372 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21373 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21374 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21375 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21376 | ········} |
21377 | ········catch (Exception) |
21378 | ········{ |
21379 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21380 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21381 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21382 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21383 | ········} |
21384 | ····} |
21385 | ····[Test] |
21386 | ····public void TestSaveReload() |
21387 | ····{ |
21388 | ········CreateObjects(); |
21389 | ········QueryOwn(); |
21390 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21391 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21392 | ····} |
21393 | ····[Test] |
21394 | ····public void TestSaveReloadNull() |
21395 | ····{ |
21396 | ········CreateObjects(); |
21397 | ········QueryOwn(); |
21398 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21399 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21400 | ········ownVar.RelField = new List<CmpBin1OwnpabsTblAutoRight>(); |
21401 | ········pm.Save(); |
21402 | ········pm.UnloadCache(); |
21403 | ········QueryOwn(); |
21404 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21405 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21406 | ····} |
21407 | ····[Test] |
21408 | ····public void TestSaveReloadRemove() |
21409 | ····{ |
21410 | ········CreateObjects(); |
21411 | ········QueryOwn(); |
21412 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21413 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21414 | ········ownVar.RemoveRelatedObject(); |
21415 | ········pm.Save(); |
21416 | ········pm.UnloadCache(); |
21417 | ········QueryOwn(); |
21418 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21419 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21420 | ····} |
21421 | ····[Test] |
21422 | ····public void TestChangeKeyHolderRight() |
21423 | ····{ |
21424 | ········CreateObjects(); |
21425 | ········QueryOther(); |
21426 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21427 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21428 | ········int x = otherVar.RelField.Dummy; |
21429 | ········otherVar.Dummy = 4711; |
21430 | ········pm.Save(); |
21431 | ········pm.UnloadCache(); |
21432 | ········QueryOther(); |
21433 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21434 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21435 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21436 | ····} |
21437 | ····[Test] |
21438 | ····public void TestChangeKeyHolderRightNoTouch() |
21439 | ····{ |
21440 | ········CreateObjects(); |
21441 | ········QueryOther(); |
21442 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21443 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21444 | ········otherVar.Dummy = 4711; |
21445 | ········pm.Save(); |
21446 | ········pm.UnloadCache(); |
21447 | ········QueryOther(); |
21448 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
21449 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21450 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
21451 | ····} |
21452 | ····[Test] |
21453 | ····public void TestRelationHash() |
21454 | ····{ |
21455 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoLeftBase)); |
21456 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21457 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoRight)); |
21458 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21459 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21460 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21461 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblAutoLeftDerived)); |
21462 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21463 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21464 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21465 | ····} |
21466 | ····void CreateObjects() |
21467 | ····{ |
21468 | ········pm.MakePersistent(ownVar); |
21469 | ········ownVar.AssignRelation(otherVar); |
21470 | ········pm.Save(); |
21471 | ········pm.UnloadCache(); |
21472 | ····} |
21473 | ····void QueryOwn() |
21474 | ····{ |
21475 | ········var q = new NDOQuery<CmpBin1OwnpabsTblAutoLeftBase>(pm); |
21476 | ········ownVar = q.ExecuteSingle(); |
21477 | ····} |
21478 | ····void QueryOther() |
21479 | ····{ |
21480 | ········var q = new NDOQuery<CmpBin1OwnpabsTblAutoRight>(pm); |
21481 | ········otherVar = q.ExecuteSingle(); |
21482 | ····} |
21483 | } |
21484 | |
21485 | |
21486 | [TestFixture] |
21487 | public class TestCmpBi1nOwnpabsTblAuto : NDOTest |
21488 | { |
21489 | ····CmpBi1nOwnpabsTblAutoLeftBase ownVar; |
21490 | ····CmpBi1nOwnpabsTblAutoRight otherVar; |
21491 | ····PersistenceManager pm; |
21492 | ····[SetUp] |
21493 | ····public void Setup() |
21494 | ····{ |
21495 | ········pm = PmFactory.NewPersistenceManager(); |
21496 | ········ownVar = new CmpBi1nOwnpabsTblAutoLeftDerived(); |
21497 | ········otherVar = new CmpBi1nOwnpabsTblAutoRight(); |
21498 | ····} |
21499 | ····[TearDown] |
21500 | ····public void TearDown() |
21501 | ····{ |
21502 | ········try |
21503 | ········{ |
21504 | ············pm.UnloadCache(); |
21505 | ············var l = pm.Objects<CmpBi1nOwnpabsTblAutoLeftBase>().ResultTable; |
21506 | ············pm.Delete(l); |
21507 | ············pm.Save(); |
21508 | ············pm.UnloadCache(); |
21509 | ············decimal count; |
21510 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21511 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21512 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21513 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21514 | ········} |
21515 | ········catch (Exception) |
21516 | ········{ |
21517 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21518 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21519 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21520 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21521 | ········} |
21522 | ····} |
21523 | ····[Test] |
21524 | ····public void TestSaveReload() |
21525 | ····{ |
21526 | ········CreateObjects(); |
21527 | ········QueryOwn(); |
21528 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21529 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21530 | ····} |
21531 | ····[Test] |
21532 | ····public void TestSaveReloadNull() |
21533 | ····{ |
21534 | ········CreateObjects(); |
21535 | ········QueryOwn(); |
21536 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21537 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21538 | ········ownVar.RelField = null; |
21539 | ········pm.Save(); |
21540 | ········pm.UnloadCache(); |
21541 | ········QueryOwn(); |
21542 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21543 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21544 | ····} |
21545 | ····[Test] |
21546 | ····public void TestChangeKeyHolderLeft() |
21547 | ····{ |
21548 | ········CreateObjects(); |
21549 | ········QueryOwn(); |
21550 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21551 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21552 | ········int x = ownVar.RelField.Dummy; |
21553 | ········ownVar.Dummy = 4711; |
21554 | ········pm.Save(); |
21555 | ········pm.UnloadCache(); |
21556 | ········QueryOwn(); |
21557 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21558 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21559 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21560 | ····} |
21561 | ····[Test] |
21562 | ····public void TestChangeKeyHolderLeftNoTouch() |
21563 | ····{ |
21564 | ········CreateObjects(); |
21565 | ········QueryOwn(); |
21566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21567 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21568 | ········ownVar.Dummy = 4711; |
21569 | ········pm.Save(); |
21570 | ········pm.UnloadCache(); |
21571 | ········QueryOwn(); |
21572 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21573 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21574 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21575 | ····} |
21576 | ····[Test] |
21577 | ····public void TestRelationHash() |
21578 | ····{ |
21579 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoLeftBase)); |
21580 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21581 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoRight)); |
21582 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21583 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21584 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21585 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblAutoLeftDerived)); |
21586 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21587 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21588 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21589 | ····} |
21590 | ····void CreateObjects() |
21591 | ····{ |
21592 | ········pm.MakePersistent(ownVar); |
21593 | ········ownVar.AssignRelation(otherVar); |
21594 | ········pm.Save(); |
21595 | ········pm.UnloadCache(); |
21596 | ····} |
21597 | ····void QueryOwn() |
21598 | ····{ |
21599 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblAutoLeftBase>(pm); |
21600 | ········ownVar = q.ExecuteSingle(); |
21601 | ····} |
21602 | ····void QueryOther() |
21603 | ····{ |
21604 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblAutoRight>(pm); |
21605 | ········otherVar = q.ExecuteSingle(); |
21606 | ····} |
21607 | } |
21608 | |
21609 | |
21610 | [TestFixture] |
21611 | public class TestCmpBinnOwnpabsTblAuto : NDOTest |
21612 | { |
21613 | ····CmpBinnOwnpabsTblAutoLeftBase ownVar; |
21614 | ····CmpBinnOwnpabsTblAutoRight otherVar; |
21615 | ····PersistenceManager pm; |
21616 | ····[SetUp] |
21617 | ····public void Setup() |
21618 | ····{ |
21619 | ········pm = PmFactory.NewPersistenceManager(); |
21620 | ········ownVar = new CmpBinnOwnpabsTblAutoLeftDerived(); |
21621 | ········otherVar = new CmpBinnOwnpabsTblAutoRight(); |
21622 | ····} |
21623 | ····[TearDown] |
21624 | ····public void TearDown() |
21625 | ····{ |
21626 | ········try |
21627 | ········{ |
21628 | ············pm.UnloadCache(); |
21629 | ············var l = pm.Objects<CmpBinnOwnpabsTblAutoLeftBase>().ResultTable; |
21630 | ············pm.Delete(l); |
21631 | ············pm.Save(); |
21632 | ············pm.UnloadCache(); |
21633 | ············decimal count; |
21634 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21635 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21636 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblAutoRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21637 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21638 | ········} |
21639 | ········catch (Exception) |
21640 | ········{ |
21641 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21642 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21643 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21644 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21645 | ········} |
21646 | ····} |
21647 | ····[Test] |
21648 | ····public void TestSaveReload() |
21649 | ····{ |
21650 | ········CreateObjects(); |
21651 | ········QueryOwn(); |
21652 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21653 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21654 | ····} |
21655 | ····[Test] |
21656 | ····public void TestSaveReloadNull() |
21657 | ····{ |
21658 | ········CreateObjects(); |
21659 | ········QueryOwn(); |
21660 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21661 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21662 | ········ownVar.RelField = new List<CmpBinnOwnpabsTblAutoRight>(); |
21663 | ········pm.Save(); |
21664 | ········pm.UnloadCache(); |
21665 | ········QueryOwn(); |
21666 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21667 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21668 | ····} |
21669 | ····[Test] |
21670 | ····public void TestSaveReloadRemove() |
21671 | ····{ |
21672 | ········CreateObjects(); |
21673 | ········QueryOwn(); |
21674 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21675 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21676 | ········ownVar.RemoveRelatedObject(); |
21677 | ········pm.Save(); |
21678 | ········pm.UnloadCache(); |
21679 | ········QueryOwn(); |
21680 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21681 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
21682 | ····} |
21683 | ····[Test] |
21684 | ····public void TestRelationHash() |
21685 | ····{ |
21686 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoLeftBase)); |
21687 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
21688 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoRight)); |
21689 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
21690 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
21691 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
21692 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblAutoLeftDerived)); |
21693 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
21694 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
21695 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
21696 | ····} |
21697 | ····void CreateObjects() |
21698 | ····{ |
21699 | ········pm.MakePersistent(ownVar); |
21700 | ········ownVar.AssignRelation(otherVar); |
21701 | ········pm.Save(); |
21702 | ········pm.UnloadCache(); |
21703 | ····} |
21704 | ····void QueryOwn() |
21705 | ····{ |
21706 | ········var q = new NDOQuery<CmpBinnOwnpabsTblAutoLeftBase>(pm); |
21707 | ········ownVar = q.ExecuteSingle(); |
21708 | ····} |
21709 | ····void QueryOther() |
21710 | ····{ |
21711 | ········var q = new NDOQuery<CmpBinnOwnpabsTblAutoRight>(pm); |
21712 | ········otherVar = q.ExecuteSingle(); |
21713 | ····} |
21714 | } |
21715 | |
21716 | |
21717 | [TestFixture] |
21718 | public class TestAgrDir1OthpabsNoTblAuto : NDOTest |
21719 | { |
21720 | ····AgrDir1OthpabsNoTblAutoLeft ownVar; |
21721 | ····AgrDir1OthpabsNoTblAutoRightBase otherVar; |
21722 | ····PersistenceManager pm; |
21723 | ····[SetUp] |
21724 | ····public void Setup() |
21725 | ····{ |
21726 | ········pm = PmFactory.NewPersistenceManager(); |
21727 | ········ownVar = new AgrDir1OthpabsNoTblAutoLeft(); |
21728 | ········otherVar = new AgrDir1OthpabsNoTblAutoRightDerived(); |
21729 | ····} |
21730 | ····[TearDown] |
21731 | ····public void TearDown() |
21732 | ····{ |
21733 | ········try |
21734 | ········{ |
21735 | ············pm.UnloadCache(); |
21736 | ············var l = pm.Objects<AgrDir1OthpabsNoTblAutoLeft>().ResultTable; |
21737 | ············pm.Delete(l); |
21738 | ············pm.Save(); |
21739 | ············pm.UnloadCache(); |
21740 | ············var m = pm.Objects<AgrDir1OthpabsNoTblAutoRightBase>().ResultTable; |
21741 | ············pm.Delete(m); |
21742 | ············pm.Save(); |
21743 | ············pm.UnloadCache(); |
21744 | ············decimal count; |
21745 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21746 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21747 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21748 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21749 | ········} |
21750 | ········catch (Exception) |
21751 | ········{ |
21752 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21753 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21754 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21755 | ········} |
21756 | ····} |
21757 | ····[Test] |
21758 | ····public void TestSaveReload() |
21759 | ····{ |
21760 | ········CreateObjects(); |
21761 | ········QueryOwn(); |
21762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21763 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21764 | ····} |
21765 | ····[Test] |
21766 | ····public void TestSaveReloadNull() |
21767 | ····{ |
21768 | ········CreateObjects(); |
21769 | ········QueryOwn(); |
21770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21771 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21772 | ········ownVar.RelField = null; |
21773 | ········pm.Save(); |
21774 | ········pm.UnloadCache(); |
21775 | ········QueryOwn(); |
21776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21777 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21778 | ····} |
21779 | ····[Test] |
21780 | ····public void TestChangeKeyHolderLeft() |
21781 | ····{ |
21782 | ········CreateObjects(); |
21783 | ········QueryOwn(); |
21784 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21785 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21786 | ········int x = ownVar.RelField.Dummy; |
21787 | ········ownVar.Dummy = 4711; |
21788 | ········pm.Save(); |
21789 | ········pm.UnloadCache(); |
21790 | ········QueryOwn(); |
21791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21792 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21793 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21794 | ····} |
21795 | ····[Test] |
21796 | ····public void TestChangeKeyHolderLeftNoTouch() |
21797 | ····{ |
21798 | ········CreateObjects(); |
21799 | ········QueryOwn(); |
21800 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21801 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21802 | ········ownVar.Dummy = 4711; |
21803 | ········pm.Save(); |
21804 | ········pm.UnloadCache(); |
21805 | ········QueryOwn(); |
21806 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21807 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21809 | ····} |
21810 | ····[Test] |
21811 | ····public void TestUpdateOrder() |
21812 | ····{ |
21813 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
21814 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
21815 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpabsNoTblAutoLeft)})) |
21816 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
21817 | ········Debug.WriteLine("AgrDir1OthpabsNoTblAutoLeft"); |
21818 | ····} |
21819 | ····void CreateObjects() |
21820 | ····{ |
21821 | ········pm.MakePersistent(ownVar); |
21822 | ········pm.Save(); |
21823 | ········pm.MakePersistent(otherVar); |
21824 | ········pm.Save(); |
21825 | ········ownVar.AssignRelation(otherVar); |
21826 | ········pm.Save(); |
21827 | ········pm.UnloadCache(); |
21828 | ····} |
21829 | ····void QueryOwn() |
21830 | ····{ |
21831 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblAutoLeft>(pm); |
21832 | ········ownVar = q.ExecuteSingle(); |
21833 | ····} |
21834 | ····void QueryOther() |
21835 | ····{ |
21836 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblAutoRightBase>(pm); |
21837 | ········otherVar = q.ExecuteSingle(); |
21838 | ····} |
21839 | } |
21840 | |
21841 | |
21842 | [TestFixture] |
21843 | public class TestAgrDir1OthpabsTblAuto : NDOTest |
21844 | { |
21845 | ····AgrDir1OthpabsTblAutoLeft ownVar; |
21846 | ····AgrDir1OthpabsTblAutoRightBase otherVar; |
21847 | ····PersistenceManager pm; |
21848 | ····[SetUp] |
21849 | ····public void Setup() |
21850 | ····{ |
21851 | ········pm = PmFactory.NewPersistenceManager(); |
21852 | ········ownVar = new AgrDir1OthpabsTblAutoLeft(); |
21853 | ········otherVar = new AgrDir1OthpabsTblAutoRightDerived(); |
21854 | ····} |
21855 | ····[TearDown] |
21856 | ····public void TearDown() |
21857 | ····{ |
21858 | ········try |
21859 | ········{ |
21860 | ············pm.UnloadCache(); |
21861 | ············var l = pm.Objects<AgrDir1OthpabsTblAutoLeft>().ResultTable; |
21862 | ············pm.Delete(l); |
21863 | ············pm.Save(); |
21864 | ············pm.UnloadCache(); |
21865 | ············var m = pm.Objects<AgrDir1OthpabsTblAutoRightBase>().ResultTable; |
21866 | ············pm.Delete(m); |
21867 | ············pm.Save(); |
21868 | ············pm.UnloadCache(); |
21869 | ············decimal count; |
21870 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21871 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21872 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21873 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21874 | ········} |
21875 | ········catch (Exception) |
21876 | ········{ |
21877 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21878 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21879 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21880 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
21881 | ········} |
21882 | ····} |
21883 | ····[Test] |
21884 | ····public void TestSaveReload() |
21885 | ····{ |
21886 | ········CreateObjects(); |
21887 | ········QueryOwn(); |
21888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21889 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21890 | ····} |
21891 | ····[Test] |
21892 | ····public void TestSaveReloadNull() |
21893 | ····{ |
21894 | ········CreateObjects(); |
21895 | ········QueryOwn(); |
21896 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21897 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21898 | ········ownVar.RelField = null; |
21899 | ········pm.Save(); |
21900 | ········pm.UnloadCache(); |
21901 | ········QueryOwn(); |
21902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21903 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
21904 | ····} |
21905 | ····[Test] |
21906 | ····public void TestChangeKeyHolderLeft() |
21907 | ····{ |
21908 | ········CreateObjects(); |
21909 | ········QueryOwn(); |
21910 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21911 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21912 | ········int x = ownVar.RelField.Dummy; |
21913 | ········ownVar.Dummy = 4711; |
21914 | ········pm.Save(); |
21915 | ········pm.UnloadCache(); |
21916 | ········QueryOwn(); |
21917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21918 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21919 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21920 | ····} |
21921 | ····[Test] |
21922 | ····public void TestChangeKeyHolderLeftNoTouch() |
21923 | ····{ |
21924 | ········CreateObjects(); |
21925 | ········QueryOwn(); |
21926 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21927 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21928 | ········ownVar.Dummy = 4711; |
21929 | ········pm.Save(); |
21930 | ········pm.UnloadCache(); |
21931 | ········QueryOwn(); |
21932 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
21933 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
21934 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
21935 | ····} |
21936 | ····void CreateObjects() |
21937 | ····{ |
21938 | ········pm.MakePersistent(ownVar); |
21939 | ········pm.MakePersistent(otherVar); |
21940 | ········ownVar.AssignRelation(otherVar); |
21941 | ········pm.Save(); |
21942 | ········pm.UnloadCache(); |
21943 | ····} |
21944 | ····void QueryOwn() |
21945 | ····{ |
21946 | ········var q = new NDOQuery<AgrDir1OthpabsTblAutoLeft>(pm); |
21947 | ········ownVar = q.ExecuteSingle(); |
21948 | ····} |
21949 | ····void QueryOther() |
21950 | ····{ |
21951 | ········var q = new NDOQuery<AgrDir1OthpabsTblAutoRightBase>(pm); |
21952 | ········otherVar = q.ExecuteSingle(); |
21953 | ····} |
21954 | } |
21955 | |
21956 | |
21957 | [TestFixture] |
21958 | public class TestAgrBi11OthpabsNoTblAuto : NDOTest |
21959 | { |
21960 | ····AgrBi11OthpabsNoTblAutoLeft ownVar; |
21961 | ····AgrBi11OthpabsNoTblAutoRightBase otherVar; |
21962 | ····PersistenceManager pm; |
21963 | ····[SetUp] |
21964 | ····public void Setup() |
21965 | ····{ |
21966 | ········pm = PmFactory.NewPersistenceManager(); |
21967 | ········ownVar = new AgrBi11OthpabsNoTblAutoLeft(); |
21968 | ········otherVar = new AgrBi11OthpabsNoTblAutoRightDerived(); |
21969 | ····} |
21970 | ····[TearDown] |
21971 | ····public void TearDown() |
21972 | ····{ |
21973 | ········try |
21974 | ········{ |
21975 | ············pm.UnloadCache(); |
21976 | ············var l = pm.Objects<AgrBi11OthpabsNoTblAutoLeft>().ResultTable; |
21977 | ············pm.Delete(l); |
21978 | ············pm.Save(); |
21979 | ············pm.UnloadCache(); |
21980 | ············var m = pm.Objects<AgrBi11OthpabsNoTblAutoRightBase>().ResultTable; |
21981 | ············pm.Delete(m); |
21982 | ············pm.Save(); |
21983 | ············pm.UnloadCache(); |
21984 | ············decimal count; |
21985 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21986 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
21987 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
21988 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
21989 | ········} |
21990 | ········catch (Exception) |
21991 | ········{ |
21992 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
21993 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
21994 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
21995 | ········} |
21996 | ····} |
21997 | ····[Test] |
21998 | ····public void TestSaveReload() |
21999 | ····{ |
22000 | ········CreateObjects(); |
22001 | ········QueryOwn(); |
22002 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22003 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22004 | ····} |
22005 | ····[Test] |
22006 | ····public void TestSaveReloadNull() |
22007 | ····{ |
22008 | ········CreateObjects(); |
22009 | ········QueryOwn(); |
22010 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22011 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22012 | ········ownVar.RelField = null; |
22013 | ········pm.Save(); |
22014 | ········pm.UnloadCache(); |
22015 | ········QueryOwn(); |
22016 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22017 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22018 | ····} |
22019 | ····[Test] |
22020 | ····public void TestChangeKeyHolderLeft() |
22021 | ····{ |
22022 | ········CreateObjects(); |
22023 | ········QueryOwn(); |
22024 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22025 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22026 | ········int x = ownVar.RelField.Dummy; |
22027 | ········ownVar.Dummy = 4711; |
22028 | ········pm.Save(); |
22029 | ········pm.UnloadCache(); |
22030 | ········QueryOwn(); |
22031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22032 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22033 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22034 | ····} |
22035 | ····[Test] |
22036 | ····public void TestChangeKeyHolderRight() |
22037 | ····{ |
22038 | ········CreateObjects(); |
22039 | ········QueryOther(); |
22040 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22041 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22042 | ········int x = otherVar.RelField.Dummy; |
22043 | ········otherVar.Dummy = 4711; |
22044 | ········pm.Save(); |
22045 | ········pm.UnloadCache(); |
22046 | ········QueryOther(); |
22047 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22048 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22049 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22050 | ····} |
22051 | ····[Test] |
22052 | ····public void TestChangeKeyHolderLeftNoTouch() |
22053 | ····{ |
22054 | ········CreateObjects(); |
22055 | ········QueryOwn(); |
22056 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22057 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22058 | ········ownVar.Dummy = 4711; |
22059 | ········pm.Save(); |
22060 | ········pm.UnloadCache(); |
22061 | ········QueryOwn(); |
22062 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22063 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22064 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22065 | ····} |
22066 | ····[Test] |
22067 | ····public void TestChangeKeyHolderRightNoTouch() |
22068 | ····{ |
22069 | ········CreateObjects(); |
22070 | ········QueryOther(); |
22071 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22072 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22073 | ········otherVar.Dummy = 4711; |
22074 | ········pm.Save(); |
22075 | ········pm.UnloadCache(); |
22076 | ········QueryOther(); |
22077 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22078 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22079 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22080 | ····} |
22081 | ····[Test] |
22082 | ····public void TestRelationHash() |
22083 | ····{ |
22084 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoLeft)); |
22085 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22086 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoRightBase)); |
22087 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22088 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22089 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22090 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblAutoRightDerived)); |
22091 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22092 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22093 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22094 | ····} |
22095 | ····void CreateObjects() |
22096 | ····{ |
22097 | ········pm.MakePersistent(ownVar); |
22098 | ········pm.Save(); |
22099 | ········pm.MakePersistent(otherVar); |
22100 | ········pm.Save(); |
22101 | ········ownVar.AssignRelation(otherVar); |
22102 | ········pm.Save(); |
22103 | ········pm.UnloadCache(); |
22104 | ····} |
22105 | ····void QueryOwn() |
22106 | ····{ |
22107 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblAutoLeft>(pm); |
22108 | ········ownVar = q.ExecuteSingle(); |
22109 | ····} |
22110 | ····void QueryOther() |
22111 | ····{ |
22112 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblAutoRightBase>(pm); |
22113 | ········otherVar = q.ExecuteSingle(); |
22114 | ····} |
22115 | } |
22116 | |
22117 | |
22118 | [TestFixture] |
22119 | public class TestAgrBi11OthpabsTblAuto : NDOTest |
22120 | { |
22121 | ····AgrBi11OthpabsTblAutoLeft ownVar; |
22122 | ····AgrBi11OthpabsTblAutoRightBase otherVar; |
22123 | ····PersistenceManager pm; |
22124 | ····[SetUp] |
22125 | ····public void Setup() |
22126 | ····{ |
22127 | ········pm = PmFactory.NewPersistenceManager(); |
22128 | ········ownVar = new AgrBi11OthpabsTblAutoLeft(); |
22129 | ········otherVar = new AgrBi11OthpabsTblAutoRightDerived(); |
22130 | ····} |
22131 | ····[TearDown] |
22132 | ····public void TearDown() |
22133 | ····{ |
22134 | ········try |
22135 | ········{ |
22136 | ············pm.UnloadCache(); |
22137 | ············var l = pm.Objects<AgrBi11OthpabsTblAutoLeft>().ResultTable; |
22138 | ············pm.Delete(l); |
22139 | ············pm.Save(); |
22140 | ············pm.UnloadCache(); |
22141 | ············var m = pm.Objects<AgrBi11OthpabsTblAutoRightBase>().ResultTable; |
22142 | ············pm.Delete(m); |
22143 | ············pm.Save(); |
22144 | ············pm.UnloadCache(); |
22145 | ············decimal count; |
22146 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22147 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22148 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22150 | ········} |
22151 | ········catch (Exception) |
22152 | ········{ |
22153 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22154 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22155 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22156 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22157 | ········} |
22158 | ····} |
22159 | ····[Test] |
22160 | ····public void TestSaveReload() |
22161 | ····{ |
22162 | ········CreateObjects(); |
22163 | ········QueryOwn(); |
22164 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22165 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22166 | ····} |
22167 | ····[Test] |
22168 | ····public void TestSaveReloadNull() |
22169 | ····{ |
22170 | ········CreateObjects(); |
22171 | ········QueryOwn(); |
22172 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22173 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22174 | ········ownVar.RelField = null; |
22175 | ········pm.Save(); |
22176 | ········pm.UnloadCache(); |
22177 | ········QueryOwn(); |
22178 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22179 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22180 | ····} |
22181 | ····[Test] |
22182 | ····public void TestChangeKeyHolderLeft() |
22183 | ····{ |
22184 | ········CreateObjects(); |
22185 | ········QueryOwn(); |
22186 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22187 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22188 | ········int x = ownVar.RelField.Dummy; |
22189 | ········ownVar.Dummy = 4711; |
22190 | ········pm.Save(); |
22191 | ········pm.UnloadCache(); |
22192 | ········QueryOwn(); |
22193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22194 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22195 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22196 | ····} |
22197 | ····[Test] |
22198 | ····public void TestChangeKeyHolderRight() |
22199 | ····{ |
22200 | ········CreateObjects(); |
22201 | ········QueryOther(); |
22202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22204 | ········int x = otherVar.RelField.Dummy; |
22205 | ········otherVar.Dummy = 4711; |
22206 | ········pm.Save(); |
22207 | ········pm.UnloadCache(); |
22208 | ········QueryOther(); |
22209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22212 | ····} |
22213 | ····[Test] |
22214 | ····public void TestChangeKeyHolderLeftNoTouch() |
22215 | ····{ |
22216 | ········CreateObjects(); |
22217 | ········QueryOwn(); |
22218 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22219 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22220 | ········ownVar.Dummy = 4711; |
22221 | ········pm.Save(); |
22222 | ········pm.UnloadCache(); |
22223 | ········QueryOwn(); |
22224 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22225 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22226 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22227 | ····} |
22228 | ····[Test] |
22229 | ····public void TestChangeKeyHolderRightNoTouch() |
22230 | ····{ |
22231 | ········CreateObjects(); |
22232 | ········QueryOther(); |
22233 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22234 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22235 | ········otherVar.Dummy = 4711; |
22236 | ········pm.Save(); |
22237 | ········pm.UnloadCache(); |
22238 | ········QueryOther(); |
22239 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22240 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22241 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22242 | ····} |
22243 | ····[Test] |
22244 | ····public void TestRelationHash() |
22245 | ····{ |
22246 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoLeft)); |
22247 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22248 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoRightBase)); |
22249 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22250 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22251 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22252 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblAutoRightDerived)); |
22253 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22254 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22255 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22256 | ····} |
22257 | ····void CreateObjects() |
22258 | ····{ |
22259 | ········pm.MakePersistent(ownVar); |
22260 | ········pm.MakePersistent(otherVar); |
22261 | ········ownVar.AssignRelation(otherVar); |
22262 | ········pm.Save(); |
22263 | ········pm.UnloadCache(); |
22264 | ····} |
22265 | ····void QueryOwn() |
22266 | ····{ |
22267 | ········var q = new NDOQuery<AgrBi11OthpabsTblAutoLeft>(pm); |
22268 | ········ownVar = q.ExecuteSingle(); |
22269 | ····} |
22270 | ····void QueryOther() |
22271 | ····{ |
22272 | ········var q = new NDOQuery<AgrBi11OthpabsTblAutoRightBase>(pm); |
22273 | ········otherVar = q.ExecuteSingle(); |
22274 | ····} |
22275 | } |
22276 | |
22277 | |
22278 | [TestFixture] |
22279 | public class TestAgrDirnOthpabsTblAuto : NDOTest |
22280 | { |
22281 | ····AgrDirnOthpabsTblAutoLeft ownVar; |
22282 | ····AgrDirnOthpabsTblAutoRightBase otherVar; |
22283 | ····PersistenceManager pm; |
22284 | ····[SetUp] |
22285 | ····public void Setup() |
22286 | ····{ |
22287 | ········pm = PmFactory.NewPersistenceManager(); |
22288 | ········ownVar = new AgrDirnOthpabsTblAutoLeft(); |
22289 | ········otherVar = new AgrDirnOthpabsTblAutoRightDerived(); |
22290 | ····} |
22291 | ····[TearDown] |
22292 | ····public void TearDown() |
22293 | ····{ |
22294 | ········try |
22295 | ········{ |
22296 | ············pm.UnloadCache(); |
22297 | ············var l = pm.Objects<AgrDirnOthpabsTblAutoLeft>().ResultTable; |
22298 | ············pm.Delete(l); |
22299 | ············pm.Save(); |
22300 | ············pm.UnloadCache(); |
22301 | ············var m = pm.Objects<AgrDirnOthpabsTblAutoRightBase>().ResultTable; |
22302 | ············pm.Delete(m); |
22303 | ············pm.Save(); |
22304 | ············pm.UnloadCache(); |
22305 | ············decimal count; |
22306 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22307 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22308 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22309 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22310 | ········} |
22311 | ········catch (Exception) |
22312 | ········{ |
22313 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22314 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22315 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22316 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22317 | ········} |
22318 | ····} |
22319 | ····[Test] |
22320 | ····public void TestSaveReload() |
22321 | ····{ |
22322 | ········CreateObjects(); |
22323 | ········QueryOwn(); |
22324 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22325 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22326 | ····} |
22327 | ····[Test] |
22328 | ····public void TestSaveReloadNull() |
22329 | ····{ |
22330 | ········CreateObjects(); |
22331 | ········QueryOwn(); |
22332 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22333 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22334 | ········ownVar.RelField = new List<AgrDirnOthpabsTblAutoRightBase>(); |
22335 | ········pm.Save(); |
22336 | ········pm.UnloadCache(); |
22337 | ········QueryOwn(); |
22338 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22339 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22340 | ····} |
22341 | ····[Test] |
22342 | ····public void TestSaveReloadRemove() |
22343 | ····{ |
22344 | ········CreateObjects(); |
22345 | ········QueryOwn(); |
22346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22347 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22348 | ········ownVar.RemoveRelatedObject(); |
22349 | ········pm.Save(); |
22350 | ········pm.UnloadCache(); |
22351 | ········QueryOwn(); |
22352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22353 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22354 | ····} |
22355 | ····void CreateObjects() |
22356 | ····{ |
22357 | ········pm.MakePersistent(ownVar); |
22358 | ········pm.MakePersistent(otherVar); |
22359 | ········ownVar.AssignRelation(otherVar); |
22360 | ········pm.Save(); |
22361 | ········pm.UnloadCache(); |
22362 | ····} |
22363 | ····void QueryOwn() |
22364 | ····{ |
22365 | ········var q = new NDOQuery<AgrDirnOthpabsTblAutoLeft>(pm); |
22366 | ········ownVar = q.ExecuteSingle(); |
22367 | ····} |
22368 | ····void QueryOther() |
22369 | ····{ |
22370 | ········var q = new NDOQuery<AgrDirnOthpabsTblAutoRightBase>(pm); |
22371 | ········otherVar = q.ExecuteSingle(); |
22372 | ····} |
22373 | } |
22374 | |
22375 | |
22376 | [TestFixture] |
22377 | public class TestAgrBin1OthpabsTblAuto : NDOTest |
22378 | { |
22379 | ····AgrBin1OthpabsTblAutoLeft ownVar; |
22380 | ····AgrBin1OthpabsTblAutoRightBase otherVar; |
22381 | ····PersistenceManager pm; |
22382 | ····[SetUp] |
22383 | ····public void Setup() |
22384 | ····{ |
22385 | ········pm = PmFactory.NewPersistenceManager(); |
22386 | ········ownVar = new AgrBin1OthpabsTblAutoLeft(); |
22387 | ········otherVar = new AgrBin1OthpabsTblAutoRightDerived(); |
22388 | ····} |
22389 | ····[TearDown] |
22390 | ····public void TearDown() |
22391 | ····{ |
22392 | ········try |
22393 | ········{ |
22394 | ············pm.UnloadCache(); |
22395 | ············var l = pm.Objects<AgrBin1OthpabsTblAutoLeft>().ResultTable; |
22396 | ············pm.Delete(l); |
22397 | ············pm.Save(); |
22398 | ············pm.UnloadCache(); |
22399 | ············var m = pm.Objects<AgrBin1OthpabsTblAutoRightBase>().ResultTable; |
22400 | ············pm.Delete(m); |
22401 | ············pm.Save(); |
22402 | ············pm.UnloadCache(); |
22403 | ············decimal count; |
22404 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22405 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22406 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22407 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22408 | ········} |
22409 | ········catch (Exception) |
22410 | ········{ |
22411 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22412 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22413 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22414 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22415 | ········} |
22416 | ····} |
22417 | ····[Test] |
22418 | ····public void TestSaveReload() |
22419 | ····{ |
22420 | ········CreateObjects(); |
22421 | ········QueryOwn(); |
22422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22424 | ····} |
22425 | ····[Test] |
22426 | ····public void TestSaveReloadNull() |
22427 | ····{ |
22428 | ········CreateObjects(); |
22429 | ········QueryOwn(); |
22430 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22431 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22432 | ········ownVar.RelField = new List<AgrBin1OthpabsTblAutoRightBase>(); |
22433 | ········pm.Save(); |
22434 | ········pm.UnloadCache(); |
22435 | ········QueryOwn(); |
22436 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22437 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22438 | ····} |
22439 | ····[Test] |
22440 | ····public void TestSaveReloadRemove() |
22441 | ····{ |
22442 | ········CreateObjects(); |
22443 | ········QueryOwn(); |
22444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22445 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22446 | ········ownVar.RemoveRelatedObject(); |
22447 | ········pm.Save(); |
22448 | ········pm.UnloadCache(); |
22449 | ········QueryOwn(); |
22450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22451 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22452 | ····} |
22453 | ····[Test] |
22454 | ····public void TestChangeKeyHolderRight() |
22455 | ····{ |
22456 | ········CreateObjects(); |
22457 | ········QueryOther(); |
22458 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22459 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22460 | ········int x = otherVar.RelField.Dummy; |
22461 | ········otherVar.Dummy = 4711; |
22462 | ········pm.Save(); |
22463 | ········pm.UnloadCache(); |
22464 | ········QueryOther(); |
22465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22468 | ····} |
22469 | ····[Test] |
22470 | ····public void TestChangeKeyHolderRightNoTouch() |
22471 | ····{ |
22472 | ········CreateObjects(); |
22473 | ········QueryOther(); |
22474 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22475 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22476 | ········otherVar.Dummy = 4711; |
22477 | ········pm.Save(); |
22478 | ········pm.UnloadCache(); |
22479 | ········QueryOther(); |
22480 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
22481 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22482 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
22483 | ····} |
22484 | ····[Test] |
22485 | ····public void TestRelationHash() |
22486 | ····{ |
22487 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoLeft)); |
22488 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22489 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoRightBase)); |
22490 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22491 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22492 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22493 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblAutoRightDerived)); |
22494 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22495 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22496 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22497 | ····} |
22498 | ····void CreateObjects() |
22499 | ····{ |
22500 | ········pm.MakePersistent(ownVar); |
22501 | ········pm.MakePersistent(otherVar); |
22502 | ········ownVar.AssignRelation(otherVar); |
22503 | ········pm.Save(); |
22504 | ········pm.UnloadCache(); |
22505 | ····} |
22506 | ····void QueryOwn() |
22507 | ····{ |
22508 | ········var q = new NDOQuery<AgrBin1OthpabsTblAutoLeft>(pm); |
22509 | ········ownVar = q.ExecuteSingle(); |
22510 | ····} |
22511 | ····void QueryOther() |
22512 | ····{ |
22513 | ········var q = new NDOQuery<AgrBin1OthpabsTblAutoRightBase>(pm); |
22514 | ········otherVar = q.ExecuteSingle(); |
22515 | ····} |
22516 | } |
22517 | |
22518 | |
22519 | [TestFixture] |
22520 | public class TestAgrBi1nOthpabsNoTblAuto : NDOTest |
22521 | { |
22522 | ····AgrBi1nOthpabsNoTblAutoLeft ownVar; |
22523 | ····AgrBi1nOthpabsNoTblAutoRightBase otherVar; |
22524 | ····PersistenceManager pm; |
22525 | ····[SetUp] |
22526 | ····public void Setup() |
22527 | ····{ |
22528 | ········pm = PmFactory.NewPersistenceManager(); |
22529 | ········ownVar = new AgrBi1nOthpabsNoTblAutoLeft(); |
22530 | ········otherVar = new AgrBi1nOthpabsNoTblAutoRightDerived(); |
22531 | ····} |
22532 | ····[TearDown] |
22533 | ····public void TearDown() |
22534 | ····{ |
22535 | ········try |
22536 | ········{ |
22537 | ············pm.UnloadCache(); |
22538 | ············var l = pm.Objects<AgrBi1nOthpabsNoTblAutoLeft>().ResultTable; |
22539 | ············pm.Delete(l); |
22540 | ············pm.Save(); |
22541 | ············pm.UnloadCache(); |
22542 | ············var m = pm.Objects<AgrBi1nOthpabsNoTblAutoRightBase>().ResultTable; |
22543 | ············pm.Delete(m); |
22544 | ············pm.Save(); |
22545 | ············pm.UnloadCache(); |
22546 | ············decimal count; |
22547 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22548 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22549 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22550 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22551 | ········} |
22552 | ········catch (Exception) |
22553 | ········{ |
22554 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22555 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22557 | ········} |
22558 | ····} |
22559 | ····[Test] |
22560 | ····public void TestSaveReload() |
22561 | ····{ |
22562 | ········CreateObjects(); |
22563 | ········QueryOwn(); |
22564 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22566 | ····} |
22567 | ····[Test] |
22568 | ····public void TestSaveReloadNull() |
22569 | ····{ |
22570 | ········CreateObjects(); |
22571 | ········QueryOwn(); |
22572 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22573 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22574 | ········ownVar.RelField = null; |
22575 | ········pm.Save(); |
22576 | ········pm.UnloadCache(); |
22577 | ········QueryOwn(); |
22578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22579 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22580 | ····} |
22581 | ····[Test] |
22582 | ····public void TestChangeKeyHolderLeft() |
22583 | ····{ |
22584 | ········CreateObjects(); |
22585 | ········QueryOwn(); |
22586 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22587 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22588 | ········int x = ownVar.RelField.Dummy; |
22589 | ········ownVar.Dummy = 4711; |
22590 | ········pm.Save(); |
22591 | ········pm.UnloadCache(); |
22592 | ········QueryOwn(); |
22593 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22594 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22595 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22596 | ····} |
22597 | ····[Test] |
22598 | ····public void TestChangeKeyHolderLeftNoTouch() |
22599 | ····{ |
22600 | ········CreateObjects(); |
22601 | ········QueryOwn(); |
22602 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22603 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22604 | ········ownVar.Dummy = 4711; |
22605 | ········pm.Save(); |
22606 | ········pm.UnloadCache(); |
22607 | ········QueryOwn(); |
22608 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22609 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22610 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22611 | ····} |
22612 | ····[Test] |
22613 | ····public void TestUpdateOrder() |
22614 | ····{ |
22615 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
22616 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
22617 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpabsNoTblAutoLeft)})) |
22618 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrBi1nOthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
22619 | ········Debug.WriteLine("AgrBi1nOthpabsNoTblAutoLeft"); |
22620 | ····} |
22621 | ····[Test] |
22622 | ····public void TestRelationHash() |
22623 | ····{ |
22624 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoLeft)); |
22625 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22626 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoRightBase)); |
22627 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22628 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22629 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22630 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblAutoRightDerived)); |
22631 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22632 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22633 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22634 | ····} |
22635 | ····void CreateObjects() |
22636 | ····{ |
22637 | ········pm.MakePersistent(ownVar); |
22638 | ········pm.Save(); |
22639 | ········pm.MakePersistent(otherVar); |
22640 | ········pm.Save(); |
22641 | ········ownVar.AssignRelation(otherVar); |
22642 | ········pm.Save(); |
22643 | ········pm.UnloadCache(); |
22644 | ····} |
22645 | ····void QueryOwn() |
22646 | ····{ |
22647 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblAutoLeft>(pm); |
22648 | ········ownVar = q.ExecuteSingle(); |
22649 | ····} |
22650 | ····void QueryOther() |
22651 | ····{ |
22652 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblAutoRightBase>(pm); |
22653 | ········otherVar = q.ExecuteSingle(); |
22654 | ····} |
22655 | } |
22656 | |
22657 | |
22658 | [TestFixture] |
22659 | public class TestAgrBi1nOthpabsTblAuto : NDOTest |
22660 | { |
22661 | ····AgrBi1nOthpabsTblAutoLeft ownVar; |
22662 | ····AgrBi1nOthpabsTblAutoRightBase otherVar; |
22663 | ····PersistenceManager pm; |
22664 | ····[SetUp] |
22665 | ····public void Setup() |
22666 | ····{ |
22667 | ········pm = PmFactory.NewPersistenceManager(); |
22668 | ········ownVar = new AgrBi1nOthpabsTblAutoLeft(); |
22669 | ········otherVar = new AgrBi1nOthpabsTblAutoRightDerived(); |
22670 | ····} |
22671 | ····[TearDown] |
22672 | ····public void TearDown() |
22673 | ····{ |
22674 | ········try |
22675 | ········{ |
22676 | ············pm.UnloadCache(); |
22677 | ············var l = pm.Objects<AgrBi1nOthpabsTblAutoLeft>().ResultTable; |
22678 | ············pm.Delete(l); |
22679 | ············pm.Save(); |
22680 | ············pm.UnloadCache(); |
22681 | ············var m = pm.Objects<AgrBi1nOthpabsTblAutoRightBase>().ResultTable; |
22682 | ············pm.Delete(m); |
22683 | ············pm.Save(); |
22684 | ············pm.UnloadCache(); |
22685 | ············decimal count; |
22686 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22687 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22688 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22689 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22690 | ········} |
22691 | ········catch (Exception) |
22692 | ········{ |
22693 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22694 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22695 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22696 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22697 | ········} |
22698 | ····} |
22699 | ····[Test] |
22700 | ····public void TestSaveReload() |
22701 | ····{ |
22702 | ········CreateObjects(); |
22703 | ········QueryOwn(); |
22704 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22705 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22706 | ····} |
22707 | ····[Test] |
22708 | ····public void TestSaveReloadNull() |
22709 | ····{ |
22710 | ········CreateObjects(); |
22711 | ········QueryOwn(); |
22712 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22713 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22714 | ········ownVar.RelField = null; |
22715 | ········pm.Save(); |
22716 | ········pm.UnloadCache(); |
22717 | ········QueryOwn(); |
22718 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22719 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22720 | ····} |
22721 | ····[Test] |
22722 | ····public void TestChangeKeyHolderLeft() |
22723 | ····{ |
22724 | ········CreateObjects(); |
22725 | ········QueryOwn(); |
22726 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22727 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22728 | ········int x = ownVar.RelField.Dummy; |
22729 | ········ownVar.Dummy = 4711; |
22730 | ········pm.Save(); |
22731 | ········pm.UnloadCache(); |
22732 | ········QueryOwn(); |
22733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22734 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22735 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22736 | ····} |
22737 | ····[Test] |
22738 | ····public void TestChangeKeyHolderLeftNoTouch() |
22739 | ····{ |
22740 | ········CreateObjects(); |
22741 | ········QueryOwn(); |
22742 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22743 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22744 | ········ownVar.Dummy = 4711; |
22745 | ········pm.Save(); |
22746 | ········pm.UnloadCache(); |
22747 | ········QueryOwn(); |
22748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22749 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
22750 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22751 | ····} |
22752 | ····[Test] |
22753 | ····public void TestRelationHash() |
22754 | ····{ |
22755 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoLeft)); |
22756 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22757 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoRightBase)); |
22758 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22759 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22760 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22761 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblAutoRightDerived)); |
22762 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22763 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22764 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22765 | ····} |
22766 | ····void CreateObjects() |
22767 | ····{ |
22768 | ········pm.MakePersistent(ownVar); |
22769 | ········pm.MakePersistent(otherVar); |
22770 | ········ownVar.AssignRelation(otherVar); |
22771 | ········pm.Save(); |
22772 | ········pm.UnloadCache(); |
22773 | ····} |
22774 | ····void QueryOwn() |
22775 | ····{ |
22776 | ········var q = new NDOQuery<AgrBi1nOthpabsTblAutoLeft>(pm); |
22777 | ········ownVar = q.ExecuteSingle(); |
22778 | ····} |
22779 | ····void QueryOther() |
22780 | ····{ |
22781 | ········var q = new NDOQuery<AgrBi1nOthpabsTblAutoRightBase>(pm); |
22782 | ········otherVar = q.ExecuteSingle(); |
22783 | ····} |
22784 | } |
22785 | |
22786 | |
22787 | [TestFixture] |
22788 | public class TestAgrBinnOthpabsTblAuto : NDOTest |
22789 | { |
22790 | ····AgrBinnOthpabsTblAutoLeft ownVar; |
22791 | ····AgrBinnOthpabsTblAutoRightBase otherVar; |
22792 | ····PersistenceManager pm; |
22793 | ····[SetUp] |
22794 | ····public void Setup() |
22795 | ····{ |
22796 | ········pm = PmFactory.NewPersistenceManager(); |
22797 | ········ownVar = new AgrBinnOthpabsTblAutoLeft(); |
22798 | ········otherVar = new AgrBinnOthpabsTblAutoRightDerived(); |
22799 | ····} |
22800 | ····[TearDown] |
22801 | ····public void TearDown() |
22802 | ····{ |
22803 | ········try |
22804 | ········{ |
22805 | ············pm.UnloadCache(); |
22806 | ············var l = pm.Objects<AgrBinnOthpabsTblAutoLeft>().ResultTable; |
22807 | ············pm.Delete(l); |
22808 | ············pm.Save(); |
22809 | ············pm.UnloadCache(); |
22810 | ············var m = pm.Objects<AgrBinnOthpabsTblAutoRightBase>().ResultTable; |
22811 | ············pm.Delete(m); |
22812 | ············pm.Save(); |
22813 | ············pm.UnloadCache(); |
22814 | ············decimal count; |
22815 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22816 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22817 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22818 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22819 | ········} |
22820 | ········catch (Exception) |
22821 | ········{ |
22822 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22823 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22824 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22825 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
22826 | ········} |
22827 | ····} |
22828 | ····[Test] |
22829 | ····public void TestSaveReload() |
22830 | ····{ |
22831 | ········CreateObjects(); |
22832 | ········QueryOwn(); |
22833 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22834 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22835 | ····} |
22836 | ····[Test] |
22837 | ····public void TestSaveReloadNull() |
22838 | ····{ |
22839 | ········CreateObjects(); |
22840 | ········QueryOwn(); |
22841 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22842 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22843 | ········ownVar.RelField = new List<AgrBinnOthpabsTblAutoRightBase>(); |
22844 | ········pm.Save(); |
22845 | ········pm.UnloadCache(); |
22846 | ········QueryOwn(); |
22847 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22848 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22849 | ····} |
22850 | ····[Test] |
22851 | ····public void TestSaveReloadRemove() |
22852 | ····{ |
22853 | ········CreateObjects(); |
22854 | ········QueryOwn(); |
22855 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22856 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22857 | ········ownVar.RemoveRelatedObject(); |
22858 | ········pm.Save(); |
22859 | ········pm.UnloadCache(); |
22860 | ········QueryOwn(); |
22861 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22862 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
22863 | ····} |
22864 | ····[Test] |
22865 | ····public void TestRelationHash() |
22866 | ····{ |
22867 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoLeft)); |
22868 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
22869 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoRightBase)); |
22870 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
22871 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
22872 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
22873 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblAutoRightDerived)); |
22874 | ········Relation relderRight = clderRight.FindRelation("relField"); |
22875 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
22876 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
22877 | ····} |
22878 | ····void CreateObjects() |
22879 | ····{ |
22880 | ········pm.MakePersistent(ownVar); |
22881 | ········pm.MakePersistent(otherVar); |
22882 | ········ownVar.AssignRelation(otherVar); |
22883 | ········pm.Save(); |
22884 | ········pm.UnloadCache(); |
22885 | ····} |
22886 | ····void QueryOwn() |
22887 | ····{ |
22888 | ········var q = new NDOQuery<AgrBinnOthpabsTblAutoLeft>(pm); |
22889 | ········ownVar = q.ExecuteSingle(); |
22890 | ····} |
22891 | ····void QueryOther() |
22892 | ····{ |
22893 | ········var q = new NDOQuery<AgrBinnOthpabsTblAutoRightBase>(pm); |
22894 | ········otherVar = q.ExecuteSingle(); |
22895 | ····} |
22896 | } |
22897 | |
22898 | |
22899 | [TestFixture] |
22900 | public class TestCmpDir1OthpabsNoTblAuto : NDOTest |
22901 | { |
22902 | ····CmpDir1OthpabsNoTblAutoLeft ownVar; |
22903 | ····CmpDir1OthpabsNoTblAutoRightBase otherVar; |
22904 | ····PersistenceManager pm; |
22905 | ····[SetUp] |
22906 | ····public void Setup() |
22907 | ····{ |
22908 | ········pm = PmFactory.NewPersistenceManager(); |
22909 | ········ownVar = new CmpDir1OthpabsNoTblAutoLeft(); |
22910 | ········otherVar = new CmpDir1OthpabsNoTblAutoRightDerived(); |
22911 | ····} |
22912 | ····[TearDown] |
22913 | ····public void TearDown() |
22914 | ····{ |
22915 | ········try |
22916 | ········{ |
22917 | ············pm.UnloadCache(); |
22918 | ············var l = pm.Objects<CmpDir1OthpabsNoTblAutoLeft>().ResultTable; |
22919 | ············pm.Delete(l); |
22920 | ············pm.Save(); |
22921 | ············pm.UnloadCache(); |
22922 | ············decimal count; |
22923 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22924 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
22925 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
22926 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
22927 | ········} |
22928 | ········catch (Exception) |
22929 | ········{ |
22930 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
22931 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
22932 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
22933 | ········} |
22934 | ····} |
22935 | ····[Test] |
22936 | ····public void TestSaveReload() |
22937 | ····{ |
22938 | ········bool thrown = false; |
22939 | ········try |
22940 | ········{ |
22941 | ············CreateObjects(); |
22942 | ············QueryOwn(); |
22943 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22944 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22945 | ········} |
22946 | ········catch (NDOException) |
22947 | ········{ |
22948 | ············thrown = true; |
22949 | ········} |
22950 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
22951 | ····} |
22952 | ····[Test] |
22953 | ····public void TestSaveReloadNull() |
22954 | ····{ |
22955 | ········bool thrown = false; |
22956 | ········try |
22957 | ········{ |
22958 | ············CreateObjects(); |
22959 | ············QueryOwn(); |
22960 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22961 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
22962 | ············ownVar.RelField = null; |
22963 | ············pm.Save(); |
22964 | ············pm.UnloadCache(); |
22965 | ············QueryOwn(); |
22966 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
22967 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
22968 | ········} |
22969 | ········catch (NDOException) |
22970 | ········{ |
22971 | ············thrown = true; |
22972 | ········} |
22973 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
22974 | ····} |
22975 | ····void CreateObjects() |
22976 | ····{ |
22977 | ········pm.MakePersistent(ownVar); |
22978 | ········pm.Save(); |
22979 | ········ownVar.AssignRelation(otherVar); |
22980 | ········pm.Save(); |
22981 | ········pm.UnloadCache(); |
22982 | ····} |
22983 | ····void QueryOwn() |
22984 | ····{ |
22985 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblAutoLeft>(pm); |
22986 | ········ownVar = q.ExecuteSingle(); |
22987 | ····} |
22988 | ····void QueryOther() |
22989 | ····{ |
22990 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblAutoRightBase>(pm); |
22991 | ········otherVar = q.ExecuteSingle(); |
22992 | ····} |
22993 | } |
22994 | |
22995 | |
22996 | [TestFixture] |
22997 | public class TestCmpDir1OthpabsTblAuto : NDOTest |
22998 | { |
22999 | ····CmpDir1OthpabsTblAutoLeft ownVar; |
23000 | ····CmpDir1OthpabsTblAutoRightBase otherVar; |
23001 | ····PersistenceManager pm; |
23002 | ····[SetUp] |
23003 | ····public void Setup() |
23004 | ····{ |
23005 | ········pm = PmFactory.NewPersistenceManager(); |
23006 | ········ownVar = new CmpDir1OthpabsTblAutoLeft(); |
23007 | ········otherVar = new CmpDir1OthpabsTblAutoRightDerived(); |
23008 | ····} |
23009 | ····[TearDown] |
23010 | ····public void TearDown() |
23011 | ····{ |
23012 | ········try |
23013 | ········{ |
23014 | ············pm.UnloadCache(); |
23015 | ············var l = pm.Objects<CmpDir1OthpabsTblAutoLeft>().ResultTable; |
23016 | ············pm.Delete(l); |
23017 | ············pm.Save(); |
23018 | ············pm.UnloadCache(); |
23019 | ············decimal count; |
23020 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23021 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23022 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23023 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23024 | ········} |
23025 | ········catch (Exception) |
23026 | ········{ |
23027 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23028 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23029 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23030 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23031 | ········} |
23032 | ····} |
23033 | ····[Test] |
23034 | ····public void TestSaveReload() |
23035 | ····{ |
23036 | ········CreateObjects(); |
23037 | ········QueryOwn(); |
23038 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23039 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23040 | ····} |
23041 | ····[Test] |
23042 | ····public void TestSaveReloadNull() |
23043 | ····{ |
23044 | ········CreateObjects(); |
23045 | ········QueryOwn(); |
23046 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23047 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23048 | ········ownVar.RelField = null; |
23049 | ········pm.Save(); |
23050 | ········pm.UnloadCache(); |
23051 | ········QueryOwn(); |
23052 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23053 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23054 | ····} |
23055 | ····[Test] |
23056 | ····public void TestChangeKeyHolderLeft() |
23057 | ····{ |
23058 | ········CreateObjects(); |
23059 | ········QueryOwn(); |
23060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23062 | ········int x = ownVar.RelField.Dummy; |
23063 | ········ownVar.Dummy = 4711; |
23064 | ········pm.Save(); |
23065 | ········pm.UnloadCache(); |
23066 | ········QueryOwn(); |
23067 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23068 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23070 | ····} |
23071 | ····[Test] |
23072 | ····public void TestChangeKeyHolderLeftNoTouch() |
23073 | ····{ |
23074 | ········CreateObjects(); |
23075 | ········QueryOwn(); |
23076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23077 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23078 | ········ownVar.Dummy = 4711; |
23079 | ········pm.Save(); |
23080 | ········pm.UnloadCache(); |
23081 | ········QueryOwn(); |
23082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23083 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23084 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23085 | ····} |
23086 | ····void CreateObjects() |
23087 | ····{ |
23088 | ········pm.MakePersistent(ownVar); |
23089 | ········ownVar.AssignRelation(otherVar); |
23090 | ········pm.Save(); |
23091 | ········pm.UnloadCache(); |
23092 | ····} |
23093 | ····void QueryOwn() |
23094 | ····{ |
23095 | ········var q = new NDOQuery<CmpDir1OthpabsTblAutoLeft>(pm); |
23096 | ········ownVar = q.ExecuteSingle(); |
23097 | ····} |
23098 | ····void QueryOther() |
23099 | ····{ |
23100 | ········var q = new NDOQuery<CmpDir1OthpabsTblAutoRightBase>(pm); |
23101 | ········otherVar = q.ExecuteSingle(); |
23102 | ····} |
23103 | } |
23104 | |
23105 | |
23106 | [TestFixture] |
23107 | public class TestCmpBi11OthpabsNoTblAuto : NDOTest |
23108 | { |
23109 | ····CmpBi11OthpabsNoTblAutoLeft ownVar; |
23110 | ····CmpBi11OthpabsNoTblAutoRightBase otherVar; |
23111 | ····PersistenceManager pm; |
23112 | ····[SetUp] |
23113 | ····public void Setup() |
23114 | ····{ |
23115 | ········pm = PmFactory.NewPersistenceManager(); |
23116 | ········ownVar = new CmpBi11OthpabsNoTblAutoLeft(); |
23117 | ········otherVar = new CmpBi11OthpabsNoTblAutoRightDerived(); |
23118 | ····} |
23119 | ····[TearDown] |
23120 | ····public void TearDown() |
23121 | ····{ |
23122 | ········try |
23123 | ········{ |
23124 | ············pm.UnloadCache(); |
23125 | ············var l = pm.Objects<CmpBi11OthpabsNoTblAutoLeft>().ResultTable; |
23126 | ············pm.Delete(l); |
23127 | ············pm.Save(); |
23128 | ············pm.UnloadCache(); |
23129 | ············decimal count; |
23130 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23131 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23132 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23133 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23134 | ········} |
23135 | ········catch (Exception) |
23136 | ········{ |
23137 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23138 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23139 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23140 | ········} |
23141 | ····} |
23142 | ····[Test] |
23143 | ····public void TestSaveReload() |
23144 | ····{ |
23145 | ········bool thrown = false; |
23146 | ········try |
23147 | ········{ |
23148 | ············CreateObjects(); |
23149 | ············QueryOwn(); |
23150 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23151 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23152 | ········} |
23153 | ········catch (NDOException) |
23154 | ········{ |
23155 | ············thrown = true; |
23156 | ········} |
23157 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23158 | ····} |
23159 | ····[Test] |
23160 | ····public void TestSaveReloadNull() |
23161 | ····{ |
23162 | ········bool thrown = false; |
23163 | ········try |
23164 | ········{ |
23165 | ············CreateObjects(); |
23166 | ············QueryOwn(); |
23167 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23168 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23169 | ············ownVar.RelField = null; |
23170 | ············pm.Save(); |
23171 | ············pm.UnloadCache(); |
23172 | ············QueryOwn(); |
23173 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23174 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23175 | ········} |
23176 | ········catch (NDOException) |
23177 | ········{ |
23178 | ············thrown = true; |
23179 | ········} |
23180 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23181 | ····} |
23182 | ····[Test] |
23183 | ····public void TestRelationHash() |
23184 | ····{ |
23185 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoLeft)); |
23186 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23187 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoRightBase)); |
23188 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23189 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23190 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23191 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblAutoRightDerived)); |
23192 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23193 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23194 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23195 | ····} |
23196 | ····void CreateObjects() |
23197 | ····{ |
23198 | ········pm.MakePersistent(ownVar); |
23199 | ········pm.Save(); |
23200 | ········ownVar.AssignRelation(otherVar); |
23201 | ········pm.Save(); |
23202 | ········pm.UnloadCache(); |
23203 | ····} |
23204 | ····void QueryOwn() |
23205 | ····{ |
23206 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblAutoLeft>(pm); |
23207 | ········ownVar = q.ExecuteSingle(); |
23208 | ····} |
23209 | ····void QueryOther() |
23210 | ····{ |
23211 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblAutoRightBase>(pm); |
23212 | ········otherVar = q.ExecuteSingle(); |
23213 | ····} |
23214 | } |
23215 | |
23216 | |
23217 | [TestFixture] |
23218 | public class TestCmpBi11OthpabsTblAuto : NDOTest |
23219 | { |
23220 | ····CmpBi11OthpabsTblAutoLeft ownVar; |
23221 | ····CmpBi11OthpabsTblAutoRightBase otherVar; |
23222 | ····PersistenceManager pm; |
23223 | ····[SetUp] |
23224 | ····public void Setup() |
23225 | ····{ |
23226 | ········pm = PmFactory.NewPersistenceManager(); |
23227 | ········ownVar = new CmpBi11OthpabsTblAutoLeft(); |
23228 | ········otherVar = new CmpBi11OthpabsTblAutoRightDerived(); |
23229 | ····} |
23230 | ····[TearDown] |
23231 | ····public void TearDown() |
23232 | ····{ |
23233 | ········try |
23234 | ········{ |
23235 | ············pm.UnloadCache(); |
23236 | ············var l = pm.Objects<CmpBi11OthpabsTblAutoLeft>().ResultTable; |
23237 | ············pm.Delete(l); |
23238 | ············pm.Save(); |
23239 | ············pm.UnloadCache(); |
23240 | ············decimal count; |
23241 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23242 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23243 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23245 | ········} |
23246 | ········catch (Exception) |
23247 | ········{ |
23248 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23249 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23250 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23251 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23252 | ········} |
23253 | ····} |
23254 | ····[Test] |
23255 | ····public void TestSaveReload() |
23256 | ····{ |
23257 | ········CreateObjects(); |
23258 | ········QueryOwn(); |
23259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23260 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23261 | ····} |
23262 | ····[Test] |
23263 | ····public void TestSaveReloadNull() |
23264 | ····{ |
23265 | ········CreateObjects(); |
23266 | ········QueryOwn(); |
23267 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23268 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23269 | ········ownVar.RelField = null; |
23270 | ········pm.Save(); |
23271 | ········pm.UnloadCache(); |
23272 | ········QueryOwn(); |
23273 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23274 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23275 | ····} |
23276 | ····[Test] |
23277 | ····public void TestChangeKeyHolderLeft() |
23278 | ····{ |
23279 | ········CreateObjects(); |
23280 | ········QueryOwn(); |
23281 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23282 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23283 | ········int x = ownVar.RelField.Dummy; |
23284 | ········ownVar.Dummy = 4711; |
23285 | ········pm.Save(); |
23286 | ········pm.UnloadCache(); |
23287 | ········QueryOwn(); |
23288 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23289 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23290 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23291 | ····} |
23292 | ····[Test] |
23293 | ····public void TestChangeKeyHolderRight() |
23294 | ····{ |
23295 | ········CreateObjects(); |
23296 | ········QueryOther(); |
23297 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23298 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23299 | ········int x = otherVar.RelField.Dummy; |
23300 | ········otherVar.Dummy = 4711; |
23301 | ········pm.Save(); |
23302 | ········pm.UnloadCache(); |
23303 | ········QueryOther(); |
23304 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23305 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23306 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23307 | ····} |
23308 | ····[Test] |
23309 | ····public void TestChangeKeyHolderLeftNoTouch() |
23310 | ····{ |
23311 | ········CreateObjects(); |
23312 | ········QueryOwn(); |
23313 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23314 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23315 | ········ownVar.Dummy = 4711; |
23316 | ········pm.Save(); |
23317 | ········pm.UnloadCache(); |
23318 | ········QueryOwn(); |
23319 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23320 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23321 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23322 | ····} |
23323 | ····[Test] |
23324 | ····public void TestChangeKeyHolderRightNoTouch() |
23325 | ····{ |
23326 | ········CreateObjects(); |
23327 | ········QueryOther(); |
23328 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23329 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23330 | ········otherVar.Dummy = 4711; |
23331 | ········pm.Save(); |
23332 | ········pm.UnloadCache(); |
23333 | ········QueryOther(); |
23334 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23335 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23336 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23337 | ····} |
23338 | ····[Test] |
23339 | ····public void TestRelationHash() |
23340 | ····{ |
23341 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoLeft)); |
23342 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23343 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoRightBase)); |
23344 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23345 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23346 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23347 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblAutoRightDerived)); |
23348 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23349 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23350 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23351 | ····} |
23352 | ····void CreateObjects() |
23353 | ····{ |
23354 | ········pm.MakePersistent(ownVar); |
23355 | ········ownVar.AssignRelation(otherVar); |
23356 | ········pm.Save(); |
23357 | ········pm.UnloadCache(); |
23358 | ····} |
23359 | ····void QueryOwn() |
23360 | ····{ |
23361 | ········var q = new NDOQuery<CmpBi11OthpabsTblAutoLeft>(pm); |
23362 | ········ownVar = q.ExecuteSingle(); |
23363 | ····} |
23364 | ····void QueryOther() |
23365 | ····{ |
23366 | ········var q = new NDOQuery<CmpBi11OthpabsTblAutoRightBase>(pm); |
23367 | ········otherVar = q.ExecuteSingle(); |
23368 | ····} |
23369 | } |
23370 | |
23371 | |
23372 | [TestFixture] |
23373 | public class TestCmpDirnOthpabsTblAuto : NDOTest |
23374 | { |
23375 | ····CmpDirnOthpabsTblAutoLeft ownVar; |
23376 | ····CmpDirnOthpabsTblAutoRightBase otherVar; |
23377 | ····PersistenceManager pm; |
23378 | ····[SetUp] |
23379 | ····public void Setup() |
23380 | ····{ |
23381 | ········pm = PmFactory.NewPersistenceManager(); |
23382 | ········ownVar = new CmpDirnOthpabsTblAutoLeft(); |
23383 | ········otherVar = new CmpDirnOthpabsTblAutoRightDerived(); |
23384 | ····} |
23385 | ····[TearDown] |
23386 | ····public void TearDown() |
23387 | ····{ |
23388 | ········try |
23389 | ········{ |
23390 | ············pm.UnloadCache(); |
23391 | ············var l = pm.Objects<CmpDirnOthpabsTblAutoLeft>().ResultTable; |
23392 | ············pm.Delete(l); |
23393 | ············pm.Save(); |
23394 | ············pm.UnloadCache(); |
23395 | ············decimal count; |
23396 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23397 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23398 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23399 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23400 | ········} |
23401 | ········catch (Exception) |
23402 | ········{ |
23403 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23404 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23405 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23406 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23407 | ········} |
23408 | ····} |
23409 | ····[Test] |
23410 | ····public void TestSaveReload() |
23411 | ····{ |
23412 | ········CreateObjects(); |
23413 | ········QueryOwn(); |
23414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23415 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23416 | ····} |
23417 | ····[Test] |
23418 | ····public void TestSaveReloadNull() |
23419 | ····{ |
23420 | ········CreateObjects(); |
23421 | ········QueryOwn(); |
23422 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23423 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23424 | ········ownVar.RelField = new List<CmpDirnOthpabsTblAutoRightBase>(); |
23425 | ········pm.Save(); |
23426 | ········pm.UnloadCache(); |
23427 | ········QueryOwn(); |
23428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23429 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23430 | ····} |
23431 | ····[Test] |
23432 | ····public void TestSaveReloadRemove() |
23433 | ····{ |
23434 | ········CreateObjects(); |
23435 | ········QueryOwn(); |
23436 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23437 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23438 | ········ownVar.RemoveRelatedObject(); |
23439 | ········pm.Save(); |
23440 | ········pm.UnloadCache(); |
23441 | ········QueryOwn(); |
23442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23443 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23444 | ····} |
23445 | ····void CreateObjects() |
23446 | ····{ |
23447 | ········pm.MakePersistent(ownVar); |
23448 | ········ownVar.AssignRelation(otherVar); |
23449 | ········pm.Save(); |
23450 | ········pm.UnloadCache(); |
23451 | ····} |
23452 | ····void QueryOwn() |
23453 | ····{ |
23454 | ········var q = new NDOQuery<CmpDirnOthpabsTblAutoLeft>(pm); |
23455 | ········ownVar = q.ExecuteSingle(); |
23456 | ····} |
23457 | ····void QueryOther() |
23458 | ····{ |
23459 | ········var q = new NDOQuery<CmpDirnOthpabsTblAutoRightBase>(pm); |
23460 | ········otherVar = q.ExecuteSingle(); |
23461 | ····} |
23462 | } |
23463 | |
23464 | |
23465 | [TestFixture] |
23466 | public class TestCmpBin1OthpabsTblAuto : NDOTest |
23467 | { |
23468 | ····CmpBin1OthpabsTblAutoLeft ownVar; |
23469 | ····CmpBin1OthpabsTblAutoRightBase otherVar; |
23470 | ····PersistenceManager pm; |
23471 | ····[SetUp] |
23472 | ····public void Setup() |
23473 | ····{ |
23474 | ········pm = PmFactory.NewPersistenceManager(); |
23475 | ········ownVar = new CmpBin1OthpabsTblAutoLeft(); |
23476 | ········otherVar = new CmpBin1OthpabsTblAutoRightDerived(); |
23477 | ····} |
23478 | ····[TearDown] |
23479 | ····public void TearDown() |
23480 | ····{ |
23481 | ········try |
23482 | ········{ |
23483 | ············pm.UnloadCache(); |
23484 | ············var l = pm.Objects<CmpBin1OthpabsTblAutoLeft>().ResultTable; |
23485 | ············pm.Delete(l); |
23486 | ············pm.Save(); |
23487 | ············pm.UnloadCache(); |
23488 | ············decimal count; |
23489 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23490 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23491 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23492 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23493 | ········} |
23494 | ········catch (Exception) |
23495 | ········{ |
23496 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23497 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23498 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23499 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23500 | ········} |
23501 | ····} |
23502 | ····[Test] |
23503 | ····public void TestSaveReload() |
23504 | ····{ |
23505 | ········CreateObjects(); |
23506 | ········QueryOwn(); |
23507 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23508 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23509 | ····} |
23510 | ····[Test] |
23511 | ····public void TestSaveReloadNull() |
23512 | ····{ |
23513 | ········CreateObjects(); |
23514 | ········QueryOwn(); |
23515 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23516 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23517 | ········ownVar.RelField = new List<CmpBin1OthpabsTblAutoRightBase>(); |
23518 | ········pm.Save(); |
23519 | ········pm.UnloadCache(); |
23520 | ········QueryOwn(); |
23521 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23522 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23523 | ····} |
23524 | ····[Test] |
23525 | ····public void TestSaveReloadRemove() |
23526 | ····{ |
23527 | ········CreateObjects(); |
23528 | ········QueryOwn(); |
23529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23530 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23531 | ········ownVar.RemoveRelatedObject(); |
23532 | ········pm.Save(); |
23533 | ········pm.UnloadCache(); |
23534 | ········QueryOwn(); |
23535 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23536 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23537 | ····} |
23538 | ····[Test] |
23539 | ····public void TestChangeKeyHolderRight() |
23540 | ····{ |
23541 | ········CreateObjects(); |
23542 | ········QueryOther(); |
23543 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23544 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23545 | ········int x = otherVar.RelField.Dummy; |
23546 | ········otherVar.Dummy = 4711; |
23547 | ········pm.Save(); |
23548 | ········pm.UnloadCache(); |
23549 | ········QueryOther(); |
23550 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23551 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23552 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23553 | ····} |
23554 | ····[Test] |
23555 | ····public void TestChangeKeyHolderRightNoTouch() |
23556 | ····{ |
23557 | ········CreateObjects(); |
23558 | ········QueryOther(); |
23559 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23560 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23561 | ········otherVar.Dummy = 4711; |
23562 | ········pm.Save(); |
23563 | ········pm.UnloadCache(); |
23564 | ········QueryOther(); |
23565 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
23566 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23567 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
23568 | ····} |
23569 | ····[Test] |
23570 | ····public void TestRelationHash() |
23571 | ····{ |
23572 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoLeft)); |
23573 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23574 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoRightBase)); |
23575 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23576 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23577 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23578 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblAutoRightDerived)); |
23579 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23580 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23581 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23582 | ····} |
23583 | ····void CreateObjects() |
23584 | ····{ |
23585 | ········pm.MakePersistent(ownVar); |
23586 | ········ownVar.AssignRelation(otherVar); |
23587 | ········pm.Save(); |
23588 | ········pm.UnloadCache(); |
23589 | ····} |
23590 | ····void QueryOwn() |
23591 | ····{ |
23592 | ········var q = new NDOQuery<CmpBin1OthpabsTblAutoLeft>(pm); |
23593 | ········ownVar = q.ExecuteSingle(); |
23594 | ····} |
23595 | ····void QueryOther() |
23596 | ····{ |
23597 | ········var q = new NDOQuery<CmpBin1OthpabsTblAutoRightBase>(pm); |
23598 | ········otherVar = q.ExecuteSingle(); |
23599 | ····} |
23600 | } |
23601 | |
23602 | |
23603 | [TestFixture] |
23604 | public class TestCmpBi1nOthpabsNoTblAuto : NDOTest |
23605 | { |
23606 | ····CmpBi1nOthpabsNoTblAutoLeft ownVar; |
23607 | ····CmpBi1nOthpabsNoTblAutoRightBase otherVar; |
23608 | ····PersistenceManager pm; |
23609 | ····[SetUp] |
23610 | ····public void Setup() |
23611 | ····{ |
23612 | ········pm = PmFactory.NewPersistenceManager(); |
23613 | ········ownVar = new CmpBi1nOthpabsNoTblAutoLeft(); |
23614 | ········otherVar = new CmpBi1nOthpabsNoTblAutoRightDerived(); |
23615 | ····} |
23616 | ····[TearDown] |
23617 | ····public void TearDown() |
23618 | ····{ |
23619 | ········try |
23620 | ········{ |
23621 | ············pm.UnloadCache(); |
23622 | ············var l = pm.Objects<CmpBi1nOthpabsNoTblAutoLeft>().ResultTable; |
23623 | ············pm.Delete(l); |
23624 | ············pm.Save(); |
23625 | ············pm.UnloadCache(); |
23626 | ············decimal count; |
23627 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23628 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23629 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23630 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23631 | ········} |
23632 | ········catch (Exception) |
23633 | ········{ |
23634 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23635 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23636 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23637 | ········} |
23638 | ····} |
23639 | ····[Test] |
23640 | ····public void TestSaveReload() |
23641 | ····{ |
23642 | ········bool thrown = false; |
23643 | ········try |
23644 | ········{ |
23645 | ············CreateObjects(); |
23646 | ············QueryOwn(); |
23647 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23648 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23649 | ········} |
23650 | ········catch (NDOException) |
23651 | ········{ |
23652 | ············thrown = true; |
23653 | ········} |
23654 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23655 | ····} |
23656 | ····[Test] |
23657 | ····public void TestSaveReloadNull() |
23658 | ····{ |
23659 | ········bool thrown = false; |
23660 | ········try |
23661 | ········{ |
23662 | ············CreateObjects(); |
23663 | ············QueryOwn(); |
23664 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23665 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23666 | ············ownVar.RelField = null; |
23667 | ············pm.Save(); |
23668 | ············pm.UnloadCache(); |
23669 | ············QueryOwn(); |
23670 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23671 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23672 | ········} |
23673 | ········catch (NDOException) |
23674 | ········{ |
23675 | ············thrown = true; |
23676 | ········} |
23677 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
23678 | ····} |
23679 | ····[Test] |
23680 | ····public void TestRelationHash() |
23681 | ····{ |
23682 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoLeft)); |
23683 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23684 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoRightBase)); |
23685 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23686 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23687 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23688 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblAutoRightDerived)); |
23689 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23690 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23691 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23692 | ····} |
23693 | ····void CreateObjects() |
23694 | ····{ |
23695 | ········pm.MakePersistent(ownVar); |
23696 | ········pm.Save(); |
23697 | ········ownVar.AssignRelation(otherVar); |
23698 | ········pm.Save(); |
23699 | ········pm.UnloadCache(); |
23700 | ····} |
23701 | ····void QueryOwn() |
23702 | ····{ |
23703 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblAutoLeft>(pm); |
23704 | ········ownVar = q.ExecuteSingle(); |
23705 | ····} |
23706 | ····void QueryOther() |
23707 | ····{ |
23708 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblAutoRightBase>(pm); |
23709 | ········otherVar = q.ExecuteSingle(); |
23710 | ····} |
23711 | } |
23712 | |
23713 | |
23714 | [TestFixture] |
23715 | public class TestCmpBi1nOthpabsTblAuto : NDOTest |
23716 | { |
23717 | ····CmpBi1nOthpabsTblAutoLeft ownVar; |
23718 | ····CmpBi1nOthpabsTblAutoRightBase otherVar; |
23719 | ····PersistenceManager pm; |
23720 | ····[SetUp] |
23721 | ····public void Setup() |
23722 | ····{ |
23723 | ········pm = PmFactory.NewPersistenceManager(); |
23724 | ········ownVar = new CmpBi1nOthpabsTblAutoLeft(); |
23725 | ········otherVar = new CmpBi1nOthpabsTblAutoRightDerived(); |
23726 | ····} |
23727 | ····[TearDown] |
23728 | ····public void TearDown() |
23729 | ····{ |
23730 | ········try |
23731 | ········{ |
23732 | ············pm.UnloadCache(); |
23733 | ············var l = pm.Objects<CmpBi1nOthpabsTblAutoLeft>().ResultTable; |
23734 | ············pm.Delete(l); |
23735 | ············pm.Save(); |
23736 | ············pm.UnloadCache(); |
23737 | ············decimal count; |
23738 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23739 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23740 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23741 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23742 | ········} |
23743 | ········catch (Exception) |
23744 | ········{ |
23745 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23746 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23747 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23748 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23749 | ········} |
23750 | ····} |
23751 | ····[Test] |
23752 | ····public void TestSaveReload() |
23753 | ····{ |
23754 | ········CreateObjects(); |
23755 | ········QueryOwn(); |
23756 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23757 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23758 | ····} |
23759 | ····[Test] |
23760 | ····public void TestSaveReloadNull() |
23761 | ····{ |
23762 | ········CreateObjects(); |
23763 | ········QueryOwn(); |
23764 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23765 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23766 | ········ownVar.RelField = null; |
23767 | ········pm.Save(); |
23768 | ········pm.UnloadCache(); |
23769 | ········QueryOwn(); |
23770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23771 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
23772 | ····} |
23773 | ····[Test] |
23774 | ····public void TestChangeKeyHolderLeft() |
23775 | ····{ |
23776 | ········CreateObjects(); |
23777 | ········QueryOwn(); |
23778 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23779 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23780 | ········int x = ownVar.RelField.Dummy; |
23781 | ········ownVar.Dummy = 4711; |
23782 | ········pm.Save(); |
23783 | ········pm.UnloadCache(); |
23784 | ········QueryOwn(); |
23785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23786 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23787 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23788 | ····} |
23789 | ····[Test] |
23790 | ····public void TestChangeKeyHolderLeftNoTouch() |
23791 | ····{ |
23792 | ········CreateObjects(); |
23793 | ········QueryOwn(); |
23794 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23795 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23796 | ········ownVar.Dummy = 4711; |
23797 | ········pm.Save(); |
23798 | ········pm.UnloadCache(); |
23799 | ········QueryOwn(); |
23800 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23801 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
23802 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23803 | ····} |
23804 | ····[Test] |
23805 | ····public void TestRelationHash() |
23806 | ····{ |
23807 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoLeft)); |
23808 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23809 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoRightBase)); |
23810 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23811 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23812 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23813 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblAutoRightDerived)); |
23814 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23815 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23816 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23817 | ····} |
23818 | ····void CreateObjects() |
23819 | ····{ |
23820 | ········pm.MakePersistent(ownVar); |
23821 | ········ownVar.AssignRelation(otherVar); |
23822 | ········pm.Save(); |
23823 | ········pm.UnloadCache(); |
23824 | ····} |
23825 | ····void QueryOwn() |
23826 | ····{ |
23827 | ········var q = new NDOQuery<CmpBi1nOthpabsTblAutoLeft>(pm); |
23828 | ········ownVar = q.ExecuteSingle(); |
23829 | ····} |
23830 | ····void QueryOther() |
23831 | ····{ |
23832 | ········var q = new NDOQuery<CmpBi1nOthpabsTblAutoRightBase>(pm); |
23833 | ········otherVar = q.ExecuteSingle(); |
23834 | ····} |
23835 | } |
23836 | |
23837 | |
23838 | [TestFixture] |
23839 | public class TestCmpBinnOthpabsTblAuto : NDOTest |
23840 | { |
23841 | ····CmpBinnOthpabsTblAutoLeft ownVar; |
23842 | ····CmpBinnOthpabsTblAutoRightBase otherVar; |
23843 | ····PersistenceManager pm; |
23844 | ····[SetUp] |
23845 | ····public void Setup() |
23846 | ····{ |
23847 | ········pm = PmFactory.NewPersistenceManager(); |
23848 | ········ownVar = new CmpBinnOthpabsTblAutoLeft(); |
23849 | ········otherVar = new CmpBinnOthpabsTblAutoRightDerived(); |
23850 | ····} |
23851 | ····[TearDown] |
23852 | ····public void TearDown() |
23853 | ····{ |
23854 | ········try |
23855 | ········{ |
23856 | ············pm.UnloadCache(); |
23857 | ············var l = pm.Objects<CmpBinnOthpabsTblAutoLeft>().ResultTable; |
23858 | ············pm.Delete(l); |
23859 | ············pm.Save(); |
23860 | ············pm.UnloadCache(); |
23861 | ············decimal count; |
23862 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblAutoLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23863 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23864 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23865 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23866 | ········} |
23867 | ········catch (Exception) |
23868 | ········{ |
23869 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23870 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23871 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23872 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
23873 | ········} |
23874 | ····} |
23875 | ····[Test] |
23876 | ····public void TestSaveReload() |
23877 | ····{ |
23878 | ········CreateObjects(); |
23879 | ········QueryOwn(); |
23880 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23881 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23882 | ····} |
23883 | ····[Test] |
23884 | ····public void TestSaveReloadNull() |
23885 | ····{ |
23886 | ········CreateObjects(); |
23887 | ········QueryOwn(); |
23888 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23889 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23890 | ········ownVar.RelField = new List<CmpBinnOthpabsTblAutoRightBase>(); |
23891 | ········pm.Save(); |
23892 | ········pm.UnloadCache(); |
23893 | ········QueryOwn(); |
23894 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23895 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23896 | ····} |
23897 | ····[Test] |
23898 | ····public void TestSaveReloadRemove() |
23899 | ····{ |
23900 | ········CreateObjects(); |
23901 | ········QueryOwn(); |
23902 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23903 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23904 | ········ownVar.RemoveRelatedObject(); |
23905 | ········pm.Save(); |
23906 | ········pm.UnloadCache(); |
23907 | ········QueryOwn(); |
23908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23909 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
23910 | ····} |
23911 | ····[Test] |
23912 | ····public void TestRelationHash() |
23913 | ····{ |
23914 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoLeft)); |
23915 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
23916 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoRightBase)); |
23917 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
23918 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
23919 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
23920 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblAutoRightDerived)); |
23921 | ········Relation relderRight = clderRight.FindRelation("relField"); |
23922 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
23923 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
23924 | ····} |
23925 | ····void CreateObjects() |
23926 | ····{ |
23927 | ········pm.MakePersistent(ownVar); |
23928 | ········ownVar.AssignRelation(otherVar); |
23929 | ········pm.Save(); |
23930 | ········pm.UnloadCache(); |
23931 | ····} |
23932 | ····void QueryOwn() |
23933 | ····{ |
23934 | ········var q = new NDOQuery<CmpBinnOthpabsTblAutoLeft>(pm); |
23935 | ········ownVar = q.ExecuteSingle(); |
23936 | ····} |
23937 | ····void QueryOther() |
23938 | ····{ |
23939 | ········var q = new NDOQuery<CmpBinnOthpabsTblAutoRightBase>(pm); |
23940 | ········otherVar = q.ExecuteSingle(); |
23941 | ····} |
23942 | } |
23943 | |
23944 | |
23945 | [TestFixture] |
23946 | public class TestAgrDir1OwnpabsOthpabsNoTblAuto : NDOTest |
23947 | { |
23948 | ····AgrDir1OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
23949 | ····AgrDir1OwnpabsOthpabsNoTblAutoRightBase otherVar; |
23950 | ····PersistenceManager pm; |
23951 | ····[SetUp] |
23952 | ····public void Setup() |
23953 | ····{ |
23954 | ········pm = PmFactory.NewPersistenceManager(); |
23955 | ········ownVar = new AgrDir1OwnpabsOthpabsNoTblAutoLeftDerived(); |
23956 | ········otherVar = new AgrDir1OwnpabsOthpabsNoTblAutoRightDerived(); |
23957 | ····} |
23958 | ····[TearDown] |
23959 | ····public void TearDown() |
23960 | ····{ |
23961 | ········try |
23962 | ········{ |
23963 | ············pm.UnloadCache(); |
23964 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
23965 | ············pm.Delete(l); |
23966 | ············pm.Save(); |
23967 | ············pm.UnloadCache(); |
23968 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>().ResultTable; |
23969 | ············pm.Delete(m); |
23970 | ············pm.Save(); |
23971 | ············pm.UnloadCache(); |
23972 | ············decimal count; |
23973 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23974 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
23975 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
23976 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
23977 | ········} |
23978 | ········catch (Exception) |
23979 | ········{ |
23980 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
23981 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
23982 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
23983 | ········} |
23984 | ····} |
23985 | ····[Test] |
23986 | ····public void TestSaveReload() |
23987 | ····{ |
23988 | ········CreateObjects(); |
23989 | ········QueryOwn(); |
23990 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23991 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
23992 | ····} |
23993 | ····[Test] |
23994 | ····public void TestSaveReloadNull() |
23995 | ····{ |
23996 | ········CreateObjects(); |
23997 | ········QueryOwn(); |
23998 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
23999 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24000 | ········ownVar.RelField = null; |
24001 | ········pm.Save(); |
24002 | ········pm.UnloadCache(); |
24003 | ········QueryOwn(); |
24004 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24005 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24006 | ····} |
24007 | ····[Test] |
24008 | ····public void TestChangeKeyHolderLeft() |
24009 | ····{ |
24010 | ········CreateObjects(); |
24011 | ········QueryOwn(); |
24012 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24013 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24014 | ········int x = ownVar.RelField.Dummy; |
24015 | ········ownVar.Dummy = 4711; |
24016 | ········pm.Save(); |
24017 | ········pm.UnloadCache(); |
24018 | ········QueryOwn(); |
24019 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24020 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24021 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24022 | ····} |
24023 | ····[Test] |
24024 | ····public void TestChangeKeyHolderLeftNoTouch() |
24025 | ····{ |
24026 | ········CreateObjects(); |
24027 | ········QueryOwn(); |
24028 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24029 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24030 | ········ownVar.Dummy = 4711; |
24031 | ········pm.Save(); |
24032 | ········pm.UnloadCache(); |
24033 | ········QueryOwn(); |
24034 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24035 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24036 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24037 | ····} |
24038 | ····[Test] |
24039 | ····public void TestUpdateOrder() |
24040 | ····{ |
24041 | ········NDO.Mapping.NDOMapping mapping = pm.NDOMapping; |
24042 | ········MethodInfo mi = mapping.GetType().GetMethod("GetUpdateOrder"); |
24043 | ········Assert.That(((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsOthpabsNoTblAutoLeftDerived)})) |
24044 | ················> ((int)mi.Invoke(mapping, new object[]{typeof(AgrDir1OwnpabsOthpabsNoTblAutoRightDerived)})), "Wrong order #2"); |
24045 | ········Debug.WriteLine("AgrDir1OwnpabsOthpabsNoTblAutoLeftBase"); |
24046 | ····} |
24047 | ····void CreateObjects() |
24048 | ····{ |
24049 | ········pm.MakePersistent(ownVar); |
24050 | ········pm.Save(); |
24051 | ········pm.MakePersistent(otherVar); |
24052 | ········pm.Save(); |
24053 | ········ownVar.AssignRelation(otherVar); |
24054 | ········pm.Save(); |
24055 | ········pm.UnloadCache(); |
24056 | ····} |
24057 | ····void QueryOwn() |
24058 | ····{ |
24059 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
24060 | ········ownVar = q.ExecuteSingle(); |
24061 | ····} |
24062 | ····void QueryOther() |
24063 | ····{ |
24064 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblAutoRightBase>(pm); |
24065 | ········otherVar = q.ExecuteSingle(); |
24066 | ····} |
24067 | } |
24068 | |
24069 | |
24070 | [TestFixture] |
24071 | public class TestAgrDir1OwnpabsOthpabsTblAuto : NDOTest |
24072 | { |
24073 | ····AgrDir1OwnpabsOthpabsTblAutoLeftBase ownVar; |
24074 | ····AgrDir1OwnpabsOthpabsTblAutoRightBase otherVar; |
24075 | ····PersistenceManager pm; |
24076 | ····[SetUp] |
24077 | ····public void Setup() |
24078 | ····{ |
24079 | ········pm = PmFactory.NewPersistenceManager(); |
24080 | ········ownVar = new AgrDir1OwnpabsOthpabsTblAutoLeftDerived(); |
24081 | ········otherVar = new AgrDir1OwnpabsOthpabsTblAutoRightDerived(); |
24082 | ····} |
24083 | ····[TearDown] |
24084 | ····public void TearDown() |
24085 | ····{ |
24086 | ········try |
24087 | ········{ |
24088 | ············pm.UnloadCache(); |
24089 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24090 | ············pm.Delete(l); |
24091 | ············pm.Save(); |
24092 | ············pm.UnloadCache(); |
24093 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24094 | ············pm.Delete(m); |
24095 | ············pm.Save(); |
24096 | ············pm.UnloadCache(); |
24097 | ············decimal count; |
24098 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24099 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24100 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24101 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24102 | ········} |
24103 | ········catch (Exception) |
24104 | ········{ |
24105 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24106 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24107 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24108 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24109 | ········} |
24110 | ····} |
24111 | ····[Test] |
24112 | ····public void TestSaveReload() |
24113 | ····{ |
24114 | ········CreateObjects(); |
24115 | ········QueryOwn(); |
24116 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24117 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24118 | ····} |
24119 | ····[Test] |
24120 | ····public void TestSaveReloadNull() |
24121 | ····{ |
24122 | ········CreateObjects(); |
24123 | ········QueryOwn(); |
24124 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24125 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24126 | ········ownVar.RelField = null; |
24127 | ········pm.Save(); |
24128 | ········pm.UnloadCache(); |
24129 | ········QueryOwn(); |
24130 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24131 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24132 | ····} |
24133 | ····[Test] |
24134 | ····public void TestChangeKeyHolderLeft() |
24135 | ····{ |
24136 | ········CreateObjects(); |
24137 | ········QueryOwn(); |
24138 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24139 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24140 | ········int x = ownVar.RelField.Dummy; |
24141 | ········ownVar.Dummy = 4711; |
24142 | ········pm.Save(); |
24143 | ········pm.UnloadCache(); |
24144 | ········QueryOwn(); |
24145 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24146 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24148 | ····} |
24149 | ····[Test] |
24150 | ····public void TestChangeKeyHolderLeftNoTouch() |
24151 | ····{ |
24152 | ········CreateObjects(); |
24153 | ········QueryOwn(); |
24154 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24155 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24156 | ········ownVar.Dummy = 4711; |
24157 | ········pm.Save(); |
24158 | ········pm.UnloadCache(); |
24159 | ········QueryOwn(); |
24160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24161 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24162 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24163 | ····} |
24164 | ····void CreateObjects() |
24165 | ····{ |
24166 | ········pm.MakePersistent(ownVar); |
24167 | ········pm.MakePersistent(otherVar); |
24168 | ········ownVar.AssignRelation(otherVar); |
24169 | ········pm.Save(); |
24170 | ········pm.UnloadCache(); |
24171 | ····} |
24172 | ····void QueryOwn() |
24173 | ····{ |
24174 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoLeftBase>(pm); |
24175 | ········ownVar = q.ExecuteSingle(); |
24176 | ····} |
24177 | ····void QueryOther() |
24178 | ····{ |
24179 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblAutoRightBase>(pm); |
24180 | ········otherVar = q.ExecuteSingle(); |
24181 | ····} |
24182 | } |
24183 | |
24184 | |
24185 | [TestFixture] |
24186 | public class TestAgrBi11OwnpabsOthpabsNoTblAuto : NDOTest |
24187 | { |
24188 | ····AgrBi11OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
24189 | ····AgrBi11OwnpabsOthpabsNoTblAutoRightBase otherVar; |
24190 | ····PersistenceManager pm; |
24191 | ····[SetUp] |
24192 | ····public void Setup() |
24193 | ····{ |
24194 | ········pm = PmFactory.NewPersistenceManager(); |
24195 | ········ownVar = new AgrBi11OwnpabsOthpabsNoTblAutoLeftDerived(); |
24196 | ········otherVar = new AgrBi11OwnpabsOthpabsNoTblAutoRightDerived(); |
24197 | ····} |
24198 | ····[TearDown] |
24199 | ····public void TearDown() |
24200 | ····{ |
24201 | ········try |
24202 | ········{ |
24203 | ············pm.UnloadCache(); |
24204 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
24205 | ············pm.Delete(l); |
24206 | ············pm.Save(); |
24207 | ············pm.UnloadCache(); |
24208 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>().ResultTable; |
24209 | ············pm.Delete(m); |
24210 | ············pm.Save(); |
24211 | ············pm.UnloadCache(); |
24212 | ············decimal count; |
24213 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24214 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24215 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24216 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24217 | ········} |
24218 | ········catch (Exception) |
24219 | ········{ |
24220 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24221 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24222 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24223 | ········} |
24224 | ····} |
24225 | ····[Test] |
24226 | ····public void TestSaveReload() |
24227 | ····{ |
24228 | ········CreateObjects(); |
24229 | ········QueryOwn(); |
24230 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24231 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24232 | ····} |
24233 | ····[Test] |
24234 | ····public void TestSaveReloadNull() |
24235 | ····{ |
24236 | ········CreateObjects(); |
24237 | ········QueryOwn(); |
24238 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24239 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24240 | ········ownVar.RelField = null; |
24241 | ········pm.Save(); |
24242 | ········pm.UnloadCache(); |
24243 | ········QueryOwn(); |
24244 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24245 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24246 | ····} |
24247 | ····[Test] |
24248 | ····public void TestChangeKeyHolderLeft() |
24249 | ····{ |
24250 | ········CreateObjects(); |
24251 | ········QueryOwn(); |
24252 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24253 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24254 | ········int x = ownVar.RelField.Dummy; |
24255 | ········ownVar.Dummy = 4711; |
24256 | ········pm.Save(); |
24257 | ········pm.UnloadCache(); |
24258 | ········QueryOwn(); |
24259 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24260 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24262 | ····} |
24263 | ····[Test] |
24264 | ····public void TestChangeKeyHolderRight() |
24265 | ····{ |
24266 | ········CreateObjects(); |
24267 | ········QueryOther(); |
24268 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24269 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24270 | ········int x = otherVar.RelField.Dummy; |
24271 | ········otherVar.Dummy = 4711; |
24272 | ········pm.Save(); |
24273 | ········pm.UnloadCache(); |
24274 | ········QueryOther(); |
24275 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24276 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24277 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24278 | ····} |
24279 | ····[Test] |
24280 | ····public void TestChangeKeyHolderLeftNoTouch() |
24281 | ····{ |
24282 | ········CreateObjects(); |
24283 | ········QueryOwn(); |
24284 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24285 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24286 | ········ownVar.Dummy = 4711; |
24287 | ········pm.Save(); |
24288 | ········pm.UnloadCache(); |
24289 | ········QueryOwn(); |
24290 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24291 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24292 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24293 | ····} |
24294 | ····[Test] |
24295 | ····public void TestChangeKeyHolderRightNoTouch() |
24296 | ····{ |
24297 | ········CreateObjects(); |
24298 | ········QueryOther(); |
24299 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24300 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24301 | ········otherVar.Dummy = 4711; |
24302 | ········pm.Save(); |
24303 | ········pm.UnloadCache(); |
24304 | ········QueryOther(); |
24305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24306 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24307 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24308 | ····} |
24309 | ····[Test] |
24310 | ····public void TestRelationHash() |
24311 | ····{ |
24312 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoLeftBase)); |
24313 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24314 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoRightBase)); |
24315 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24316 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24317 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24318 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoLeftDerived)); |
24319 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24320 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24321 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24322 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblAutoRightDerived)); |
24323 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24324 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24325 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24326 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24327 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24328 | ····} |
24329 | ····void CreateObjects() |
24330 | ····{ |
24331 | ········pm.MakePersistent(ownVar); |
24332 | ········pm.Save(); |
24333 | ········pm.MakePersistent(otherVar); |
24334 | ········pm.Save(); |
24335 | ········pm.Save(); |
24336 | ········ownVar.AssignRelation(otherVar); |
24337 | ········pm.Save(); |
24338 | ········pm.UnloadCache(); |
24339 | ····} |
24340 | ····void QueryOwn() |
24341 | ····{ |
24342 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
24343 | ········ownVar = q.ExecuteSingle(); |
24344 | ····} |
24345 | ····void QueryOther() |
24346 | ····{ |
24347 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblAutoRightBase>(pm); |
24348 | ········otherVar = q.ExecuteSingle(); |
24349 | ····} |
24350 | } |
24351 | |
24352 | |
24353 | [TestFixture] |
24354 | public class TestAgrBi11OwnpabsOthpabsTblAuto : NDOTest |
24355 | { |
24356 | ····AgrBi11OwnpabsOthpabsTblAutoLeftBase ownVar; |
24357 | ····AgrBi11OwnpabsOthpabsTblAutoRightBase otherVar; |
24358 | ····PersistenceManager pm; |
24359 | ····[SetUp] |
24360 | ····public void Setup() |
24361 | ····{ |
24362 | ········pm = PmFactory.NewPersistenceManager(); |
24363 | ········ownVar = new AgrBi11OwnpabsOthpabsTblAutoLeftDerived(); |
24364 | ········otherVar = new AgrBi11OwnpabsOthpabsTblAutoRightDerived(); |
24365 | ····} |
24366 | ····[TearDown] |
24367 | ····public void TearDown() |
24368 | ····{ |
24369 | ········try |
24370 | ········{ |
24371 | ············pm.UnloadCache(); |
24372 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24373 | ············pm.Delete(l); |
24374 | ············pm.Save(); |
24375 | ············pm.UnloadCache(); |
24376 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24377 | ············pm.Delete(m); |
24378 | ············pm.Save(); |
24379 | ············pm.UnloadCache(); |
24380 | ············decimal count; |
24381 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24382 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24383 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24384 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24385 | ········} |
24386 | ········catch (Exception) |
24387 | ········{ |
24388 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24389 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24390 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24391 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24392 | ········} |
24393 | ····} |
24394 | ····[Test] |
24395 | ····public void TestSaveReload() |
24396 | ····{ |
24397 | ········CreateObjects(); |
24398 | ········QueryOwn(); |
24399 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24400 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24401 | ····} |
24402 | ····[Test] |
24403 | ····public void TestSaveReloadNull() |
24404 | ····{ |
24405 | ········CreateObjects(); |
24406 | ········QueryOwn(); |
24407 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24408 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24409 | ········ownVar.RelField = null; |
24410 | ········pm.Save(); |
24411 | ········pm.UnloadCache(); |
24412 | ········QueryOwn(); |
24413 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24414 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24415 | ····} |
24416 | ····[Test] |
24417 | ····public void TestChangeKeyHolderLeft() |
24418 | ····{ |
24419 | ········CreateObjects(); |
24420 | ········QueryOwn(); |
24421 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24422 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24423 | ········int x = ownVar.RelField.Dummy; |
24424 | ········ownVar.Dummy = 4711; |
24425 | ········pm.Save(); |
24426 | ········pm.UnloadCache(); |
24427 | ········QueryOwn(); |
24428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24429 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24430 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24431 | ····} |
24432 | ····[Test] |
24433 | ····public void TestChangeKeyHolderRight() |
24434 | ····{ |
24435 | ········CreateObjects(); |
24436 | ········QueryOther(); |
24437 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24438 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24439 | ········int x = otherVar.RelField.Dummy; |
24440 | ········otherVar.Dummy = 4711; |
24441 | ········pm.Save(); |
24442 | ········pm.UnloadCache(); |
24443 | ········QueryOther(); |
24444 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24445 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24446 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24447 | ····} |
24448 | ····[Test] |
24449 | ····public void TestChangeKeyHolderLeftNoTouch() |
24450 | ····{ |
24451 | ········CreateObjects(); |
24452 | ········QueryOwn(); |
24453 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24454 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24455 | ········ownVar.Dummy = 4711; |
24456 | ········pm.Save(); |
24457 | ········pm.UnloadCache(); |
24458 | ········QueryOwn(); |
24459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24460 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24461 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24462 | ····} |
24463 | ····[Test] |
24464 | ····public void TestChangeKeyHolderRightNoTouch() |
24465 | ····{ |
24466 | ········CreateObjects(); |
24467 | ········QueryOther(); |
24468 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24469 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24470 | ········otherVar.Dummy = 4711; |
24471 | ········pm.Save(); |
24472 | ········pm.UnloadCache(); |
24473 | ········QueryOther(); |
24474 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24475 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24476 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24477 | ····} |
24478 | ····[Test] |
24479 | ····public void TestRelationHash() |
24480 | ····{ |
24481 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoLeftBase)); |
24482 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24483 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoRightBase)); |
24484 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24485 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24486 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24487 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoLeftDerived)); |
24488 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24489 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24490 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24491 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblAutoRightDerived)); |
24492 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24493 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24494 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24495 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24496 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24497 | ····} |
24498 | ····void CreateObjects() |
24499 | ····{ |
24500 | ········pm.MakePersistent(ownVar); |
24501 | ········pm.MakePersistent(otherVar); |
24502 | ········pm.Save(); |
24503 | ········ownVar.AssignRelation(otherVar); |
24504 | ········pm.Save(); |
24505 | ········pm.UnloadCache(); |
24506 | ····} |
24507 | ····void QueryOwn() |
24508 | ····{ |
24509 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoLeftBase>(pm); |
24510 | ········ownVar = q.ExecuteSingle(); |
24511 | ····} |
24512 | ····void QueryOther() |
24513 | ····{ |
24514 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblAutoRightBase>(pm); |
24515 | ········otherVar = q.ExecuteSingle(); |
24516 | ····} |
24517 | } |
24518 | |
24519 | |
24520 | [TestFixture] |
24521 | public class TestAgrDirnOwnpabsOthpabsTblAuto : NDOTest |
24522 | { |
24523 | ····AgrDirnOwnpabsOthpabsTblAutoLeftBase ownVar; |
24524 | ····AgrDirnOwnpabsOthpabsTblAutoRightBase otherVar; |
24525 | ····PersistenceManager pm; |
24526 | ····[SetUp] |
24527 | ····public void Setup() |
24528 | ····{ |
24529 | ········pm = PmFactory.NewPersistenceManager(); |
24530 | ········ownVar = new AgrDirnOwnpabsOthpabsTblAutoLeftDerived(); |
24531 | ········otherVar = new AgrDirnOwnpabsOthpabsTblAutoRightDerived(); |
24532 | ····} |
24533 | ····[TearDown] |
24534 | ····public void TearDown() |
24535 | ····{ |
24536 | ········try |
24537 | ········{ |
24538 | ············pm.UnloadCache(); |
24539 | ············var l = pm.Objects<AgrDirnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24540 | ············pm.Delete(l); |
24541 | ············pm.Save(); |
24542 | ············pm.UnloadCache(); |
24543 | ············var m = pm.Objects<AgrDirnOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24544 | ············pm.Delete(m); |
24545 | ············pm.Save(); |
24546 | ············pm.UnloadCache(); |
24547 | ············decimal count; |
24548 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24550 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24552 | ········} |
24553 | ········catch (Exception) |
24554 | ········{ |
24555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24559 | ········} |
24560 | ····} |
24561 | ····[Test] |
24562 | ····public void TestSaveReload() |
24563 | ····{ |
24564 | ········CreateObjects(); |
24565 | ········QueryOwn(); |
24566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24568 | ····} |
24569 | ····[Test] |
24570 | ····public void TestSaveReloadNull() |
24571 | ····{ |
24572 | ········CreateObjects(); |
24573 | ········QueryOwn(); |
24574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24576 | ········ownVar.RelField = new List<AgrDirnOwnpabsOthpabsTblAutoRightBase>(); |
24577 | ········pm.Save(); |
24578 | ········pm.UnloadCache(); |
24579 | ········QueryOwn(); |
24580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24582 | ····} |
24583 | ····[Test] |
24584 | ····public void TestSaveReloadRemove() |
24585 | ····{ |
24586 | ········CreateObjects(); |
24587 | ········QueryOwn(); |
24588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24590 | ········ownVar.RemoveRelatedObject(); |
24591 | ········pm.Save(); |
24592 | ········pm.UnloadCache(); |
24593 | ········QueryOwn(); |
24594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24596 | ····} |
24597 | ····void CreateObjects() |
24598 | ····{ |
24599 | ········pm.MakePersistent(ownVar); |
24600 | ········pm.MakePersistent(otherVar); |
24601 | ········ownVar.AssignRelation(otherVar); |
24602 | ········pm.Save(); |
24603 | ········pm.UnloadCache(); |
24604 | ····} |
24605 | ····void QueryOwn() |
24606 | ····{ |
24607 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoLeftBase>(pm); |
24608 | ········ownVar = q.ExecuteSingle(); |
24609 | ····} |
24610 | ····void QueryOther() |
24611 | ····{ |
24612 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblAutoRightBase>(pm); |
24613 | ········otherVar = q.ExecuteSingle(); |
24614 | ····} |
24615 | } |
24616 | |
24617 | |
24618 | [TestFixture] |
24619 | public class TestAgrBin1OwnpabsOthpabsTblAuto : NDOTest |
24620 | { |
24621 | ····AgrBin1OwnpabsOthpabsTblAutoLeftBase ownVar; |
24622 | ····AgrBin1OwnpabsOthpabsTblAutoRightBase otherVar; |
24623 | ····PersistenceManager pm; |
24624 | ····[SetUp] |
24625 | ····public void Setup() |
24626 | ····{ |
24627 | ········pm = PmFactory.NewPersistenceManager(); |
24628 | ········ownVar = new AgrBin1OwnpabsOthpabsTblAutoLeftDerived(); |
24629 | ········otherVar = new AgrBin1OwnpabsOthpabsTblAutoRightDerived(); |
24630 | ····} |
24631 | ····[TearDown] |
24632 | ····public void TearDown() |
24633 | ····{ |
24634 | ········try |
24635 | ········{ |
24636 | ············pm.UnloadCache(); |
24637 | ············var l = pm.Objects<AgrBin1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24638 | ············pm.Delete(l); |
24639 | ············pm.Save(); |
24640 | ············pm.UnloadCache(); |
24641 | ············var m = pm.Objects<AgrBin1OwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24642 | ············pm.Delete(m); |
24643 | ············pm.Save(); |
24644 | ············pm.UnloadCache(); |
24645 | ············decimal count; |
24646 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24647 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24648 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24649 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24650 | ········} |
24651 | ········catch (Exception) |
24652 | ········{ |
24653 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24654 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24655 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24656 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24657 | ········} |
24658 | ····} |
24659 | ····[Test] |
24660 | ····public void TestSaveReload() |
24661 | ····{ |
24662 | ········CreateObjects(); |
24663 | ········QueryOwn(); |
24664 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24665 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24666 | ····} |
24667 | ····[Test] |
24668 | ····public void TestSaveReloadNull() |
24669 | ····{ |
24670 | ········CreateObjects(); |
24671 | ········QueryOwn(); |
24672 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24673 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24674 | ········ownVar.RelField = new List<AgrBin1OwnpabsOthpabsTblAutoRightBase>(); |
24675 | ········pm.Save(); |
24676 | ········pm.UnloadCache(); |
24677 | ········QueryOwn(); |
24678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24679 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24680 | ····} |
24681 | ····[Test] |
24682 | ····public void TestSaveReloadRemove() |
24683 | ····{ |
24684 | ········CreateObjects(); |
24685 | ········QueryOwn(); |
24686 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24687 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24688 | ········ownVar.RemoveRelatedObject(); |
24689 | ········pm.Save(); |
24690 | ········pm.UnloadCache(); |
24691 | ········QueryOwn(); |
24692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24693 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24694 | ····} |
24695 | ····[Test] |
24696 | ····public void TestChangeKeyHolderRight() |
24697 | ····{ |
24698 | ········CreateObjects(); |
24699 | ········QueryOther(); |
24700 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24701 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24702 | ········int x = otherVar.RelField.Dummy; |
24703 | ········otherVar.Dummy = 4711; |
24704 | ········pm.Save(); |
24705 | ········pm.UnloadCache(); |
24706 | ········QueryOther(); |
24707 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24708 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24709 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24710 | ····} |
24711 | ····[Test] |
24712 | ····public void TestChangeKeyHolderRightNoTouch() |
24713 | ····{ |
24714 | ········CreateObjects(); |
24715 | ········QueryOther(); |
24716 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24717 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24718 | ········otherVar.Dummy = 4711; |
24719 | ········pm.Save(); |
24720 | ········pm.UnloadCache(); |
24721 | ········QueryOther(); |
24722 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
24723 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24724 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
24725 | ····} |
24726 | ····[Test] |
24727 | ····public void TestRelationHash() |
24728 | ····{ |
24729 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoLeftBase)); |
24730 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24731 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoRightBase)); |
24732 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24733 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24734 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24735 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoLeftDerived)); |
24736 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24737 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24738 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24739 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblAutoRightDerived)); |
24740 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24741 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24742 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24743 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24744 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24745 | ····} |
24746 | ····void CreateObjects() |
24747 | ····{ |
24748 | ········pm.MakePersistent(ownVar); |
24749 | ········pm.MakePersistent(otherVar); |
24750 | ········pm.Save(); |
24751 | ········ownVar.AssignRelation(otherVar); |
24752 | ········pm.Save(); |
24753 | ········pm.UnloadCache(); |
24754 | ····} |
24755 | ····void QueryOwn() |
24756 | ····{ |
24757 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoLeftBase>(pm); |
24758 | ········ownVar = q.ExecuteSingle(); |
24759 | ····} |
24760 | ····void QueryOther() |
24761 | ····{ |
24762 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblAutoRightBase>(pm); |
24763 | ········otherVar = q.ExecuteSingle(); |
24764 | ····} |
24765 | } |
24766 | |
24767 | |
24768 | [TestFixture] |
24769 | public class TestAgrBi1nOwnpabsOthpabsTblAuto : NDOTest |
24770 | { |
24771 | ····AgrBi1nOwnpabsOthpabsTblAutoLeftBase ownVar; |
24772 | ····AgrBi1nOwnpabsOthpabsTblAutoRightBase otherVar; |
24773 | ····PersistenceManager pm; |
24774 | ····[SetUp] |
24775 | ····public void Setup() |
24776 | ····{ |
24777 | ········pm = PmFactory.NewPersistenceManager(); |
24778 | ········ownVar = new AgrBi1nOwnpabsOthpabsTblAutoLeftDerived(); |
24779 | ········otherVar = new AgrBi1nOwnpabsOthpabsTblAutoRightDerived(); |
24780 | ····} |
24781 | ····[TearDown] |
24782 | ····public void TearDown() |
24783 | ····{ |
24784 | ········try |
24785 | ········{ |
24786 | ············pm.UnloadCache(); |
24787 | ············var l = pm.Objects<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24788 | ············pm.Delete(l); |
24789 | ············pm.Save(); |
24790 | ············pm.UnloadCache(); |
24791 | ············var m = pm.Objects<AgrBi1nOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24792 | ············pm.Delete(m); |
24793 | ············pm.Save(); |
24794 | ············pm.UnloadCache(); |
24795 | ············decimal count; |
24796 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24797 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24798 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24799 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24800 | ········} |
24801 | ········catch (Exception) |
24802 | ········{ |
24803 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24804 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24805 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24806 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24807 | ········} |
24808 | ····} |
24809 | ····[Test] |
24810 | ····public void TestSaveReload() |
24811 | ····{ |
24812 | ········CreateObjects(); |
24813 | ········QueryOwn(); |
24814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24815 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24816 | ····} |
24817 | ····[Test] |
24818 | ····public void TestSaveReloadNull() |
24819 | ····{ |
24820 | ········CreateObjects(); |
24821 | ········QueryOwn(); |
24822 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24823 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24824 | ········ownVar.RelField = null; |
24825 | ········pm.Save(); |
24826 | ········pm.UnloadCache(); |
24827 | ········QueryOwn(); |
24828 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24829 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
24830 | ····} |
24831 | ····[Test] |
24832 | ····public void TestChangeKeyHolderLeft() |
24833 | ····{ |
24834 | ········CreateObjects(); |
24835 | ········QueryOwn(); |
24836 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24837 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24838 | ········int x = ownVar.RelField.Dummy; |
24839 | ········ownVar.Dummy = 4711; |
24840 | ········pm.Save(); |
24841 | ········pm.UnloadCache(); |
24842 | ········QueryOwn(); |
24843 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24844 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24845 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24846 | ····} |
24847 | ····[Test] |
24848 | ····public void TestChangeKeyHolderLeftNoTouch() |
24849 | ····{ |
24850 | ········CreateObjects(); |
24851 | ········QueryOwn(); |
24852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24853 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24854 | ········ownVar.Dummy = 4711; |
24855 | ········pm.Save(); |
24856 | ········pm.UnloadCache(); |
24857 | ········QueryOwn(); |
24858 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24859 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
24860 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
24861 | ····} |
24862 | ····[Test] |
24863 | ····public void TestRelationHash() |
24864 | ····{ |
24865 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoLeftBase)); |
24866 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24867 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoRightBase)); |
24868 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24869 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24870 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24871 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoLeftDerived)); |
24872 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24873 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24874 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24875 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblAutoRightDerived)); |
24876 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24877 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24878 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24879 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24880 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24881 | ····} |
24882 | ····void CreateObjects() |
24883 | ····{ |
24884 | ········pm.MakePersistent(ownVar); |
24885 | ········pm.MakePersistent(otherVar); |
24886 | ········ownVar.AssignRelation(otherVar); |
24887 | ········pm.Save(); |
24888 | ········pm.UnloadCache(); |
24889 | ····} |
24890 | ····void QueryOwn() |
24891 | ····{ |
24892 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoLeftBase>(pm); |
24893 | ········ownVar = q.ExecuteSingle(); |
24894 | ····} |
24895 | ····void QueryOther() |
24896 | ····{ |
24897 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblAutoRightBase>(pm); |
24898 | ········otherVar = q.ExecuteSingle(); |
24899 | ····} |
24900 | } |
24901 | |
24902 | |
24903 | [TestFixture] |
24904 | public class TestAgrBinnOwnpabsOthpabsTblAuto : NDOTest |
24905 | { |
24906 | ····AgrBinnOwnpabsOthpabsTblAutoLeftBase ownVar; |
24907 | ····AgrBinnOwnpabsOthpabsTblAutoRightBase otherVar; |
24908 | ····PersistenceManager pm; |
24909 | ····[SetUp] |
24910 | ····public void Setup() |
24911 | ····{ |
24912 | ········pm = PmFactory.NewPersistenceManager(); |
24913 | ········ownVar = new AgrBinnOwnpabsOthpabsTblAutoLeftDerived(); |
24914 | ········otherVar = new AgrBinnOwnpabsOthpabsTblAutoRightDerived(); |
24915 | ····} |
24916 | ····[TearDown] |
24917 | ····public void TearDown() |
24918 | ····{ |
24919 | ········try |
24920 | ········{ |
24921 | ············pm.UnloadCache(); |
24922 | ············var l = pm.Objects<AgrBinnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
24923 | ············pm.Delete(l); |
24924 | ············pm.Save(); |
24925 | ············pm.UnloadCache(); |
24926 | ············var m = pm.Objects<AgrBinnOwnpabsOthpabsTblAutoRightBase>().ResultTable; |
24927 | ············pm.Delete(m); |
24928 | ············pm.Save(); |
24929 | ············pm.UnloadCache(); |
24930 | ············decimal count; |
24931 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24932 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
24933 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
24934 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
24935 | ········} |
24936 | ········catch (Exception) |
24937 | ········{ |
24938 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
24939 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
24940 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
24941 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
24942 | ········} |
24943 | ····} |
24944 | ····[Test] |
24945 | ····public void TestSaveReload() |
24946 | ····{ |
24947 | ········CreateObjects(); |
24948 | ········QueryOwn(); |
24949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24950 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24951 | ····} |
24952 | ····[Test] |
24953 | ····public void TestSaveReloadNull() |
24954 | ····{ |
24955 | ········CreateObjects(); |
24956 | ········QueryOwn(); |
24957 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24958 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24959 | ········ownVar.RelField = new List<AgrBinnOwnpabsOthpabsTblAutoRightBase>(); |
24960 | ········pm.Save(); |
24961 | ········pm.UnloadCache(); |
24962 | ········QueryOwn(); |
24963 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24964 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24965 | ····} |
24966 | ····[Test] |
24967 | ····public void TestSaveReloadRemove() |
24968 | ····{ |
24969 | ········CreateObjects(); |
24970 | ········QueryOwn(); |
24971 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24972 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24973 | ········ownVar.RemoveRelatedObject(); |
24974 | ········pm.Save(); |
24975 | ········pm.UnloadCache(); |
24976 | ········QueryOwn(); |
24977 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
24978 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
24979 | ····} |
24980 | ····[Test] |
24981 | ····public void TestRelationHash() |
24982 | ····{ |
24983 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoLeftBase)); |
24984 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
24985 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoRightBase)); |
24986 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
24987 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
24988 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
24989 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoLeftDerived)); |
24990 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
24991 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
24992 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
24993 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblAutoRightDerived)); |
24994 | ········Relation relderRight = clderRight.FindRelation("relField"); |
24995 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
24996 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
24997 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
24998 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
24999 | ····} |
25000 | ····void CreateObjects() |
25001 | ····{ |
25002 | ········pm.MakePersistent(ownVar); |
25003 | ········pm.MakePersistent(otherVar); |
25004 | ········ownVar.AssignRelation(otherVar); |
25005 | ········pm.Save(); |
25006 | ········pm.UnloadCache(); |
25007 | ····} |
25008 | ····void QueryOwn() |
25009 | ····{ |
25010 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25011 | ········ownVar = q.ExecuteSingle(); |
25012 | ····} |
25013 | ····void QueryOther() |
25014 | ····{ |
25015 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblAutoRightBase>(pm); |
25016 | ········otherVar = q.ExecuteSingle(); |
25017 | ····} |
25018 | } |
25019 | |
25020 | |
25021 | [TestFixture] |
25022 | public class TestCmpDir1OwnpabsOthpabsNoTblAuto : NDOTest |
25023 | { |
25024 | ····CmpDir1OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
25025 | ····CmpDir1OwnpabsOthpabsNoTblAutoRightBase otherVar; |
25026 | ····PersistenceManager pm; |
25027 | ····[SetUp] |
25028 | ····public void Setup() |
25029 | ····{ |
25030 | ········pm = PmFactory.NewPersistenceManager(); |
25031 | ········ownVar = new CmpDir1OwnpabsOthpabsNoTblAutoLeftDerived(); |
25032 | ········otherVar = new CmpDir1OwnpabsOthpabsNoTblAutoRightDerived(); |
25033 | ····} |
25034 | ····[TearDown] |
25035 | ····public void TearDown() |
25036 | ····{ |
25037 | ········try |
25038 | ········{ |
25039 | ············pm.UnloadCache(); |
25040 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
25041 | ············pm.Delete(l); |
25042 | ············pm.Save(); |
25043 | ············pm.UnloadCache(); |
25044 | ············decimal count; |
25045 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25046 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25047 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25048 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25049 | ········} |
25050 | ········catch (Exception) |
25051 | ········{ |
25052 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25053 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25054 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25055 | ········} |
25056 | ····} |
25057 | ····[Test] |
25058 | ····public void TestSaveReload() |
25059 | ····{ |
25060 | ········bool thrown = false; |
25061 | ········try |
25062 | ········{ |
25063 | ············CreateObjects(); |
25064 | ············QueryOwn(); |
25065 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25066 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25067 | ········} |
25068 | ········catch (NDOException) |
25069 | ········{ |
25070 | ············thrown = true; |
25071 | ········} |
25072 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25073 | ····} |
25074 | ····[Test] |
25075 | ····public void TestSaveReloadNull() |
25076 | ····{ |
25077 | ········bool thrown = false; |
25078 | ········try |
25079 | ········{ |
25080 | ············CreateObjects(); |
25081 | ············QueryOwn(); |
25082 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25083 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25084 | ············ownVar.RelField = null; |
25085 | ············pm.Save(); |
25086 | ············pm.UnloadCache(); |
25087 | ············QueryOwn(); |
25088 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25089 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25090 | ········} |
25091 | ········catch (NDOException) |
25092 | ········{ |
25093 | ············thrown = true; |
25094 | ········} |
25095 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25096 | ····} |
25097 | ····void CreateObjects() |
25098 | ····{ |
25099 | ········pm.MakePersistent(ownVar); |
25100 | ········pm.Save(); |
25101 | ········ownVar.AssignRelation(otherVar); |
25102 | ········pm.Save(); |
25103 | ········pm.UnloadCache(); |
25104 | ····} |
25105 | ····void QueryOwn() |
25106 | ····{ |
25107 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
25108 | ········ownVar = q.ExecuteSingle(); |
25109 | ····} |
25110 | ····void QueryOther() |
25111 | ····{ |
25112 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblAutoRightBase>(pm); |
25113 | ········otherVar = q.ExecuteSingle(); |
25114 | ····} |
25115 | } |
25116 | |
25117 | |
25118 | [TestFixture] |
25119 | public class TestCmpDir1OwnpabsOthpabsTblAuto : NDOTest |
25120 | { |
25121 | ····CmpDir1OwnpabsOthpabsTblAutoLeftBase ownVar; |
25122 | ····CmpDir1OwnpabsOthpabsTblAutoRightBase otherVar; |
25123 | ····PersistenceManager pm; |
25124 | ····[SetUp] |
25125 | ····public void Setup() |
25126 | ····{ |
25127 | ········pm = PmFactory.NewPersistenceManager(); |
25128 | ········ownVar = new CmpDir1OwnpabsOthpabsTblAutoLeftDerived(); |
25129 | ········otherVar = new CmpDir1OwnpabsOthpabsTblAutoRightDerived(); |
25130 | ····} |
25131 | ····[TearDown] |
25132 | ····public void TearDown() |
25133 | ····{ |
25134 | ········try |
25135 | ········{ |
25136 | ············pm.UnloadCache(); |
25137 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25138 | ············pm.Delete(l); |
25139 | ············pm.Save(); |
25140 | ············pm.UnloadCache(); |
25141 | ············decimal count; |
25142 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25143 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25144 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25145 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25146 | ········} |
25147 | ········catch (Exception) |
25148 | ········{ |
25149 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25150 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25151 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25152 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25153 | ········} |
25154 | ····} |
25155 | ····[Test] |
25156 | ····public void TestSaveReload() |
25157 | ····{ |
25158 | ········CreateObjects(); |
25159 | ········QueryOwn(); |
25160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25161 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25162 | ····} |
25163 | ····[Test] |
25164 | ····public void TestSaveReloadNull() |
25165 | ····{ |
25166 | ········CreateObjects(); |
25167 | ········QueryOwn(); |
25168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25169 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25170 | ········ownVar.RelField = null; |
25171 | ········pm.Save(); |
25172 | ········pm.UnloadCache(); |
25173 | ········QueryOwn(); |
25174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25175 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25176 | ····} |
25177 | ····[Test] |
25178 | ····public void TestChangeKeyHolderLeft() |
25179 | ····{ |
25180 | ········CreateObjects(); |
25181 | ········QueryOwn(); |
25182 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25183 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25184 | ········int x = ownVar.RelField.Dummy; |
25185 | ········ownVar.Dummy = 4711; |
25186 | ········pm.Save(); |
25187 | ········pm.UnloadCache(); |
25188 | ········QueryOwn(); |
25189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25190 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25191 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25192 | ····} |
25193 | ····[Test] |
25194 | ····public void TestChangeKeyHolderLeftNoTouch() |
25195 | ····{ |
25196 | ········CreateObjects(); |
25197 | ········QueryOwn(); |
25198 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25199 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25200 | ········ownVar.Dummy = 4711; |
25201 | ········pm.Save(); |
25202 | ········pm.UnloadCache(); |
25203 | ········QueryOwn(); |
25204 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25205 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25206 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25207 | ····} |
25208 | ····void CreateObjects() |
25209 | ····{ |
25210 | ········pm.MakePersistent(ownVar); |
25211 | ········ownVar.AssignRelation(otherVar); |
25212 | ········pm.Save(); |
25213 | ········pm.UnloadCache(); |
25214 | ····} |
25215 | ····void QueryOwn() |
25216 | ····{ |
25217 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoLeftBase>(pm); |
25218 | ········ownVar = q.ExecuteSingle(); |
25219 | ····} |
25220 | ····void QueryOther() |
25221 | ····{ |
25222 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblAutoRightBase>(pm); |
25223 | ········otherVar = q.ExecuteSingle(); |
25224 | ····} |
25225 | } |
25226 | |
25227 | |
25228 | [TestFixture] |
25229 | public class TestCmpBi11OwnpabsOthpabsNoTblAuto : NDOTest |
25230 | { |
25231 | ····CmpBi11OwnpabsOthpabsNoTblAutoLeftBase ownVar; |
25232 | ····CmpBi11OwnpabsOthpabsNoTblAutoRightBase otherVar; |
25233 | ····PersistenceManager pm; |
25234 | ····[SetUp] |
25235 | ····public void Setup() |
25236 | ····{ |
25237 | ········pm = PmFactory.NewPersistenceManager(); |
25238 | ········ownVar = new CmpBi11OwnpabsOthpabsNoTblAutoLeftDerived(); |
25239 | ········otherVar = new CmpBi11OwnpabsOthpabsNoTblAutoRightDerived(); |
25240 | ····} |
25241 | ····[TearDown] |
25242 | ····public void TearDown() |
25243 | ····{ |
25244 | ········try |
25245 | ········{ |
25246 | ············pm.UnloadCache(); |
25247 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>().ResultTable; |
25248 | ············pm.Delete(l); |
25249 | ············pm.Save(); |
25250 | ············pm.UnloadCache(); |
25251 | ············decimal count; |
25252 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25253 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25254 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25255 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25256 | ········} |
25257 | ········catch (Exception) |
25258 | ········{ |
25259 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25260 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25261 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25262 | ········} |
25263 | ····} |
25264 | ····[Test] |
25265 | ····public void TestSaveReload() |
25266 | ····{ |
25267 | ········bool thrown = false; |
25268 | ········try |
25269 | ········{ |
25270 | ············CreateObjects(); |
25271 | ············QueryOwn(); |
25272 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25273 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25274 | ········} |
25275 | ········catch (NDOException) |
25276 | ········{ |
25277 | ············thrown = true; |
25278 | ········} |
25279 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25280 | ····} |
25281 | ····[Test] |
25282 | ····public void TestSaveReloadNull() |
25283 | ····{ |
25284 | ········bool thrown = false; |
25285 | ········try |
25286 | ········{ |
25287 | ············CreateObjects(); |
25288 | ············QueryOwn(); |
25289 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25290 | ············Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25291 | ············ownVar.RelField = null; |
25292 | ············pm.Save(); |
25293 | ············pm.UnloadCache(); |
25294 | ············QueryOwn(); |
25295 | ············Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25296 | ············Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25297 | ········} |
25298 | ········catch (NDOException) |
25299 | ········{ |
25300 | ············thrown = true; |
25301 | ········} |
25302 | ········Assert.That(true, Is.EqualTo(thrown), "NDOException should have been thrown"); |
25303 | ····} |
25304 | ····[Test] |
25305 | ····public void TestRelationHash() |
25306 | ····{ |
25307 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoLeftBase)); |
25308 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25309 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoRightBase)); |
25310 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25311 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25312 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25313 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoLeftDerived)); |
25314 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25315 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25316 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25317 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblAutoRightDerived)); |
25318 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25319 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25320 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25321 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25322 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25323 | ····} |
25324 | ····void CreateObjects() |
25325 | ····{ |
25326 | ········pm.MakePersistent(ownVar); |
25327 | ········pm.Save(); |
25328 | ········ownVar.AssignRelation(otherVar); |
25329 | ········pm.Save(); |
25330 | ········pm.UnloadCache(); |
25331 | ····} |
25332 | ····void QueryOwn() |
25333 | ····{ |
25334 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoLeftBase>(pm); |
25335 | ········ownVar = q.ExecuteSingle(); |
25336 | ····} |
25337 | ····void QueryOther() |
25338 | ····{ |
25339 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblAutoRightBase>(pm); |
25340 | ········otherVar = q.ExecuteSingle(); |
25341 | ····} |
25342 | } |
25343 | |
25344 | |
25345 | [TestFixture] |
25346 | public class TestCmpBi11OwnpabsOthpabsTblAuto : NDOTest |
25347 | { |
25348 | ····CmpBi11OwnpabsOthpabsTblAutoLeftBase ownVar; |
25349 | ····CmpBi11OwnpabsOthpabsTblAutoRightBase otherVar; |
25350 | ····PersistenceManager pm; |
25351 | ····[SetUp] |
25352 | ····public void Setup() |
25353 | ····{ |
25354 | ········pm = PmFactory.NewPersistenceManager(); |
25355 | ········ownVar = new CmpBi11OwnpabsOthpabsTblAutoLeftDerived(); |
25356 | ········otherVar = new CmpBi11OwnpabsOthpabsTblAutoRightDerived(); |
25357 | ····} |
25358 | ····[TearDown] |
25359 | ····public void TearDown() |
25360 | ····{ |
25361 | ········try |
25362 | ········{ |
25363 | ············pm.UnloadCache(); |
25364 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25365 | ············pm.Delete(l); |
25366 | ············pm.Save(); |
25367 | ············pm.UnloadCache(); |
25368 | ············decimal count; |
25369 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25370 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25371 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25372 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25373 | ········} |
25374 | ········catch (Exception) |
25375 | ········{ |
25376 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25377 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25378 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25379 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25380 | ········} |
25381 | ····} |
25382 | ····[Test] |
25383 | ····public void TestSaveReload() |
25384 | ····{ |
25385 | ········CreateObjects(); |
25386 | ········QueryOwn(); |
25387 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25388 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25389 | ····} |
25390 | ····[Test] |
25391 | ····public void TestSaveReloadNull() |
25392 | ····{ |
25393 | ········CreateObjects(); |
25394 | ········QueryOwn(); |
25395 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25396 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25397 | ········ownVar.RelField = null; |
25398 | ········pm.Save(); |
25399 | ········pm.UnloadCache(); |
25400 | ········QueryOwn(); |
25401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25402 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25403 | ····} |
25404 | ····[Test] |
25405 | ····public void TestChangeKeyHolderLeft() |
25406 | ····{ |
25407 | ········CreateObjects(); |
25408 | ········QueryOwn(); |
25409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25410 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25411 | ········int x = ownVar.RelField.Dummy; |
25412 | ········ownVar.Dummy = 4711; |
25413 | ········pm.Save(); |
25414 | ········pm.UnloadCache(); |
25415 | ········QueryOwn(); |
25416 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25417 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25418 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25419 | ····} |
25420 | ····[Test] |
25421 | ····public void TestChangeKeyHolderRight() |
25422 | ····{ |
25423 | ········CreateObjects(); |
25424 | ········QueryOther(); |
25425 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25426 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25427 | ········int x = otherVar.RelField.Dummy; |
25428 | ········otherVar.Dummy = 4711; |
25429 | ········pm.Save(); |
25430 | ········pm.UnloadCache(); |
25431 | ········QueryOther(); |
25432 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25433 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25434 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25435 | ····} |
25436 | ····[Test] |
25437 | ····public void TestChangeKeyHolderLeftNoTouch() |
25438 | ····{ |
25439 | ········CreateObjects(); |
25440 | ········QueryOwn(); |
25441 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25442 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25443 | ········ownVar.Dummy = 4711; |
25444 | ········pm.Save(); |
25445 | ········pm.UnloadCache(); |
25446 | ········QueryOwn(); |
25447 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25448 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25449 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25450 | ····} |
25451 | ····[Test] |
25452 | ····public void TestChangeKeyHolderRightNoTouch() |
25453 | ····{ |
25454 | ········CreateObjects(); |
25455 | ········QueryOther(); |
25456 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25457 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25458 | ········otherVar.Dummy = 4711; |
25459 | ········pm.Save(); |
25460 | ········pm.UnloadCache(); |
25461 | ········QueryOther(); |
25462 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25463 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25464 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25465 | ····} |
25466 | ····[Test] |
25467 | ····public void TestRelationHash() |
25468 | ····{ |
25469 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoLeftBase)); |
25470 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25471 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoRightBase)); |
25472 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25473 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25474 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25475 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoLeftDerived)); |
25476 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25477 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25478 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25479 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblAutoRightDerived)); |
25480 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25481 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25482 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25483 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25484 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25485 | ····} |
25486 | ····void CreateObjects() |
25487 | ····{ |
25488 | ········pm.MakePersistent(ownVar); |
25489 | ········ownVar.AssignRelation(otherVar); |
25490 | ········pm.Save(); |
25491 | ········pm.UnloadCache(); |
25492 | ····} |
25493 | ····void QueryOwn() |
25494 | ····{ |
25495 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoLeftBase>(pm); |
25496 | ········ownVar = q.ExecuteSingle(); |
25497 | ····} |
25498 | ····void QueryOther() |
25499 | ····{ |
25500 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblAutoRightBase>(pm); |
25501 | ········otherVar = q.ExecuteSingle(); |
25502 | ····} |
25503 | } |
25504 | |
25505 | |
25506 | [TestFixture] |
25507 | public class TestCmpDirnOwnpabsOthpabsTblAuto : NDOTest |
25508 | { |
25509 | ····CmpDirnOwnpabsOthpabsTblAutoLeftBase ownVar; |
25510 | ····CmpDirnOwnpabsOthpabsTblAutoRightBase otherVar; |
25511 | ····PersistenceManager pm; |
25512 | ····[SetUp] |
25513 | ····public void Setup() |
25514 | ····{ |
25515 | ········pm = PmFactory.NewPersistenceManager(); |
25516 | ········ownVar = new CmpDirnOwnpabsOthpabsTblAutoLeftDerived(); |
25517 | ········otherVar = new CmpDirnOwnpabsOthpabsTblAutoRightDerived(); |
25518 | ····} |
25519 | ····[TearDown] |
25520 | ····public void TearDown() |
25521 | ····{ |
25522 | ········try |
25523 | ········{ |
25524 | ············pm.UnloadCache(); |
25525 | ············var l = pm.Objects<CmpDirnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25526 | ············pm.Delete(l); |
25527 | ············pm.Save(); |
25528 | ············pm.UnloadCache(); |
25529 | ············decimal count; |
25530 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25531 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25532 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25533 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25534 | ········} |
25535 | ········catch (Exception) |
25536 | ········{ |
25537 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25538 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25539 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25540 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25541 | ········} |
25542 | ····} |
25543 | ····[Test] |
25544 | ····public void TestSaveReload() |
25545 | ····{ |
25546 | ········CreateObjects(); |
25547 | ········QueryOwn(); |
25548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25549 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25550 | ····} |
25551 | ····[Test] |
25552 | ····public void TestSaveReloadNull() |
25553 | ····{ |
25554 | ········CreateObjects(); |
25555 | ········QueryOwn(); |
25556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25557 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25558 | ········ownVar.RelField = new List<CmpDirnOwnpabsOthpabsTblAutoRightBase>(); |
25559 | ········pm.Save(); |
25560 | ········pm.UnloadCache(); |
25561 | ········QueryOwn(); |
25562 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25563 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25564 | ····} |
25565 | ····[Test] |
25566 | ····public void TestSaveReloadRemove() |
25567 | ····{ |
25568 | ········CreateObjects(); |
25569 | ········QueryOwn(); |
25570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25571 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25572 | ········ownVar.RemoveRelatedObject(); |
25573 | ········pm.Save(); |
25574 | ········pm.UnloadCache(); |
25575 | ········QueryOwn(); |
25576 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25577 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25578 | ····} |
25579 | ····void CreateObjects() |
25580 | ····{ |
25581 | ········pm.MakePersistent(ownVar); |
25582 | ········ownVar.AssignRelation(otherVar); |
25583 | ········pm.Save(); |
25584 | ········pm.UnloadCache(); |
25585 | ····} |
25586 | ····void QueryOwn() |
25587 | ····{ |
25588 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25589 | ········ownVar = q.ExecuteSingle(); |
25590 | ····} |
25591 | ····void QueryOther() |
25592 | ····{ |
25593 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblAutoRightBase>(pm); |
25594 | ········otherVar = q.ExecuteSingle(); |
25595 | ····} |
25596 | } |
25597 | |
25598 | |
25599 | [TestFixture] |
25600 | public class TestCmpBin1OwnpabsOthpabsTblAuto : NDOTest |
25601 | { |
25602 | ····CmpBin1OwnpabsOthpabsTblAutoLeftBase ownVar; |
25603 | ····CmpBin1OwnpabsOthpabsTblAutoRightBase otherVar; |
25604 | ····PersistenceManager pm; |
25605 | ····[SetUp] |
25606 | ····public void Setup() |
25607 | ····{ |
25608 | ········pm = PmFactory.NewPersistenceManager(); |
25609 | ········ownVar = new CmpBin1OwnpabsOthpabsTblAutoLeftDerived(); |
25610 | ········otherVar = new CmpBin1OwnpabsOthpabsTblAutoRightDerived(); |
25611 | ····} |
25612 | ····[TearDown] |
25613 | ····public void TearDown() |
25614 | ····{ |
25615 | ········try |
25616 | ········{ |
25617 | ············pm.UnloadCache(); |
25618 | ············var l = pm.Objects<CmpBin1OwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25619 | ············pm.Delete(l); |
25620 | ············pm.Save(); |
25621 | ············pm.UnloadCache(); |
25622 | ············decimal count; |
25623 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25624 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25625 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25626 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25627 | ········} |
25628 | ········catch (Exception) |
25629 | ········{ |
25630 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25631 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25632 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25633 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25634 | ········} |
25635 | ····} |
25636 | ····[Test] |
25637 | ····public void TestSaveReload() |
25638 | ····{ |
25639 | ········CreateObjects(); |
25640 | ········QueryOwn(); |
25641 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25642 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25643 | ····} |
25644 | ····[Test] |
25645 | ····public void TestSaveReloadNull() |
25646 | ····{ |
25647 | ········CreateObjects(); |
25648 | ········QueryOwn(); |
25649 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25650 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25651 | ········ownVar.RelField = new List<CmpBin1OwnpabsOthpabsTblAutoRightBase>(); |
25652 | ········pm.Save(); |
25653 | ········pm.UnloadCache(); |
25654 | ········QueryOwn(); |
25655 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25656 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25657 | ····} |
25658 | ····[Test] |
25659 | ····public void TestSaveReloadRemove() |
25660 | ····{ |
25661 | ········CreateObjects(); |
25662 | ········QueryOwn(); |
25663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25664 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25665 | ········ownVar.RemoveRelatedObject(); |
25666 | ········pm.Save(); |
25667 | ········pm.UnloadCache(); |
25668 | ········QueryOwn(); |
25669 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25670 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25671 | ····} |
25672 | ····[Test] |
25673 | ····public void TestChangeKeyHolderRight() |
25674 | ····{ |
25675 | ········CreateObjects(); |
25676 | ········QueryOther(); |
25677 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25678 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25679 | ········int x = otherVar.RelField.Dummy; |
25680 | ········otherVar.Dummy = 4711; |
25681 | ········pm.Save(); |
25682 | ········pm.UnloadCache(); |
25683 | ········QueryOther(); |
25684 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25685 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25686 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25687 | ····} |
25688 | ····[Test] |
25689 | ····public void TestChangeKeyHolderRightNoTouch() |
25690 | ····{ |
25691 | ········CreateObjects(); |
25692 | ········QueryOther(); |
25693 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25694 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25695 | ········otherVar.Dummy = 4711; |
25696 | ········pm.Save(); |
25697 | ········pm.UnloadCache(); |
25698 | ········QueryOther(); |
25699 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
25700 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25701 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
25702 | ····} |
25703 | ····[Test] |
25704 | ····public void TestRelationHash() |
25705 | ····{ |
25706 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoLeftBase)); |
25707 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25708 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoRightBase)); |
25709 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25710 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25711 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25712 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoLeftDerived)); |
25713 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25714 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25715 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25716 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblAutoRightDerived)); |
25717 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25718 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25719 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25720 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25721 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25722 | ····} |
25723 | ····void CreateObjects() |
25724 | ····{ |
25725 | ········pm.MakePersistent(ownVar); |
25726 | ········ownVar.AssignRelation(otherVar); |
25727 | ········pm.Save(); |
25728 | ········pm.UnloadCache(); |
25729 | ····} |
25730 | ····void QueryOwn() |
25731 | ····{ |
25732 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoLeftBase>(pm); |
25733 | ········ownVar = q.ExecuteSingle(); |
25734 | ····} |
25735 | ····void QueryOther() |
25736 | ····{ |
25737 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblAutoRightBase>(pm); |
25738 | ········otherVar = q.ExecuteSingle(); |
25739 | ····} |
25740 | } |
25741 | |
25742 | |
25743 | [TestFixture] |
25744 | public class TestCmpBi1nOwnpabsOthpabsTblAuto : NDOTest |
25745 | { |
25746 | ····CmpBi1nOwnpabsOthpabsTblAutoLeftBase ownVar; |
25747 | ····CmpBi1nOwnpabsOthpabsTblAutoRightBase otherVar; |
25748 | ····PersistenceManager pm; |
25749 | ····[SetUp] |
25750 | ····public void Setup() |
25751 | ····{ |
25752 | ········pm = PmFactory.NewPersistenceManager(); |
25753 | ········ownVar = new CmpBi1nOwnpabsOthpabsTblAutoLeftDerived(); |
25754 | ········otherVar = new CmpBi1nOwnpabsOthpabsTblAutoRightDerived(); |
25755 | ····} |
25756 | ····[TearDown] |
25757 | ····public void TearDown() |
25758 | ····{ |
25759 | ········try |
25760 | ········{ |
25761 | ············pm.UnloadCache(); |
25762 | ············var l = pm.Objects<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25763 | ············pm.Delete(l); |
25764 | ············pm.Save(); |
25765 | ············pm.UnloadCache(); |
25766 | ············decimal count; |
25767 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25768 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25769 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25770 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25771 | ········} |
25772 | ········catch (Exception) |
25773 | ········{ |
25774 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25775 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25776 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25777 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25778 | ········} |
25779 | ····} |
25780 | ····[Test] |
25781 | ····public void TestSaveReload() |
25782 | ····{ |
25783 | ········CreateObjects(); |
25784 | ········QueryOwn(); |
25785 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25786 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25787 | ····} |
25788 | ····[Test] |
25789 | ····public void TestSaveReloadNull() |
25790 | ····{ |
25791 | ········CreateObjects(); |
25792 | ········QueryOwn(); |
25793 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25794 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25795 | ········ownVar.RelField = null; |
25796 | ········pm.Save(); |
25797 | ········pm.UnloadCache(); |
25798 | ········QueryOwn(); |
25799 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25800 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
25801 | ····} |
25802 | ····[Test] |
25803 | ····public void TestChangeKeyHolderLeft() |
25804 | ····{ |
25805 | ········CreateObjects(); |
25806 | ········QueryOwn(); |
25807 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25808 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25809 | ········int x = ownVar.RelField.Dummy; |
25810 | ········ownVar.Dummy = 4711; |
25811 | ········pm.Save(); |
25812 | ········pm.UnloadCache(); |
25813 | ········QueryOwn(); |
25814 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25815 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25816 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25817 | ····} |
25818 | ····[Test] |
25819 | ····public void TestChangeKeyHolderLeftNoTouch() |
25820 | ····{ |
25821 | ········CreateObjects(); |
25822 | ········QueryOwn(); |
25823 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25824 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25825 | ········ownVar.Dummy = 4711; |
25826 | ········pm.Save(); |
25827 | ········pm.UnloadCache(); |
25828 | ········QueryOwn(); |
25829 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25830 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
25831 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
25832 | ····} |
25833 | ····[Test] |
25834 | ····public void TestRelationHash() |
25835 | ····{ |
25836 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoLeftBase)); |
25837 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25838 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoRightBase)); |
25839 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25840 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25841 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25842 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoLeftDerived)); |
25843 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25844 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25845 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25846 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblAutoRightDerived)); |
25847 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25848 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25849 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25850 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25851 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25852 | ····} |
25853 | ····void CreateObjects() |
25854 | ····{ |
25855 | ········pm.MakePersistent(ownVar); |
25856 | ········ownVar.AssignRelation(otherVar); |
25857 | ········pm.Save(); |
25858 | ········pm.UnloadCache(); |
25859 | ····} |
25860 | ····void QueryOwn() |
25861 | ····{ |
25862 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoLeftBase>(pm); |
25863 | ········ownVar = q.ExecuteSingle(); |
25864 | ····} |
25865 | ····void QueryOther() |
25866 | ····{ |
25867 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblAutoRightBase>(pm); |
25868 | ········otherVar = q.ExecuteSingle(); |
25869 | ····} |
25870 | } |
25871 | |
25872 | |
25873 | [TestFixture] |
25874 | public class TestCmpBinnOwnpabsOthpabsTblAuto : NDOTest |
25875 | { |
25876 | ····CmpBinnOwnpabsOthpabsTblAutoLeftBase ownVar; |
25877 | ····CmpBinnOwnpabsOthpabsTblAutoRightBase otherVar; |
25878 | ····PersistenceManager pm; |
25879 | ····[SetUp] |
25880 | ····public void Setup() |
25881 | ····{ |
25882 | ········pm = PmFactory.NewPersistenceManager(); |
25883 | ········ownVar = new CmpBinnOwnpabsOthpabsTblAutoLeftDerived(); |
25884 | ········otherVar = new CmpBinnOwnpabsOthpabsTblAutoRightDerived(); |
25885 | ····} |
25886 | ····[TearDown] |
25887 | ····public void TearDown() |
25888 | ····{ |
25889 | ········try |
25890 | ········{ |
25891 | ············pm.UnloadCache(); |
25892 | ············var l = pm.Objects<CmpBinnOwnpabsOthpabsTblAutoLeftBase>().ResultTable; |
25893 | ············pm.Delete(l); |
25894 | ············pm.Save(); |
25895 | ············pm.UnloadCache(); |
25896 | ············decimal count; |
25897 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25898 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
25899 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
25900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
25901 | ········} |
25902 | ········catch (Exception) |
25903 | ········{ |
25904 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
25905 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
25906 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
25907 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
25908 | ········} |
25909 | ····} |
25910 | ····[Test] |
25911 | ····public void TestSaveReload() |
25912 | ····{ |
25913 | ········CreateObjects(); |
25914 | ········QueryOwn(); |
25915 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25916 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25917 | ····} |
25918 | ····[Test] |
25919 | ····public void TestSaveReloadNull() |
25920 | ····{ |
25921 | ········CreateObjects(); |
25922 | ········QueryOwn(); |
25923 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25924 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25925 | ········ownVar.RelField = new List<CmpBinnOwnpabsOthpabsTblAutoRightBase>(); |
25926 | ········pm.Save(); |
25927 | ········pm.UnloadCache(); |
25928 | ········QueryOwn(); |
25929 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25930 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25931 | ····} |
25932 | ····[Test] |
25933 | ····public void TestSaveReloadRemove() |
25934 | ····{ |
25935 | ········CreateObjects(); |
25936 | ········QueryOwn(); |
25937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25938 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25939 | ········ownVar.RemoveRelatedObject(); |
25940 | ········pm.Save(); |
25941 | ········pm.UnloadCache(); |
25942 | ········QueryOwn(); |
25943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
25944 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
25945 | ····} |
25946 | ····[Test] |
25947 | ····public void TestRelationHash() |
25948 | ····{ |
25949 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoLeftBase)); |
25950 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
25951 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoRightBase)); |
25952 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
25953 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
25954 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
25955 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoLeftDerived)); |
25956 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
25957 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
25958 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
25959 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblAutoRightDerived)); |
25960 | ········Relation relderRight = clderRight.FindRelation("relField"); |
25961 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
25962 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
25963 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
25964 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
25965 | ····} |
25966 | ····void CreateObjects() |
25967 | ····{ |
25968 | ········pm.MakePersistent(ownVar); |
25969 | ········ownVar.AssignRelation(otherVar); |
25970 | ········pm.Save(); |
25971 | ········pm.UnloadCache(); |
25972 | ····} |
25973 | ····void QueryOwn() |
25974 | ····{ |
25975 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoLeftBase>(pm); |
25976 | ········ownVar = q.ExecuteSingle(); |
25977 | ····} |
25978 | ····void QueryOther() |
25979 | ····{ |
25980 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblAutoRightBase>(pm); |
25981 | ········otherVar = q.ExecuteSingle(); |
25982 | ····} |
25983 | } |
25984 | |
25985 | |
25986 | [TestFixture] |
25987 | public class TestAgrDir1OwnpabsNoTblGuid : NDOTest |
25988 | { |
25989 | ····AgrDir1OwnpabsNoTblGuidLeftBase ownVar; |
25990 | ····AgrDir1OwnpabsNoTblGuidRight otherVar; |
25991 | ····PersistenceManager pm; |
25992 | ····[SetUp] |
25993 | ····public void Setup() |
25994 | ····{ |
25995 | ········pm = PmFactory.NewPersistenceManager(); |
25996 | ········ownVar = new AgrDir1OwnpabsNoTblGuidLeftDerived(); |
25997 | ········otherVar = new AgrDir1OwnpabsNoTblGuidRight(); |
25998 | ····} |
25999 | ····[TearDown] |
26000 | ····public void TearDown() |
26001 | ····{ |
26002 | ········try |
26003 | ········{ |
26004 | ············pm.UnloadCache(); |
26005 | ············var l = pm.Objects<AgrDir1OwnpabsNoTblGuidLeftBase>().ResultTable; |
26006 | ············pm.Delete(l); |
26007 | ············pm.Save(); |
26008 | ············pm.UnloadCache(); |
26009 | ············var m = pm.Objects<AgrDir1OwnpabsNoTblGuidRight>().ResultTable; |
26010 | ············pm.Delete(m); |
26011 | ············pm.Save(); |
26012 | ············pm.UnloadCache(); |
26013 | ············decimal count; |
26014 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26015 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26016 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26017 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26018 | ········} |
26019 | ········catch (Exception) |
26020 | ········{ |
26021 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26022 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26023 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26024 | ········} |
26025 | ····} |
26026 | ····[Test] |
26027 | ····public void TestSaveReload() |
26028 | ····{ |
26029 | ········CreateObjects(); |
26030 | ········QueryOwn(); |
26031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26032 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26033 | ····} |
26034 | ····[Test] |
26035 | ····public void TestSaveReloadNull() |
26036 | ····{ |
26037 | ········CreateObjects(); |
26038 | ········QueryOwn(); |
26039 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26040 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26041 | ········ownVar.RelField = null; |
26042 | ········pm.Save(); |
26043 | ········pm.UnloadCache(); |
26044 | ········QueryOwn(); |
26045 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26046 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26047 | ····} |
26048 | ····[Test] |
26049 | ····public void TestChangeKeyHolderLeft() |
26050 | ····{ |
26051 | ········CreateObjects(); |
26052 | ········QueryOwn(); |
26053 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26054 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26055 | ········int x = ownVar.RelField.Dummy; |
26056 | ········ownVar.Dummy = 4711; |
26057 | ········pm.Save(); |
26058 | ········pm.UnloadCache(); |
26059 | ········QueryOwn(); |
26060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26061 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26062 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26063 | ····} |
26064 | ····[Test] |
26065 | ····public void TestChangeKeyHolderLeftNoTouch() |
26066 | ····{ |
26067 | ········CreateObjects(); |
26068 | ········QueryOwn(); |
26069 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26070 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26071 | ········ownVar.Dummy = 4711; |
26072 | ········pm.Save(); |
26073 | ········pm.UnloadCache(); |
26074 | ········QueryOwn(); |
26075 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26076 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26077 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26078 | ····} |
26079 | ····void CreateObjects() |
26080 | ····{ |
26081 | ········pm.MakePersistent(ownVar); |
26082 | ········pm.MakePersistent(otherVar); |
26083 | ········ownVar.AssignRelation(otherVar); |
26084 | ········pm.Save(); |
26085 | ········pm.UnloadCache(); |
26086 | ····} |
26087 | ····void QueryOwn() |
26088 | ····{ |
26089 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblGuidLeftBase>(pm); |
26090 | ········ownVar = q.ExecuteSingle(); |
26091 | ····} |
26092 | ····void QueryOther() |
26093 | ····{ |
26094 | ········var q = new NDOQuery<AgrDir1OwnpabsNoTblGuidRight>(pm); |
26095 | ········otherVar = q.ExecuteSingle(); |
26096 | ····} |
26097 | } |
26098 | |
26099 | |
26100 | [TestFixture] |
26101 | public class TestAgrDir1OwnpabsTblGuid : NDOTest |
26102 | { |
26103 | ····AgrDir1OwnpabsTblGuidLeftBase ownVar; |
26104 | ····AgrDir1OwnpabsTblGuidRight otherVar; |
26105 | ····PersistenceManager pm; |
26106 | ····[SetUp] |
26107 | ····public void Setup() |
26108 | ····{ |
26109 | ········pm = PmFactory.NewPersistenceManager(); |
26110 | ········ownVar = new AgrDir1OwnpabsTblGuidLeftDerived(); |
26111 | ········otherVar = new AgrDir1OwnpabsTblGuidRight(); |
26112 | ····} |
26113 | ····[TearDown] |
26114 | ····public void TearDown() |
26115 | ····{ |
26116 | ········try |
26117 | ········{ |
26118 | ············pm.UnloadCache(); |
26119 | ············var l = pm.Objects<AgrDir1OwnpabsTblGuidLeftBase>().ResultTable; |
26120 | ············pm.Delete(l); |
26121 | ············pm.Save(); |
26122 | ············pm.UnloadCache(); |
26123 | ············var m = pm.Objects<AgrDir1OwnpabsTblGuidRight>().ResultTable; |
26124 | ············pm.Delete(m); |
26125 | ············pm.Save(); |
26126 | ············pm.UnloadCache(); |
26127 | ············decimal count; |
26128 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26129 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26130 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26131 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26132 | ········} |
26133 | ········catch (Exception) |
26134 | ········{ |
26135 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26136 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26137 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26138 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26139 | ········} |
26140 | ····} |
26141 | ····[Test] |
26142 | ····public void TestSaveReload() |
26143 | ····{ |
26144 | ········CreateObjects(); |
26145 | ········QueryOwn(); |
26146 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26147 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26148 | ····} |
26149 | ····[Test] |
26150 | ····public void TestSaveReloadNull() |
26151 | ····{ |
26152 | ········CreateObjects(); |
26153 | ········QueryOwn(); |
26154 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26155 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26156 | ········ownVar.RelField = null; |
26157 | ········pm.Save(); |
26158 | ········pm.UnloadCache(); |
26159 | ········QueryOwn(); |
26160 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26161 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26162 | ····} |
26163 | ····[Test] |
26164 | ····public void TestChangeKeyHolderLeft() |
26165 | ····{ |
26166 | ········CreateObjects(); |
26167 | ········QueryOwn(); |
26168 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26169 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26170 | ········int x = ownVar.RelField.Dummy; |
26171 | ········ownVar.Dummy = 4711; |
26172 | ········pm.Save(); |
26173 | ········pm.UnloadCache(); |
26174 | ········QueryOwn(); |
26175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26176 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26177 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26178 | ····} |
26179 | ····[Test] |
26180 | ····public void TestChangeKeyHolderLeftNoTouch() |
26181 | ····{ |
26182 | ········CreateObjects(); |
26183 | ········QueryOwn(); |
26184 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26185 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26186 | ········ownVar.Dummy = 4711; |
26187 | ········pm.Save(); |
26188 | ········pm.UnloadCache(); |
26189 | ········QueryOwn(); |
26190 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26191 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26192 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26193 | ····} |
26194 | ····void CreateObjects() |
26195 | ····{ |
26196 | ········pm.MakePersistent(ownVar); |
26197 | ········pm.MakePersistent(otherVar); |
26198 | ········ownVar.AssignRelation(otherVar); |
26199 | ········pm.Save(); |
26200 | ········pm.UnloadCache(); |
26201 | ····} |
26202 | ····void QueryOwn() |
26203 | ····{ |
26204 | ········var q = new NDOQuery<AgrDir1OwnpabsTblGuidLeftBase>(pm); |
26205 | ········ownVar = q.ExecuteSingle(); |
26206 | ····} |
26207 | ····void QueryOther() |
26208 | ····{ |
26209 | ········var q = new NDOQuery<AgrDir1OwnpabsTblGuidRight>(pm); |
26210 | ········otherVar = q.ExecuteSingle(); |
26211 | ····} |
26212 | } |
26213 | |
26214 | |
26215 | [TestFixture] |
26216 | public class TestAgrBi11OwnpabsNoTblGuid : NDOTest |
26217 | { |
26218 | ····AgrBi11OwnpabsNoTblGuidLeftBase ownVar; |
26219 | ····AgrBi11OwnpabsNoTblGuidRight otherVar; |
26220 | ····PersistenceManager pm; |
26221 | ····[SetUp] |
26222 | ····public void Setup() |
26223 | ····{ |
26224 | ········pm = PmFactory.NewPersistenceManager(); |
26225 | ········ownVar = new AgrBi11OwnpabsNoTblGuidLeftDerived(); |
26226 | ········otherVar = new AgrBi11OwnpabsNoTblGuidRight(); |
26227 | ····} |
26228 | ····[TearDown] |
26229 | ····public void TearDown() |
26230 | ····{ |
26231 | ········try |
26232 | ········{ |
26233 | ············pm.UnloadCache(); |
26234 | ············var l = pm.Objects<AgrBi11OwnpabsNoTblGuidLeftBase>().ResultTable; |
26235 | ············pm.Delete(l); |
26236 | ············pm.Save(); |
26237 | ············pm.UnloadCache(); |
26238 | ············var m = pm.Objects<AgrBi11OwnpabsNoTblGuidRight>().ResultTable; |
26239 | ············pm.Delete(m); |
26240 | ············pm.Save(); |
26241 | ············pm.UnloadCache(); |
26242 | ············decimal count; |
26243 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26244 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26245 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26246 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26247 | ········} |
26248 | ········catch (Exception) |
26249 | ········{ |
26250 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26251 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26252 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26253 | ········} |
26254 | ····} |
26255 | ····[Test] |
26256 | ····public void TestSaveReload() |
26257 | ····{ |
26258 | ········CreateObjects(); |
26259 | ········QueryOwn(); |
26260 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26261 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26262 | ····} |
26263 | ····[Test] |
26264 | ····public void TestSaveReloadNull() |
26265 | ····{ |
26266 | ········CreateObjects(); |
26267 | ········QueryOwn(); |
26268 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26269 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26270 | ········ownVar.RelField = null; |
26271 | ········pm.Save(); |
26272 | ········pm.UnloadCache(); |
26273 | ········QueryOwn(); |
26274 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26275 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26276 | ····} |
26277 | ····[Test] |
26278 | ····public void TestChangeKeyHolderLeft() |
26279 | ····{ |
26280 | ········CreateObjects(); |
26281 | ········QueryOwn(); |
26282 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26283 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26284 | ········int x = ownVar.RelField.Dummy; |
26285 | ········ownVar.Dummy = 4711; |
26286 | ········pm.Save(); |
26287 | ········pm.UnloadCache(); |
26288 | ········QueryOwn(); |
26289 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26290 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26291 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26292 | ····} |
26293 | ····[Test] |
26294 | ····public void TestChangeKeyHolderRight() |
26295 | ····{ |
26296 | ········CreateObjects(); |
26297 | ········QueryOther(); |
26298 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26299 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26300 | ········int x = otherVar.RelField.Dummy; |
26301 | ········otherVar.Dummy = 4711; |
26302 | ········pm.Save(); |
26303 | ········pm.UnloadCache(); |
26304 | ········QueryOther(); |
26305 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26306 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26307 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26308 | ····} |
26309 | ····[Test] |
26310 | ····public void TestChangeKeyHolderLeftNoTouch() |
26311 | ····{ |
26312 | ········CreateObjects(); |
26313 | ········QueryOwn(); |
26314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26315 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26316 | ········ownVar.Dummy = 4711; |
26317 | ········pm.Save(); |
26318 | ········pm.UnloadCache(); |
26319 | ········QueryOwn(); |
26320 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26321 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26322 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26323 | ····} |
26324 | ····[Test] |
26325 | ····public void TestChangeKeyHolderRightNoTouch() |
26326 | ····{ |
26327 | ········CreateObjects(); |
26328 | ········QueryOther(); |
26329 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26330 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26331 | ········otherVar.Dummy = 4711; |
26332 | ········pm.Save(); |
26333 | ········pm.UnloadCache(); |
26334 | ········QueryOther(); |
26335 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26336 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26337 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26338 | ····} |
26339 | ····[Test] |
26340 | ····public void TestRelationHash() |
26341 | ····{ |
26342 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidLeftBase)); |
26343 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26344 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidRight)); |
26345 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26346 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26347 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26348 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsNoTblGuidLeftDerived)); |
26349 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26350 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26351 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26352 | ····} |
26353 | ····void CreateObjects() |
26354 | ····{ |
26355 | ········pm.MakePersistent(ownVar); |
26356 | ········pm.MakePersistent(otherVar); |
26357 | ········ownVar.AssignRelation(otherVar); |
26358 | ········pm.Save(); |
26359 | ········pm.UnloadCache(); |
26360 | ····} |
26361 | ····void QueryOwn() |
26362 | ····{ |
26363 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblGuidLeftBase>(pm); |
26364 | ········ownVar = q.ExecuteSingle(); |
26365 | ····} |
26366 | ····void QueryOther() |
26367 | ····{ |
26368 | ········var q = new NDOQuery<AgrBi11OwnpabsNoTblGuidRight>(pm); |
26369 | ········otherVar = q.ExecuteSingle(); |
26370 | ····} |
26371 | } |
26372 | |
26373 | |
26374 | [TestFixture] |
26375 | public class TestAgrBi11OwnpabsTblGuid : NDOTest |
26376 | { |
26377 | ····AgrBi11OwnpabsTblGuidLeftBase ownVar; |
26378 | ····AgrBi11OwnpabsTblGuidRight otherVar; |
26379 | ····PersistenceManager pm; |
26380 | ····[SetUp] |
26381 | ····public void Setup() |
26382 | ····{ |
26383 | ········pm = PmFactory.NewPersistenceManager(); |
26384 | ········ownVar = new AgrBi11OwnpabsTblGuidLeftDerived(); |
26385 | ········otherVar = new AgrBi11OwnpabsTblGuidRight(); |
26386 | ····} |
26387 | ····[TearDown] |
26388 | ····public void TearDown() |
26389 | ····{ |
26390 | ········try |
26391 | ········{ |
26392 | ············pm.UnloadCache(); |
26393 | ············var l = pm.Objects<AgrBi11OwnpabsTblGuidLeftBase>().ResultTable; |
26394 | ············pm.Delete(l); |
26395 | ············pm.Save(); |
26396 | ············pm.UnloadCache(); |
26397 | ············var m = pm.Objects<AgrBi11OwnpabsTblGuidRight>().ResultTable; |
26398 | ············pm.Delete(m); |
26399 | ············pm.Save(); |
26400 | ············pm.UnloadCache(); |
26401 | ············decimal count; |
26402 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26403 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26404 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26405 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26406 | ········} |
26407 | ········catch (Exception) |
26408 | ········{ |
26409 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26410 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26411 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26412 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26413 | ········} |
26414 | ····} |
26415 | ····[Test] |
26416 | ····public void TestSaveReload() |
26417 | ····{ |
26418 | ········CreateObjects(); |
26419 | ········QueryOwn(); |
26420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26421 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26422 | ····} |
26423 | ····[Test] |
26424 | ····public void TestSaveReloadNull() |
26425 | ····{ |
26426 | ········CreateObjects(); |
26427 | ········QueryOwn(); |
26428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26429 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26430 | ········ownVar.RelField = null; |
26431 | ········pm.Save(); |
26432 | ········pm.UnloadCache(); |
26433 | ········QueryOwn(); |
26434 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26435 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
26436 | ····} |
26437 | ····[Test] |
26438 | ····public void TestChangeKeyHolderLeft() |
26439 | ····{ |
26440 | ········CreateObjects(); |
26441 | ········QueryOwn(); |
26442 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26443 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26444 | ········int x = ownVar.RelField.Dummy; |
26445 | ········ownVar.Dummy = 4711; |
26446 | ········pm.Save(); |
26447 | ········pm.UnloadCache(); |
26448 | ········QueryOwn(); |
26449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26450 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26451 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26452 | ····} |
26453 | ····[Test] |
26454 | ····public void TestChangeKeyHolderRight() |
26455 | ····{ |
26456 | ········CreateObjects(); |
26457 | ········QueryOther(); |
26458 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26459 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26460 | ········int x = otherVar.RelField.Dummy; |
26461 | ········otherVar.Dummy = 4711; |
26462 | ········pm.Save(); |
26463 | ········pm.UnloadCache(); |
26464 | ········QueryOther(); |
26465 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26466 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26467 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26468 | ····} |
26469 | ····[Test] |
26470 | ····public void TestChangeKeyHolderLeftNoTouch() |
26471 | ····{ |
26472 | ········CreateObjects(); |
26473 | ········QueryOwn(); |
26474 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26475 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26476 | ········ownVar.Dummy = 4711; |
26477 | ········pm.Save(); |
26478 | ········pm.UnloadCache(); |
26479 | ········QueryOwn(); |
26480 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26481 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26482 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
26483 | ····} |
26484 | ····[Test] |
26485 | ····public void TestChangeKeyHolderRightNoTouch() |
26486 | ····{ |
26487 | ········CreateObjects(); |
26488 | ········QueryOther(); |
26489 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26490 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26491 | ········otherVar.Dummy = 4711; |
26492 | ········pm.Save(); |
26493 | ········pm.UnloadCache(); |
26494 | ········QueryOther(); |
26495 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26496 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26497 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26498 | ····} |
26499 | ····[Test] |
26500 | ····public void TestRelationHash() |
26501 | ····{ |
26502 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidLeftBase)); |
26503 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26504 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidRight)); |
26505 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26506 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26507 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26508 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsTblGuidLeftDerived)); |
26509 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26510 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26511 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26512 | ····} |
26513 | ····void CreateObjects() |
26514 | ····{ |
26515 | ········pm.MakePersistent(ownVar); |
26516 | ········pm.MakePersistent(otherVar); |
26517 | ········ownVar.AssignRelation(otherVar); |
26518 | ········pm.Save(); |
26519 | ········pm.UnloadCache(); |
26520 | ····} |
26521 | ····void QueryOwn() |
26522 | ····{ |
26523 | ········var q = new NDOQuery<AgrBi11OwnpabsTblGuidLeftBase>(pm); |
26524 | ········ownVar = q.ExecuteSingle(); |
26525 | ····} |
26526 | ····void QueryOther() |
26527 | ····{ |
26528 | ········var q = new NDOQuery<AgrBi11OwnpabsTblGuidRight>(pm); |
26529 | ········otherVar = q.ExecuteSingle(); |
26530 | ····} |
26531 | } |
26532 | |
26533 | |
26534 | [TestFixture] |
26535 | public class TestAgrDirnOwnpabsNoTblGuid : NDOTest |
26536 | { |
26537 | ····AgrDirnOwnpabsNoTblGuidLeftBase ownVar; |
26538 | ····AgrDirnOwnpabsNoTblGuidRight otherVar; |
26539 | ····PersistenceManager pm; |
26540 | ····[SetUp] |
26541 | ····public void Setup() |
26542 | ····{ |
26543 | ········pm = PmFactory.NewPersistenceManager(); |
26544 | ········ownVar = new AgrDirnOwnpabsNoTblGuidLeftDerived(); |
26545 | ········otherVar = new AgrDirnOwnpabsNoTblGuidRight(); |
26546 | ····} |
26547 | ····[TearDown] |
26548 | ····public void TearDown() |
26549 | ····{ |
26550 | ········try |
26551 | ········{ |
26552 | ············pm.UnloadCache(); |
26553 | ············var l = pm.Objects<AgrDirnOwnpabsNoTblGuidLeftBase>().ResultTable; |
26554 | ············pm.Delete(l); |
26555 | ············pm.Save(); |
26556 | ············pm.UnloadCache(); |
26557 | ············var m = pm.Objects<AgrDirnOwnpabsNoTblGuidRight>().ResultTable; |
26558 | ············pm.Delete(m); |
26559 | ············pm.Save(); |
26560 | ············pm.UnloadCache(); |
26561 | ············decimal count; |
26562 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26563 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26564 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26565 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26566 | ········} |
26567 | ········catch (Exception) |
26568 | ········{ |
26569 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26570 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26571 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26572 | ········} |
26573 | ····} |
26574 | ····[Test] |
26575 | ····public void TestSaveReload() |
26576 | ····{ |
26577 | ········CreateObjects(); |
26578 | ········QueryOwn(); |
26579 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26580 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26581 | ····} |
26582 | ····[Test] |
26583 | ····public void TestSaveReloadNull() |
26584 | ····{ |
26585 | ········CreateObjects(); |
26586 | ········QueryOwn(); |
26587 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26588 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26589 | ········ownVar.RelField = new List<AgrDirnOwnpabsNoTblGuidRight>(); |
26590 | ········pm.Save(); |
26591 | ········pm.UnloadCache(); |
26592 | ········QueryOwn(); |
26593 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26594 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26595 | ····} |
26596 | ····[Test] |
26597 | ····public void TestSaveReloadRemove() |
26598 | ····{ |
26599 | ········CreateObjects(); |
26600 | ········QueryOwn(); |
26601 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26602 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26603 | ········ownVar.RemoveRelatedObject(); |
26604 | ········pm.Save(); |
26605 | ········pm.UnloadCache(); |
26606 | ········QueryOwn(); |
26607 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26608 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26609 | ····} |
26610 | ····void CreateObjects() |
26611 | ····{ |
26612 | ········pm.MakePersistent(ownVar); |
26613 | ········pm.MakePersistent(otherVar); |
26614 | ········ownVar.AssignRelation(otherVar); |
26615 | ········pm.Save(); |
26616 | ········pm.UnloadCache(); |
26617 | ····} |
26618 | ····void QueryOwn() |
26619 | ····{ |
26620 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblGuidLeftBase>(pm); |
26621 | ········ownVar = q.ExecuteSingle(); |
26622 | ····} |
26623 | ····void QueryOther() |
26624 | ····{ |
26625 | ········var q = new NDOQuery<AgrDirnOwnpabsNoTblGuidRight>(pm); |
26626 | ········otherVar = q.ExecuteSingle(); |
26627 | ····} |
26628 | } |
26629 | |
26630 | |
26631 | [TestFixture] |
26632 | public class TestAgrDirnOwnpabsTblGuid : NDOTest |
26633 | { |
26634 | ····AgrDirnOwnpabsTblGuidLeftBase ownVar; |
26635 | ····AgrDirnOwnpabsTblGuidRight otherVar; |
26636 | ····PersistenceManager pm; |
26637 | ····[SetUp] |
26638 | ····public void Setup() |
26639 | ····{ |
26640 | ········pm = PmFactory.NewPersistenceManager(); |
26641 | ········ownVar = new AgrDirnOwnpabsTblGuidLeftDerived(); |
26642 | ········otherVar = new AgrDirnOwnpabsTblGuidRight(); |
26643 | ····} |
26644 | ····[TearDown] |
26645 | ····public void TearDown() |
26646 | ····{ |
26647 | ········try |
26648 | ········{ |
26649 | ············pm.UnloadCache(); |
26650 | ············var l = pm.Objects<AgrDirnOwnpabsTblGuidLeftBase>().ResultTable; |
26651 | ············pm.Delete(l); |
26652 | ············pm.Save(); |
26653 | ············pm.UnloadCache(); |
26654 | ············var m = pm.Objects<AgrDirnOwnpabsTblGuidRight>().ResultTable; |
26655 | ············pm.Delete(m); |
26656 | ············pm.Save(); |
26657 | ············pm.UnloadCache(); |
26658 | ············decimal count; |
26659 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26660 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26661 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26662 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26663 | ········} |
26664 | ········catch (Exception) |
26665 | ········{ |
26666 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26667 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26668 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26669 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26670 | ········} |
26671 | ····} |
26672 | ····[Test] |
26673 | ····public void TestSaveReload() |
26674 | ····{ |
26675 | ········CreateObjects(); |
26676 | ········QueryOwn(); |
26677 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26678 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26679 | ····} |
26680 | ····[Test] |
26681 | ····public void TestSaveReloadNull() |
26682 | ····{ |
26683 | ········CreateObjects(); |
26684 | ········QueryOwn(); |
26685 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26686 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26687 | ········ownVar.RelField = new List<AgrDirnOwnpabsTblGuidRight>(); |
26688 | ········pm.Save(); |
26689 | ········pm.UnloadCache(); |
26690 | ········QueryOwn(); |
26691 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26692 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26693 | ····} |
26694 | ····[Test] |
26695 | ····public void TestSaveReloadRemove() |
26696 | ····{ |
26697 | ········CreateObjects(); |
26698 | ········QueryOwn(); |
26699 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26700 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26701 | ········ownVar.RemoveRelatedObject(); |
26702 | ········pm.Save(); |
26703 | ········pm.UnloadCache(); |
26704 | ········QueryOwn(); |
26705 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26706 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26707 | ····} |
26708 | ····void CreateObjects() |
26709 | ····{ |
26710 | ········pm.MakePersistent(ownVar); |
26711 | ········pm.MakePersistent(otherVar); |
26712 | ········ownVar.AssignRelation(otherVar); |
26713 | ········pm.Save(); |
26714 | ········pm.UnloadCache(); |
26715 | ····} |
26716 | ····void QueryOwn() |
26717 | ····{ |
26718 | ········var q = new NDOQuery<AgrDirnOwnpabsTblGuidLeftBase>(pm); |
26719 | ········ownVar = q.ExecuteSingle(); |
26720 | ····} |
26721 | ····void QueryOther() |
26722 | ····{ |
26723 | ········var q = new NDOQuery<AgrDirnOwnpabsTblGuidRight>(pm); |
26724 | ········otherVar = q.ExecuteSingle(); |
26725 | ····} |
26726 | } |
26727 | |
26728 | |
26729 | [TestFixture] |
26730 | public class TestAgrBin1OwnpabsNoTblGuid : NDOTest |
26731 | { |
26732 | ····AgrBin1OwnpabsNoTblGuidLeftBase ownVar; |
26733 | ····AgrBin1OwnpabsNoTblGuidRight otherVar; |
26734 | ····PersistenceManager pm; |
26735 | ····[SetUp] |
26736 | ····public void Setup() |
26737 | ····{ |
26738 | ········pm = PmFactory.NewPersistenceManager(); |
26739 | ········ownVar = new AgrBin1OwnpabsNoTblGuidLeftDerived(); |
26740 | ········otherVar = new AgrBin1OwnpabsNoTblGuidRight(); |
26741 | ····} |
26742 | ····[TearDown] |
26743 | ····public void TearDown() |
26744 | ····{ |
26745 | ········try |
26746 | ········{ |
26747 | ············pm.UnloadCache(); |
26748 | ············var l = pm.Objects<AgrBin1OwnpabsNoTblGuidLeftBase>().ResultTable; |
26749 | ············pm.Delete(l); |
26750 | ············pm.Save(); |
26751 | ············pm.UnloadCache(); |
26752 | ············var m = pm.Objects<AgrBin1OwnpabsNoTblGuidRight>().ResultTable; |
26753 | ············pm.Delete(m); |
26754 | ············pm.Save(); |
26755 | ············pm.UnloadCache(); |
26756 | ············decimal count; |
26757 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26758 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26759 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26760 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26761 | ········} |
26762 | ········catch (Exception) |
26763 | ········{ |
26764 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26765 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26766 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26767 | ········} |
26768 | ····} |
26769 | ····[Test] |
26770 | ····public void TestSaveReload() |
26771 | ····{ |
26772 | ········CreateObjects(); |
26773 | ········QueryOwn(); |
26774 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26775 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26776 | ····} |
26777 | ····[Test] |
26778 | ····public void TestSaveReloadNull() |
26779 | ····{ |
26780 | ········CreateObjects(); |
26781 | ········QueryOwn(); |
26782 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26783 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26784 | ········ownVar.RelField = new List<AgrBin1OwnpabsNoTblGuidRight>(); |
26785 | ········pm.Save(); |
26786 | ········pm.UnloadCache(); |
26787 | ········QueryOwn(); |
26788 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26789 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26790 | ····} |
26791 | ····[Test] |
26792 | ····public void TestSaveReloadRemove() |
26793 | ····{ |
26794 | ········CreateObjects(); |
26795 | ········QueryOwn(); |
26796 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26797 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26798 | ········ownVar.RemoveRelatedObject(); |
26799 | ········pm.Save(); |
26800 | ········pm.UnloadCache(); |
26801 | ········QueryOwn(); |
26802 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26803 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26804 | ····} |
26805 | ····[Test] |
26806 | ····public void TestChangeKeyHolderRight() |
26807 | ····{ |
26808 | ········CreateObjects(); |
26809 | ········QueryOther(); |
26810 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26811 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26812 | ········int x = otherVar.RelField.Dummy; |
26813 | ········otherVar.Dummy = 4711; |
26814 | ········pm.Save(); |
26815 | ········pm.UnloadCache(); |
26816 | ········QueryOther(); |
26817 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26818 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26819 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26820 | ····} |
26821 | ····[Test] |
26822 | ····public void TestChangeKeyHolderRightNoTouch() |
26823 | ····{ |
26824 | ········CreateObjects(); |
26825 | ········QueryOther(); |
26826 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26827 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26828 | ········otherVar.Dummy = 4711; |
26829 | ········pm.Save(); |
26830 | ········pm.UnloadCache(); |
26831 | ········QueryOther(); |
26832 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26833 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26834 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26835 | ····} |
26836 | ····[Test] |
26837 | ····public void TestRelationHash() |
26838 | ····{ |
26839 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidLeftBase)); |
26840 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26841 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidRight)); |
26842 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26843 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26844 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26845 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsNoTblGuidLeftDerived)); |
26846 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26847 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26848 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26849 | ····} |
26850 | ····void CreateObjects() |
26851 | ····{ |
26852 | ········pm.MakePersistent(ownVar); |
26853 | ········pm.MakePersistent(otherVar); |
26854 | ········ownVar.AssignRelation(otherVar); |
26855 | ········pm.Save(); |
26856 | ········pm.UnloadCache(); |
26857 | ····} |
26858 | ····void QueryOwn() |
26859 | ····{ |
26860 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblGuidLeftBase>(pm); |
26861 | ········ownVar = q.ExecuteSingle(); |
26862 | ····} |
26863 | ····void QueryOther() |
26864 | ····{ |
26865 | ········var q = new NDOQuery<AgrBin1OwnpabsNoTblGuidRight>(pm); |
26866 | ········otherVar = q.ExecuteSingle(); |
26867 | ····} |
26868 | } |
26869 | |
26870 | |
26871 | [TestFixture] |
26872 | public class TestAgrBin1OwnpabsTblGuid : NDOTest |
26873 | { |
26874 | ····AgrBin1OwnpabsTblGuidLeftBase ownVar; |
26875 | ····AgrBin1OwnpabsTblGuidRight otherVar; |
26876 | ····PersistenceManager pm; |
26877 | ····[SetUp] |
26878 | ····public void Setup() |
26879 | ····{ |
26880 | ········pm = PmFactory.NewPersistenceManager(); |
26881 | ········ownVar = new AgrBin1OwnpabsTblGuidLeftDerived(); |
26882 | ········otherVar = new AgrBin1OwnpabsTblGuidRight(); |
26883 | ····} |
26884 | ····[TearDown] |
26885 | ····public void TearDown() |
26886 | ····{ |
26887 | ········try |
26888 | ········{ |
26889 | ············pm.UnloadCache(); |
26890 | ············var l = pm.Objects<AgrBin1OwnpabsTblGuidLeftBase>().ResultTable; |
26891 | ············pm.Delete(l); |
26892 | ············pm.Save(); |
26893 | ············pm.UnloadCache(); |
26894 | ············var m = pm.Objects<AgrBin1OwnpabsTblGuidRight>().ResultTable; |
26895 | ············pm.Delete(m); |
26896 | ············pm.Save(); |
26897 | ············pm.UnloadCache(); |
26898 | ············decimal count; |
26899 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
26901 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
26902 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
26903 | ········} |
26904 | ········catch (Exception) |
26905 | ········{ |
26906 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
26907 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
26908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
26909 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
26910 | ········} |
26911 | ····} |
26912 | ····[Test] |
26913 | ····public void TestSaveReload() |
26914 | ····{ |
26915 | ········CreateObjects(); |
26916 | ········QueryOwn(); |
26917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26918 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26919 | ····} |
26920 | ····[Test] |
26921 | ····public void TestSaveReloadNull() |
26922 | ····{ |
26923 | ········CreateObjects(); |
26924 | ········QueryOwn(); |
26925 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26926 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26927 | ········ownVar.RelField = new List<AgrBin1OwnpabsTblGuidRight>(); |
26928 | ········pm.Save(); |
26929 | ········pm.UnloadCache(); |
26930 | ········QueryOwn(); |
26931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26932 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26933 | ····} |
26934 | ····[Test] |
26935 | ····public void TestSaveReloadRemove() |
26936 | ····{ |
26937 | ········CreateObjects(); |
26938 | ········QueryOwn(); |
26939 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26940 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26941 | ········ownVar.RemoveRelatedObject(); |
26942 | ········pm.Save(); |
26943 | ········pm.UnloadCache(); |
26944 | ········QueryOwn(); |
26945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
26946 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
26947 | ····} |
26948 | ····[Test] |
26949 | ····public void TestChangeKeyHolderRight() |
26950 | ····{ |
26951 | ········CreateObjects(); |
26952 | ········QueryOther(); |
26953 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26954 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26955 | ········int x = otherVar.RelField.Dummy; |
26956 | ········otherVar.Dummy = 4711; |
26957 | ········pm.Save(); |
26958 | ········pm.UnloadCache(); |
26959 | ········QueryOther(); |
26960 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26961 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26962 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26963 | ····} |
26964 | ····[Test] |
26965 | ····public void TestChangeKeyHolderRightNoTouch() |
26966 | ····{ |
26967 | ········CreateObjects(); |
26968 | ········QueryOther(); |
26969 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26970 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26971 | ········otherVar.Dummy = 4711; |
26972 | ········pm.Save(); |
26973 | ········pm.UnloadCache(); |
26974 | ········QueryOther(); |
26975 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
26976 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
26977 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
26978 | ····} |
26979 | ····[Test] |
26980 | ····public void TestRelationHash() |
26981 | ····{ |
26982 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidLeftBase)); |
26983 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
26984 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidRight)); |
26985 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
26986 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
26987 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
26988 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsTblGuidLeftDerived)); |
26989 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
26990 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
26991 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
26992 | ····} |
26993 | ····void CreateObjects() |
26994 | ····{ |
26995 | ········pm.MakePersistent(ownVar); |
26996 | ········pm.MakePersistent(otherVar); |
26997 | ········ownVar.AssignRelation(otherVar); |
26998 | ········pm.Save(); |
26999 | ········pm.UnloadCache(); |
27000 | ····} |
27001 | ····void QueryOwn() |
27002 | ····{ |
27003 | ········var q = new NDOQuery<AgrBin1OwnpabsTblGuidLeftBase>(pm); |
27004 | ········ownVar = q.ExecuteSingle(); |
27005 | ····} |
27006 | ····void QueryOther() |
27007 | ····{ |
27008 | ········var q = new NDOQuery<AgrBin1OwnpabsTblGuidRight>(pm); |
27009 | ········otherVar = q.ExecuteSingle(); |
27010 | ····} |
27011 | } |
27012 | |
27013 | |
27014 | [TestFixture] |
27015 | public class TestAgrBi1nOwnpabsTblGuid : NDOTest |
27016 | { |
27017 | ····AgrBi1nOwnpabsTblGuidLeftBase ownVar; |
27018 | ····AgrBi1nOwnpabsTblGuidRight otherVar; |
27019 | ····PersistenceManager pm; |
27020 | ····[SetUp] |
27021 | ····public void Setup() |
27022 | ····{ |
27023 | ········pm = PmFactory.NewPersistenceManager(); |
27024 | ········ownVar = new AgrBi1nOwnpabsTblGuidLeftDerived(); |
27025 | ········otherVar = new AgrBi1nOwnpabsTblGuidRight(); |
27026 | ····} |
27027 | ····[TearDown] |
27028 | ····public void TearDown() |
27029 | ····{ |
27030 | ········try |
27031 | ········{ |
27032 | ············pm.UnloadCache(); |
27033 | ············var l = pm.Objects<AgrBi1nOwnpabsTblGuidLeftBase>().ResultTable; |
27034 | ············pm.Delete(l); |
27035 | ············pm.Save(); |
27036 | ············pm.UnloadCache(); |
27037 | ············var m = pm.Objects<AgrBi1nOwnpabsTblGuidRight>().ResultTable; |
27038 | ············pm.Delete(m); |
27039 | ············pm.Save(); |
27040 | ············pm.UnloadCache(); |
27041 | ············decimal count; |
27042 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27043 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27044 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27045 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27046 | ········} |
27047 | ········catch (Exception) |
27048 | ········{ |
27049 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27050 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27051 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27052 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27053 | ········} |
27054 | ····} |
27055 | ····[Test] |
27056 | ····public void TestSaveReload() |
27057 | ····{ |
27058 | ········CreateObjects(); |
27059 | ········QueryOwn(); |
27060 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27061 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27062 | ····} |
27063 | ····[Test] |
27064 | ····public void TestSaveReloadNull() |
27065 | ····{ |
27066 | ········CreateObjects(); |
27067 | ········QueryOwn(); |
27068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27069 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27070 | ········ownVar.RelField = null; |
27071 | ········pm.Save(); |
27072 | ········pm.UnloadCache(); |
27073 | ········QueryOwn(); |
27074 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27075 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27076 | ····} |
27077 | ····[Test] |
27078 | ····public void TestChangeKeyHolderLeft() |
27079 | ····{ |
27080 | ········CreateObjects(); |
27081 | ········QueryOwn(); |
27082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27083 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27084 | ········int x = ownVar.RelField.Dummy; |
27085 | ········ownVar.Dummy = 4711; |
27086 | ········pm.Save(); |
27087 | ········pm.UnloadCache(); |
27088 | ········QueryOwn(); |
27089 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27090 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27091 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27092 | ····} |
27093 | ····[Test] |
27094 | ····public void TestChangeKeyHolderLeftNoTouch() |
27095 | ····{ |
27096 | ········CreateObjects(); |
27097 | ········QueryOwn(); |
27098 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27099 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27100 | ········ownVar.Dummy = 4711; |
27101 | ········pm.Save(); |
27102 | ········pm.UnloadCache(); |
27103 | ········QueryOwn(); |
27104 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27105 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27106 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27107 | ····} |
27108 | ····[Test] |
27109 | ····public void TestRelationHash() |
27110 | ····{ |
27111 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidLeftBase)); |
27112 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27113 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidRight)); |
27114 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27115 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27116 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27117 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsTblGuidLeftDerived)); |
27118 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27119 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27120 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27121 | ····} |
27122 | ····void CreateObjects() |
27123 | ····{ |
27124 | ········pm.MakePersistent(ownVar); |
27125 | ········pm.MakePersistent(otherVar); |
27126 | ········ownVar.AssignRelation(otherVar); |
27127 | ········pm.Save(); |
27128 | ········pm.UnloadCache(); |
27129 | ····} |
27130 | ····void QueryOwn() |
27131 | ····{ |
27132 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblGuidLeftBase>(pm); |
27133 | ········ownVar = q.ExecuteSingle(); |
27134 | ····} |
27135 | ····void QueryOther() |
27136 | ····{ |
27137 | ········var q = new NDOQuery<AgrBi1nOwnpabsTblGuidRight>(pm); |
27138 | ········otherVar = q.ExecuteSingle(); |
27139 | ····} |
27140 | } |
27141 | |
27142 | |
27143 | [TestFixture] |
27144 | public class TestAgrBinnOwnpabsTblGuid : NDOTest |
27145 | { |
27146 | ····AgrBinnOwnpabsTblGuidLeftBase ownVar; |
27147 | ····AgrBinnOwnpabsTblGuidRight otherVar; |
27148 | ····PersistenceManager pm; |
27149 | ····[SetUp] |
27150 | ····public void Setup() |
27151 | ····{ |
27152 | ········pm = PmFactory.NewPersistenceManager(); |
27153 | ········ownVar = new AgrBinnOwnpabsTblGuidLeftDerived(); |
27154 | ········otherVar = new AgrBinnOwnpabsTblGuidRight(); |
27155 | ····} |
27156 | ····[TearDown] |
27157 | ····public void TearDown() |
27158 | ····{ |
27159 | ········try |
27160 | ········{ |
27161 | ············pm.UnloadCache(); |
27162 | ············var l = pm.Objects<AgrBinnOwnpabsTblGuidLeftBase>().ResultTable; |
27163 | ············pm.Delete(l); |
27164 | ············pm.Save(); |
27165 | ············pm.UnloadCache(); |
27166 | ············var m = pm.Objects<AgrBinnOwnpabsTblGuidRight>().ResultTable; |
27167 | ············pm.Delete(m); |
27168 | ············pm.Save(); |
27169 | ············pm.UnloadCache(); |
27170 | ············decimal count; |
27171 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27172 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27173 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27174 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27175 | ········} |
27176 | ········catch (Exception) |
27177 | ········{ |
27178 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27179 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27180 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27181 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27182 | ········} |
27183 | ····} |
27184 | ····[Test] |
27185 | ····public void TestSaveReload() |
27186 | ····{ |
27187 | ········CreateObjects(); |
27188 | ········QueryOwn(); |
27189 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27190 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27191 | ····} |
27192 | ····[Test] |
27193 | ····public void TestSaveReloadNull() |
27194 | ····{ |
27195 | ········CreateObjects(); |
27196 | ········QueryOwn(); |
27197 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27198 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27199 | ········ownVar.RelField = new List<AgrBinnOwnpabsTblGuidRight>(); |
27200 | ········pm.Save(); |
27201 | ········pm.UnloadCache(); |
27202 | ········QueryOwn(); |
27203 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27204 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27205 | ····} |
27206 | ····[Test] |
27207 | ····public void TestSaveReloadRemove() |
27208 | ····{ |
27209 | ········CreateObjects(); |
27210 | ········QueryOwn(); |
27211 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27212 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27213 | ········ownVar.RemoveRelatedObject(); |
27214 | ········pm.Save(); |
27215 | ········pm.UnloadCache(); |
27216 | ········QueryOwn(); |
27217 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27218 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27219 | ····} |
27220 | ····[Test] |
27221 | ····public void TestRelationHash() |
27222 | ····{ |
27223 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidLeftBase)); |
27224 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27225 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidRight)); |
27226 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27227 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27228 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27229 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsTblGuidLeftDerived)); |
27230 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27231 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27232 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27233 | ····} |
27234 | ····void CreateObjects() |
27235 | ····{ |
27236 | ········pm.MakePersistent(ownVar); |
27237 | ········pm.MakePersistent(otherVar); |
27238 | ········ownVar.AssignRelation(otherVar); |
27239 | ········pm.Save(); |
27240 | ········pm.UnloadCache(); |
27241 | ····} |
27242 | ····void QueryOwn() |
27243 | ····{ |
27244 | ········var q = new NDOQuery<AgrBinnOwnpabsTblGuidLeftBase>(pm); |
27245 | ········ownVar = q.ExecuteSingle(); |
27246 | ····} |
27247 | ····void QueryOther() |
27248 | ····{ |
27249 | ········var q = new NDOQuery<AgrBinnOwnpabsTblGuidRight>(pm); |
27250 | ········otherVar = q.ExecuteSingle(); |
27251 | ····} |
27252 | } |
27253 | |
27254 | |
27255 | [TestFixture] |
27256 | public class TestCmpDir1OwnpabsNoTblGuid : NDOTest |
27257 | { |
27258 | ····CmpDir1OwnpabsNoTblGuidLeftBase ownVar; |
27259 | ····CmpDir1OwnpabsNoTblGuidRight otherVar; |
27260 | ····PersistenceManager pm; |
27261 | ····[SetUp] |
27262 | ····public void Setup() |
27263 | ····{ |
27264 | ········pm = PmFactory.NewPersistenceManager(); |
27265 | ········ownVar = new CmpDir1OwnpabsNoTblGuidLeftDerived(); |
27266 | ········otherVar = new CmpDir1OwnpabsNoTblGuidRight(); |
27267 | ····} |
27268 | ····[TearDown] |
27269 | ····public void TearDown() |
27270 | ····{ |
27271 | ········try |
27272 | ········{ |
27273 | ············pm.UnloadCache(); |
27274 | ············var l = pm.Objects<CmpDir1OwnpabsNoTblGuidLeftBase>().ResultTable; |
27275 | ············pm.Delete(l); |
27276 | ············pm.Save(); |
27277 | ············pm.UnloadCache(); |
27278 | ············decimal count; |
27279 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27280 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27281 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27282 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27283 | ········} |
27284 | ········catch (Exception) |
27285 | ········{ |
27286 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27287 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27288 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27289 | ········} |
27290 | ····} |
27291 | ····[Test] |
27292 | ····public void TestSaveReload() |
27293 | ····{ |
27294 | ········CreateObjects(); |
27295 | ········QueryOwn(); |
27296 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27297 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27298 | ····} |
27299 | ····[Test] |
27300 | ····public void TestSaveReloadNull() |
27301 | ····{ |
27302 | ········CreateObjects(); |
27303 | ········QueryOwn(); |
27304 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27305 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27306 | ········ownVar.RelField = null; |
27307 | ········pm.Save(); |
27308 | ········pm.UnloadCache(); |
27309 | ········QueryOwn(); |
27310 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27311 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27312 | ····} |
27313 | ····[Test] |
27314 | ····public void TestChangeKeyHolderLeft() |
27315 | ····{ |
27316 | ········CreateObjects(); |
27317 | ········QueryOwn(); |
27318 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27319 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27320 | ········int x = ownVar.RelField.Dummy; |
27321 | ········ownVar.Dummy = 4711; |
27322 | ········pm.Save(); |
27323 | ········pm.UnloadCache(); |
27324 | ········QueryOwn(); |
27325 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27326 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27327 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27328 | ····} |
27329 | ····[Test] |
27330 | ····public void TestChangeKeyHolderLeftNoTouch() |
27331 | ····{ |
27332 | ········CreateObjects(); |
27333 | ········QueryOwn(); |
27334 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27335 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27336 | ········ownVar.Dummy = 4711; |
27337 | ········pm.Save(); |
27338 | ········pm.UnloadCache(); |
27339 | ········QueryOwn(); |
27340 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27341 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27342 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27343 | ····} |
27344 | ····void CreateObjects() |
27345 | ····{ |
27346 | ········pm.MakePersistent(ownVar); |
27347 | ········ownVar.AssignRelation(otherVar); |
27348 | ········pm.Save(); |
27349 | ········pm.UnloadCache(); |
27350 | ····} |
27351 | ····void QueryOwn() |
27352 | ····{ |
27353 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblGuidLeftBase>(pm); |
27354 | ········ownVar = q.ExecuteSingle(); |
27355 | ····} |
27356 | ····void QueryOther() |
27357 | ····{ |
27358 | ········var q = new NDOQuery<CmpDir1OwnpabsNoTblGuidRight>(pm); |
27359 | ········otherVar = q.ExecuteSingle(); |
27360 | ····} |
27361 | } |
27362 | |
27363 | |
27364 | [TestFixture] |
27365 | public class TestCmpDir1OwnpabsTblGuid : NDOTest |
27366 | { |
27367 | ····CmpDir1OwnpabsTblGuidLeftBase ownVar; |
27368 | ····CmpDir1OwnpabsTblGuidRight otherVar; |
27369 | ····PersistenceManager pm; |
27370 | ····[SetUp] |
27371 | ····public void Setup() |
27372 | ····{ |
27373 | ········pm = PmFactory.NewPersistenceManager(); |
27374 | ········ownVar = new CmpDir1OwnpabsTblGuidLeftDerived(); |
27375 | ········otherVar = new CmpDir1OwnpabsTblGuidRight(); |
27376 | ····} |
27377 | ····[TearDown] |
27378 | ····public void TearDown() |
27379 | ····{ |
27380 | ········try |
27381 | ········{ |
27382 | ············pm.UnloadCache(); |
27383 | ············var l = pm.Objects<CmpDir1OwnpabsTblGuidLeftBase>().ResultTable; |
27384 | ············pm.Delete(l); |
27385 | ············pm.Save(); |
27386 | ············pm.UnloadCache(); |
27387 | ············decimal count; |
27388 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27389 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27390 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27391 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27392 | ········} |
27393 | ········catch (Exception) |
27394 | ········{ |
27395 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27396 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27397 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27398 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27399 | ········} |
27400 | ····} |
27401 | ····[Test] |
27402 | ····public void TestSaveReload() |
27403 | ····{ |
27404 | ········CreateObjects(); |
27405 | ········QueryOwn(); |
27406 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27407 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27408 | ····} |
27409 | ····[Test] |
27410 | ····public void TestSaveReloadNull() |
27411 | ····{ |
27412 | ········CreateObjects(); |
27413 | ········QueryOwn(); |
27414 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27415 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27416 | ········ownVar.RelField = null; |
27417 | ········pm.Save(); |
27418 | ········pm.UnloadCache(); |
27419 | ········QueryOwn(); |
27420 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27421 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27422 | ····} |
27423 | ····[Test] |
27424 | ····public void TestChangeKeyHolderLeft() |
27425 | ····{ |
27426 | ········CreateObjects(); |
27427 | ········QueryOwn(); |
27428 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27429 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27430 | ········int x = ownVar.RelField.Dummy; |
27431 | ········ownVar.Dummy = 4711; |
27432 | ········pm.Save(); |
27433 | ········pm.UnloadCache(); |
27434 | ········QueryOwn(); |
27435 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27436 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27437 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27438 | ····} |
27439 | ····[Test] |
27440 | ····public void TestChangeKeyHolderLeftNoTouch() |
27441 | ····{ |
27442 | ········CreateObjects(); |
27443 | ········QueryOwn(); |
27444 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27445 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27446 | ········ownVar.Dummy = 4711; |
27447 | ········pm.Save(); |
27448 | ········pm.UnloadCache(); |
27449 | ········QueryOwn(); |
27450 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27451 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27452 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27453 | ····} |
27454 | ····void CreateObjects() |
27455 | ····{ |
27456 | ········pm.MakePersistent(ownVar); |
27457 | ········ownVar.AssignRelation(otherVar); |
27458 | ········pm.Save(); |
27459 | ········pm.UnloadCache(); |
27460 | ····} |
27461 | ····void QueryOwn() |
27462 | ····{ |
27463 | ········var q = new NDOQuery<CmpDir1OwnpabsTblGuidLeftBase>(pm); |
27464 | ········ownVar = q.ExecuteSingle(); |
27465 | ····} |
27466 | ····void QueryOther() |
27467 | ····{ |
27468 | ········var q = new NDOQuery<CmpDir1OwnpabsTblGuidRight>(pm); |
27469 | ········otherVar = q.ExecuteSingle(); |
27470 | ····} |
27471 | } |
27472 | |
27473 | |
27474 | [TestFixture] |
27475 | public class TestCmpBi11OwnpabsNoTblGuid : NDOTest |
27476 | { |
27477 | ····CmpBi11OwnpabsNoTblGuidLeftBase ownVar; |
27478 | ····CmpBi11OwnpabsNoTblGuidRight otherVar; |
27479 | ····PersistenceManager pm; |
27480 | ····[SetUp] |
27481 | ····public void Setup() |
27482 | ····{ |
27483 | ········pm = PmFactory.NewPersistenceManager(); |
27484 | ········ownVar = new CmpBi11OwnpabsNoTblGuidLeftDerived(); |
27485 | ········otherVar = new CmpBi11OwnpabsNoTblGuidRight(); |
27486 | ····} |
27487 | ····[TearDown] |
27488 | ····public void TearDown() |
27489 | ····{ |
27490 | ········try |
27491 | ········{ |
27492 | ············pm.UnloadCache(); |
27493 | ············var l = pm.Objects<CmpBi11OwnpabsNoTblGuidLeftBase>().ResultTable; |
27494 | ············pm.Delete(l); |
27495 | ············pm.Save(); |
27496 | ············pm.UnloadCache(); |
27497 | ············decimal count; |
27498 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27499 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27500 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27501 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27502 | ········} |
27503 | ········catch (Exception) |
27504 | ········{ |
27505 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27506 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27507 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27508 | ········} |
27509 | ····} |
27510 | ····[Test] |
27511 | ····public void TestSaveReload() |
27512 | ····{ |
27513 | ········CreateObjects(); |
27514 | ········QueryOwn(); |
27515 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27516 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27517 | ····} |
27518 | ····[Test] |
27519 | ····public void TestSaveReloadNull() |
27520 | ····{ |
27521 | ········CreateObjects(); |
27522 | ········QueryOwn(); |
27523 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27524 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27525 | ········ownVar.RelField = null; |
27526 | ········pm.Save(); |
27527 | ········pm.UnloadCache(); |
27528 | ········QueryOwn(); |
27529 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27530 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27531 | ····} |
27532 | ····[Test] |
27533 | ····public void TestChangeKeyHolderLeft() |
27534 | ····{ |
27535 | ········CreateObjects(); |
27536 | ········QueryOwn(); |
27537 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27538 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27539 | ········int x = ownVar.RelField.Dummy; |
27540 | ········ownVar.Dummy = 4711; |
27541 | ········pm.Save(); |
27542 | ········pm.UnloadCache(); |
27543 | ········QueryOwn(); |
27544 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27545 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27546 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27547 | ····} |
27548 | ····[Test] |
27549 | ····public void TestChangeKeyHolderRight() |
27550 | ····{ |
27551 | ········CreateObjects(); |
27552 | ········QueryOther(); |
27553 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27554 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27555 | ········int x = otherVar.RelField.Dummy; |
27556 | ········otherVar.Dummy = 4711; |
27557 | ········pm.Save(); |
27558 | ········pm.UnloadCache(); |
27559 | ········QueryOther(); |
27560 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27561 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27562 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27563 | ····} |
27564 | ····[Test] |
27565 | ····public void TestChangeKeyHolderLeftNoTouch() |
27566 | ····{ |
27567 | ········CreateObjects(); |
27568 | ········QueryOwn(); |
27569 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27570 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27571 | ········ownVar.Dummy = 4711; |
27572 | ········pm.Save(); |
27573 | ········pm.UnloadCache(); |
27574 | ········QueryOwn(); |
27575 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27576 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27577 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27578 | ····} |
27579 | ····[Test] |
27580 | ····public void TestChangeKeyHolderRightNoTouch() |
27581 | ····{ |
27582 | ········CreateObjects(); |
27583 | ········QueryOther(); |
27584 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27585 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27586 | ········otherVar.Dummy = 4711; |
27587 | ········pm.Save(); |
27588 | ········pm.UnloadCache(); |
27589 | ········QueryOther(); |
27590 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27591 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27592 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27593 | ····} |
27594 | ····[Test] |
27595 | ····public void TestRelationHash() |
27596 | ····{ |
27597 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidLeftBase)); |
27598 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27599 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidRight)); |
27600 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27601 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27602 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27603 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsNoTblGuidLeftDerived)); |
27604 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27605 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27606 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27607 | ····} |
27608 | ····void CreateObjects() |
27609 | ····{ |
27610 | ········pm.MakePersistent(ownVar); |
27611 | ········ownVar.AssignRelation(otherVar); |
27612 | ········pm.Save(); |
27613 | ········pm.UnloadCache(); |
27614 | ····} |
27615 | ····void QueryOwn() |
27616 | ····{ |
27617 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblGuidLeftBase>(pm); |
27618 | ········ownVar = q.ExecuteSingle(); |
27619 | ····} |
27620 | ····void QueryOther() |
27621 | ····{ |
27622 | ········var q = new NDOQuery<CmpBi11OwnpabsNoTblGuidRight>(pm); |
27623 | ········otherVar = q.ExecuteSingle(); |
27624 | ····} |
27625 | } |
27626 | |
27627 | |
27628 | [TestFixture] |
27629 | public class TestCmpBi11OwnpabsTblGuid : NDOTest |
27630 | { |
27631 | ····CmpBi11OwnpabsTblGuidLeftBase ownVar; |
27632 | ····CmpBi11OwnpabsTblGuidRight otherVar; |
27633 | ····PersistenceManager pm; |
27634 | ····[SetUp] |
27635 | ····public void Setup() |
27636 | ····{ |
27637 | ········pm = PmFactory.NewPersistenceManager(); |
27638 | ········ownVar = new CmpBi11OwnpabsTblGuidLeftDerived(); |
27639 | ········otherVar = new CmpBi11OwnpabsTblGuidRight(); |
27640 | ····} |
27641 | ····[TearDown] |
27642 | ····public void TearDown() |
27643 | ····{ |
27644 | ········try |
27645 | ········{ |
27646 | ············pm.UnloadCache(); |
27647 | ············var l = pm.Objects<CmpBi11OwnpabsTblGuidLeftBase>().ResultTable; |
27648 | ············pm.Delete(l); |
27649 | ············pm.Save(); |
27650 | ············pm.UnloadCache(); |
27651 | ············decimal count; |
27652 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27653 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27654 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27655 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27656 | ········} |
27657 | ········catch (Exception) |
27658 | ········{ |
27659 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27660 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27661 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27662 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27663 | ········} |
27664 | ····} |
27665 | ····[Test] |
27666 | ····public void TestSaveReload() |
27667 | ····{ |
27668 | ········CreateObjects(); |
27669 | ········QueryOwn(); |
27670 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27671 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27672 | ····} |
27673 | ····[Test] |
27674 | ····public void TestSaveReloadNull() |
27675 | ····{ |
27676 | ········CreateObjects(); |
27677 | ········QueryOwn(); |
27678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27679 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27680 | ········ownVar.RelField = null; |
27681 | ········pm.Save(); |
27682 | ········pm.UnloadCache(); |
27683 | ········QueryOwn(); |
27684 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27685 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
27686 | ····} |
27687 | ····[Test] |
27688 | ····public void TestChangeKeyHolderLeft() |
27689 | ····{ |
27690 | ········CreateObjects(); |
27691 | ········QueryOwn(); |
27692 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27693 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27694 | ········int x = ownVar.RelField.Dummy; |
27695 | ········ownVar.Dummy = 4711; |
27696 | ········pm.Save(); |
27697 | ········pm.UnloadCache(); |
27698 | ········QueryOwn(); |
27699 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27700 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27701 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27702 | ····} |
27703 | ····[Test] |
27704 | ····public void TestChangeKeyHolderRight() |
27705 | ····{ |
27706 | ········CreateObjects(); |
27707 | ········QueryOther(); |
27708 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27709 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27710 | ········int x = otherVar.RelField.Dummy; |
27711 | ········otherVar.Dummy = 4711; |
27712 | ········pm.Save(); |
27713 | ········pm.UnloadCache(); |
27714 | ········QueryOther(); |
27715 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27716 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27717 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27718 | ····} |
27719 | ····[Test] |
27720 | ····public void TestChangeKeyHolderLeftNoTouch() |
27721 | ····{ |
27722 | ········CreateObjects(); |
27723 | ········QueryOwn(); |
27724 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27725 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27726 | ········ownVar.Dummy = 4711; |
27727 | ········pm.Save(); |
27728 | ········pm.UnloadCache(); |
27729 | ········QueryOwn(); |
27730 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27731 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27732 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
27733 | ····} |
27734 | ····[Test] |
27735 | ····public void TestChangeKeyHolderRightNoTouch() |
27736 | ····{ |
27737 | ········CreateObjects(); |
27738 | ········QueryOther(); |
27739 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27740 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27741 | ········otherVar.Dummy = 4711; |
27742 | ········pm.Save(); |
27743 | ········pm.UnloadCache(); |
27744 | ········QueryOther(); |
27745 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
27746 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
27747 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
27748 | ····} |
27749 | ····[Test] |
27750 | ····public void TestRelationHash() |
27751 | ····{ |
27752 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidLeftBase)); |
27753 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
27754 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidRight)); |
27755 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
27756 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
27757 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
27758 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsTblGuidLeftDerived)); |
27759 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
27760 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
27761 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
27762 | ····} |
27763 | ····void CreateObjects() |
27764 | ····{ |
27765 | ········pm.MakePersistent(ownVar); |
27766 | ········ownVar.AssignRelation(otherVar); |
27767 | ········pm.Save(); |
27768 | ········pm.UnloadCache(); |
27769 | ····} |
27770 | ····void QueryOwn() |
27771 | ····{ |
27772 | ········var q = new NDOQuery<CmpBi11OwnpabsTblGuidLeftBase>(pm); |
27773 | ········ownVar = q.ExecuteSingle(); |
27774 | ····} |
27775 | ····void QueryOther() |
27776 | ····{ |
27777 | ········var q = new NDOQuery<CmpBi11OwnpabsTblGuidRight>(pm); |
27778 | ········otherVar = q.ExecuteSingle(); |
27779 | ····} |
27780 | } |
27781 | |
27782 | |
27783 | [TestFixture] |
27784 | public class TestCmpDirnOwnpabsNoTblGuid : NDOTest |
27785 | { |
27786 | ····CmpDirnOwnpabsNoTblGuidLeftBase ownVar; |
27787 | ····CmpDirnOwnpabsNoTblGuidRight otherVar; |
27788 | ····PersistenceManager pm; |
27789 | ····[SetUp] |
27790 | ····public void Setup() |
27791 | ····{ |
27792 | ········pm = PmFactory.NewPersistenceManager(); |
27793 | ········ownVar = new CmpDirnOwnpabsNoTblGuidLeftDerived(); |
27794 | ········otherVar = new CmpDirnOwnpabsNoTblGuidRight(); |
27795 | ····} |
27796 | ····[TearDown] |
27797 | ····public void TearDown() |
27798 | ····{ |
27799 | ········try |
27800 | ········{ |
27801 | ············pm.UnloadCache(); |
27802 | ············var l = pm.Objects<CmpDirnOwnpabsNoTblGuidLeftBase>().ResultTable; |
27803 | ············pm.Delete(l); |
27804 | ············pm.Save(); |
27805 | ············pm.UnloadCache(); |
27806 | ············decimal count; |
27807 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27808 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27809 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27810 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27811 | ········} |
27812 | ········catch (Exception) |
27813 | ········{ |
27814 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27815 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27816 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27817 | ········} |
27818 | ····} |
27819 | ····[Test] |
27820 | ····public void TestSaveReload() |
27821 | ····{ |
27822 | ········CreateObjects(); |
27823 | ········QueryOwn(); |
27824 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27825 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27826 | ····} |
27827 | ····[Test] |
27828 | ····public void TestSaveReloadNull() |
27829 | ····{ |
27830 | ········CreateObjects(); |
27831 | ········QueryOwn(); |
27832 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27833 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27834 | ········ownVar.RelField = new List<CmpDirnOwnpabsNoTblGuidRight>(); |
27835 | ········pm.Save(); |
27836 | ········pm.UnloadCache(); |
27837 | ········QueryOwn(); |
27838 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27839 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27840 | ····} |
27841 | ····[Test] |
27842 | ····public void TestSaveReloadRemove() |
27843 | ····{ |
27844 | ········CreateObjects(); |
27845 | ········QueryOwn(); |
27846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27847 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27848 | ········ownVar.RemoveRelatedObject(); |
27849 | ········pm.Save(); |
27850 | ········pm.UnloadCache(); |
27851 | ········QueryOwn(); |
27852 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27853 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27854 | ····} |
27855 | ····void CreateObjects() |
27856 | ····{ |
27857 | ········pm.MakePersistent(ownVar); |
27858 | ········ownVar.AssignRelation(otherVar); |
27859 | ········pm.Save(); |
27860 | ········pm.UnloadCache(); |
27861 | ····} |
27862 | ····void QueryOwn() |
27863 | ····{ |
27864 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblGuidLeftBase>(pm); |
27865 | ········ownVar = q.ExecuteSingle(); |
27866 | ····} |
27867 | ····void QueryOther() |
27868 | ····{ |
27869 | ········var q = new NDOQuery<CmpDirnOwnpabsNoTblGuidRight>(pm); |
27870 | ········otherVar = q.ExecuteSingle(); |
27871 | ····} |
27872 | } |
27873 | |
27874 | |
27875 | [TestFixture] |
27876 | public class TestCmpDirnOwnpabsTblGuid : NDOTest |
27877 | { |
27878 | ····CmpDirnOwnpabsTblGuidLeftBase ownVar; |
27879 | ····CmpDirnOwnpabsTblGuidRight otherVar; |
27880 | ····PersistenceManager pm; |
27881 | ····[SetUp] |
27882 | ····public void Setup() |
27883 | ····{ |
27884 | ········pm = PmFactory.NewPersistenceManager(); |
27885 | ········ownVar = new CmpDirnOwnpabsTblGuidLeftDerived(); |
27886 | ········otherVar = new CmpDirnOwnpabsTblGuidRight(); |
27887 | ····} |
27888 | ····[TearDown] |
27889 | ····public void TearDown() |
27890 | ····{ |
27891 | ········try |
27892 | ········{ |
27893 | ············pm.UnloadCache(); |
27894 | ············var l = pm.Objects<CmpDirnOwnpabsTblGuidLeftBase>().ResultTable; |
27895 | ············pm.Delete(l); |
27896 | ············pm.Save(); |
27897 | ············pm.UnloadCache(); |
27898 | ············decimal count; |
27899 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27900 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27901 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27902 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27903 | ········} |
27904 | ········catch (Exception) |
27905 | ········{ |
27906 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
27907 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
27908 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
27909 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
27910 | ········} |
27911 | ····} |
27912 | ····[Test] |
27913 | ····public void TestSaveReload() |
27914 | ····{ |
27915 | ········CreateObjects(); |
27916 | ········QueryOwn(); |
27917 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27918 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27919 | ····} |
27920 | ····[Test] |
27921 | ····public void TestSaveReloadNull() |
27922 | ····{ |
27923 | ········CreateObjects(); |
27924 | ········QueryOwn(); |
27925 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27926 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27927 | ········ownVar.RelField = new List<CmpDirnOwnpabsTblGuidRight>(); |
27928 | ········pm.Save(); |
27929 | ········pm.UnloadCache(); |
27930 | ········QueryOwn(); |
27931 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27932 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27933 | ····} |
27934 | ····[Test] |
27935 | ····public void TestSaveReloadRemove() |
27936 | ····{ |
27937 | ········CreateObjects(); |
27938 | ········QueryOwn(); |
27939 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27940 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27941 | ········ownVar.RemoveRelatedObject(); |
27942 | ········pm.Save(); |
27943 | ········pm.UnloadCache(); |
27944 | ········QueryOwn(); |
27945 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
27946 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
27947 | ····} |
27948 | ····void CreateObjects() |
27949 | ····{ |
27950 | ········pm.MakePersistent(ownVar); |
27951 | ········ownVar.AssignRelation(otherVar); |
27952 | ········pm.Save(); |
27953 | ········pm.UnloadCache(); |
27954 | ····} |
27955 | ····void QueryOwn() |
27956 | ····{ |
27957 | ········var q = new NDOQuery<CmpDirnOwnpabsTblGuidLeftBase>(pm); |
27958 | ········ownVar = q.ExecuteSingle(); |
27959 | ····} |
27960 | ····void QueryOther() |
27961 | ····{ |
27962 | ········var q = new NDOQuery<CmpDirnOwnpabsTblGuidRight>(pm); |
27963 | ········otherVar = q.ExecuteSingle(); |
27964 | ····} |
27965 | } |
27966 | |
27967 | |
27968 | [TestFixture] |
27969 | public class TestCmpBin1OwnpabsNoTblGuid : NDOTest |
27970 | { |
27971 | ····CmpBin1OwnpabsNoTblGuidLeftBase ownVar; |
27972 | ····CmpBin1OwnpabsNoTblGuidRight otherVar; |
27973 | ····PersistenceManager pm; |
27974 | ····[SetUp] |
27975 | ····public void Setup() |
27976 | ····{ |
27977 | ········pm = PmFactory.NewPersistenceManager(); |
27978 | ········ownVar = new CmpBin1OwnpabsNoTblGuidLeftDerived(); |
27979 | ········otherVar = new CmpBin1OwnpabsNoTblGuidRight(); |
27980 | ····} |
27981 | ····[TearDown] |
27982 | ····public void TearDown() |
27983 | ····{ |
27984 | ········try |
27985 | ········{ |
27986 | ············pm.UnloadCache(); |
27987 | ············var l = pm.Objects<CmpBin1OwnpabsNoTblGuidLeftBase>().ResultTable; |
27988 | ············pm.Delete(l); |
27989 | ············pm.Save(); |
27990 | ············pm.UnloadCache(); |
27991 | ············decimal count; |
27992 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27993 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
27994 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsNoTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
27995 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
27996 | ········} |
27997 | ········catch (Exception) |
27998 | ········{ |
27999 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28000 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28001 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28002 | ········} |
28003 | ····} |
28004 | ····[Test] |
28005 | ····public void TestSaveReload() |
28006 | ····{ |
28007 | ········CreateObjects(); |
28008 | ········QueryOwn(); |
28009 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28010 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28011 | ····} |
28012 | ····[Test] |
28013 | ····public void TestSaveReloadNull() |
28014 | ····{ |
28015 | ········CreateObjects(); |
28016 | ········QueryOwn(); |
28017 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28018 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28019 | ········ownVar.RelField = new List<CmpBin1OwnpabsNoTblGuidRight>(); |
28020 | ········pm.Save(); |
28021 | ········pm.UnloadCache(); |
28022 | ········QueryOwn(); |
28023 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28024 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28025 | ····} |
28026 | ····[Test] |
28027 | ····public void TestSaveReloadRemove() |
28028 | ····{ |
28029 | ········CreateObjects(); |
28030 | ········QueryOwn(); |
28031 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28032 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28033 | ········ownVar.RemoveRelatedObject(); |
28034 | ········pm.Save(); |
28035 | ········pm.UnloadCache(); |
28036 | ········QueryOwn(); |
28037 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28038 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28039 | ····} |
28040 | ····[Test] |
28041 | ····public void TestChangeKeyHolderRight() |
28042 | ····{ |
28043 | ········CreateObjects(); |
28044 | ········QueryOther(); |
28045 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28046 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28047 | ········int x = otherVar.RelField.Dummy; |
28048 | ········otherVar.Dummy = 4711; |
28049 | ········pm.Save(); |
28050 | ········pm.UnloadCache(); |
28051 | ········QueryOther(); |
28052 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28053 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28054 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28055 | ····} |
28056 | ····[Test] |
28057 | ····public void TestChangeKeyHolderRightNoTouch() |
28058 | ····{ |
28059 | ········CreateObjects(); |
28060 | ········QueryOther(); |
28061 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28062 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28063 | ········otherVar.Dummy = 4711; |
28064 | ········pm.Save(); |
28065 | ········pm.UnloadCache(); |
28066 | ········QueryOther(); |
28067 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28068 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28069 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28070 | ····} |
28071 | ····[Test] |
28072 | ····public void TestRelationHash() |
28073 | ····{ |
28074 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidLeftBase)); |
28075 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28076 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidRight)); |
28077 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28078 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28079 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28080 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsNoTblGuidLeftDerived)); |
28081 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28082 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28083 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28084 | ····} |
28085 | ····void CreateObjects() |
28086 | ····{ |
28087 | ········pm.MakePersistent(ownVar); |
28088 | ········ownVar.AssignRelation(otherVar); |
28089 | ········pm.Save(); |
28090 | ········pm.UnloadCache(); |
28091 | ····} |
28092 | ····void QueryOwn() |
28093 | ····{ |
28094 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblGuidLeftBase>(pm); |
28095 | ········ownVar = q.ExecuteSingle(); |
28096 | ····} |
28097 | ····void QueryOther() |
28098 | ····{ |
28099 | ········var q = new NDOQuery<CmpBin1OwnpabsNoTblGuidRight>(pm); |
28100 | ········otherVar = q.ExecuteSingle(); |
28101 | ····} |
28102 | } |
28103 | |
28104 | |
28105 | [TestFixture] |
28106 | public class TestCmpBin1OwnpabsTblGuid : NDOTest |
28107 | { |
28108 | ····CmpBin1OwnpabsTblGuidLeftBase ownVar; |
28109 | ····CmpBin1OwnpabsTblGuidRight otherVar; |
28110 | ····PersistenceManager pm; |
28111 | ····[SetUp] |
28112 | ····public void Setup() |
28113 | ····{ |
28114 | ········pm = PmFactory.NewPersistenceManager(); |
28115 | ········ownVar = new CmpBin1OwnpabsTblGuidLeftDerived(); |
28116 | ········otherVar = new CmpBin1OwnpabsTblGuidRight(); |
28117 | ····} |
28118 | ····[TearDown] |
28119 | ····public void TearDown() |
28120 | ····{ |
28121 | ········try |
28122 | ········{ |
28123 | ············pm.UnloadCache(); |
28124 | ············var l = pm.Objects<CmpBin1OwnpabsTblGuidLeftBase>().ResultTable; |
28125 | ············pm.Delete(l); |
28126 | ············pm.Save(); |
28127 | ············pm.UnloadCache(); |
28128 | ············decimal count; |
28129 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28130 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28131 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28132 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28133 | ········} |
28134 | ········catch (Exception) |
28135 | ········{ |
28136 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28137 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28138 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28139 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28140 | ········} |
28141 | ····} |
28142 | ····[Test] |
28143 | ····public void TestSaveReload() |
28144 | ····{ |
28145 | ········CreateObjects(); |
28146 | ········QueryOwn(); |
28147 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28148 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28149 | ····} |
28150 | ····[Test] |
28151 | ····public void TestSaveReloadNull() |
28152 | ····{ |
28153 | ········CreateObjects(); |
28154 | ········QueryOwn(); |
28155 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28156 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28157 | ········ownVar.RelField = new List<CmpBin1OwnpabsTblGuidRight>(); |
28158 | ········pm.Save(); |
28159 | ········pm.UnloadCache(); |
28160 | ········QueryOwn(); |
28161 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28162 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28163 | ····} |
28164 | ····[Test] |
28165 | ····public void TestSaveReloadRemove() |
28166 | ····{ |
28167 | ········CreateObjects(); |
28168 | ········QueryOwn(); |
28169 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28170 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28171 | ········ownVar.RemoveRelatedObject(); |
28172 | ········pm.Save(); |
28173 | ········pm.UnloadCache(); |
28174 | ········QueryOwn(); |
28175 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28176 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28177 | ····} |
28178 | ····[Test] |
28179 | ····public void TestChangeKeyHolderRight() |
28180 | ····{ |
28181 | ········CreateObjects(); |
28182 | ········QueryOther(); |
28183 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28184 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28185 | ········int x = otherVar.RelField.Dummy; |
28186 | ········otherVar.Dummy = 4711; |
28187 | ········pm.Save(); |
28188 | ········pm.UnloadCache(); |
28189 | ········QueryOther(); |
28190 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28191 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28192 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28193 | ····} |
28194 | ····[Test] |
28195 | ····public void TestChangeKeyHolderRightNoTouch() |
28196 | ····{ |
28197 | ········CreateObjects(); |
28198 | ········QueryOther(); |
28199 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28200 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28201 | ········otherVar.Dummy = 4711; |
28202 | ········pm.Save(); |
28203 | ········pm.UnloadCache(); |
28204 | ········QueryOther(); |
28205 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28206 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28207 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28208 | ····} |
28209 | ····[Test] |
28210 | ····public void TestRelationHash() |
28211 | ····{ |
28212 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidLeftBase)); |
28213 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28214 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidRight)); |
28215 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28216 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28217 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28218 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsTblGuidLeftDerived)); |
28219 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28220 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28221 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28222 | ····} |
28223 | ····void CreateObjects() |
28224 | ····{ |
28225 | ········pm.MakePersistent(ownVar); |
28226 | ········ownVar.AssignRelation(otherVar); |
28227 | ········pm.Save(); |
28228 | ········pm.UnloadCache(); |
28229 | ····} |
28230 | ····void QueryOwn() |
28231 | ····{ |
28232 | ········var q = new NDOQuery<CmpBin1OwnpabsTblGuidLeftBase>(pm); |
28233 | ········ownVar = q.ExecuteSingle(); |
28234 | ····} |
28235 | ····void QueryOther() |
28236 | ····{ |
28237 | ········var q = new NDOQuery<CmpBin1OwnpabsTblGuidRight>(pm); |
28238 | ········otherVar = q.ExecuteSingle(); |
28239 | ····} |
28240 | } |
28241 | |
28242 | |
28243 | [TestFixture] |
28244 | public class TestCmpBi1nOwnpabsTblGuid : NDOTest |
28245 | { |
28246 | ····CmpBi1nOwnpabsTblGuidLeftBase ownVar; |
28247 | ····CmpBi1nOwnpabsTblGuidRight otherVar; |
28248 | ····PersistenceManager pm; |
28249 | ····[SetUp] |
28250 | ····public void Setup() |
28251 | ····{ |
28252 | ········pm = PmFactory.NewPersistenceManager(); |
28253 | ········ownVar = new CmpBi1nOwnpabsTblGuidLeftDerived(); |
28254 | ········otherVar = new CmpBi1nOwnpabsTblGuidRight(); |
28255 | ····} |
28256 | ····[TearDown] |
28257 | ····public void TearDown() |
28258 | ····{ |
28259 | ········try |
28260 | ········{ |
28261 | ············pm.UnloadCache(); |
28262 | ············var l = pm.Objects<CmpBi1nOwnpabsTblGuidLeftBase>().ResultTable; |
28263 | ············pm.Delete(l); |
28264 | ············pm.Save(); |
28265 | ············pm.UnloadCache(); |
28266 | ············decimal count; |
28267 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28268 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28269 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28270 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28271 | ········} |
28272 | ········catch (Exception) |
28273 | ········{ |
28274 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28275 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28276 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28277 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28278 | ········} |
28279 | ····} |
28280 | ····[Test] |
28281 | ····public void TestSaveReload() |
28282 | ····{ |
28283 | ········CreateObjects(); |
28284 | ········QueryOwn(); |
28285 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28286 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28287 | ····} |
28288 | ····[Test] |
28289 | ····public void TestSaveReloadNull() |
28290 | ····{ |
28291 | ········CreateObjects(); |
28292 | ········QueryOwn(); |
28293 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28294 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28295 | ········ownVar.RelField = null; |
28296 | ········pm.Save(); |
28297 | ········pm.UnloadCache(); |
28298 | ········QueryOwn(); |
28299 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28300 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28301 | ····} |
28302 | ····[Test] |
28303 | ····public void TestChangeKeyHolderLeft() |
28304 | ····{ |
28305 | ········CreateObjects(); |
28306 | ········QueryOwn(); |
28307 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28308 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28309 | ········int x = ownVar.RelField.Dummy; |
28310 | ········ownVar.Dummy = 4711; |
28311 | ········pm.Save(); |
28312 | ········pm.UnloadCache(); |
28313 | ········QueryOwn(); |
28314 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28315 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28316 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28317 | ····} |
28318 | ····[Test] |
28319 | ····public void TestChangeKeyHolderLeftNoTouch() |
28320 | ····{ |
28321 | ········CreateObjects(); |
28322 | ········QueryOwn(); |
28323 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28324 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28325 | ········ownVar.Dummy = 4711; |
28326 | ········pm.Save(); |
28327 | ········pm.UnloadCache(); |
28328 | ········QueryOwn(); |
28329 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28330 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28332 | ····} |
28333 | ····[Test] |
28334 | ····public void TestRelationHash() |
28335 | ····{ |
28336 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidLeftBase)); |
28337 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28338 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidRight)); |
28339 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28340 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28341 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28342 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsTblGuidLeftDerived)); |
28343 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28344 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28345 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28346 | ····} |
28347 | ····void CreateObjects() |
28348 | ····{ |
28349 | ········pm.MakePersistent(ownVar); |
28350 | ········ownVar.AssignRelation(otherVar); |
28351 | ········pm.Save(); |
28352 | ········pm.UnloadCache(); |
28353 | ····} |
28354 | ····void QueryOwn() |
28355 | ····{ |
28356 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblGuidLeftBase>(pm); |
28357 | ········ownVar = q.ExecuteSingle(); |
28358 | ····} |
28359 | ····void QueryOther() |
28360 | ····{ |
28361 | ········var q = new NDOQuery<CmpBi1nOwnpabsTblGuidRight>(pm); |
28362 | ········otherVar = q.ExecuteSingle(); |
28363 | ····} |
28364 | } |
28365 | |
28366 | |
28367 | [TestFixture] |
28368 | public class TestCmpBinnOwnpabsTblGuid : NDOTest |
28369 | { |
28370 | ····CmpBinnOwnpabsTblGuidLeftBase ownVar; |
28371 | ····CmpBinnOwnpabsTblGuidRight otherVar; |
28372 | ····PersistenceManager pm; |
28373 | ····[SetUp] |
28374 | ····public void Setup() |
28375 | ····{ |
28376 | ········pm = PmFactory.NewPersistenceManager(); |
28377 | ········ownVar = new CmpBinnOwnpabsTblGuidLeftDerived(); |
28378 | ········otherVar = new CmpBinnOwnpabsTblGuidRight(); |
28379 | ····} |
28380 | ····[TearDown] |
28381 | ····public void TearDown() |
28382 | ····{ |
28383 | ········try |
28384 | ········{ |
28385 | ············pm.UnloadCache(); |
28386 | ············var l = pm.Objects<CmpBinnOwnpabsTblGuidLeftBase>().ResultTable; |
28387 | ············pm.Delete(l); |
28388 | ············pm.Save(); |
28389 | ············pm.UnloadCache(); |
28390 | ············decimal count; |
28391 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28392 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28393 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsTblGuidRight>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28394 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28395 | ········} |
28396 | ········catch (Exception) |
28397 | ········{ |
28398 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28399 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28400 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28401 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28402 | ········} |
28403 | ····} |
28404 | ····[Test] |
28405 | ····public void TestSaveReload() |
28406 | ····{ |
28407 | ········CreateObjects(); |
28408 | ········QueryOwn(); |
28409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28410 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28411 | ····} |
28412 | ····[Test] |
28413 | ····public void TestSaveReloadNull() |
28414 | ····{ |
28415 | ········CreateObjects(); |
28416 | ········QueryOwn(); |
28417 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28418 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28419 | ········ownVar.RelField = new List<CmpBinnOwnpabsTblGuidRight>(); |
28420 | ········pm.Save(); |
28421 | ········pm.UnloadCache(); |
28422 | ········QueryOwn(); |
28423 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28424 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28425 | ····} |
28426 | ····[Test] |
28427 | ····public void TestSaveReloadRemove() |
28428 | ····{ |
28429 | ········CreateObjects(); |
28430 | ········QueryOwn(); |
28431 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28432 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28433 | ········ownVar.RemoveRelatedObject(); |
28434 | ········pm.Save(); |
28435 | ········pm.UnloadCache(); |
28436 | ········QueryOwn(); |
28437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28438 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
28439 | ····} |
28440 | ····[Test] |
28441 | ····public void TestRelationHash() |
28442 | ····{ |
28443 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidLeftBase)); |
28444 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28445 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidRight)); |
28446 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28447 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28448 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28449 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsTblGuidLeftDerived)); |
28450 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
28451 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
28452 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
28453 | ····} |
28454 | ····void CreateObjects() |
28455 | ····{ |
28456 | ········pm.MakePersistent(ownVar); |
28457 | ········ownVar.AssignRelation(otherVar); |
28458 | ········pm.Save(); |
28459 | ········pm.UnloadCache(); |
28460 | ····} |
28461 | ····void QueryOwn() |
28462 | ····{ |
28463 | ········var q = new NDOQuery<CmpBinnOwnpabsTblGuidLeftBase>(pm); |
28464 | ········ownVar = q.ExecuteSingle(); |
28465 | ····} |
28466 | ····void QueryOther() |
28467 | ····{ |
28468 | ········var q = new NDOQuery<CmpBinnOwnpabsTblGuidRight>(pm); |
28469 | ········otherVar = q.ExecuteSingle(); |
28470 | ····} |
28471 | } |
28472 | |
28473 | |
28474 | [TestFixture] |
28475 | public class TestAgrDir1OthpabsNoTblGuid : NDOTest |
28476 | { |
28477 | ····AgrDir1OthpabsNoTblGuidLeft ownVar; |
28478 | ····AgrDir1OthpabsNoTblGuidRightBase otherVar; |
28479 | ····PersistenceManager pm; |
28480 | ····[SetUp] |
28481 | ····public void Setup() |
28482 | ····{ |
28483 | ········pm = PmFactory.NewPersistenceManager(); |
28484 | ········ownVar = new AgrDir1OthpabsNoTblGuidLeft(); |
28485 | ········otherVar = new AgrDir1OthpabsNoTblGuidRightDerived(); |
28486 | ····} |
28487 | ····[TearDown] |
28488 | ····public void TearDown() |
28489 | ····{ |
28490 | ········try |
28491 | ········{ |
28492 | ············pm.UnloadCache(); |
28493 | ············var l = pm.Objects<AgrDir1OthpabsNoTblGuidLeft>().ResultTable; |
28494 | ············pm.Delete(l); |
28495 | ············pm.Save(); |
28496 | ············pm.UnloadCache(); |
28497 | ············var m = pm.Objects<AgrDir1OthpabsNoTblGuidRightBase>().ResultTable; |
28498 | ············pm.Delete(m); |
28499 | ············pm.Save(); |
28500 | ············pm.UnloadCache(); |
28501 | ············decimal count; |
28502 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28503 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28504 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28505 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28506 | ········} |
28507 | ········catch (Exception) |
28508 | ········{ |
28509 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28510 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28511 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28512 | ········} |
28513 | ····} |
28514 | ····[Test] |
28515 | ····public void TestSaveReload() |
28516 | ····{ |
28517 | ········CreateObjects(); |
28518 | ········QueryOwn(); |
28519 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28520 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28521 | ····} |
28522 | ····[Test] |
28523 | ····public void TestSaveReloadNull() |
28524 | ····{ |
28525 | ········CreateObjects(); |
28526 | ········QueryOwn(); |
28527 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28528 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28529 | ········ownVar.RelField = null; |
28530 | ········pm.Save(); |
28531 | ········pm.UnloadCache(); |
28532 | ········QueryOwn(); |
28533 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28534 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28535 | ····} |
28536 | ····[Test] |
28537 | ····public void TestChangeKeyHolderLeft() |
28538 | ····{ |
28539 | ········CreateObjects(); |
28540 | ········QueryOwn(); |
28541 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28542 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28543 | ········int x = ownVar.RelField.Dummy; |
28544 | ········ownVar.Dummy = 4711; |
28545 | ········pm.Save(); |
28546 | ········pm.UnloadCache(); |
28547 | ········QueryOwn(); |
28548 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28549 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28550 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28551 | ····} |
28552 | ····[Test] |
28553 | ····public void TestChangeKeyHolderLeftNoTouch() |
28554 | ····{ |
28555 | ········CreateObjects(); |
28556 | ········QueryOwn(); |
28557 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28558 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28559 | ········ownVar.Dummy = 4711; |
28560 | ········pm.Save(); |
28561 | ········pm.UnloadCache(); |
28562 | ········QueryOwn(); |
28563 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28564 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28566 | ····} |
28567 | ····void CreateObjects() |
28568 | ····{ |
28569 | ········pm.MakePersistent(ownVar); |
28570 | ········pm.MakePersistent(otherVar); |
28571 | ········ownVar.AssignRelation(otherVar); |
28572 | ········pm.Save(); |
28573 | ········pm.UnloadCache(); |
28574 | ····} |
28575 | ····void QueryOwn() |
28576 | ····{ |
28577 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblGuidLeft>(pm); |
28578 | ········ownVar = q.ExecuteSingle(); |
28579 | ····} |
28580 | ····void QueryOther() |
28581 | ····{ |
28582 | ········var q = new NDOQuery<AgrDir1OthpabsNoTblGuidRightBase>(pm); |
28583 | ········otherVar = q.ExecuteSingle(); |
28584 | ····} |
28585 | } |
28586 | |
28587 | |
28588 | [TestFixture] |
28589 | public class TestAgrDir1OthpabsTblGuid : NDOTest |
28590 | { |
28591 | ····AgrDir1OthpabsTblGuidLeft ownVar; |
28592 | ····AgrDir1OthpabsTblGuidRightBase otherVar; |
28593 | ····PersistenceManager pm; |
28594 | ····[SetUp] |
28595 | ····public void Setup() |
28596 | ····{ |
28597 | ········pm = PmFactory.NewPersistenceManager(); |
28598 | ········ownVar = new AgrDir1OthpabsTblGuidLeft(); |
28599 | ········otherVar = new AgrDir1OthpabsTblGuidRightDerived(); |
28600 | ····} |
28601 | ····[TearDown] |
28602 | ····public void TearDown() |
28603 | ····{ |
28604 | ········try |
28605 | ········{ |
28606 | ············pm.UnloadCache(); |
28607 | ············var l = pm.Objects<AgrDir1OthpabsTblGuidLeft>().ResultTable; |
28608 | ············pm.Delete(l); |
28609 | ············pm.Save(); |
28610 | ············pm.UnloadCache(); |
28611 | ············var m = pm.Objects<AgrDir1OthpabsTblGuidRightBase>().ResultTable; |
28612 | ············pm.Delete(m); |
28613 | ············pm.Save(); |
28614 | ············pm.UnloadCache(); |
28615 | ············decimal count; |
28616 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28617 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28618 | ············count = (decimal) new NDOQuery<AgrDir1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28619 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28620 | ········} |
28621 | ········catch (Exception) |
28622 | ········{ |
28623 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28624 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28625 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28626 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28627 | ········} |
28628 | ····} |
28629 | ····[Test] |
28630 | ····public void TestSaveReload() |
28631 | ····{ |
28632 | ········CreateObjects(); |
28633 | ········QueryOwn(); |
28634 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28635 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28636 | ····} |
28637 | ····[Test] |
28638 | ····public void TestSaveReloadNull() |
28639 | ····{ |
28640 | ········CreateObjects(); |
28641 | ········QueryOwn(); |
28642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28643 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28644 | ········ownVar.RelField = null; |
28645 | ········pm.Save(); |
28646 | ········pm.UnloadCache(); |
28647 | ········QueryOwn(); |
28648 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28649 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28650 | ····} |
28651 | ····[Test] |
28652 | ····public void TestChangeKeyHolderLeft() |
28653 | ····{ |
28654 | ········CreateObjects(); |
28655 | ········QueryOwn(); |
28656 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28657 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28658 | ········int x = ownVar.RelField.Dummy; |
28659 | ········ownVar.Dummy = 4711; |
28660 | ········pm.Save(); |
28661 | ········pm.UnloadCache(); |
28662 | ········QueryOwn(); |
28663 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28664 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28665 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28666 | ····} |
28667 | ····[Test] |
28668 | ····public void TestChangeKeyHolderLeftNoTouch() |
28669 | ····{ |
28670 | ········CreateObjects(); |
28671 | ········QueryOwn(); |
28672 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28673 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28674 | ········ownVar.Dummy = 4711; |
28675 | ········pm.Save(); |
28676 | ········pm.UnloadCache(); |
28677 | ········QueryOwn(); |
28678 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28679 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28680 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28681 | ····} |
28682 | ····void CreateObjects() |
28683 | ····{ |
28684 | ········pm.MakePersistent(ownVar); |
28685 | ········pm.MakePersistent(otherVar); |
28686 | ········ownVar.AssignRelation(otherVar); |
28687 | ········pm.Save(); |
28688 | ········pm.UnloadCache(); |
28689 | ····} |
28690 | ····void QueryOwn() |
28691 | ····{ |
28692 | ········var q = new NDOQuery<AgrDir1OthpabsTblGuidLeft>(pm); |
28693 | ········ownVar = q.ExecuteSingle(); |
28694 | ····} |
28695 | ····void QueryOther() |
28696 | ····{ |
28697 | ········var q = new NDOQuery<AgrDir1OthpabsTblGuidRightBase>(pm); |
28698 | ········otherVar = q.ExecuteSingle(); |
28699 | ····} |
28700 | } |
28701 | |
28702 | |
28703 | [TestFixture] |
28704 | public class TestAgrBi11OthpabsNoTblGuid : NDOTest |
28705 | { |
28706 | ····AgrBi11OthpabsNoTblGuidLeft ownVar; |
28707 | ····AgrBi11OthpabsNoTblGuidRightBase otherVar; |
28708 | ····PersistenceManager pm; |
28709 | ····[SetUp] |
28710 | ····public void Setup() |
28711 | ····{ |
28712 | ········pm = PmFactory.NewPersistenceManager(); |
28713 | ········ownVar = new AgrBi11OthpabsNoTblGuidLeft(); |
28714 | ········otherVar = new AgrBi11OthpabsNoTblGuidRightDerived(); |
28715 | ····} |
28716 | ····[TearDown] |
28717 | ····public void TearDown() |
28718 | ····{ |
28719 | ········try |
28720 | ········{ |
28721 | ············pm.UnloadCache(); |
28722 | ············var l = pm.Objects<AgrBi11OthpabsNoTblGuidLeft>().ResultTable; |
28723 | ············pm.Delete(l); |
28724 | ············pm.Save(); |
28725 | ············pm.UnloadCache(); |
28726 | ············var m = pm.Objects<AgrBi11OthpabsNoTblGuidRightBase>().ResultTable; |
28727 | ············pm.Delete(m); |
28728 | ············pm.Save(); |
28729 | ············pm.UnloadCache(); |
28730 | ············decimal count; |
28731 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28732 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28733 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28734 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28735 | ········} |
28736 | ········catch (Exception) |
28737 | ········{ |
28738 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28739 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28740 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28741 | ········} |
28742 | ····} |
28743 | ····[Test] |
28744 | ····public void TestSaveReload() |
28745 | ····{ |
28746 | ········CreateObjects(); |
28747 | ········QueryOwn(); |
28748 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28749 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28750 | ····} |
28751 | ····[Test] |
28752 | ····public void TestSaveReloadNull() |
28753 | ····{ |
28754 | ········CreateObjects(); |
28755 | ········QueryOwn(); |
28756 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28757 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28758 | ········ownVar.RelField = null; |
28759 | ········pm.Save(); |
28760 | ········pm.UnloadCache(); |
28761 | ········QueryOwn(); |
28762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28763 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28764 | ····} |
28765 | ····[Test] |
28766 | ····public void TestChangeKeyHolderLeft() |
28767 | ····{ |
28768 | ········CreateObjects(); |
28769 | ········QueryOwn(); |
28770 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28771 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28772 | ········int x = ownVar.RelField.Dummy; |
28773 | ········ownVar.Dummy = 4711; |
28774 | ········pm.Save(); |
28775 | ········pm.UnloadCache(); |
28776 | ········QueryOwn(); |
28777 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28778 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28779 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28780 | ····} |
28781 | ····[Test] |
28782 | ····public void TestChangeKeyHolderRight() |
28783 | ····{ |
28784 | ········CreateObjects(); |
28785 | ········QueryOther(); |
28786 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28787 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28788 | ········int x = otherVar.RelField.Dummy; |
28789 | ········otherVar.Dummy = 4711; |
28790 | ········pm.Save(); |
28791 | ········pm.UnloadCache(); |
28792 | ········QueryOther(); |
28793 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28794 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28795 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28796 | ····} |
28797 | ····[Test] |
28798 | ····public void TestChangeKeyHolderLeftNoTouch() |
28799 | ····{ |
28800 | ········CreateObjects(); |
28801 | ········QueryOwn(); |
28802 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28803 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28804 | ········ownVar.Dummy = 4711; |
28805 | ········pm.Save(); |
28806 | ········pm.UnloadCache(); |
28807 | ········QueryOwn(); |
28808 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28809 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28810 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28811 | ····} |
28812 | ····[Test] |
28813 | ····public void TestChangeKeyHolderRightNoTouch() |
28814 | ····{ |
28815 | ········CreateObjects(); |
28816 | ········QueryOther(); |
28817 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28818 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28819 | ········otherVar.Dummy = 4711; |
28820 | ········pm.Save(); |
28821 | ········pm.UnloadCache(); |
28822 | ········QueryOther(); |
28823 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28824 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28825 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28826 | ····} |
28827 | ····[Test] |
28828 | ····public void TestRelationHash() |
28829 | ····{ |
28830 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidLeft)); |
28831 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28832 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidRightBase)); |
28833 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28834 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28835 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28836 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsNoTblGuidRightDerived)); |
28837 | ········Relation relderRight = clderRight.FindRelation("relField"); |
28838 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
28839 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
28840 | ····} |
28841 | ····void CreateObjects() |
28842 | ····{ |
28843 | ········pm.MakePersistent(ownVar); |
28844 | ········pm.MakePersistent(otherVar); |
28845 | ········ownVar.AssignRelation(otherVar); |
28846 | ········pm.Save(); |
28847 | ········pm.UnloadCache(); |
28848 | ····} |
28849 | ····void QueryOwn() |
28850 | ····{ |
28851 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblGuidLeft>(pm); |
28852 | ········ownVar = q.ExecuteSingle(); |
28853 | ····} |
28854 | ····void QueryOther() |
28855 | ····{ |
28856 | ········var q = new NDOQuery<AgrBi11OthpabsNoTblGuidRightBase>(pm); |
28857 | ········otherVar = q.ExecuteSingle(); |
28858 | ····} |
28859 | } |
28860 | |
28861 | |
28862 | [TestFixture] |
28863 | public class TestAgrBi11OthpabsTblGuid : NDOTest |
28864 | { |
28865 | ····AgrBi11OthpabsTblGuidLeft ownVar; |
28866 | ····AgrBi11OthpabsTblGuidRightBase otherVar; |
28867 | ····PersistenceManager pm; |
28868 | ····[SetUp] |
28869 | ····public void Setup() |
28870 | ····{ |
28871 | ········pm = PmFactory.NewPersistenceManager(); |
28872 | ········ownVar = new AgrBi11OthpabsTblGuidLeft(); |
28873 | ········otherVar = new AgrBi11OthpabsTblGuidRightDerived(); |
28874 | ····} |
28875 | ····[TearDown] |
28876 | ····public void TearDown() |
28877 | ····{ |
28878 | ········try |
28879 | ········{ |
28880 | ············pm.UnloadCache(); |
28881 | ············var l = pm.Objects<AgrBi11OthpabsTblGuidLeft>().ResultTable; |
28882 | ············pm.Delete(l); |
28883 | ············pm.Save(); |
28884 | ············pm.UnloadCache(); |
28885 | ············var m = pm.Objects<AgrBi11OthpabsTblGuidRightBase>().ResultTable; |
28886 | ············pm.Delete(m); |
28887 | ············pm.Save(); |
28888 | ············pm.UnloadCache(); |
28889 | ············decimal count; |
28890 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28891 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
28892 | ············count = (decimal) new NDOQuery<AgrBi11OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
28893 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
28894 | ········} |
28895 | ········catch (Exception) |
28896 | ········{ |
28897 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
28898 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
28899 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
28900 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
28901 | ········} |
28902 | ····} |
28903 | ····[Test] |
28904 | ····public void TestSaveReload() |
28905 | ····{ |
28906 | ········CreateObjects(); |
28907 | ········QueryOwn(); |
28908 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28909 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28910 | ····} |
28911 | ····[Test] |
28912 | ····public void TestSaveReloadNull() |
28913 | ····{ |
28914 | ········CreateObjects(); |
28915 | ········QueryOwn(); |
28916 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28917 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28918 | ········ownVar.RelField = null; |
28919 | ········pm.Save(); |
28920 | ········pm.UnloadCache(); |
28921 | ········QueryOwn(); |
28922 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28923 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
28924 | ····} |
28925 | ····[Test] |
28926 | ····public void TestChangeKeyHolderLeft() |
28927 | ····{ |
28928 | ········CreateObjects(); |
28929 | ········QueryOwn(); |
28930 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28931 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28932 | ········int x = ownVar.RelField.Dummy; |
28933 | ········ownVar.Dummy = 4711; |
28934 | ········pm.Save(); |
28935 | ········pm.UnloadCache(); |
28936 | ········QueryOwn(); |
28937 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28938 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28939 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28940 | ····} |
28941 | ····[Test] |
28942 | ····public void TestChangeKeyHolderRight() |
28943 | ····{ |
28944 | ········CreateObjects(); |
28945 | ········QueryOther(); |
28946 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28947 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28948 | ········int x = otherVar.RelField.Dummy; |
28949 | ········otherVar.Dummy = 4711; |
28950 | ········pm.Save(); |
28951 | ········pm.UnloadCache(); |
28952 | ········QueryOther(); |
28953 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28954 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28955 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28956 | ····} |
28957 | ····[Test] |
28958 | ····public void TestChangeKeyHolderLeftNoTouch() |
28959 | ····{ |
28960 | ········CreateObjects(); |
28961 | ········QueryOwn(); |
28962 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28963 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28964 | ········ownVar.Dummy = 4711; |
28965 | ········pm.Save(); |
28966 | ········pm.UnloadCache(); |
28967 | ········QueryOwn(); |
28968 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
28969 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28970 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
28971 | ····} |
28972 | ····[Test] |
28973 | ····public void TestChangeKeyHolderRightNoTouch() |
28974 | ····{ |
28975 | ········CreateObjects(); |
28976 | ········QueryOther(); |
28977 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28978 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28979 | ········otherVar.Dummy = 4711; |
28980 | ········pm.Save(); |
28981 | ········pm.UnloadCache(); |
28982 | ········QueryOther(); |
28983 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
28984 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
28985 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
28986 | ····} |
28987 | ····[Test] |
28988 | ····public void TestRelationHash() |
28989 | ····{ |
28990 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidLeft)); |
28991 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
28992 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidRightBase)); |
28993 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
28994 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
28995 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
28996 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OthpabsTblGuidRightDerived)); |
28997 | ········Relation relderRight = clderRight.FindRelation("relField"); |
28998 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
28999 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29000 | ····} |
29001 | ····void CreateObjects() |
29002 | ····{ |
29003 | ········pm.MakePersistent(ownVar); |
29004 | ········pm.MakePersistent(otherVar); |
29005 | ········ownVar.AssignRelation(otherVar); |
29006 | ········pm.Save(); |
29007 | ········pm.UnloadCache(); |
29008 | ····} |
29009 | ····void QueryOwn() |
29010 | ····{ |
29011 | ········var q = new NDOQuery<AgrBi11OthpabsTblGuidLeft>(pm); |
29012 | ········ownVar = q.ExecuteSingle(); |
29013 | ····} |
29014 | ····void QueryOther() |
29015 | ····{ |
29016 | ········var q = new NDOQuery<AgrBi11OthpabsTblGuidRightBase>(pm); |
29017 | ········otherVar = q.ExecuteSingle(); |
29018 | ····} |
29019 | } |
29020 | |
29021 | |
29022 | [TestFixture] |
29023 | public class TestAgrDirnOthpabsTblGuid : NDOTest |
29024 | { |
29025 | ····AgrDirnOthpabsTblGuidLeft ownVar; |
29026 | ····AgrDirnOthpabsTblGuidRightBase otherVar; |
29027 | ····PersistenceManager pm; |
29028 | ····[SetUp] |
29029 | ····public void Setup() |
29030 | ····{ |
29031 | ········pm = PmFactory.NewPersistenceManager(); |
29032 | ········ownVar = new AgrDirnOthpabsTblGuidLeft(); |
29033 | ········otherVar = new AgrDirnOthpabsTblGuidRightDerived(); |
29034 | ····} |
29035 | ····[TearDown] |
29036 | ····public void TearDown() |
29037 | ····{ |
29038 | ········try |
29039 | ········{ |
29040 | ············pm.UnloadCache(); |
29041 | ············var l = pm.Objects<AgrDirnOthpabsTblGuidLeft>().ResultTable; |
29042 | ············pm.Delete(l); |
29043 | ············pm.Save(); |
29044 | ············pm.UnloadCache(); |
29045 | ············var m = pm.Objects<AgrDirnOthpabsTblGuidRightBase>().ResultTable; |
29046 | ············pm.Delete(m); |
29047 | ············pm.Save(); |
29048 | ············pm.UnloadCache(); |
29049 | ············decimal count; |
29050 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29051 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29052 | ············count = (decimal) new NDOQuery<AgrDirnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29053 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29054 | ········} |
29055 | ········catch (Exception) |
29056 | ········{ |
29057 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29058 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29059 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29060 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29061 | ········} |
29062 | ····} |
29063 | ····[Test] |
29064 | ····public void TestSaveReload() |
29065 | ····{ |
29066 | ········CreateObjects(); |
29067 | ········QueryOwn(); |
29068 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29069 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29070 | ····} |
29071 | ····[Test] |
29072 | ····public void TestSaveReloadNull() |
29073 | ····{ |
29074 | ········CreateObjects(); |
29075 | ········QueryOwn(); |
29076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29077 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29078 | ········ownVar.RelField = new List<AgrDirnOthpabsTblGuidRightBase>(); |
29079 | ········pm.Save(); |
29080 | ········pm.UnloadCache(); |
29081 | ········QueryOwn(); |
29082 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29083 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29084 | ····} |
29085 | ····[Test] |
29086 | ····public void TestSaveReloadRemove() |
29087 | ····{ |
29088 | ········CreateObjects(); |
29089 | ········QueryOwn(); |
29090 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29091 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29092 | ········ownVar.RemoveRelatedObject(); |
29093 | ········pm.Save(); |
29094 | ········pm.UnloadCache(); |
29095 | ········QueryOwn(); |
29096 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29097 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29098 | ····} |
29099 | ····void CreateObjects() |
29100 | ····{ |
29101 | ········pm.MakePersistent(ownVar); |
29102 | ········pm.MakePersistent(otherVar); |
29103 | ········ownVar.AssignRelation(otherVar); |
29104 | ········pm.Save(); |
29105 | ········pm.UnloadCache(); |
29106 | ····} |
29107 | ····void QueryOwn() |
29108 | ····{ |
29109 | ········var q = new NDOQuery<AgrDirnOthpabsTblGuidLeft>(pm); |
29110 | ········ownVar = q.ExecuteSingle(); |
29111 | ····} |
29112 | ····void QueryOther() |
29113 | ····{ |
29114 | ········var q = new NDOQuery<AgrDirnOthpabsTblGuidRightBase>(pm); |
29115 | ········otherVar = q.ExecuteSingle(); |
29116 | ····} |
29117 | } |
29118 | |
29119 | |
29120 | [TestFixture] |
29121 | public class TestAgrBin1OthpabsTblGuid : NDOTest |
29122 | { |
29123 | ····AgrBin1OthpabsTblGuidLeft ownVar; |
29124 | ····AgrBin1OthpabsTblGuidRightBase otherVar; |
29125 | ····PersistenceManager pm; |
29126 | ····[SetUp] |
29127 | ····public void Setup() |
29128 | ····{ |
29129 | ········pm = PmFactory.NewPersistenceManager(); |
29130 | ········ownVar = new AgrBin1OthpabsTblGuidLeft(); |
29131 | ········otherVar = new AgrBin1OthpabsTblGuidRightDerived(); |
29132 | ····} |
29133 | ····[TearDown] |
29134 | ····public void TearDown() |
29135 | ····{ |
29136 | ········try |
29137 | ········{ |
29138 | ············pm.UnloadCache(); |
29139 | ············var l = pm.Objects<AgrBin1OthpabsTblGuidLeft>().ResultTable; |
29140 | ············pm.Delete(l); |
29141 | ············pm.Save(); |
29142 | ············pm.UnloadCache(); |
29143 | ············var m = pm.Objects<AgrBin1OthpabsTblGuidRightBase>().ResultTable; |
29144 | ············pm.Delete(m); |
29145 | ············pm.Save(); |
29146 | ············pm.UnloadCache(); |
29147 | ············decimal count; |
29148 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29149 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29150 | ············count = (decimal) new NDOQuery<AgrBin1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29151 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29152 | ········} |
29153 | ········catch (Exception) |
29154 | ········{ |
29155 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29156 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29157 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29158 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29159 | ········} |
29160 | ····} |
29161 | ····[Test] |
29162 | ····public void TestSaveReload() |
29163 | ····{ |
29164 | ········CreateObjects(); |
29165 | ········QueryOwn(); |
29166 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29167 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29168 | ····} |
29169 | ····[Test] |
29170 | ····public void TestSaveReloadNull() |
29171 | ····{ |
29172 | ········CreateObjects(); |
29173 | ········QueryOwn(); |
29174 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29175 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29176 | ········ownVar.RelField = new List<AgrBin1OthpabsTblGuidRightBase>(); |
29177 | ········pm.Save(); |
29178 | ········pm.UnloadCache(); |
29179 | ········QueryOwn(); |
29180 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29181 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29182 | ····} |
29183 | ····[Test] |
29184 | ····public void TestSaveReloadRemove() |
29185 | ····{ |
29186 | ········CreateObjects(); |
29187 | ········QueryOwn(); |
29188 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29189 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29190 | ········ownVar.RemoveRelatedObject(); |
29191 | ········pm.Save(); |
29192 | ········pm.UnloadCache(); |
29193 | ········QueryOwn(); |
29194 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29195 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29196 | ····} |
29197 | ····[Test] |
29198 | ····public void TestChangeKeyHolderRight() |
29199 | ····{ |
29200 | ········CreateObjects(); |
29201 | ········QueryOther(); |
29202 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29203 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29204 | ········int x = otherVar.RelField.Dummy; |
29205 | ········otherVar.Dummy = 4711; |
29206 | ········pm.Save(); |
29207 | ········pm.UnloadCache(); |
29208 | ········QueryOther(); |
29209 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29210 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29211 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29212 | ····} |
29213 | ····[Test] |
29214 | ····public void TestChangeKeyHolderRightNoTouch() |
29215 | ····{ |
29216 | ········CreateObjects(); |
29217 | ········QueryOther(); |
29218 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29219 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29220 | ········otherVar.Dummy = 4711; |
29221 | ········pm.Save(); |
29222 | ········pm.UnloadCache(); |
29223 | ········QueryOther(); |
29224 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29225 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29226 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29227 | ····} |
29228 | ····[Test] |
29229 | ····public void TestRelationHash() |
29230 | ····{ |
29231 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidLeft)); |
29232 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29233 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidRightBase)); |
29234 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29235 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29236 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29237 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OthpabsTblGuidRightDerived)); |
29238 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29239 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29240 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29241 | ····} |
29242 | ····void CreateObjects() |
29243 | ····{ |
29244 | ········pm.MakePersistent(ownVar); |
29245 | ········pm.MakePersistent(otherVar); |
29246 | ········ownVar.AssignRelation(otherVar); |
29247 | ········pm.Save(); |
29248 | ········pm.UnloadCache(); |
29249 | ····} |
29250 | ····void QueryOwn() |
29251 | ····{ |
29252 | ········var q = new NDOQuery<AgrBin1OthpabsTblGuidLeft>(pm); |
29253 | ········ownVar = q.ExecuteSingle(); |
29254 | ····} |
29255 | ····void QueryOther() |
29256 | ····{ |
29257 | ········var q = new NDOQuery<AgrBin1OthpabsTblGuidRightBase>(pm); |
29258 | ········otherVar = q.ExecuteSingle(); |
29259 | ····} |
29260 | } |
29261 | |
29262 | |
29263 | [TestFixture] |
29264 | public class TestAgrBi1nOthpabsNoTblGuid : NDOTest |
29265 | { |
29266 | ····AgrBi1nOthpabsNoTblGuidLeft ownVar; |
29267 | ····AgrBi1nOthpabsNoTblGuidRightBase otherVar; |
29268 | ····PersistenceManager pm; |
29269 | ····[SetUp] |
29270 | ····public void Setup() |
29271 | ····{ |
29272 | ········pm = PmFactory.NewPersistenceManager(); |
29273 | ········ownVar = new AgrBi1nOthpabsNoTblGuidLeft(); |
29274 | ········otherVar = new AgrBi1nOthpabsNoTblGuidRightDerived(); |
29275 | ····} |
29276 | ····[TearDown] |
29277 | ····public void TearDown() |
29278 | ····{ |
29279 | ········try |
29280 | ········{ |
29281 | ············pm.UnloadCache(); |
29282 | ············var l = pm.Objects<AgrBi1nOthpabsNoTblGuidLeft>().ResultTable; |
29283 | ············pm.Delete(l); |
29284 | ············pm.Save(); |
29285 | ············pm.UnloadCache(); |
29286 | ············var m = pm.Objects<AgrBi1nOthpabsNoTblGuidRightBase>().ResultTable; |
29287 | ············pm.Delete(m); |
29288 | ············pm.Save(); |
29289 | ············pm.UnloadCache(); |
29290 | ············decimal count; |
29291 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29292 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29293 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29294 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29295 | ········} |
29296 | ········catch (Exception) |
29297 | ········{ |
29298 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29299 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29300 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29301 | ········} |
29302 | ····} |
29303 | ····[Test] |
29304 | ····public void TestSaveReload() |
29305 | ····{ |
29306 | ········CreateObjects(); |
29307 | ········QueryOwn(); |
29308 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29309 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29310 | ····} |
29311 | ····[Test] |
29312 | ····public void TestSaveReloadNull() |
29313 | ····{ |
29314 | ········CreateObjects(); |
29315 | ········QueryOwn(); |
29316 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29317 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29318 | ········ownVar.RelField = null; |
29319 | ········pm.Save(); |
29320 | ········pm.UnloadCache(); |
29321 | ········QueryOwn(); |
29322 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29323 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29324 | ····} |
29325 | ····[Test] |
29326 | ····public void TestChangeKeyHolderLeft() |
29327 | ····{ |
29328 | ········CreateObjects(); |
29329 | ········QueryOwn(); |
29330 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29331 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29332 | ········int x = ownVar.RelField.Dummy; |
29333 | ········ownVar.Dummy = 4711; |
29334 | ········pm.Save(); |
29335 | ········pm.UnloadCache(); |
29336 | ········QueryOwn(); |
29337 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29338 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29339 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29340 | ····} |
29341 | ····[Test] |
29342 | ····public void TestChangeKeyHolderLeftNoTouch() |
29343 | ····{ |
29344 | ········CreateObjects(); |
29345 | ········QueryOwn(); |
29346 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29347 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29348 | ········ownVar.Dummy = 4711; |
29349 | ········pm.Save(); |
29350 | ········pm.UnloadCache(); |
29351 | ········QueryOwn(); |
29352 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29353 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29354 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29355 | ····} |
29356 | ····[Test] |
29357 | ····public void TestRelationHash() |
29358 | ····{ |
29359 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidLeft)); |
29360 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29361 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidRightBase)); |
29362 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29363 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29364 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29365 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsNoTblGuidRightDerived)); |
29366 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29367 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29368 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29369 | ····} |
29370 | ····void CreateObjects() |
29371 | ····{ |
29372 | ········pm.MakePersistent(ownVar); |
29373 | ········pm.MakePersistent(otherVar); |
29374 | ········ownVar.AssignRelation(otherVar); |
29375 | ········pm.Save(); |
29376 | ········pm.UnloadCache(); |
29377 | ····} |
29378 | ····void QueryOwn() |
29379 | ····{ |
29380 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblGuidLeft>(pm); |
29381 | ········ownVar = q.ExecuteSingle(); |
29382 | ····} |
29383 | ····void QueryOther() |
29384 | ····{ |
29385 | ········var q = new NDOQuery<AgrBi1nOthpabsNoTblGuidRightBase>(pm); |
29386 | ········otherVar = q.ExecuteSingle(); |
29387 | ····} |
29388 | } |
29389 | |
29390 | |
29391 | [TestFixture] |
29392 | public class TestAgrBi1nOthpabsTblGuid : NDOTest |
29393 | { |
29394 | ····AgrBi1nOthpabsTblGuidLeft ownVar; |
29395 | ····AgrBi1nOthpabsTblGuidRightBase otherVar; |
29396 | ····PersistenceManager pm; |
29397 | ····[SetUp] |
29398 | ····public void Setup() |
29399 | ····{ |
29400 | ········pm = PmFactory.NewPersistenceManager(); |
29401 | ········ownVar = new AgrBi1nOthpabsTblGuidLeft(); |
29402 | ········otherVar = new AgrBi1nOthpabsTblGuidRightDerived(); |
29403 | ····} |
29404 | ····[TearDown] |
29405 | ····public void TearDown() |
29406 | ····{ |
29407 | ········try |
29408 | ········{ |
29409 | ············pm.UnloadCache(); |
29410 | ············var l = pm.Objects<AgrBi1nOthpabsTblGuidLeft>().ResultTable; |
29411 | ············pm.Delete(l); |
29412 | ············pm.Save(); |
29413 | ············pm.UnloadCache(); |
29414 | ············var m = pm.Objects<AgrBi1nOthpabsTblGuidRightBase>().ResultTable; |
29415 | ············pm.Delete(m); |
29416 | ············pm.Save(); |
29417 | ············pm.UnloadCache(); |
29418 | ············decimal count; |
29419 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29420 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29421 | ············count = (decimal) new NDOQuery<AgrBi1nOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29422 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29423 | ········} |
29424 | ········catch (Exception) |
29425 | ········{ |
29426 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29427 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29428 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29429 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29430 | ········} |
29431 | ····} |
29432 | ····[Test] |
29433 | ····public void TestSaveReload() |
29434 | ····{ |
29435 | ········CreateObjects(); |
29436 | ········QueryOwn(); |
29437 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29438 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29439 | ····} |
29440 | ····[Test] |
29441 | ····public void TestSaveReloadNull() |
29442 | ····{ |
29443 | ········CreateObjects(); |
29444 | ········QueryOwn(); |
29445 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29446 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29447 | ········ownVar.RelField = null; |
29448 | ········pm.Save(); |
29449 | ········pm.UnloadCache(); |
29450 | ········QueryOwn(); |
29451 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29452 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29453 | ····} |
29454 | ····[Test] |
29455 | ····public void TestChangeKeyHolderLeft() |
29456 | ····{ |
29457 | ········CreateObjects(); |
29458 | ········QueryOwn(); |
29459 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29460 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29461 | ········int x = ownVar.RelField.Dummy; |
29462 | ········ownVar.Dummy = 4711; |
29463 | ········pm.Save(); |
29464 | ········pm.UnloadCache(); |
29465 | ········QueryOwn(); |
29466 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29467 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29468 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29469 | ····} |
29470 | ····[Test] |
29471 | ····public void TestChangeKeyHolderLeftNoTouch() |
29472 | ····{ |
29473 | ········CreateObjects(); |
29474 | ········QueryOwn(); |
29475 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29476 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29477 | ········ownVar.Dummy = 4711; |
29478 | ········pm.Save(); |
29479 | ········pm.UnloadCache(); |
29480 | ········QueryOwn(); |
29481 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29482 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29483 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29484 | ····} |
29485 | ····[Test] |
29486 | ····public void TestRelationHash() |
29487 | ····{ |
29488 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidLeft)); |
29489 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29490 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidRightBase)); |
29491 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29492 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29493 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29494 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOthpabsTblGuidRightDerived)); |
29495 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29496 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29497 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29498 | ····} |
29499 | ····void CreateObjects() |
29500 | ····{ |
29501 | ········pm.MakePersistent(ownVar); |
29502 | ········pm.MakePersistent(otherVar); |
29503 | ········ownVar.AssignRelation(otherVar); |
29504 | ········pm.Save(); |
29505 | ········pm.UnloadCache(); |
29506 | ····} |
29507 | ····void QueryOwn() |
29508 | ····{ |
29509 | ········var q = new NDOQuery<AgrBi1nOthpabsTblGuidLeft>(pm); |
29510 | ········ownVar = q.ExecuteSingle(); |
29511 | ····} |
29512 | ····void QueryOther() |
29513 | ····{ |
29514 | ········var q = new NDOQuery<AgrBi1nOthpabsTblGuidRightBase>(pm); |
29515 | ········otherVar = q.ExecuteSingle(); |
29516 | ····} |
29517 | } |
29518 | |
29519 | |
29520 | [TestFixture] |
29521 | public class TestAgrBinnOthpabsTblGuid : NDOTest |
29522 | { |
29523 | ····AgrBinnOthpabsTblGuidLeft ownVar; |
29524 | ····AgrBinnOthpabsTblGuidRightBase otherVar; |
29525 | ····PersistenceManager pm; |
29526 | ····[SetUp] |
29527 | ····public void Setup() |
29528 | ····{ |
29529 | ········pm = PmFactory.NewPersistenceManager(); |
29530 | ········ownVar = new AgrBinnOthpabsTblGuidLeft(); |
29531 | ········otherVar = new AgrBinnOthpabsTblGuidRightDerived(); |
29532 | ····} |
29533 | ····[TearDown] |
29534 | ····public void TearDown() |
29535 | ····{ |
29536 | ········try |
29537 | ········{ |
29538 | ············pm.UnloadCache(); |
29539 | ············var l = pm.Objects<AgrBinnOthpabsTblGuidLeft>().ResultTable; |
29540 | ············pm.Delete(l); |
29541 | ············pm.Save(); |
29542 | ············pm.UnloadCache(); |
29543 | ············var m = pm.Objects<AgrBinnOthpabsTblGuidRightBase>().ResultTable; |
29544 | ············pm.Delete(m); |
29545 | ············pm.Save(); |
29546 | ············pm.UnloadCache(); |
29547 | ············decimal count; |
29548 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29549 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29550 | ············count = (decimal) new NDOQuery<AgrBinnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29551 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29552 | ········} |
29553 | ········catch (Exception) |
29554 | ········{ |
29555 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29556 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29557 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29558 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29559 | ········} |
29560 | ····} |
29561 | ····[Test] |
29562 | ····public void TestSaveReload() |
29563 | ····{ |
29564 | ········CreateObjects(); |
29565 | ········QueryOwn(); |
29566 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29567 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29568 | ····} |
29569 | ····[Test] |
29570 | ····public void TestSaveReloadNull() |
29571 | ····{ |
29572 | ········CreateObjects(); |
29573 | ········QueryOwn(); |
29574 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29575 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29576 | ········ownVar.RelField = new List<AgrBinnOthpabsTblGuidRightBase>(); |
29577 | ········pm.Save(); |
29578 | ········pm.UnloadCache(); |
29579 | ········QueryOwn(); |
29580 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29581 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29582 | ····} |
29583 | ····[Test] |
29584 | ····public void TestSaveReloadRemove() |
29585 | ····{ |
29586 | ········CreateObjects(); |
29587 | ········QueryOwn(); |
29588 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29589 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29590 | ········ownVar.RemoveRelatedObject(); |
29591 | ········pm.Save(); |
29592 | ········pm.UnloadCache(); |
29593 | ········QueryOwn(); |
29594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29595 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
29596 | ····} |
29597 | ····[Test] |
29598 | ····public void TestRelationHash() |
29599 | ····{ |
29600 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidLeft)); |
29601 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29602 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidRightBase)); |
29603 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29604 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29605 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29606 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOthpabsTblGuidRightDerived)); |
29607 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29608 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29609 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29610 | ····} |
29611 | ····void CreateObjects() |
29612 | ····{ |
29613 | ········pm.MakePersistent(ownVar); |
29614 | ········pm.MakePersistent(otherVar); |
29615 | ········ownVar.AssignRelation(otherVar); |
29616 | ········pm.Save(); |
29617 | ········pm.UnloadCache(); |
29618 | ····} |
29619 | ····void QueryOwn() |
29620 | ····{ |
29621 | ········var q = new NDOQuery<AgrBinnOthpabsTblGuidLeft>(pm); |
29622 | ········ownVar = q.ExecuteSingle(); |
29623 | ····} |
29624 | ····void QueryOther() |
29625 | ····{ |
29626 | ········var q = new NDOQuery<AgrBinnOthpabsTblGuidRightBase>(pm); |
29627 | ········otherVar = q.ExecuteSingle(); |
29628 | ····} |
29629 | } |
29630 | |
29631 | |
29632 | [TestFixture] |
29633 | public class TestCmpDir1OthpabsNoTblGuid : NDOTest |
29634 | { |
29635 | ····CmpDir1OthpabsNoTblGuidLeft ownVar; |
29636 | ····CmpDir1OthpabsNoTblGuidRightBase otherVar; |
29637 | ····PersistenceManager pm; |
29638 | ····[SetUp] |
29639 | ····public void Setup() |
29640 | ····{ |
29641 | ········pm = PmFactory.NewPersistenceManager(); |
29642 | ········ownVar = new CmpDir1OthpabsNoTblGuidLeft(); |
29643 | ········otherVar = new CmpDir1OthpabsNoTblGuidRightDerived(); |
29644 | ····} |
29645 | ····[TearDown] |
29646 | ····public void TearDown() |
29647 | ····{ |
29648 | ········try |
29649 | ········{ |
29650 | ············pm.UnloadCache(); |
29651 | ············var l = pm.Objects<CmpDir1OthpabsNoTblGuidLeft>().ResultTable; |
29652 | ············pm.Delete(l); |
29653 | ············pm.Save(); |
29654 | ············pm.UnloadCache(); |
29655 | ············decimal count; |
29656 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29657 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29658 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29659 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29660 | ········} |
29661 | ········catch (Exception) |
29662 | ········{ |
29663 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29664 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29665 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29666 | ········} |
29667 | ····} |
29668 | ····[Test] |
29669 | ····public void TestSaveReload() |
29670 | ····{ |
29671 | ········CreateObjects(); |
29672 | ········QueryOwn(); |
29673 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29674 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29675 | ····} |
29676 | ····[Test] |
29677 | ····public void TestSaveReloadNull() |
29678 | ····{ |
29679 | ········CreateObjects(); |
29680 | ········QueryOwn(); |
29681 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29682 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29683 | ········ownVar.RelField = null; |
29684 | ········pm.Save(); |
29685 | ········pm.UnloadCache(); |
29686 | ········QueryOwn(); |
29687 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29688 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29689 | ····} |
29690 | ····[Test] |
29691 | ····public void TestChangeKeyHolderLeft() |
29692 | ····{ |
29693 | ········CreateObjects(); |
29694 | ········QueryOwn(); |
29695 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29696 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29697 | ········int x = ownVar.RelField.Dummy; |
29698 | ········ownVar.Dummy = 4711; |
29699 | ········pm.Save(); |
29700 | ········pm.UnloadCache(); |
29701 | ········QueryOwn(); |
29702 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29703 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29704 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29705 | ····} |
29706 | ····[Test] |
29707 | ····public void TestChangeKeyHolderLeftNoTouch() |
29708 | ····{ |
29709 | ········CreateObjects(); |
29710 | ········QueryOwn(); |
29711 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29712 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29713 | ········ownVar.Dummy = 4711; |
29714 | ········pm.Save(); |
29715 | ········pm.UnloadCache(); |
29716 | ········QueryOwn(); |
29717 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29718 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29719 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29720 | ····} |
29721 | ····void CreateObjects() |
29722 | ····{ |
29723 | ········pm.MakePersistent(ownVar); |
29724 | ········ownVar.AssignRelation(otherVar); |
29725 | ········pm.Save(); |
29726 | ········pm.UnloadCache(); |
29727 | ····} |
29728 | ····void QueryOwn() |
29729 | ····{ |
29730 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblGuidLeft>(pm); |
29731 | ········ownVar = q.ExecuteSingle(); |
29732 | ····} |
29733 | ····void QueryOther() |
29734 | ····{ |
29735 | ········var q = new NDOQuery<CmpDir1OthpabsNoTblGuidRightBase>(pm); |
29736 | ········otherVar = q.ExecuteSingle(); |
29737 | ····} |
29738 | } |
29739 | |
29740 | |
29741 | [TestFixture] |
29742 | public class TestCmpDir1OthpabsTblGuid : NDOTest |
29743 | { |
29744 | ····CmpDir1OthpabsTblGuidLeft ownVar; |
29745 | ····CmpDir1OthpabsTblGuidRightBase otherVar; |
29746 | ····PersistenceManager pm; |
29747 | ····[SetUp] |
29748 | ····public void Setup() |
29749 | ····{ |
29750 | ········pm = PmFactory.NewPersistenceManager(); |
29751 | ········ownVar = new CmpDir1OthpabsTblGuidLeft(); |
29752 | ········otherVar = new CmpDir1OthpabsTblGuidRightDerived(); |
29753 | ····} |
29754 | ····[TearDown] |
29755 | ····public void TearDown() |
29756 | ····{ |
29757 | ········try |
29758 | ········{ |
29759 | ············pm.UnloadCache(); |
29760 | ············var l = pm.Objects<CmpDir1OthpabsTblGuidLeft>().ResultTable; |
29761 | ············pm.Delete(l); |
29762 | ············pm.Save(); |
29763 | ············pm.UnloadCache(); |
29764 | ············decimal count; |
29765 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29766 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29767 | ············count = (decimal) new NDOQuery<CmpDir1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29768 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29769 | ········} |
29770 | ········catch (Exception) |
29771 | ········{ |
29772 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29773 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29774 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29775 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
29776 | ········} |
29777 | ····} |
29778 | ····[Test] |
29779 | ····public void TestSaveReload() |
29780 | ····{ |
29781 | ········CreateObjects(); |
29782 | ········QueryOwn(); |
29783 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29784 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29785 | ····} |
29786 | ····[Test] |
29787 | ····public void TestSaveReloadNull() |
29788 | ····{ |
29789 | ········CreateObjects(); |
29790 | ········QueryOwn(); |
29791 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29792 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29793 | ········ownVar.RelField = null; |
29794 | ········pm.Save(); |
29795 | ········pm.UnloadCache(); |
29796 | ········QueryOwn(); |
29797 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29798 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29799 | ····} |
29800 | ····[Test] |
29801 | ····public void TestChangeKeyHolderLeft() |
29802 | ····{ |
29803 | ········CreateObjects(); |
29804 | ········QueryOwn(); |
29805 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29806 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29807 | ········int x = ownVar.RelField.Dummy; |
29808 | ········ownVar.Dummy = 4711; |
29809 | ········pm.Save(); |
29810 | ········pm.UnloadCache(); |
29811 | ········QueryOwn(); |
29812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29813 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29814 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29815 | ····} |
29816 | ····[Test] |
29817 | ····public void TestChangeKeyHolderLeftNoTouch() |
29818 | ····{ |
29819 | ········CreateObjects(); |
29820 | ········QueryOwn(); |
29821 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29822 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29823 | ········ownVar.Dummy = 4711; |
29824 | ········pm.Save(); |
29825 | ········pm.UnloadCache(); |
29826 | ········QueryOwn(); |
29827 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29828 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29829 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29830 | ····} |
29831 | ····void CreateObjects() |
29832 | ····{ |
29833 | ········pm.MakePersistent(ownVar); |
29834 | ········ownVar.AssignRelation(otherVar); |
29835 | ········pm.Save(); |
29836 | ········pm.UnloadCache(); |
29837 | ····} |
29838 | ····void QueryOwn() |
29839 | ····{ |
29840 | ········var q = new NDOQuery<CmpDir1OthpabsTblGuidLeft>(pm); |
29841 | ········ownVar = q.ExecuteSingle(); |
29842 | ····} |
29843 | ····void QueryOther() |
29844 | ····{ |
29845 | ········var q = new NDOQuery<CmpDir1OthpabsTblGuidRightBase>(pm); |
29846 | ········otherVar = q.ExecuteSingle(); |
29847 | ····} |
29848 | } |
29849 | |
29850 | |
29851 | [TestFixture] |
29852 | public class TestCmpBi11OthpabsNoTblGuid : NDOTest |
29853 | { |
29854 | ····CmpBi11OthpabsNoTblGuidLeft ownVar; |
29855 | ····CmpBi11OthpabsNoTblGuidRightBase otherVar; |
29856 | ····PersistenceManager pm; |
29857 | ····[SetUp] |
29858 | ····public void Setup() |
29859 | ····{ |
29860 | ········pm = PmFactory.NewPersistenceManager(); |
29861 | ········ownVar = new CmpBi11OthpabsNoTblGuidLeft(); |
29862 | ········otherVar = new CmpBi11OthpabsNoTblGuidRightDerived(); |
29863 | ····} |
29864 | ····[TearDown] |
29865 | ····public void TearDown() |
29866 | ····{ |
29867 | ········try |
29868 | ········{ |
29869 | ············pm.UnloadCache(); |
29870 | ············var l = pm.Objects<CmpBi11OthpabsNoTblGuidLeft>().ResultTable; |
29871 | ············pm.Delete(l); |
29872 | ············pm.Save(); |
29873 | ············pm.UnloadCache(); |
29874 | ············decimal count; |
29875 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29876 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
29877 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
29878 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
29879 | ········} |
29880 | ········catch (Exception) |
29881 | ········{ |
29882 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
29883 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
29884 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
29885 | ········} |
29886 | ····} |
29887 | ····[Test] |
29888 | ····public void TestSaveReload() |
29889 | ····{ |
29890 | ········CreateObjects(); |
29891 | ········QueryOwn(); |
29892 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29893 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29894 | ····} |
29895 | ····[Test] |
29896 | ····public void TestSaveReloadNull() |
29897 | ····{ |
29898 | ········CreateObjects(); |
29899 | ········QueryOwn(); |
29900 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29901 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29902 | ········ownVar.RelField = null; |
29903 | ········pm.Save(); |
29904 | ········pm.UnloadCache(); |
29905 | ········QueryOwn(); |
29906 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29907 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
29908 | ····} |
29909 | ····[Test] |
29910 | ····public void TestChangeKeyHolderLeft() |
29911 | ····{ |
29912 | ········CreateObjects(); |
29913 | ········QueryOwn(); |
29914 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29915 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29916 | ········int x = ownVar.RelField.Dummy; |
29917 | ········ownVar.Dummy = 4711; |
29918 | ········pm.Save(); |
29919 | ········pm.UnloadCache(); |
29920 | ········QueryOwn(); |
29921 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29922 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29923 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29924 | ····} |
29925 | ····[Test] |
29926 | ····public void TestChangeKeyHolderRight() |
29927 | ····{ |
29928 | ········CreateObjects(); |
29929 | ········QueryOther(); |
29930 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29931 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29932 | ········int x = otherVar.RelField.Dummy; |
29933 | ········otherVar.Dummy = 4711; |
29934 | ········pm.Save(); |
29935 | ········pm.UnloadCache(); |
29936 | ········QueryOther(); |
29937 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29938 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29939 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29940 | ····} |
29941 | ····[Test] |
29942 | ····public void TestChangeKeyHolderLeftNoTouch() |
29943 | ····{ |
29944 | ········CreateObjects(); |
29945 | ········QueryOwn(); |
29946 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29947 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29948 | ········ownVar.Dummy = 4711; |
29949 | ········pm.Save(); |
29950 | ········pm.UnloadCache(); |
29951 | ········QueryOwn(); |
29952 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
29953 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29954 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
29955 | ····} |
29956 | ····[Test] |
29957 | ····public void TestChangeKeyHolderRightNoTouch() |
29958 | ····{ |
29959 | ········CreateObjects(); |
29960 | ········QueryOther(); |
29961 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29962 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29963 | ········otherVar.Dummy = 4711; |
29964 | ········pm.Save(); |
29965 | ········pm.UnloadCache(); |
29966 | ········QueryOther(); |
29967 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
29968 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
29969 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
29970 | ····} |
29971 | ····[Test] |
29972 | ····public void TestRelationHash() |
29973 | ····{ |
29974 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidLeft)); |
29975 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
29976 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidRightBase)); |
29977 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
29978 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
29979 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
29980 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsNoTblGuidRightDerived)); |
29981 | ········Relation relderRight = clderRight.FindRelation("relField"); |
29982 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
29983 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
29984 | ····} |
29985 | ····void CreateObjects() |
29986 | ····{ |
29987 | ········pm.MakePersistent(ownVar); |
29988 | ········ownVar.AssignRelation(otherVar); |
29989 | ········pm.Save(); |
29990 | ········pm.UnloadCache(); |
29991 | ····} |
29992 | ····void QueryOwn() |
29993 | ····{ |
29994 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblGuidLeft>(pm); |
29995 | ········ownVar = q.ExecuteSingle(); |
29996 | ····} |
29997 | ····void QueryOther() |
29998 | ····{ |
29999 | ········var q = new NDOQuery<CmpBi11OthpabsNoTblGuidRightBase>(pm); |
30000 | ········otherVar = q.ExecuteSingle(); |
30001 | ····} |
30002 | } |
30003 | |
30004 | |
30005 | [TestFixture] |
30006 | public class TestCmpBi11OthpabsTblGuid : NDOTest |
30007 | { |
30008 | ····CmpBi11OthpabsTblGuidLeft ownVar; |
30009 | ····CmpBi11OthpabsTblGuidRightBase otherVar; |
30010 | ····PersistenceManager pm; |
30011 | ····[SetUp] |
30012 | ····public void Setup() |
30013 | ····{ |
30014 | ········pm = PmFactory.NewPersistenceManager(); |
30015 | ········ownVar = new CmpBi11OthpabsTblGuidLeft(); |
30016 | ········otherVar = new CmpBi11OthpabsTblGuidRightDerived(); |
30017 | ····} |
30018 | ····[TearDown] |
30019 | ····public void TearDown() |
30020 | ····{ |
30021 | ········try |
30022 | ········{ |
30023 | ············pm.UnloadCache(); |
30024 | ············var l = pm.Objects<CmpBi11OthpabsTblGuidLeft>().ResultTable; |
30025 | ············pm.Delete(l); |
30026 | ············pm.Save(); |
30027 | ············pm.UnloadCache(); |
30028 | ············decimal count; |
30029 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30030 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30031 | ············count = (decimal) new NDOQuery<CmpBi11OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30032 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30033 | ········} |
30034 | ········catch (Exception) |
30035 | ········{ |
30036 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30037 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30038 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30039 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30040 | ········} |
30041 | ····} |
30042 | ····[Test] |
30043 | ····public void TestSaveReload() |
30044 | ····{ |
30045 | ········CreateObjects(); |
30046 | ········QueryOwn(); |
30047 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30048 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30049 | ····} |
30050 | ····[Test] |
30051 | ····public void TestSaveReloadNull() |
30052 | ····{ |
30053 | ········CreateObjects(); |
30054 | ········QueryOwn(); |
30055 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30056 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30057 | ········ownVar.RelField = null; |
30058 | ········pm.Save(); |
30059 | ········pm.UnloadCache(); |
30060 | ········QueryOwn(); |
30061 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30062 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30063 | ····} |
30064 | ····[Test] |
30065 | ····public void TestChangeKeyHolderLeft() |
30066 | ····{ |
30067 | ········CreateObjects(); |
30068 | ········QueryOwn(); |
30069 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30070 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30071 | ········int x = ownVar.RelField.Dummy; |
30072 | ········ownVar.Dummy = 4711; |
30073 | ········pm.Save(); |
30074 | ········pm.UnloadCache(); |
30075 | ········QueryOwn(); |
30076 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30077 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30078 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30079 | ····} |
30080 | ····[Test] |
30081 | ····public void TestChangeKeyHolderRight() |
30082 | ····{ |
30083 | ········CreateObjects(); |
30084 | ········QueryOther(); |
30085 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30086 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30087 | ········int x = otherVar.RelField.Dummy; |
30088 | ········otherVar.Dummy = 4711; |
30089 | ········pm.Save(); |
30090 | ········pm.UnloadCache(); |
30091 | ········QueryOther(); |
30092 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30093 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30094 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30095 | ····} |
30096 | ····[Test] |
30097 | ····public void TestChangeKeyHolderLeftNoTouch() |
30098 | ····{ |
30099 | ········CreateObjects(); |
30100 | ········QueryOwn(); |
30101 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30102 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30103 | ········ownVar.Dummy = 4711; |
30104 | ········pm.Save(); |
30105 | ········pm.UnloadCache(); |
30106 | ········QueryOwn(); |
30107 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30108 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30109 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30110 | ····} |
30111 | ····[Test] |
30112 | ····public void TestChangeKeyHolderRightNoTouch() |
30113 | ····{ |
30114 | ········CreateObjects(); |
30115 | ········QueryOther(); |
30116 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30117 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30118 | ········otherVar.Dummy = 4711; |
30119 | ········pm.Save(); |
30120 | ········pm.UnloadCache(); |
30121 | ········QueryOther(); |
30122 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30123 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30124 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30125 | ····} |
30126 | ····[Test] |
30127 | ····public void TestRelationHash() |
30128 | ····{ |
30129 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidLeft)); |
30130 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30131 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidRightBase)); |
30132 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30133 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30134 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30135 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OthpabsTblGuidRightDerived)); |
30136 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30137 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30138 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30139 | ····} |
30140 | ····void CreateObjects() |
30141 | ····{ |
30142 | ········pm.MakePersistent(ownVar); |
30143 | ········ownVar.AssignRelation(otherVar); |
30144 | ········pm.Save(); |
30145 | ········pm.UnloadCache(); |
30146 | ····} |
30147 | ····void QueryOwn() |
30148 | ····{ |
30149 | ········var q = new NDOQuery<CmpBi11OthpabsTblGuidLeft>(pm); |
30150 | ········ownVar = q.ExecuteSingle(); |
30151 | ····} |
30152 | ····void QueryOther() |
30153 | ····{ |
30154 | ········var q = new NDOQuery<CmpBi11OthpabsTblGuidRightBase>(pm); |
30155 | ········otherVar = q.ExecuteSingle(); |
30156 | ····} |
30157 | } |
30158 | |
30159 | |
30160 | [TestFixture] |
30161 | public class TestCmpDirnOthpabsTblGuid : NDOTest |
30162 | { |
30163 | ····CmpDirnOthpabsTblGuidLeft ownVar; |
30164 | ····CmpDirnOthpabsTblGuidRightBase otherVar; |
30165 | ····PersistenceManager pm; |
30166 | ····[SetUp] |
30167 | ····public void Setup() |
30168 | ····{ |
30169 | ········pm = PmFactory.NewPersistenceManager(); |
30170 | ········ownVar = new CmpDirnOthpabsTblGuidLeft(); |
30171 | ········otherVar = new CmpDirnOthpabsTblGuidRightDerived(); |
30172 | ····} |
30173 | ····[TearDown] |
30174 | ····public void TearDown() |
30175 | ····{ |
30176 | ········try |
30177 | ········{ |
30178 | ············pm.UnloadCache(); |
30179 | ············var l = pm.Objects<CmpDirnOthpabsTblGuidLeft>().ResultTable; |
30180 | ············pm.Delete(l); |
30181 | ············pm.Save(); |
30182 | ············pm.UnloadCache(); |
30183 | ············decimal count; |
30184 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30185 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30186 | ············count = (decimal) new NDOQuery<CmpDirnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30187 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30188 | ········} |
30189 | ········catch (Exception) |
30190 | ········{ |
30191 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30192 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30193 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30194 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30195 | ········} |
30196 | ····} |
30197 | ····[Test] |
30198 | ····public void TestSaveReload() |
30199 | ····{ |
30200 | ········CreateObjects(); |
30201 | ········QueryOwn(); |
30202 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30203 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30204 | ····} |
30205 | ····[Test] |
30206 | ····public void TestSaveReloadNull() |
30207 | ····{ |
30208 | ········CreateObjects(); |
30209 | ········QueryOwn(); |
30210 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30211 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30212 | ········ownVar.RelField = new List<CmpDirnOthpabsTblGuidRightBase>(); |
30213 | ········pm.Save(); |
30214 | ········pm.UnloadCache(); |
30215 | ········QueryOwn(); |
30216 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30217 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30218 | ····} |
30219 | ····[Test] |
30220 | ····public void TestSaveReloadRemove() |
30221 | ····{ |
30222 | ········CreateObjects(); |
30223 | ········QueryOwn(); |
30224 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30225 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30226 | ········ownVar.RemoveRelatedObject(); |
30227 | ········pm.Save(); |
30228 | ········pm.UnloadCache(); |
30229 | ········QueryOwn(); |
30230 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30231 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30232 | ····} |
30233 | ····void CreateObjects() |
30234 | ····{ |
30235 | ········pm.MakePersistent(ownVar); |
30236 | ········ownVar.AssignRelation(otherVar); |
30237 | ········pm.Save(); |
30238 | ········pm.UnloadCache(); |
30239 | ····} |
30240 | ····void QueryOwn() |
30241 | ····{ |
30242 | ········var q = new NDOQuery<CmpDirnOthpabsTblGuidLeft>(pm); |
30243 | ········ownVar = q.ExecuteSingle(); |
30244 | ····} |
30245 | ····void QueryOther() |
30246 | ····{ |
30247 | ········var q = new NDOQuery<CmpDirnOthpabsTblGuidRightBase>(pm); |
30248 | ········otherVar = q.ExecuteSingle(); |
30249 | ····} |
30250 | } |
30251 | |
30252 | |
30253 | [TestFixture] |
30254 | public class TestCmpBin1OthpabsTblGuid : NDOTest |
30255 | { |
30256 | ····CmpBin1OthpabsTblGuidLeft ownVar; |
30257 | ····CmpBin1OthpabsTblGuidRightBase otherVar; |
30258 | ····PersistenceManager pm; |
30259 | ····[SetUp] |
30260 | ····public void Setup() |
30261 | ····{ |
30262 | ········pm = PmFactory.NewPersistenceManager(); |
30263 | ········ownVar = new CmpBin1OthpabsTblGuidLeft(); |
30264 | ········otherVar = new CmpBin1OthpabsTblGuidRightDerived(); |
30265 | ····} |
30266 | ····[TearDown] |
30267 | ····public void TearDown() |
30268 | ····{ |
30269 | ········try |
30270 | ········{ |
30271 | ············pm.UnloadCache(); |
30272 | ············var l = pm.Objects<CmpBin1OthpabsTblGuidLeft>().ResultTable; |
30273 | ············pm.Delete(l); |
30274 | ············pm.Save(); |
30275 | ············pm.UnloadCache(); |
30276 | ············decimal count; |
30277 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30278 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30279 | ············count = (decimal) new NDOQuery<CmpBin1OthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30280 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30281 | ········} |
30282 | ········catch (Exception) |
30283 | ········{ |
30284 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30285 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30286 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30287 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30288 | ········} |
30289 | ····} |
30290 | ····[Test] |
30291 | ····public void TestSaveReload() |
30292 | ····{ |
30293 | ········CreateObjects(); |
30294 | ········QueryOwn(); |
30295 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30296 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30297 | ····} |
30298 | ····[Test] |
30299 | ····public void TestSaveReloadNull() |
30300 | ····{ |
30301 | ········CreateObjects(); |
30302 | ········QueryOwn(); |
30303 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30304 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30305 | ········ownVar.RelField = new List<CmpBin1OthpabsTblGuidRightBase>(); |
30306 | ········pm.Save(); |
30307 | ········pm.UnloadCache(); |
30308 | ········QueryOwn(); |
30309 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30310 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30311 | ····} |
30312 | ····[Test] |
30313 | ····public void TestSaveReloadRemove() |
30314 | ····{ |
30315 | ········CreateObjects(); |
30316 | ········QueryOwn(); |
30317 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30318 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30319 | ········ownVar.RemoveRelatedObject(); |
30320 | ········pm.Save(); |
30321 | ········pm.UnloadCache(); |
30322 | ········QueryOwn(); |
30323 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30324 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30325 | ····} |
30326 | ····[Test] |
30327 | ····public void TestChangeKeyHolderRight() |
30328 | ····{ |
30329 | ········CreateObjects(); |
30330 | ········QueryOther(); |
30331 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30332 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30333 | ········int x = otherVar.RelField.Dummy; |
30334 | ········otherVar.Dummy = 4711; |
30335 | ········pm.Save(); |
30336 | ········pm.UnloadCache(); |
30337 | ········QueryOther(); |
30338 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30339 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30340 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30341 | ····} |
30342 | ····[Test] |
30343 | ····public void TestChangeKeyHolderRightNoTouch() |
30344 | ····{ |
30345 | ········CreateObjects(); |
30346 | ········QueryOther(); |
30347 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30348 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30349 | ········otherVar.Dummy = 4711; |
30350 | ········pm.Save(); |
30351 | ········pm.UnloadCache(); |
30352 | ········QueryOther(); |
30353 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
30354 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30355 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
30356 | ····} |
30357 | ····[Test] |
30358 | ····public void TestRelationHash() |
30359 | ····{ |
30360 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidLeft)); |
30361 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30362 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidRightBase)); |
30363 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30364 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30365 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30366 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OthpabsTblGuidRightDerived)); |
30367 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30368 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30369 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30370 | ····} |
30371 | ····void CreateObjects() |
30372 | ····{ |
30373 | ········pm.MakePersistent(ownVar); |
30374 | ········ownVar.AssignRelation(otherVar); |
30375 | ········pm.Save(); |
30376 | ········pm.UnloadCache(); |
30377 | ····} |
30378 | ····void QueryOwn() |
30379 | ····{ |
30380 | ········var q = new NDOQuery<CmpBin1OthpabsTblGuidLeft>(pm); |
30381 | ········ownVar = q.ExecuteSingle(); |
30382 | ····} |
30383 | ····void QueryOther() |
30384 | ····{ |
30385 | ········var q = new NDOQuery<CmpBin1OthpabsTblGuidRightBase>(pm); |
30386 | ········otherVar = q.ExecuteSingle(); |
30387 | ····} |
30388 | } |
30389 | |
30390 | |
30391 | [TestFixture] |
30392 | public class TestCmpBi1nOthpabsNoTblGuid : NDOTest |
30393 | { |
30394 | ····CmpBi1nOthpabsNoTblGuidLeft ownVar; |
30395 | ····CmpBi1nOthpabsNoTblGuidRightBase otherVar; |
30396 | ····PersistenceManager pm; |
30397 | ····[SetUp] |
30398 | ····public void Setup() |
30399 | ····{ |
30400 | ········pm = PmFactory.NewPersistenceManager(); |
30401 | ········ownVar = new CmpBi1nOthpabsNoTblGuidLeft(); |
30402 | ········otherVar = new CmpBi1nOthpabsNoTblGuidRightDerived(); |
30403 | ····} |
30404 | ····[TearDown] |
30405 | ····public void TearDown() |
30406 | ····{ |
30407 | ········try |
30408 | ········{ |
30409 | ············pm.UnloadCache(); |
30410 | ············var l = pm.Objects<CmpBi1nOthpabsNoTblGuidLeft>().ResultTable; |
30411 | ············pm.Delete(l); |
30412 | ············pm.Save(); |
30413 | ············pm.UnloadCache(); |
30414 | ············decimal count; |
30415 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30416 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30417 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30418 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30419 | ········} |
30420 | ········catch (Exception) |
30421 | ········{ |
30422 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30423 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30424 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30425 | ········} |
30426 | ····} |
30427 | ····[Test] |
30428 | ····public void TestSaveReload() |
30429 | ····{ |
30430 | ········CreateObjects(); |
30431 | ········QueryOwn(); |
30432 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30433 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30434 | ····} |
30435 | ····[Test] |
30436 | ····public void TestSaveReloadNull() |
30437 | ····{ |
30438 | ········CreateObjects(); |
30439 | ········QueryOwn(); |
30440 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30441 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30442 | ········ownVar.RelField = null; |
30443 | ········pm.Save(); |
30444 | ········pm.UnloadCache(); |
30445 | ········QueryOwn(); |
30446 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30447 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30448 | ····} |
30449 | ····[Test] |
30450 | ····public void TestChangeKeyHolderLeft() |
30451 | ····{ |
30452 | ········CreateObjects(); |
30453 | ········QueryOwn(); |
30454 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30455 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30456 | ········int x = ownVar.RelField.Dummy; |
30457 | ········ownVar.Dummy = 4711; |
30458 | ········pm.Save(); |
30459 | ········pm.UnloadCache(); |
30460 | ········QueryOwn(); |
30461 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30462 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30463 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30464 | ····} |
30465 | ····[Test] |
30466 | ····public void TestChangeKeyHolderLeftNoTouch() |
30467 | ····{ |
30468 | ········CreateObjects(); |
30469 | ········QueryOwn(); |
30470 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30471 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30472 | ········ownVar.Dummy = 4711; |
30473 | ········pm.Save(); |
30474 | ········pm.UnloadCache(); |
30475 | ········QueryOwn(); |
30476 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30477 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30478 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30479 | ····} |
30480 | ····[Test] |
30481 | ····public void TestRelationHash() |
30482 | ····{ |
30483 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidLeft)); |
30484 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30485 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidRightBase)); |
30486 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30487 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30488 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30489 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsNoTblGuidRightDerived)); |
30490 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30491 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30492 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30493 | ····} |
30494 | ····void CreateObjects() |
30495 | ····{ |
30496 | ········pm.MakePersistent(ownVar); |
30497 | ········ownVar.AssignRelation(otherVar); |
30498 | ········pm.Save(); |
30499 | ········pm.UnloadCache(); |
30500 | ····} |
30501 | ····void QueryOwn() |
30502 | ····{ |
30503 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblGuidLeft>(pm); |
30504 | ········ownVar = q.ExecuteSingle(); |
30505 | ····} |
30506 | ····void QueryOther() |
30507 | ····{ |
30508 | ········var q = new NDOQuery<CmpBi1nOthpabsNoTblGuidRightBase>(pm); |
30509 | ········otherVar = q.ExecuteSingle(); |
30510 | ····} |
30511 | } |
30512 | |
30513 | |
30514 | [TestFixture] |
30515 | public class TestCmpBi1nOthpabsTblGuid : NDOTest |
30516 | { |
30517 | ····CmpBi1nOthpabsTblGuidLeft ownVar; |
30518 | ····CmpBi1nOthpabsTblGuidRightBase otherVar; |
30519 | ····PersistenceManager pm; |
30520 | ····[SetUp] |
30521 | ····public void Setup() |
30522 | ····{ |
30523 | ········pm = PmFactory.NewPersistenceManager(); |
30524 | ········ownVar = new CmpBi1nOthpabsTblGuidLeft(); |
30525 | ········otherVar = new CmpBi1nOthpabsTblGuidRightDerived(); |
30526 | ····} |
30527 | ····[TearDown] |
30528 | ····public void TearDown() |
30529 | ····{ |
30530 | ········try |
30531 | ········{ |
30532 | ············pm.UnloadCache(); |
30533 | ············var l = pm.Objects<CmpBi1nOthpabsTblGuidLeft>().ResultTable; |
30534 | ············pm.Delete(l); |
30535 | ············pm.Save(); |
30536 | ············pm.UnloadCache(); |
30537 | ············decimal count; |
30538 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30539 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30540 | ············count = (decimal) new NDOQuery<CmpBi1nOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30541 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30542 | ········} |
30543 | ········catch (Exception) |
30544 | ········{ |
30545 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30546 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30547 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30548 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30549 | ········} |
30550 | ····} |
30551 | ····[Test] |
30552 | ····public void TestSaveReload() |
30553 | ····{ |
30554 | ········CreateObjects(); |
30555 | ········QueryOwn(); |
30556 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30557 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30558 | ····} |
30559 | ····[Test] |
30560 | ····public void TestSaveReloadNull() |
30561 | ····{ |
30562 | ········CreateObjects(); |
30563 | ········QueryOwn(); |
30564 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30565 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30566 | ········ownVar.RelField = null; |
30567 | ········pm.Save(); |
30568 | ········pm.UnloadCache(); |
30569 | ········QueryOwn(); |
30570 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30571 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30572 | ····} |
30573 | ····[Test] |
30574 | ····public void TestChangeKeyHolderLeft() |
30575 | ····{ |
30576 | ········CreateObjects(); |
30577 | ········QueryOwn(); |
30578 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30579 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30580 | ········int x = ownVar.RelField.Dummy; |
30581 | ········ownVar.Dummy = 4711; |
30582 | ········pm.Save(); |
30583 | ········pm.UnloadCache(); |
30584 | ········QueryOwn(); |
30585 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30586 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30587 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30588 | ····} |
30589 | ····[Test] |
30590 | ····public void TestChangeKeyHolderLeftNoTouch() |
30591 | ····{ |
30592 | ········CreateObjects(); |
30593 | ········QueryOwn(); |
30594 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30595 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30596 | ········ownVar.Dummy = 4711; |
30597 | ········pm.Save(); |
30598 | ········pm.UnloadCache(); |
30599 | ········QueryOwn(); |
30600 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30601 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30602 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30603 | ····} |
30604 | ····[Test] |
30605 | ····public void TestRelationHash() |
30606 | ····{ |
30607 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidLeft)); |
30608 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30609 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidRightBase)); |
30610 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30611 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30612 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30613 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOthpabsTblGuidRightDerived)); |
30614 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30615 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30616 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30617 | ····} |
30618 | ····void CreateObjects() |
30619 | ····{ |
30620 | ········pm.MakePersistent(ownVar); |
30621 | ········ownVar.AssignRelation(otherVar); |
30622 | ········pm.Save(); |
30623 | ········pm.UnloadCache(); |
30624 | ····} |
30625 | ····void QueryOwn() |
30626 | ····{ |
30627 | ········var q = new NDOQuery<CmpBi1nOthpabsTblGuidLeft>(pm); |
30628 | ········ownVar = q.ExecuteSingle(); |
30629 | ····} |
30630 | ····void QueryOther() |
30631 | ····{ |
30632 | ········var q = new NDOQuery<CmpBi1nOthpabsTblGuidRightBase>(pm); |
30633 | ········otherVar = q.ExecuteSingle(); |
30634 | ····} |
30635 | } |
30636 | |
30637 | |
30638 | [TestFixture] |
30639 | public class TestCmpBinnOthpabsTblGuid : NDOTest |
30640 | { |
30641 | ····CmpBinnOthpabsTblGuidLeft ownVar; |
30642 | ····CmpBinnOthpabsTblGuidRightBase otherVar; |
30643 | ····PersistenceManager pm; |
30644 | ····[SetUp] |
30645 | ····public void Setup() |
30646 | ····{ |
30647 | ········pm = PmFactory.NewPersistenceManager(); |
30648 | ········ownVar = new CmpBinnOthpabsTblGuidLeft(); |
30649 | ········otherVar = new CmpBinnOthpabsTblGuidRightDerived(); |
30650 | ····} |
30651 | ····[TearDown] |
30652 | ····public void TearDown() |
30653 | ····{ |
30654 | ········try |
30655 | ········{ |
30656 | ············pm.UnloadCache(); |
30657 | ············var l = pm.Objects<CmpBinnOthpabsTblGuidLeft>().ResultTable; |
30658 | ············pm.Delete(l); |
30659 | ············pm.Save(); |
30660 | ············pm.UnloadCache(); |
30661 | ············decimal count; |
30662 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblGuidLeft>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30663 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30664 | ············count = (decimal) new NDOQuery<CmpBinnOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30665 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30666 | ········} |
30667 | ········catch (Exception) |
30668 | ········{ |
30669 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30670 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30671 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30672 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30673 | ········} |
30674 | ····} |
30675 | ····[Test] |
30676 | ····public void TestSaveReload() |
30677 | ····{ |
30678 | ········CreateObjects(); |
30679 | ········QueryOwn(); |
30680 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30681 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30682 | ····} |
30683 | ····[Test] |
30684 | ····public void TestSaveReloadNull() |
30685 | ····{ |
30686 | ········CreateObjects(); |
30687 | ········QueryOwn(); |
30688 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30689 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30690 | ········ownVar.RelField = new List<CmpBinnOthpabsTblGuidRightBase>(); |
30691 | ········pm.Save(); |
30692 | ········pm.UnloadCache(); |
30693 | ········QueryOwn(); |
30694 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30695 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30696 | ····} |
30697 | ····[Test] |
30698 | ····public void TestSaveReloadRemove() |
30699 | ····{ |
30700 | ········CreateObjects(); |
30701 | ········QueryOwn(); |
30702 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30703 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30704 | ········ownVar.RemoveRelatedObject(); |
30705 | ········pm.Save(); |
30706 | ········pm.UnloadCache(); |
30707 | ········QueryOwn(); |
30708 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30709 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
30710 | ····} |
30711 | ····[Test] |
30712 | ····public void TestRelationHash() |
30713 | ····{ |
30714 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidLeft)); |
30715 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
30716 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidRightBase)); |
30717 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
30718 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
30719 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
30720 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOthpabsTblGuidRightDerived)); |
30721 | ········Relation relderRight = clderRight.FindRelation("relField"); |
30722 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
30723 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
30724 | ····} |
30725 | ····void CreateObjects() |
30726 | ····{ |
30727 | ········pm.MakePersistent(ownVar); |
30728 | ········ownVar.AssignRelation(otherVar); |
30729 | ········pm.Save(); |
30730 | ········pm.UnloadCache(); |
30731 | ····} |
30732 | ····void QueryOwn() |
30733 | ····{ |
30734 | ········var q = new NDOQuery<CmpBinnOthpabsTblGuidLeft>(pm); |
30735 | ········ownVar = q.ExecuteSingle(); |
30736 | ····} |
30737 | ····void QueryOther() |
30738 | ····{ |
30739 | ········var q = new NDOQuery<CmpBinnOthpabsTblGuidRightBase>(pm); |
30740 | ········otherVar = q.ExecuteSingle(); |
30741 | ····} |
30742 | } |
30743 | |
30744 | |
30745 | [TestFixture] |
30746 | public class TestAgrDir1OwnpabsOthpabsNoTblGuid : NDOTest |
30747 | { |
30748 | ····AgrDir1OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
30749 | ····AgrDir1OwnpabsOthpabsNoTblGuidRightBase otherVar; |
30750 | ····PersistenceManager pm; |
30751 | ····[SetUp] |
30752 | ····public void Setup() |
30753 | ····{ |
30754 | ········pm = PmFactory.NewPersistenceManager(); |
30755 | ········ownVar = new AgrDir1OwnpabsOthpabsNoTblGuidLeftDerived(); |
30756 | ········otherVar = new AgrDir1OwnpabsOthpabsNoTblGuidRightDerived(); |
30757 | ····} |
30758 | ····[TearDown] |
30759 | ····public void TearDown() |
30760 | ····{ |
30761 | ········try |
30762 | ········{ |
30763 | ············pm.UnloadCache(); |
30764 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
30765 | ············pm.Delete(l); |
30766 | ············pm.Save(); |
30767 | ············pm.UnloadCache(); |
30768 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>().ResultTable; |
30769 | ············pm.Delete(m); |
30770 | ············pm.Save(); |
30771 | ············pm.UnloadCache(); |
30772 | ············decimal count; |
30773 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30774 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30775 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30776 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30777 | ········} |
30778 | ········catch (Exception) |
30779 | ········{ |
30780 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30781 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30782 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30783 | ········} |
30784 | ····} |
30785 | ····[Test] |
30786 | ····public void TestSaveReload() |
30787 | ····{ |
30788 | ········CreateObjects(); |
30789 | ········QueryOwn(); |
30790 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30791 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30792 | ····} |
30793 | ····[Test] |
30794 | ····public void TestSaveReloadNull() |
30795 | ····{ |
30796 | ········CreateObjects(); |
30797 | ········QueryOwn(); |
30798 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30799 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30800 | ········ownVar.RelField = null; |
30801 | ········pm.Save(); |
30802 | ········pm.UnloadCache(); |
30803 | ········QueryOwn(); |
30804 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30805 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30806 | ····} |
30807 | ····[Test] |
30808 | ····public void TestChangeKeyHolderLeft() |
30809 | ····{ |
30810 | ········CreateObjects(); |
30811 | ········QueryOwn(); |
30812 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30813 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30814 | ········int x = ownVar.RelField.Dummy; |
30815 | ········ownVar.Dummy = 4711; |
30816 | ········pm.Save(); |
30817 | ········pm.UnloadCache(); |
30818 | ········QueryOwn(); |
30819 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30820 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30821 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30822 | ····} |
30823 | ····[Test] |
30824 | ····public void TestChangeKeyHolderLeftNoTouch() |
30825 | ····{ |
30826 | ········CreateObjects(); |
30827 | ········QueryOwn(); |
30828 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30829 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30830 | ········ownVar.Dummy = 4711; |
30831 | ········pm.Save(); |
30832 | ········pm.UnloadCache(); |
30833 | ········QueryOwn(); |
30834 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30835 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30836 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30837 | ····} |
30838 | ····void CreateObjects() |
30839 | ····{ |
30840 | ········pm.MakePersistent(ownVar); |
30841 | ········pm.MakePersistent(otherVar); |
30842 | ········ownVar.AssignRelation(otherVar); |
30843 | ········pm.Save(); |
30844 | ········pm.UnloadCache(); |
30845 | ····} |
30846 | ····void QueryOwn() |
30847 | ····{ |
30848 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
30849 | ········ownVar = q.ExecuteSingle(); |
30850 | ····} |
30851 | ····void QueryOther() |
30852 | ····{ |
30853 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsNoTblGuidRightBase>(pm); |
30854 | ········otherVar = q.ExecuteSingle(); |
30855 | ····} |
30856 | } |
30857 | |
30858 | |
30859 | [TestFixture] |
30860 | public class TestAgrDir1OwnpabsOthpabsTblGuid : NDOTest |
30861 | { |
30862 | ····AgrDir1OwnpabsOthpabsTblGuidLeftBase ownVar; |
30863 | ····AgrDir1OwnpabsOthpabsTblGuidRightBase otherVar; |
30864 | ····PersistenceManager pm; |
30865 | ····[SetUp] |
30866 | ····public void Setup() |
30867 | ····{ |
30868 | ········pm = PmFactory.NewPersistenceManager(); |
30869 | ········ownVar = new AgrDir1OwnpabsOthpabsTblGuidLeftDerived(); |
30870 | ········otherVar = new AgrDir1OwnpabsOthpabsTblGuidRightDerived(); |
30871 | ····} |
30872 | ····[TearDown] |
30873 | ····public void TearDown() |
30874 | ····{ |
30875 | ········try |
30876 | ········{ |
30877 | ············pm.UnloadCache(); |
30878 | ············var l = pm.Objects<AgrDir1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
30879 | ············pm.Delete(l); |
30880 | ············pm.Save(); |
30881 | ············pm.UnloadCache(); |
30882 | ············var m = pm.Objects<AgrDir1OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
30883 | ············pm.Delete(m); |
30884 | ············pm.Save(); |
30885 | ············pm.UnloadCache(); |
30886 | ············decimal count; |
30887 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30888 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
30889 | ············count = (decimal) new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
30890 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
30891 | ········} |
30892 | ········catch (Exception) |
30893 | ········{ |
30894 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
30895 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
30896 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
30897 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
30898 | ········} |
30899 | ····} |
30900 | ····[Test] |
30901 | ····public void TestSaveReload() |
30902 | ····{ |
30903 | ········CreateObjects(); |
30904 | ········QueryOwn(); |
30905 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30906 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30907 | ····} |
30908 | ····[Test] |
30909 | ····public void TestSaveReloadNull() |
30910 | ····{ |
30911 | ········CreateObjects(); |
30912 | ········QueryOwn(); |
30913 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30914 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30915 | ········ownVar.RelField = null; |
30916 | ········pm.Save(); |
30917 | ········pm.UnloadCache(); |
30918 | ········QueryOwn(); |
30919 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30920 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
30921 | ····} |
30922 | ····[Test] |
30923 | ····public void TestChangeKeyHolderLeft() |
30924 | ····{ |
30925 | ········CreateObjects(); |
30926 | ········QueryOwn(); |
30927 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30928 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30929 | ········int x = ownVar.RelField.Dummy; |
30930 | ········ownVar.Dummy = 4711; |
30931 | ········pm.Save(); |
30932 | ········pm.UnloadCache(); |
30933 | ········QueryOwn(); |
30934 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30935 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30936 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30937 | ····} |
30938 | ····[Test] |
30939 | ····public void TestChangeKeyHolderLeftNoTouch() |
30940 | ····{ |
30941 | ········CreateObjects(); |
30942 | ········QueryOwn(); |
30943 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30944 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30945 | ········ownVar.Dummy = 4711; |
30946 | ········pm.Save(); |
30947 | ········pm.UnloadCache(); |
30948 | ········QueryOwn(); |
30949 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
30950 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
30951 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
30952 | ····} |
30953 | ····void CreateObjects() |
30954 | ····{ |
30955 | ········pm.MakePersistent(ownVar); |
30956 | ········pm.MakePersistent(otherVar); |
30957 | ········ownVar.AssignRelation(otherVar); |
30958 | ········pm.Save(); |
30959 | ········pm.UnloadCache(); |
30960 | ····} |
30961 | ····void QueryOwn() |
30962 | ····{ |
30963 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidLeftBase>(pm); |
30964 | ········ownVar = q.ExecuteSingle(); |
30965 | ····} |
30966 | ····void QueryOther() |
30967 | ····{ |
30968 | ········var q = new NDOQuery<AgrDir1OwnpabsOthpabsTblGuidRightBase>(pm); |
30969 | ········otherVar = q.ExecuteSingle(); |
30970 | ····} |
30971 | } |
30972 | |
30973 | |
30974 | [TestFixture] |
30975 | public class TestAgrBi11OwnpabsOthpabsNoTblGuid : NDOTest |
30976 | { |
30977 | ····AgrBi11OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
30978 | ····AgrBi11OwnpabsOthpabsNoTblGuidRightBase otherVar; |
30979 | ····PersistenceManager pm; |
30980 | ····[SetUp] |
30981 | ····public void Setup() |
30982 | ····{ |
30983 | ········pm = PmFactory.NewPersistenceManager(); |
30984 | ········ownVar = new AgrBi11OwnpabsOthpabsNoTblGuidLeftDerived(); |
30985 | ········otherVar = new AgrBi11OwnpabsOthpabsNoTblGuidRightDerived(); |
30986 | ····} |
30987 | ····[TearDown] |
30988 | ····public void TearDown() |
30989 | ····{ |
30990 | ········try |
30991 | ········{ |
30992 | ············pm.UnloadCache(); |
30993 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
30994 | ············pm.Delete(l); |
30995 | ············pm.Save(); |
30996 | ············pm.UnloadCache(); |
30997 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>().ResultTable; |
30998 | ············pm.Delete(m); |
30999 | ············pm.Save(); |
31000 | ············pm.UnloadCache(); |
31001 | ············decimal count; |
31002 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31003 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31004 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31005 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31006 | ········} |
31007 | ········catch (Exception) |
31008 | ········{ |
31009 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31010 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31011 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31012 | ········} |
31013 | ····} |
31014 | ····[Test] |
31015 | ····public void TestSaveReload() |
31016 | ····{ |
31017 | ········CreateObjects(); |
31018 | ········QueryOwn(); |
31019 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31020 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31021 | ····} |
31022 | ····[Test] |
31023 | ····public void TestSaveReloadNull() |
31024 | ····{ |
31025 | ········CreateObjects(); |
31026 | ········QueryOwn(); |
31027 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31028 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31029 | ········ownVar.RelField = null; |
31030 | ········pm.Save(); |
31031 | ········pm.UnloadCache(); |
31032 | ········QueryOwn(); |
31033 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31034 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31035 | ····} |
31036 | ····[Test] |
31037 | ····public void TestChangeKeyHolderLeft() |
31038 | ····{ |
31039 | ········CreateObjects(); |
31040 | ········QueryOwn(); |
31041 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31042 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31043 | ········int x = ownVar.RelField.Dummy; |
31044 | ········ownVar.Dummy = 4711; |
31045 | ········pm.Save(); |
31046 | ········pm.UnloadCache(); |
31047 | ········QueryOwn(); |
31048 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31049 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31050 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31051 | ····} |
31052 | ····[Test] |
31053 | ····public void TestChangeKeyHolderRight() |
31054 | ····{ |
31055 | ········CreateObjects(); |
31056 | ········QueryOther(); |
31057 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31058 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31059 | ········int x = otherVar.RelField.Dummy; |
31060 | ········otherVar.Dummy = 4711; |
31061 | ········pm.Save(); |
31062 | ········pm.UnloadCache(); |
31063 | ········QueryOther(); |
31064 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31065 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31066 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31067 | ····} |
31068 | ····[Test] |
31069 | ····public void TestChangeKeyHolderLeftNoTouch() |
31070 | ····{ |
31071 | ········CreateObjects(); |
31072 | ········QueryOwn(); |
31073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31074 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31075 | ········ownVar.Dummy = 4711; |
31076 | ········pm.Save(); |
31077 | ········pm.UnloadCache(); |
31078 | ········QueryOwn(); |
31079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31080 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31081 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31082 | ····} |
31083 | ····[Test] |
31084 | ····public void TestChangeKeyHolderRightNoTouch() |
31085 | ····{ |
31086 | ········CreateObjects(); |
31087 | ········QueryOther(); |
31088 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31089 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31090 | ········otherVar.Dummy = 4711; |
31091 | ········pm.Save(); |
31092 | ········pm.UnloadCache(); |
31093 | ········QueryOther(); |
31094 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31095 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31096 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31097 | ····} |
31098 | ····[Test] |
31099 | ····public void TestRelationHash() |
31100 | ····{ |
31101 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidLeftBase)); |
31102 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31103 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidRightBase)); |
31104 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31105 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31106 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31107 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidLeftDerived)); |
31108 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31109 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31110 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31111 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsNoTblGuidRightDerived)); |
31112 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31113 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31114 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31115 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31116 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31117 | ····} |
31118 | ····void CreateObjects() |
31119 | ····{ |
31120 | ········pm.MakePersistent(ownVar); |
31121 | ········pm.MakePersistent(otherVar); |
31122 | ········ownVar.AssignRelation(otherVar); |
31123 | ········pm.Save(); |
31124 | ········pm.UnloadCache(); |
31125 | ····} |
31126 | ····void QueryOwn() |
31127 | ····{ |
31128 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
31129 | ········ownVar = q.ExecuteSingle(); |
31130 | ····} |
31131 | ····void QueryOther() |
31132 | ····{ |
31133 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsNoTblGuidRightBase>(pm); |
31134 | ········otherVar = q.ExecuteSingle(); |
31135 | ····} |
31136 | } |
31137 | |
31138 | |
31139 | [TestFixture] |
31140 | public class TestAgrBi11OwnpabsOthpabsTblGuid : NDOTest |
31141 | { |
31142 | ····AgrBi11OwnpabsOthpabsTblGuidLeftBase ownVar; |
31143 | ····AgrBi11OwnpabsOthpabsTblGuidRightBase otherVar; |
31144 | ····PersistenceManager pm; |
31145 | ····[SetUp] |
31146 | ····public void Setup() |
31147 | ····{ |
31148 | ········pm = PmFactory.NewPersistenceManager(); |
31149 | ········ownVar = new AgrBi11OwnpabsOthpabsTblGuidLeftDerived(); |
31150 | ········otherVar = new AgrBi11OwnpabsOthpabsTblGuidRightDerived(); |
31151 | ····} |
31152 | ····[TearDown] |
31153 | ····public void TearDown() |
31154 | ····{ |
31155 | ········try |
31156 | ········{ |
31157 | ············pm.UnloadCache(); |
31158 | ············var l = pm.Objects<AgrBi11OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31159 | ············pm.Delete(l); |
31160 | ············pm.Save(); |
31161 | ············pm.UnloadCache(); |
31162 | ············var m = pm.Objects<AgrBi11OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31163 | ············pm.Delete(m); |
31164 | ············pm.Save(); |
31165 | ············pm.UnloadCache(); |
31166 | ············decimal count; |
31167 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31168 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31169 | ············count = (decimal) new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31170 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31171 | ········} |
31172 | ········catch (Exception) |
31173 | ········{ |
31174 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31175 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31176 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31177 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31178 | ········} |
31179 | ····} |
31180 | ····[Test] |
31181 | ····public void TestSaveReload() |
31182 | ····{ |
31183 | ········CreateObjects(); |
31184 | ········QueryOwn(); |
31185 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31186 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31187 | ····} |
31188 | ····[Test] |
31189 | ····public void TestSaveReloadNull() |
31190 | ····{ |
31191 | ········CreateObjects(); |
31192 | ········QueryOwn(); |
31193 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31194 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31195 | ········ownVar.RelField = null; |
31196 | ········pm.Save(); |
31197 | ········pm.UnloadCache(); |
31198 | ········QueryOwn(); |
31199 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31200 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31201 | ····} |
31202 | ····[Test] |
31203 | ····public void TestChangeKeyHolderLeft() |
31204 | ····{ |
31205 | ········CreateObjects(); |
31206 | ········QueryOwn(); |
31207 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31208 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31209 | ········int x = ownVar.RelField.Dummy; |
31210 | ········ownVar.Dummy = 4711; |
31211 | ········pm.Save(); |
31212 | ········pm.UnloadCache(); |
31213 | ········QueryOwn(); |
31214 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31215 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31216 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31217 | ····} |
31218 | ····[Test] |
31219 | ····public void TestChangeKeyHolderRight() |
31220 | ····{ |
31221 | ········CreateObjects(); |
31222 | ········QueryOther(); |
31223 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31224 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31225 | ········int x = otherVar.RelField.Dummy; |
31226 | ········otherVar.Dummy = 4711; |
31227 | ········pm.Save(); |
31228 | ········pm.UnloadCache(); |
31229 | ········QueryOther(); |
31230 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31231 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31232 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31233 | ····} |
31234 | ····[Test] |
31235 | ····public void TestChangeKeyHolderLeftNoTouch() |
31236 | ····{ |
31237 | ········CreateObjects(); |
31238 | ········QueryOwn(); |
31239 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31240 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31241 | ········ownVar.Dummy = 4711; |
31242 | ········pm.Save(); |
31243 | ········pm.UnloadCache(); |
31244 | ········QueryOwn(); |
31245 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31246 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31247 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31248 | ····} |
31249 | ····[Test] |
31250 | ····public void TestChangeKeyHolderRightNoTouch() |
31251 | ····{ |
31252 | ········CreateObjects(); |
31253 | ········QueryOther(); |
31254 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31255 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31256 | ········otherVar.Dummy = 4711; |
31257 | ········pm.Save(); |
31258 | ········pm.UnloadCache(); |
31259 | ········QueryOther(); |
31260 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31261 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31262 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31263 | ····} |
31264 | ····[Test] |
31265 | ····public void TestRelationHash() |
31266 | ····{ |
31267 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidLeftBase)); |
31268 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31269 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidRightBase)); |
31270 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31271 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31272 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31273 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidLeftDerived)); |
31274 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31275 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31276 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31277 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi11OwnpabsOthpabsTblGuidRightDerived)); |
31278 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31279 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31280 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31281 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31282 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31283 | ····} |
31284 | ····void CreateObjects() |
31285 | ····{ |
31286 | ········pm.MakePersistent(ownVar); |
31287 | ········pm.MakePersistent(otherVar); |
31288 | ········ownVar.AssignRelation(otherVar); |
31289 | ········pm.Save(); |
31290 | ········pm.UnloadCache(); |
31291 | ····} |
31292 | ····void QueryOwn() |
31293 | ····{ |
31294 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidLeftBase>(pm); |
31295 | ········ownVar = q.ExecuteSingle(); |
31296 | ····} |
31297 | ····void QueryOther() |
31298 | ····{ |
31299 | ········var q = new NDOQuery<AgrBi11OwnpabsOthpabsTblGuidRightBase>(pm); |
31300 | ········otherVar = q.ExecuteSingle(); |
31301 | ····} |
31302 | } |
31303 | |
31304 | |
31305 | [TestFixture] |
31306 | public class TestAgrDirnOwnpabsOthpabsTblGuid : NDOTest |
31307 | { |
31308 | ····AgrDirnOwnpabsOthpabsTblGuidLeftBase ownVar; |
31309 | ····AgrDirnOwnpabsOthpabsTblGuidRightBase otherVar; |
31310 | ····PersistenceManager pm; |
31311 | ····[SetUp] |
31312 | ····public void Setup() |
31313 | ····{ |
31314 | ········pm = PmFactory.NewPersistenceManager(); |
31315 | ········ownVar = new AgrDirnOwnpabsOthpabsTblGuidLeftDerived(); |
31316 | ········otherVar = new AgrDirnOwnpabsOthpabsTblGuidRightDerived(); |
31317 | ····} |
31318 | ····[TearDown] |
31319 | ····public void TearDown() |
31320 | ····{ |
31321 | ········try |
31322 | ········{ |
31323 | ············pm.UnloadCache(); |
31324 | ············var l = pm.Objects<AgrDirnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31325 | ············pm.Delete(l); |
31326 | ············pm.Save(); |
31327 | ············pm.UnloadCache(); |
31328 | ············var m = pm.Objects<AgrDirnOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31329 | ············pm.Delete(m); |
31330 | ············pm.Save(); |
31331 | ············pm.UnloadCache(); |
31332 | ············decimal count; |
31333 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31334 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31335 | ············count = (decimal) new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31336 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31337 | ········} |
31338 | ········catch (Exception) |
31339 | ········{ |
31340 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31341 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31342 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31343 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31344 | ········} |
31345 | ····} |
31346 | ····[Test] |
31347 | ····public void TestSaveReload() |
31348 | ····{ |
31349 | ········CreateObjects(); |
31350 | ········QueryOwn(); |
31351 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31352 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31353 | ····} |
31354 | ····[Test] |
31355 | ····public void TestSaveReloadNull() |
31356 | ····{ |
31357 | ········CreateObjects(); |
31358 | ········QueryOwn(); |
31359 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31360 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31361 | ········ownVar.RelField = new List<AgrDirnOwnpabsOthpabsTblGuidRightBase>(); |
31362 | ········pm.Save(); |
31363 | ········pm.UnloadCache(); |
31364 | ········QueryOwn(); |
31365 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31366 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31367 | ····} |
31368 | ····[Test] |
31369 | ····public void TestSaveReloadRemove() |
31370 | ····{ |
31371 | ········CreateObjects(); |
31372 | ········QueryOwn(); |
31373 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31374 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31375 | ········ownVar.RemoveRelatedObject(); |
31376 | ········pm.Save(); |
31377 | ········pm.UnloadCache(); |
31378 | ········QueryOwn(); |
31379 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31380 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31381 | ····} |
31382 | ····void CreateObjects() |
31383 | ····{ |
31384 | ········pm.MakePersistent(ownVar); |
31385 | ········pm.MakePersistent(otherVar); |
31386 | ········ownVar.AssignRelation(otherVar); |
31387 | ········pm.Save(); |
31388 | ········pm.UnloadCache(); |
31389 | ····} |
31390 | ····void QueryOwn() |
31391 | ····{ |
31392 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidLeftBase>(pm); |
31393 | ········ownVar = q.ExecuteSingle(); |
31394 | ····} |
31395 | ····void QueryOther() |
31396 | ····{ |
31397 | ········var q = new NDOQuery<AgrDirnOwnpabsOthpabsTblGuidRightBase>(pm); |
31398 | ········otherVar = q.ExecuteSingle(); |
31399 | ····} |
31400 | } |
31401 | |
31402 | |
31403 | [TestFixture] |
31404 | public class TestAgrBin1OwnpabsOthpabsTblGuid : NDOTest |
31405 | { |
31406 | ····AgrBin1OwnpabsOthpabsTblGuidLeftBase ownVar; |
31407 | ····AgrBin1OwnpabsOthpabsTblGuidRightBase otherVar; |
31408 | ····PersistenceManager pm; |
31409 | ····[SetUp] |
31410 | ····public void Setup() |
31411 | ····{ |
31412 | ········pm = PmFactory.NewPersistenceManager(); |
31413 | ········ownVar = new AgrBin1OwnpabsOthpabsTblGuidLeftDerived(); |
31414 | ········otherVar = new AgrBin1OwnpabsOthpabsTblGuidRightDerived(); |
31415 | ····} |
31416 | ····[TearDown] |
31417 | ····public void TearDown() |
31418 | ····{ |
31419 | ········try |
31420 | ········{ |
31421 | ············pm.UnloadCache(); |
31422 | ············var l = pm.Objects<AgrBin1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31423 | ············pm.Delete(l); |
31424 | ············pm.Save(); |
31425 | ············pm.UnloadCache(); |
31426 | ············var m = pm.Objects<AgrBin1OwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31427 | ············pm.Delete(m); |
31428 | ············pm.Save(); |
31429 | ············pm.UnloadCache(); |
31430 | ············decimal count; |
31431 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31432 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31433 | ············count = (decimal) new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31434 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31435 | ········} |
31436 | ········catch (Exception) |
31437 | ········{ |
31438 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31439 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31440 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31441 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31442 | ········} |
31443 | ····} |
31444 | ····[Test] |
31445 | ····public void TestSaveReload() |
31446 | ····{ |
31447 | ········CreateObjects(); |
31448 | ········QueryOwn(); |
31449 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31450 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31451 | ····} |
31452 | ····[Test] |
31453 | ····public void TestSaveReloadNull() |
31454 | ····{ |
31455 | ········CreateObjects(); |
31456 | ········QueryOwn(); |
31457 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31458 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31459 | ········ownVar.RelField = new List<AgrBin1OwnpabsOthpabsTblGuidRightBase>(); |
31460 | ········pm.Save(); |
31461 | ········pm.UnloadCache(); |
31462 | ········QueryOwn(); |
31463 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31464 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31465 | ····} |
31466 | ····[Test] |
31467 | ····public void TestSaveReloadRemove() |
31468 | ····{ |
31469 | ········CreateObjects(); |
31470 | ········QueryOwn(); |
31471 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31472 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31473 | ········ownVar.RemoveRelatedObject(); |
31474 | ········pm.Save(); |
31475 | ········pm.UnloadCache(); |
31476 | ········QueryOwn(); |
31477 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31478 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31479 | ····} |
31480 | ····[Test] |
31481 | ····public void TestChangeKeyHolderRight() |
31482 | ····{ |
31483 | ········CreateObjects(); |
31484 | ········QueryOther(); |
31485 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31486 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31487 | ········int x = otherVar.RelField.Dummy; |
31488 | ········otherVar.Dummy = 4711; |
31489 | ········pm.Save(); |
31490 | ········pm.UnloadCache(); |
31491 | ········QueryOther(); |
31492 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31493 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31494 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31495 | ····} |
31496 | ····[Test] |
31497 | ····public void TestChangeKeyHolderRightNoTouch() |
31498 | ····{ |
31499 | ········CreateObjects(); |
31500 | ········QueryOther(); |
31501 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31502 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31503 | ········otherVar.Dummy = 4711; |
31504 | ········pm.Save(); |
31505 | ········pm.UnloadCache(); |
31506 | ········QueryOther(); |
31507 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
31508 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31509 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
31510 | ····} |
31511 | ····[Test] |
31512 | ····public void TestRelationHash() |
31513 | ····{ |
31514 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidLeftBase)); |
31515 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31516 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidRightBase)); |
31517 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31518 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31519 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31520 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidLeftDerived)); |
31521 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31522 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31523 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31524 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBin1OwnpabsOthpabsTblGuidRightDerived)); |
31525 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31526 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31527 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31528 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31529 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31530 | ····} |
31531 | ····void CreateObjects() |
31532 | ····{ |
31533 | ········pm.MakePersistent(ownVar); |
31534 | ········pm.MakePersistent(otherVar); |
31535 | ········ownVar.AssignRelation(otherVar); |
31536 | ········pm.Save(); |
31537 | ········pm.UnloadCache(); |
31538 | ····} |
31539 | ····void QueryOwn() |
31540 | ····{ |
31541 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidLeftBase>(pm); |
31542 | ········ownVar = q.ExecuteSingle(); |
31543 | ····} |
31544 | ····void QueryOther() |
31545 | ····{ |
31546 | ········var q = new NDOQuery<AgrBin1OwnpabsOthpabsTblGuidRightBase>(pm); |
31547 | ········otherVar = q.ExecuteSingle(); |
31548 | ····} |
31549 | } |
31550 | |
31551 | |
31552 | [TestFixture] |
31553 | public class TestAgrBi1nOwnpabsOthpabsTblGuid : NDOTest |
31554 | { |
31555 | ····AgrBi1nOwnpabsOthpabsTblGuidLeftBase ownVar; |
31556 | ····AgrBi1nOwnpabsOthpabsTblGuidRightBase otherVar; |
31557 | ····PersistenceManager pm; |
31558 | ····[SetUp] |
31559 | ····public void Setup() |
31560 | ····{ |
31561 | ········pm = PmFactory.NewPersistenceManager(); |
31562 | ········ownVar = new AgrBi1nOwnpabsOthpabsTblGuidLeftDerived(); |
31563 | ········otherVar = new AgrBi1nOwnpabsOthpabsTblGuidRightDerived(); |
31564 | ····} |
31565 | ····[TearDown] |
31566 | ····public void TearDown() |
31567 | ····{ |
31568 | ········try |
31569 | ········{ |
31570 | ············pm.UnloadCache(); |
31571 | ············var l = pm.Objects<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31572 | ············pm.Delete(l); |
31573 | ············pm.Save(); |
31574 | ············pm.UnloadCache(); |
31575 | ············var m = pm.Objects<AgrBi1nOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31576 | ············pm.Delete(m); |
31577 | ············pm.Save(); |
31578 | ············pm.UnloadCache(); |
31579 | ············decimal count; |
31580 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31581 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31582 | ············count = (decimal) new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31583 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31584 | ········} |
31585 | ········catch (Exception) |
31586 | ········{ |
31587 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31588 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31589 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31590 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31591 | ········} |
31592 | ····} |
31593 | ····[Test] |
31594 | ····public void TestSaveReload() |
31595 | ····{ |
31596 | ········CreateObjects(); |
31597 | ········QueryOwn(); |
31598 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31599 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31600 | ····} |
31601 | ····[Test] |
31602 | ····public void TestSaveReloadNull() |
31603 | ····{ |
31604 | ········CreateObjects(); |
31605 | ········QueryOwn(); |
31606 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31607 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31608 | ········ownVar.RelField = null; |
31609 | ········pm.Save(); |
31610 | ········pm.UnloadCache(); |
31611 | ········QueryOwn(); |
31612 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31613 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31614 | ····} |
31615 | ····[Test] |
31616 | ····public void TestChangeKeyHolderLeft() |
31617 | ····{ |
31618 | ········CreateObjects(); |
31619 | ········QueryOwn(); |
31620 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31621 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31622 | ········int x = ownVar.RelField.Dummy; |
31623 | ········ownVar.Dummy = 4711; |
31624 | ········pm.Save(); |
31625 | ········pm.UnloadCache(); |
31626 | ········QueryOwn(); |
31627 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31628 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31629 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31630 | ····} |
31631 | ····[Test] |
31632 | ····public void TestChangeKeyHolderLeftNoTouch() |
31633 | ····{ |
31634 | ········CreateObjects(); |
31635 | ········QueryOwn(); |
31636 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31637 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31638 | ········ownVar.Dummy = 4711; |
31639 | ········pm.Save(); |
31640 | ········pm.UnloadCache(); |
31641 | ········QueryOwn(); |
31642 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31643 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31644 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31645 | ····} |
31646 | ····[Test] |
31647 | ····public void TestRelationHash() |
31648 | ····{ |
31649 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidLeftBase)); |
31650 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31651 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidRightBase)); |
31652 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31653 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31654 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31655 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidLeftDerived)); |
31656 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31657 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31658 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31659 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBi1nOwnpabsOthpabsTblGuidRightDerived)); |
31660 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31661 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31662 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31663 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31664 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31665 | ····} |
31666 | ····void CreateObjects() |
31667 | ····{ |
31668 | ········pm.MakePersistent(ownVar); |
31669 | ········pm.MakePersistent(otherVar); |
31670 | ········ownVar.AssignRelation(otherVar); |
31671 | ········pm.Save(); |
31672 | ········pm.UnloadCache(); |
31673 | ····} |
31674 | ····void QueryOwn() |
31675 | ····{ |
31676 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidLeftBase>(pm); |
31677 | ········ownVar = q.ExecuteSingle(); |
31678 | ····} |
31679 | ····void QueryOther() |
31680 | ····{ |
31681 | ········var q = new NDOQuery<AgrBi1nOwnpabsOthpabsTblGuidRightBase>(pm); |
31682 | ········otherVar = q.ExecuteSingle(); |
31683 | ····} |
31684 | } |
31685 | |
31686 | |
31687 | [TestFixture] |
31688 | public class TestAgrBinnOwnpabsOthpabsTblGuid : NDOTest |
31689 | { |
31690 | ····AgrBinnOwnpabsOthpabsTblGuidLeftBase ownVar; |
31691 | ····AgrBinnOwnpabsOthpabsTblGuidRightBase otherVar; |
31692 | ····PersistenceManager pm; |
31693 | ····[SetUp] |
31694 | ····public void Setup() |
31695 | ····{ |
31696 | ········pm = PmFactory.NewPersistenceManager(); |
31697 | ········ownVar = new AgrBinnOwnpabsOthpabsTblGuidLeftDerived(); |
31698 | ········otherVar = new AgrBinnOwnpabsOthpabsTblGuidRightDerived(); |
31699 | ····} |
31700 | ····[TearDown] |
31701 | ····public void TearDown() |
31702 | ····{ |
31703 | ········try |
31704 | ········{ |
31705 | ············pm.UnloadCache(); |
31706 | ············var l = pm.Objects<AgrBinnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31707 | ············pm.Delete(l); |
31708 | ············pm.Save(); |
31709 | ············pm.UnloadCache(); |
31710 | ············var m = pm.Objects<AgrBinnOwnpabsOthpabsTblGuidRightBase>().ResultTable; |
31711 | ············pm.Delete(m); |
31712 | ············pm.Save(); |
31713 | ············pm.UnloadCache(); |
31714 | ············decimal count; |
31715 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31716 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31717 | ············count = (decimal) new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31718 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31719 | ········} |
31720 | ········catch (Exception) |
31721 | ········{ |
31722 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31723 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31724 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31725 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31726 | ········} |
31727 | ····} |
31728 | ····[Test] |
31729 | ····public void TestSaveReload() |
31730 | ····{ |
31731 | ········CreateObjects(); |
31732 | ········QueryOwn(); |
31733 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31734 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31735 | ····} |
31736 | ····[Test] |
31737 | ····public void TestSaveReloadNull() |
31738 | ····{ |
31739 | ········CreateObjects(); |
31740 | ········QueryOwn(); |
31741 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31742 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31743 | ········ownVar.RelField = new List<AgrBinnOwnpabsOthpabsTblGuidRightBase>(); |
31744 | ········pm.Save(); |
31745 | ········pm.UnloadCache(); |
31746 | ········QueryOwn(); |
31747 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31748 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31749 | ····} |
31750 | ····[Test] |
31751 | ····public void TestSaveReloadRemove() |
31752 | ····{ |
31753 | ········CreateObjects(); |
31754 | ········QueryOwn(); |
31755 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31756 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31757 | ········ownVar.RemoveRelatedObject(); |
31758 | ········pm.Save(); |
31759 | ········pm.UnloadCache(); |
31760 | ········QueryOwn(); |
31761 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31762 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
31763 | ····} |
31764 | ····[Test] |
31765 | ····public void TestRelationHash() |
31766 | ····{ |
31767 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidLeftBase)); |
31768 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
31769 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidRightBase)); |
31770 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
31771 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
31772 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
31773 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidLeftDerived)); |
31774 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
31775 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
31776 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
31777 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(AgrBinnOwnpabsOthpabsTblGuidRightDerived)); |
31778 | ········Relation relderRight = clderRight.FindRelation("relField"); |
31779 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
31780 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
31781 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
31782 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
31783 | ····} |
31784 | ····void CreateObjects() |
31785 | ····{ |
31786 | ········pm.MakePersistent(ownVar); |
31787 | ········pm.MakePersistent(otherVar); |
31788 | ········ownVar.AssignRelation(otherVar); |
31789 | ········pm.Save(); |
31790 | ········pm.UnloadCache(); |
31791 | ····} |
31792 | ····void QueryOwn() |
31793 | ····{ |
31794 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidLeftBase>(pm); |
31795 | ········ownVar = q.ExecuteSingle(); |
31796 | ····} |
31797 | ····void QueryOther() |
31798 | ····{ |
31799 | ········var q = new NDOQuery<AgrBinnOwnpabsOthpabsTblGuidRightBase>(pm); |
31800 | ········otherVar = q.ExecuteSingle(); |
31801 | ····} |
31802 | } |
31803 | |
31804 | |
31805 | [TestFixture] |
31806 | public class TestCmpDir1OwnpabsOthpabsNoTblGuid : NDOTest |
31807 | { |
31808 | ····CmpDir1OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
31809 | ····CmpDir1OwnpabsOthpabsNoTblGuidRightBase otherVar; |
31810 | ····PersistenceManager pm; |
31811 | ····[SetUp] |
31812 | ····public void Setup() |
31813 | ····{ |
31814 | ········pm = PmFactory.NewPersistenceManager(); |
31815 | ········ownVar = new CmpDir1OwnpabsOthpabsNoTblGuidLeftDerived(); |
31816 | ········otherVar = new CmpDir1OwnpabsOthpabsNoTblGuidRightDerived(); |
31817 | ····} |
31818 | ····[TearDown] |
31819 | ····public void TearDown() |
31820 | ····{ |
31821 | ········try |
31822 | ········{ |
31823 | ············pm.UnloadCache(); |
31824 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
31825 | ············pm.Delete(l); |
31826 | ············pm.Save(); |
31827 | ············pm.UnloadCache(); |
31828 | ············decimal count; |
31829 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31830 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31831 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31832 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31833 | ········} |
31834 | ········catch (Exception) |
31835 | ········{ |
31836 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31837 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31838 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31839 | ········} |
31840 | ····} |
31841 | ····[Test] |
31842 | ····public void TestSaveReload() |
31843 | ····{ |
31844 | ········CreateObjects(); |
31845 | ········QueryOwn(); |
31846 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31847 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31848 | ····} |
31849 | ····[Test] |
31850 | ····public void TestSaveReloadNull() |
31851 | ····{ |
31852 | ········CreateObjects(); |
31853 | ········QueryOwn(); |
31854 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31855 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31856 | ········ownVar.RelField = null; |
31857 | ········pm.Save(); |
31858 | ········pm.UnloadCache(); |
31859 | ········QueryOwn(); |
31860 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31861 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31862 | ····} |
31863 | ····[Test] |
31864 | ····public void TestChangeKeyHolderLeft() |
31865 | ····{ |
31866 | ········CreateObjects(); |
31867 | ········QueryOwn(); |
31868 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31869 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31870 | ········int x = ownVar.RelField.Dummy; |
31871 | ········ownVar.Dummy = 4711; |
31872 | ········pm.Save(); |
31873 | ········pm.UnloadCache(); |
31874 | ········QueryOwn(); |
31875 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31876 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31877 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31878 | ····} |
31879 | ····[Test] |
31880 | ····public void TestChangeKeyHolderLeftNoTouch() |
31881 | ····{ |
31882 | ········CreateObjects(); |
31883 | ········QueryOwn(); |
31884 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31885 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31886 | ········ownVar.Dummy = 4711; |
31887 | ········pm.Save(); |
31888 | ········pm.UnloadCache(); |
31889 | ········QueryOwn(); |
31890 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31891 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31892 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31893 | ····} |
31894 | ····void CreateObjects() |
31895 | ····{ |
31896 | ········pm.MakePersistent(ownVar); |
31897 | ········ownVar.AssignRelation(otherVar); |
31898 | ········pm.Save(); |
31899 | ········pm.UnloadCache(); |
31900 | ····} |
31901 | ····void QueryOwn() |
31902 | ····{ |
31903 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
31904 | ········ownVar = q.ExecuteSingle(); |
31905 | ····} |
31906 | ····void QueryOther() |
31907 | ····{ |
31908 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsNoTblGuidRightBase>(pm); |
31909 | ········otherVar = q.ExecuteSingle(); |
31910 | ····} |
31911 | } |
31912 | |
31913 | |
31914 | [TestFixture] |
31915 | public class TestCmpDir1OwnpabsOthpabsTblGuid : NDOTest |
31916 | { |
31917 | ····CmpDir1OwnpabsOthpabsTblGuidLeftBase ownVar; |
31918 | ····CmpDir1OwnpabsOthpabsTblGuidRightBase otherVar; |
31919 | ····PersistenceManager pm; |
31920 | ····[SetUp] |
31921 | ····public void Setup() |
31922 | ····{ |
31923 | ········pm = PmFactory.NewPersistenceManager(); |
31924 | ········ownVar = new CmpDir1OwnpabsOthpabsTblGuidLeftDerived(); |
31925 | ········otherVar = new CmpDir1OwnpabsOthpabsTblGuidRightDerived(); |
31926 | ····} |
31927 | ····[TearDown] |
31928 | ····public void TearDown() |
31929 | ····{ |
31930 | ········try |
31931 | ········{ |
31932 | ············pm.UnloadCache(); |
31933 | ············var l = pm.Objects<CmpDir1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
31934 | ············pm.Delete(l); |
31935 | ············pm.Save(); |
31936 | ············pm.UnloadCache(); |
31937 | ············decimal count; |
31938 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31939 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
31940 | ············count = (decimal) new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
31941 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
31942 | ········} |
31943 | ········catch (Exception) |
31944 | ········{ |
31945 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
31946 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
31947 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
31948 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
31949 | ········} |
31950 | ····} |
31951 | ····[Test] |
31952 | ····public void TestSaveReload() |
31953 | ····{ |
31954 | ········CreateObjects(); |
31955 | ········QueryOwn(); |
31956 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31957 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31958 | ····} |
31959 | ····[Test] |
31960 | ····public void TestSaveReloadNull() |
31961 | ····{ |
31962 | ········CreateObjects(); |
31963 | ········QueryOwn(); |
31964 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31965 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31966 | ········ownVar.RelField = null; |
31967 | ········pm.Save(); |
31968 | ········pm.UnloadCache(); |
31969 | ········QueryOwn(); |
31970 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31971 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
31972 | ····} |
31973 | ····[Test] |
31974 | ····public void TestChangeKeyHolderLeft() |
31975 | ····{ |
31976 | ········CreateObjects(); |
31977 | ········QueryOwn(); |
31978 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31979 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31980 | ········int x = ownVar.RelField.Dummy; |
31981 | ········ownVar.Dummy = 4711; |
31982 | ········pm.Save(); |
31983 | ········pm.UnloadCache(); |
31984 | ········QueryOwn(); |
31985 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31986 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
31987 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31988 | ····} |
31989 | ····[Test] |
31990 | ····public void TestChangeKeyHolderLeftNoTouch() |
31991 | ····{ |
31992 | ········CreateObjects(); |
31993 | ········QueryOwn(); |
31994 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
31995 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
31996 | ········ownVar.Dummy = 4711; |
31997 | ········pm.Save(); |
31998 | ········pm.UnloadCache(); |
31999 | ········QueryOwn(); |
32000 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32001 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32002 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32003 | ····} |
32004 | ····void CreateObjects() |
32005 | ····{ |
32006 | ········pm.MakePersistent(ownVar); |
32007 | ········ownVar.AssignRelation(otherVar); |
32008 | ········pm.Save(); |
32009 | ········pm.UnloadCache(); |
32010 | ····} |
32011 | ····void QueryOwn() |
32012 | ····{ |
32013 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidLeftBase>(pm); |
32014 | ········ownVar = q.ExecuteSingle(); |
32015 | ····} |
32016 | ····void QueryOther() |
32017 | ····{ |
32018 | ········var q = new NDOQuery<CmpDir1OwnpabsOthpabsTblGuidRightBase>(pm); |
32019 | ········otherVar = q.ExecuteSingle(); |
32020 | ····} |
32021 | } |
32022 | |
32023 | |
32024 | [TestFixture] |
32025 | public class TestCmpBi11OwnpabsOthpabsNoTblGuid : NDOTest |
32026 | { |
32027 | ····CmpBi11OwnpabsOthpabsNoTblGuidLeftBase ownVar; |
32028 | ····CmpBi11OwnpabsOthpabsNoTblGuidRightBase otherVar; |
32029 | ····PersistenceManager pm; |
32030 | ····[SetUp] |
32031 | ····public void Setup() |
32032 | ····{ |
32033 | ········pm = PmFactory.NewPersistenceManager(); |
32034 | ········ownVar = new CmpBi11OwnpabsOthpabsNoTblGuidLeftDerived(); |
32035 | ········otherVar = new CmpBi11OwnpabsOthpabsNoTblGuidRightDerived(); |
32036 | ····} |
32037 | ····[TearDown] |
32038 | ····public void TearDown() |
32039 | ····{ |
32040 | ········try |
32041 | ········{ |
32042 | ············pm.UnloadCache(); |
32043 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>().ResultTable; |
32044 | ············pm.Delete(l); |
32045 | ············pm.Save(); |
32046 | ············pm.UnloadCache(); |
32047 | ············decimal count; |
32048 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32049 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32050 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32051 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32052 | ········} |
32053 | ········catch (Exception) |
32054 | ········{ |
32055 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32056 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32057 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32058 | ········} |
32059 | ····} |
32060 | ····[Test] |
32061 | ····public void TestSaveReload() |
32062 | ····{ |
32063 | ········CreateObjects(); |
32064 | ········QueryOwn(); |
32065 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32066 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32067 | ····} |
32068 | ····[Test] |
32069 | ····public void TestSaveReloadNull() |
32070 | ····{ |
32071 | ········CreateObjects(); |
32072 | ········QueryOwn(); |
32073 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32074 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32075 | ········ownVar.RelField = null; |
32076 | ········pm.Save(); |
32077 | ········pm.UnloadCache(); |
32078 | ········QueryOwn(); |
32079 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32080 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32081 | ····} |
32082 | ····[Test] |
32083 | ····public void TestChangeKeyHolderLeft() |
32084 | ····{ |
32085 | ········CreateObjects(); |
32086 | ········QueryOwn(); |
32087 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32088 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32089 | ········int x = ownVar.RelField.Dummy; |
32090 | ········ownVar.Dummy = 4711; |
32091 | ········pm.Save(); |
32092 | ········pm.UnloadCache(); |
32093 | ········QueryOwn(); |
32094 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32095 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32096 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32097 | ····} |
32098 | ····[Test] |
32099 | ····public void TestChangeKeyHolderRight() |
32100 | ····{ |
32101 | ········CreateObjects(); |
32102 | ········QueryOther(); |
32103 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32104 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32105 | ········int x = otherVar.RelField.Dummy; |
32106 | ········otherVar.Dummy = 4711; |
32107 | ········pm.Save(); |
32108 | ········pm.UnloadCache(); |
32109 | ········QueryOther(); |
32110 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32111 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32112 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32113 | ····} |
32114 | ····[Test] |
32115 | ····public void TestChangeKeyHolderLeftNoTouch() |
32116 | ····{ |
32117 | ········CreateObjects(); |
32118 | ········QueryOwn(); |
32119 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32120 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32121 | ········ownVar.Dummy = 4711; |
32122 | ········pm.Save(); |
32123 | ········pm.UnloadCache(); |
32124 | ········QueryOwn(); |
32125 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32126 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32127 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32128 | ····} |
32129 | ····[Test] |
32130 | ····public void TestChangeKeyHolderRightNoTouch() |
32131 | ····{ |
32132 | ········CreateObjects(); |
32133 | ········QueryOther(); |
32134 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32135 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32136 | ········otherVar.Dummy = 4711; |
32137 | ········pm.Save(); |
32138 | ········pm.UnloadCache(); |
32139 | ········QueryOther(); |
32140 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32141 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32142 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32143 | ····} |
32144 | ····[Test] |
32145 | ····public void TestRelationHash() |
32146 | ····{ |
32147 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidLeftBase)); |
32148 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32149 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidRightBase)); |
32150 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32151 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32152 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32153 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidLeftDerived)); |
32154 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32155 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32156 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32157 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsNoTblGuidRightDerived)); |
32158 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32159 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32160 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32161 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32162 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32163 | ····} |
32164 | ····void CreateObjects() |
32165 | ····{ |
32166 | ········pm.MakePersistent(ownVar); |
32167 | ········ownVar.AssignRelation(otherVar); |
32168 | ········pm.Save(); |
32169 | ········pm.UnloadCache(); |
32170 | ····} |
32171 | ····void QueryOwn() |
32172 | ····{ |
32173 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidLeftBase>(pm); |
32174 | ········ownVar = q.ExecuteSingle(); |
32175 | ····} |
32176 | ····void QueryOther() |
32177 | ····{ |
32178 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsNoTblGuidRightBase>(pm); |
32179 | ········otherVar = q.ExecuteSingle(); |
32180 | ····} |
32181 | } |
32182 | |
32183 | |
32184 | [TestFixture] |
32185 | public class TestCmpBi11OwnpabsOthpabsTblGuid : NDOTest |
32186 | { |
32187 | ····CmpBi11OwnpabsOthpabsTblGuidLeftBase ownVar; |
32188 | ····CmpBi11OwnpabsOthpabsTblGuidRightBase otherVar; |
32189 | ····PersistenceManager pm; |
32190 | ····[SetUp] |
32191 | ····public void Setup() |
32192 | ····{ |
32193 | ········pm = PmFactory.NewPersistenceManager(); |
32194 | ········ownVar = new CmpBi11OwnpabsOthpabsTblGuidLeftDerived(); |
32195 | ········otherVar = new CmpBi11OwnpabsOthpabsTblGuidRightDerived(); |
32196 | ····} |
32197 | ····[TearDown] |
32198 | ····public void TearDown() |
32199 | ····{ |
32200 | ········try |
32201 | ········{ |
32202 | ············pm.UnloadCache(); |
32203 | ············var l = pm.Objects<CmpBi11OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32204 | ············pm.Delete(l); |
32205 | ············pm.Save(); |
32206 | ············pm.UnloadCache(); |
32207 | ············decimal count; |
32208 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32209 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32210 | ············count = (decimal) new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32211 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32212 | ········} |
32213 | ········catch (Exception) |
32214 | ········{ |
32215 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32216 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32217 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32218 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32219 | ········} |
32220 | ····} |
32221 | ····[Test] |
32222 | ····public void TestSaveReload() |
32223 | ····{ |
32224 | ········CreateObjects(); |
32225 | ········QueryOwn(); |
32226 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32227 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32228 | ····} |
32229 | ····[Test] |
32230 | ····public void TestSaveReloadNull() |
32231 | ····{ |
32232 | ········CreateObjects(); |
32233 | ········QueryOwn(); |
32234 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32235 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32236 | ········ownVar.RelField = null; |
32237 | ········pm.Save(); |
32238 | ········pm.UnloadCache(); |
32239 | ········QueryOwn(); |
32240 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32241 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32242 | ····} |
32243 | ····[Test] |
32244 | ····public void TestChangeKeyHolderLeft() |
32245 | ····{ |
32246 | ········CreateObjects(); |
32247 | ········QueryOwn(); |
32248 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32249 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32250 | ········int x = ownVar.RelField.Dummy; |
32251 | ········ownVar.Dummy = 4711; |
32252 | ········pm.Save(); |
32253 | ········pm.UnloadCache(); |
32254 | ········QueryOwn(); |
32255 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32256 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32257 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32258 | ····} |
32259 | ····[Test] |
32260 | ····public void TestChangeKeyHolderRight() |
32261 | ····{ |
32262 | ········CreateObjects(); |
32263 | ········QueryOther(); |
32264 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32265 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32266 | ········int x = otherVar.RelField.Dummy; |
32267 | ········otherVar.Dummy = 4711; |
32268 | ········pm.Save(); |
32269 | ········pm.UnloadCache(); |
32270 | ········QueryOther(); |
32271 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32272 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32273 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32274 | ····} |
32275 | ····[Test] |
32276 | ····public void TestChangeKeyHolderLeftNoTouch() |
32277 | ····{ |
32278 | ········CreateObjects(); |
32279 | ········QueryOwn(); |
32280 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32281 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32282 | ········ownVar.Dummy = 4711; |
32283 | ········pm.Save(); |
32284 | ········pm.UnloadCache(); |
32285 | ········QueryOwn(); |
32286 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32287 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32288 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32289 | ····} |
32290 | ····[Test] |
32291 | ····public void TestChangeKeyHolderRightNoTouch() |
32292 | ····{ |
32293 | ········CreateObjects(); |
32294 | ········QueryOther(); |
32295 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32296 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32297 | ········otherVar.Dummy = 4711; |
32298 | ········pm.Save(); |
32299 | ········pm.UnloadCache(); |
32300 | ········QueryOther(); |
32301 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32302 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32303 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32304 | ····} |
32305 | ····[Test] |
32306 | ····public void TestRelationHash() |
32307 | ····{ |
32308 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidLeftBase)); |
32309 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32310 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidRightBase)); |
32311 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32312 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32313 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32314 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidLeftDerived)); |
32315 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32316 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32317 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32318 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi11OwnpabsOthpabsTblGuidRightDerived)); |
32319 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32320 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32321 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32322 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32323 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32324 | ····} |
32325 | ····void CreateObjects() |
32326 | ····{ |
32327 | ········pm.MakePersistent(ownVar); |
32328 | ········ownVar.AssignRelation(otherVar); |
32329 | ········pm.Save(); |
32330 | ········pm.UnloadCache(); |
32331 | ····} |
32332 | ····void QueryOwn() |
32333 | ····{ |
32334 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidLeftBase>(pm); |
32335 | ········ownVar = q.ExecuteSingle(); |
32336 | ····} |
32337 | ····void QueryOther() |
32338 | ····{ |
32339 | ········var q = new NDOQuery<CmpBi11OwnpabsOthpabsTblGuidRightBase>(pm); |
32340 | ········otherVar = q.ExecuteSingle(); |
32341 | ····} |
32342 | } |
32343 | |
32344 | |
32345 | [TestFixture] |
32346 | public class TestCmpDirnOwnpabsOthpabsTblGuid : NDOTest |
32347 | { |
32348 | ····CmpDirnOwnpabsOthpabsTblGuidLeftBase ownVar; |
32349 | ····CmpDirnOwnpabsOthpabsTblGuidRightBase otherVar; |
32350 | ····PersistenceManager pm; |
32351 | ····[SetUp] |
32352 | ····public void Setup() |
32353 | ····{ |
32354 | ········pm = PmFactory.NewPersistenceManager(); |
32355 | ········ownVar = new CmpDirnOwnpabsOthpabsTblGuidLeftDerived(); |
32356 | ········otherVar = new CmpDirnOwnpabsOthpabsTblGuidRightDerived(); |
32357 | ····} |
32358 | ····[TearDown] |
32359 | ····public void TearDown() |
32360 | ····{ |
32361 | ········try |
32362 | ········{ |
32363 | ············pm.UnloadCache(); |
32364 | ············var l = pm.Objects<CmpDirnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32365 | ············pm.Delete(l); |
32366 | ············pm.Save(); |
32367 | ············pm.UnloadCache(); |
32368 | ············decimal count; |
32369 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32370 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32371 | ············count = (decimal) new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32372 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32373 | ········} |
32374 | ········catch (Exception) |
32375 | ········{ |
32376 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32377 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32378 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32379 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32380 | ········} |
32381 | ····} |
32382 | ····[Test] |
32383 | ····public void TestSaveReload() |
32384 | ····{ |
32385 | ········CreateObjects(); |
32386 | ········QueryOwn(); |
32387 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32388 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32389 | ····} |
32390 | ····[Test] |
32391 | ····public void TestSaveReloadNull() |
32392 | ····{ |
32393 | ········CreateObjects(); |
32394 | ········QueryOwn(); |
32395 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32396 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32397 | ········ownVar.RelField = new List<CmpDirnOwnpabsOthpabsTblGuidRightBase>(); |
32398 | ········pm.Save(); |
32399 | ········pm.UnloadCache(); |
32400 | ········QueryOwn(); |
32401 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32402 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32403 | ····} |
32404 | ····[Test] |
32405 | ····public void TestSaveReloadRemove() |
32406 | ····{ |
32407 | ········CreateObjects(); |
32408 | ········QueryOwn(); |
32409 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32410 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32411 | ········ownVar.RemoveRelatedObject(); |
32412 | ········pm.Save(); |
32413 | ········pm.UnloadCache(); |
32414 | ········QueryOwn(); |
32415 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32416 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32417 | ····} |
32418 | ····void CreateObjects() |
32419 | ····{ |
32420 | ········pm.MakePersistent(ownVar); |
32421 | ········ownVar.AssignRelation(otherVar); |
32422 | ········pm.Save(); |
32423 | ········pm.UnloadCache(); |
32424 | ····} |
32425 | ····void QueryOwn() |
32426 | ····{ |
32427 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidLeftBase>(pm); |
32428 | ········ownVar = q.ExecuteSingle(); |
32429 | ····} |
32430 | ····void QueryOther() |
32431 | ····{ |
32432 | ········var q = new NDOQuery<CmpDirnOwnpabsOthpabsTblGuidRightBase>(pm); |
32433 | ········otherVar = q.ExecuteSingle(); |
32434 | ····} |
32435 | } |
32436 | |
32437 | |
32438 | [TestFixture] |
32439 | public class TestCmpBin1OwnpabsOthpabsTblGuid : NDOTest |
32440 | { |
32441 | ····CmpBin1OwnpabsOthpabsTblGuidLeftBase ownVar; |
32442 | ····CmpBin1OwnpabsOthpabsTblGuidRightBase otherVar; |
32443 | ····PersistenceManager pm; |
32444 | ····[SetUp] |
32445 | ····public void Setup() |
32446 | ····{ |
32447 | ········pm = PmFactory.NewPersistenceManager(); |
32448 | ········ownVar = new CmpBin1OwnpabsOthpabsTblGuidLeftDerived(); |
32449 | ········otherVar = new CmpBin1OwnpabsOthpabsTblGuidRightDerived(); |
32450 | ····} |
32451 | ····[TearDown] |
32452 | ····public void TearDown() |
32453 | ····{ |
32454 | ········try |
32455 | ········{ |
32456 | ············pm.UnloadCache(); |
32457 | ············var l = pm.Objects<CmpBin1OwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32458 | ············pm.Delete(l); |
32459 | ············pm.Save(); |
32460 | ············pm.UnloadCache(); |
32461 | ············decimal count; |
32462 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32463 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32464 | ············count = (decimal) new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32465 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32466 | ········} |
32467 | ········catch (Exception) |
32468 | ········{ |
32469 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32470 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32471 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32472 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32473 | ········} |
32474 | ····} |
32475 | ····[Test] |
32476 | ····public void TestSaveReload() |
32477 | ····{ |
32478 | ········CreateObjects(); |
32479 | ········QueryOwn(); |
32480 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32481 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32482 | ····} |
32483 | ····[Test] |
32484 | ····public void TestSaveReloadNull() |
32485 | ····{ |
32486 | ········CreateObjects(); |
32487 | ········QueryOwn(); |
32488 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32489 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32490 | ········ownVar.RelField = new List<CmpBin1OwnpabsOthpabsTblGuidRightBase>(); |
32491 | ········pm.Save(); |
32492 | ········pm.UnloadCache(); |
32493 | ········QueryOwn(); |
32494 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32495 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32496 | ····} |
32497 | ····[Test] |
32498 | ····public void TestSaveReloadRemove() |
32499 | ····{ |
32500 | ········CreateObjects(); |
32501 | ········QueryOwn(); |
32502 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32503 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32504 | ········ownVar.RemoveRelatedObject(); |
32505 | ········pm.Save(); |
32506 | ········pm.UnloadCache(); |
32507 | ········QueryOwn(); |
32508 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32509 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32510 | ····} |
32511 | ····[Test] |
32512 | ····public void TestChangeKeyHolderRight() |
32513 | ····{ |
32514 | ········CreateObjects(); |
32515 | ········QueryOther(); |
32516 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32517 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32518 | ········int x = otherVar.RelField.Dummy; |
32519 | ········otherVar.Dummy = 4711; |
32520 | ········pm.Save(); |
32521 | ········pm.UnloadCache(); |
32522 | ········QueryOther(); |
32523 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32524 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32525 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32526 | ····} |
32527 | ····[Test] |
32528 | ····public void TestChangeKeyHolderRightNoTouch() |
32529 | ····{ |
32530 | ········CreateObjects(); |
32531 | ········QueryOther(); |
32532 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32533 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32534 | ········otherVar.Dummy = 4711; |
32535 | ········pm.Save(); |
32536 | ········pm.UnloadCache(); |
32537 | ········QueryOther(); |
32538 | ········Assert.That(otherVar, Is.Not.Null, "No Query Result"); |
32539 | ········Assert.That(otherVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32540 | ········Assert.That(otherVar.RelField, Is.Not.Null, "No related object"); |
32541 | ····} |
32542 | ····[Test] |
32543 | ····public void TestRelationHash() |
32544 | ····{ |
32545 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidLeftBase)); |
32546 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32547 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidRightBase)); |
32548 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32549 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32550 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32551 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidLeftDerived)); |
32552 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32553 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32554 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32555 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBin1OwnpabsOthpabsTblGuidRightDerived)); |
32556 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32557 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32558 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32559 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32560 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32561 | ····} |
32562 | ····void CreateObjects() |
32563 | ····{ |
32564 | ········pm.MakePersistent(ownVar); |
32565 | ········ownVar.AssignRelation(otherVar); |
32566 | ········pm.Save(); |
32567 | ········pm.UnloadCache(); |
32568 | ····} |
32569 | ····void QueryOwn() |
32570 | ····{ |
32571 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidLeftBase>(pm); |
32572 | ········ownVar = q.ExecuteSingle(); |
32573 | ····} |
32574 | ····void QueryOther() |
32575 | ····{ |
32576 | ········var q = new NDOQuery<CmpBin1OwnpabsOthpabsTblGuidRightBase>(pm); |
32577 | ········otherVar = q.ExecuteSingle(); |
32578 | ····} |
32579 | } |
32580 | |
32581 | |
32582 | [TestFixture] |
32583 | public class TestCmpBi1nOwnpabsOthpabsTblGuid : NDOTest |
32584 | { |
32585 | ····CmpBi1nOwnpabsOthpabsTblGuidLeftBase ownVar; |
32586 | ····CmpBi1nOwnpabsOthpabsTblGuidRightBase otherVar; |
32587 | ····PersistenceManager pm; |
32588 | ····[SetUp] |
32589 | ····public void Setup() |
32590 | ····{ |
32591 | ········pm = PmFactory.NewPersistenceManager(); |
32592 | ········ownVar = new CmpBi1nOwnpabsOthpabsTblGuidLeftDerived(); |
32593 | ········otherVar = new CmpBi1nOwnpabsOthpabsTblGuidRightDerived(); |
32594 | ····} |
32595 | ····[TearDown] |
32596 | ····public void TearDown() |
32597 | ····{ |
32598 | ········try |
32599 | ········{ |
32600 | ············pm.UnloadCache(); |
32601 | ············var l = pm.Objects<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32602 | ············pm.Delete(l); |
32603 | ············pm.Save(); |
32604 | ············pm.UnloadCache(); |
32605 | ············decimal count; |
32606 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32607 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32608 | ············count = (decimal) new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32609 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32610 | ········} |
32611 | ········catch (Exception) |
32612 | ········{ |
32613 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32614 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32615 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32616 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32617 | ········} |
32618 | ····} |
32619 | ····[Test] |
32620 | ····public void TestSaveReload() |
32621 | ····{ |
32622 | ········CreateObjects(); |
32623 | ········QueryOwn(); |
32624 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32625 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32626 | ····} |
32627 | ····[Test] |
32628 | ····public void TestSaveReloadNull() |
32629 | ····{ |
32630 | ········CreateObjects(); |
32631 | ········QueryOwn(); |
32632 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32633 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32634 | ········ownVar.RelField = null; |
32635 | ········pm.Save(); |
32636 | ········pm.UnloadCache(); |
32637 | ········QueryOwn(); |
32638 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32639 | ········Assert.That(ownVar.RelField, Is.Null, "There should be no object"); |
32640 | ····} |
32641 | ····[Test] |
32642 | ····public void TestChangeKeyHolderLeft() |
32643 | ····{ |
32644 | ········CreateObjects(); |
32645 | ········QueryOwn(); |
32646 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32647 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32648 | ········int x = ownVar.RelField.Dummy; |
32649 | ········ownVar.Dummy = 4711; |
32650 | ········pm.Save(); |
32651 | ········pm.UnloadCache(); |
32652 | ········QueryOwn(); |
32653 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32654 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32655 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32656 | ····} |
32657 | ····[Test] |
32658 | ····public void TestChangeKeyHolderLeftNoTouch() |
32659 | ····{ |
32660 | ········CreateObjects(); |
32661 | ········QueryOwn(); |
32662 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32663 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32664 | ········ownVar.Dummy = 4711; |
32665 | ········pm.Save(); |
32666 | ········pm.UnloadCache(); |
32667 | ········QueryOwn(); |
32668 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32669 | ········Assert.That(ownVar.Dummy == 4711, Is.Not.Null, "Wrong value"); |
32670 | ········Assert.That(ownVar.RelField, Is.Not.Null, "No related object"); |
32671 | ····} |
32672 | ····[Test] |
32673 | ····public void TestRelationHash() |
32674 | ····{ |
32675 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidLeftBase)); |
32676 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32677 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidRightBase)); |
32678 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32679 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32680 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32681 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidLeftDerived)); |
32682 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32683 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32684 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32685 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBi1nOwnpabsOthpabsTblGuidRightDerived)); |
32686 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32687 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32688 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32689 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32690 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32691 | ····} |
32692 | ····void CreateObjects() |
32693 | ····{ |
32694 | ········pm.MakePersistent(ownVar); |
32695 | ········ownVar.AssignRelation(otherVar); |
32696 | ········pm.Save(); |
32697 | ········pm.UnloadCache(); |
32698 | ····} |
32699 | ····void QueryOwn() |
32700 | ····{ |
32701 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidLeftBase>(pm); |
32702 | ········ownVar = q.ExecuteSingle(); |
32703 | ····} |
32704 | ····void QueryOther() |
32705 | ····{ |
32706 | ········var q = new NDOQuery<CmpBi1nOwnpabsOthpabsTblGuidRightBase>(pm); |
32707 | ········otherVar = q.ExecuteSingle(); |
32708 | ····} |
32709 | } |
32710 | |
32711 | |
32712 | [TestFixture] |
32713 | public class TestCmpBinnOwnpabsOthpabsTblGuid : NDOTest |
32714 | { |
32715 | ····CmpBinnOwnpabsOthpabsTblGuidLeftBase ownVar; |
32716 | ····CmpBinnOwnpabsOthpabsTblGuidRightBase otherVar; |
32717 | ····PersistenceManager pm; |
32718 | ····[SetUp] |
32719 | ····public void Setup() |
32720 | ····{ |
32721 | ········pm = PmFactory.NewPersistenceManager(); |
32722 | ········ownVar = new CmpBinnOwnpabsOthpabsTblGuidLeftDerived(); |
32723 | ········otherVar = new CmpBinnOwnpabsOthpabsTblGuidRightDerived(); |
32724 | ····} |
32725 | ····[TearDown] |
32726 | ····public void TearDown() |
32727 | ····{ |
32728 | ········try |
32729 | ········{ |
32730 | ············pm.UnloadCache(); |
32731 | ············var l = pm.Objects<CmpBinnOwnpabsOthpabsTblGuidLeftBase>().ResultTable; |
32732 | ············pm.Delete(l); |
32733 | ············pm.Save(); |
32734 | ············pm.UnloadCache(); |
32735 | ············decimal count; |
32736 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidLeftBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32737 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #1"); |
32738 | ············count = (decimal) new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidRightBase>(pm).ExecuteAggregate("dummy", AggregateType.Count); |
32739 | ············Assert.That(0, Is.EqualTo(count), "Count wrong #2"); |
32740 | ········} |
32741 | ········catch (Exception) |
32742 | ········{ |
32743 | ············var handler = pm.GetSqlPassThroughHandler( pm.NDOMapping.Connections.First() ); |
32744 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).TableName}"); |
32745 | ············handler.Execute($"DELETE FROM {pm.NDOMapping.FindClass( otherVar.GetType() ).TableName}"); |
32746 | ············handler.Execute( $"DELETE FROM {pm.NDOMapping.FindClass( ownVar.GetType() ).Relations.First().MappingTable.TableName}" ); |
32747 | ········} |
32748 | ····} |
32749 | ····[Test] |
32750 | ····public void TestSaveReload() |
32751 | ····{ |
32752 | ········CreateObjects(); |
32753 | ········QueryOwn(); |
32754 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32755 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32756 | ····} |
32757 | ····[Test] |
32758 | ····public void TestSaveReloadNull() |
32759 | ····{ |
32760 | ········CreateObjects(); |
32761 | ········QueryOwn(); |
32762 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32763 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32764 | ········ownVar.RelField = new List<CmpBinnOwnpabsOthpabsTblGuidRightBase>(); |
32765 | ········pm.Save(); |
32766 | ········pm.UnloadCache(); |
32767 | ········QueryOwn(); |
32768 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32769 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32770 | ····} |
32771 | ····[Test] |
32772 | ····public void TestSaveReloadRemove() |
32773 | ····{ |
32774 | ········CreateObjects(); |
32775 | ········QueryOwn(); |
32776 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32777 | ········Assert.That(1, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32778 | ········ownVar.RemoveRelatedObject(); |
32779 | ········pm.Save(); |
32780 | ········pm.UnloadCache(); |
32781 | ········QueryOwn(); |
32782 | ········Assert.That(ownVar, Is.Not.Null, "No Query Result"); |
32783 | ········Assert.That(0, Is.EqualTo(ownVar.RelField.Count), "Count wrong"); |
32784 | ····} |
32785 | ····[Test] |
32786 | ····public void TestRelationHash() |
32787 | ····{ |
32788 | ········Class clbaseLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidLeftBase)); |
32789 | ········Relation relbaseLeft = clbaseLeft.FindRelation("relField"); |
32790 | ········Class clbaseRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidRightBase)); |
32791 | ········Relation relbaseRight = clbaseRight.FindRelation("relField"); |
32792 | ········Assert.That(relbaseRight.Equals(relbaseLeft), "Relation should be equal #1"); |
32793 | ········Assert.That(relbaseLeft.Equals(relbaseRight), "Relation should be equal #2"); |
32794 | ········Class clderLeft = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidLeftDerived)); |
32795 | ········Relation relderLeft = clderLeft.FindRelation("relField"); |
32796 | ········Assert.That(relderLeft.Equals(relbaseRight), "Relation should be equal #3"); |
32797 | ········Assert.That(relbaseRight.Equals(relderLeft), "Relation should be equal #4"); |
32798 | ········Class clderRight = pm.NDOMapping.FindClass(typeof(CmpBinnOwnpabsOthpabsTblGuidRightDerived)); |
32799 | ········Relation relderRight = clderRight.FindRelation("relField"); |
32800 | ········Assert.That(relbaseLeft.Equals(relderRight), "Relation should be equal #5"); |
32801 | ········Assert.That(relderRight.Equals(relbaseLeft), "Relation should be equal #6"); |
32802 | ········Assert.That(relderLeft.Equals(relderRight), "Relation should be equal #7"); |
32803 | ········Assert.That(relderRight.Equals(relderLeft), "Relation should be equal #8"); |
32804 | ····} |
32805 | ····void CreateObjects() |
32806 | ····{ |
32807 | ········pm.MakePersistent(ownVar); |
32808 | ········ownVar.AssignRelation(otherVar); |
32809 | ········pm.Save(); |
32810 | ········pm.UnloadCache(); |
32811 | ····} |
32812 | ····void QueryOwn() |
32813 | ····{ |
32814 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidLeftBase>(pm); |
32815 | ········ownVar = q.ExecuteSingle(); |
32816 | ····} |
32817 | ····void QueryOther() |
32818 | ····{ |
32819 | ········var q = new NDOQuery<CmpBinnOwnpabsOthpabsTblGuidRightBase>(pm); |
32820 | ········otherVar = q.ExecuteSingle(); |
32821 | ····} |
32822 | } |
32823 | |
32824 | |
32825 | |
32826 | } |
32827 |