Datei: IntegrationTests/IntegrationTests/ArrayListTests.cs
Last Commit (08b23aa)
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.Reflection; |
25 | using System.Collections; |
26 | using NUnit.Framework; |
27 | using NDO; |
28 | using Reisekosten; |
29 | using Reisekosten.Personal; |
30 | using NDO.Query; |
31 | |
32 | namespace NdoUnitTests |
33 | { |
34 | ····[TestFixture] |
35 | ····public class ArrayListTests : NDOTest |
36 | ····{ |
37 | ········private PersistenceManager pm; |
38 | ········private Mitarbeiter m; |
39 | ········private Reise r; |
40 | ········private Reise r2; |
41 | |
42 | ········[SetUp] |
43 | ········public void Setup() |
44 | ········{ |
45 | ············pm = PmFactory.NewPersistenceManager(); |
46 | ············m = CreateMitarbeiter("Hartmut", "Kocher"); |
47 | ············pm.MakePersistent(m); |
48 | ············r = CreateReise("ADC"); |
49 | ············r2 = CreateReise("ADW"); |
50 | ········} |
51 | |
52 | ········[TearDown] |
53 | ········public void TearDown() |
54 | ········{ |
55 | ············pm.Abort(); |
56 | ············IList mitarbeiterListe = pm.GetClassExtent( typeof( Mitarbeiter ), true ); |
57 | ············pm.Delete( mitarbeiterListe ); |
58 | ············pm.Save(); |
59 | ············pm.Dispose(); |
60 | ········} |
61 | |
62 | |
63 | ········private void AddRange() |
64 | ········{ |
65 | ············ArrayList l = new ArrayList(); |
66 | ············l.Add(r); |
67 | ············l.Add(r2); |
68 | ············m.ReisenAddRange(l); |
69 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
70 | ············pm.Save(); |
71 | ············Assert.That(NDOObjectState.Persistent ==··m.NDOObjectState, "Wrong state #1"); |
72 | ············pm.MakeAllHollow(); |
73 | ············pm.UnloadCache(); |
74 | ············Assert.That(NDOObjectState.Hollow ==··m.NDOObjectState, "Wrong state #2"); |
75 | ············Assert.That(!GetLoadState(), "Relation should not be loaded"); |
76 | ········} |
77 | |
78 | |
79 | ········[Test] |
80 | ········public void TestAddRange() |
81 | ········{ |
82 | ············AddRange(); |
83 | ············NDOQuery<Mitarbeiter> q = new NDOQuery<Mitarbeiter>(pm); |
84 | ············m = q.ExecuteSingle(true); |
85 | ············Assert.That(2 ==··m.Reisen.Count, "Count of Reisen wrong"); |
86 | ········} |
87 | |
88 | ········[Test] |
89 | ········public void TestBinarySearch() |
90 | ········{ |
91 | ············AddRange(); |
92 | ············int index = m.ReisenBinarySearch(r); |
93 | ············// Don't care about the result, the object won't be fount |
94 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
95 | ········} |
96 | |
97 | ········[Test] |
98 | ········public void ReisenCapacity() |
99 | ········{ |
100 | ············AddRange(); |
101 | ············int result = m.ReisenCapacity; |
102 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
103 | ········} |
104 | |
105 | ········[Test] |
106 | ········public void ReisenGetRange() |
107 | ········{ |
108 | ············AddRange(); |
109 | ············IList l = m.ReisenGetRange(0, 2); |
110 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
111 | ············Assert.That(2 ==··l.Count, "Count is wrong"); |
112 | ········} |
113 | |
114 | ········[Test] |
115 | ········public void ReisenInsertRange() |
116 | ········{ |
117 | ············AddRange(); |
118 | ············ArrayList range = new ArrayList(); |
119 | ············range.Add(CreateReise("foo")); |
120 | ············range.Add(CreateReise("bar")); |
121 | ············m.ReisenInsertRange(1, range); |
122 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
123 | ············Assert.That(m.Reisen[1] ==··(Reise)range[0], "Wrong order"); |
124 | ············SaveAndReload(); |
125 | ············Assert.That(4 ==··m.Reisen.Count, "Count of Reisen wrong"); |
126 | ········} |
127 | |
128 | ········[Test] |
129 | ········public void ReisenLastIndexOf() |
130 | ········{ |
131 | ············AddRange(); |
132 | ············int i = m.ReisenLastIndexOf(r, 1, 2); |
133 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
134 | ········} |
135 | |
136 | ········[Test] |
137 | ········public void ReisenRemoveRange() |
138 | ········{ |
139 | ············AddRange(); |
140 | ············m.ReisenRemoveRange(0, 1); |
141 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
142 | ············Assert.That(1 ==··m.Reisen.Count, "Count of Reisen wrong #1"); |
143 | ············SaveAndReload(); |
144 | ············Assert.That(1 ==··m.Reisen.Count, "Count of Reisen wrong #2"); |
145 | ········} |
146 | |
147 | ········[Test] |
148 | ········public void ReisenReverse() |
149 | ········{ |
150 | ············AddRange(); |
151 | ············m.ReisenReverse(); |
152 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
153 | ········} |
154 | |
155 | ········//[Test] |
156 | ········//public void ReisenSetRange() |
157 | ········//{ |
158 | ········//····AddRange(); |
159 | ········//····ArrayList l = new ArrayList(); |
160 | ········//····l.Add(CreateReise("foo")); |
161 | ········//····l.Add(CreateReise("bar")); |
162 | ········//····m.ReisenSetRange(0, l); |
163 | ····//Assert.That(GetLoadState(), "Relation not loaded"); |
164 | ····//Assert.That("foo" ==··(m.Reisen[0] as Reise).Zweck, "Falsche Reise #1"); |
165 | ····//Assert.That("bar" ==··(m.Reisen[1] as Reise).Zweck, "Falsche Reise #2"); |
166 | ····//····//····SaveAndReload(); |
167 | ····//Assert.That(2 ==··m.Reisen.Count, "Count of Reisen wrong"); |
168 | ····//····//····if (((Reise)m.Reisen[0]).NDOObjectId.Id[0] is Int32) |
169 | ····//····//····{ |
170 | ····//····//········m.ReisenSort(); |
171 | ····//····Assert.That("bar" ==··(m.Reisen[0] as Reise).Zweck, "Falsche Reise #3"); |
172 | ····//····Assert.That("foo" ==··(m.Reisen[1] as Reise).Zweck, "Falsche Reise #4"); |
173 | ········//····} |
174 | ········//} |
175 | |
176 | ········[Test] |
177 | ········public void ReisenSort() |
178 | ········{ |
179 | ············AddRange(); |
180 | ············m.ReisenSort(); |
181 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
182 | ········} |
183 | |
184 | ········[Test] |
185 | ········public void ReisenToArray() |
186 | ········{ |
187 | ············AddRange(); |
188 | ············object o = m.ReisenToArray(typeof(Reise)); |
189 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
190 | ········} |
191 | |
192 | ········//[Test] |
193 | ········//public void ReisenTrimToSize() |
194 | ········//{ |
195 | ········//····AddRange(); |
196 | ········//····m.ReisenTrimToSize(); |
197 | ········//Assert.That(GetLoadState(), "Relation not loaded"); |
198 | ········//} |
199 | ········ |
200 | ········[Test] |
201 | ········public void ReisenCount() |
202 | ········{ |
203 | ············AddRange(); |
204 | ············int x = m.ReisenCount; |
205 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
206 | ········} |
207 | |
208 | ········[Test] |
209 | ········public void ReisenContains() |
210 | ········{ |
211 | ············AddRange(); |
212 | ············bool test = m.ReisenContains(r); |
213 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
214 | ········} |
215 | |
216 | ········[Test] |
217 | ········public void ReisenCopyTo() |
218 | ········{ |
219 | ············AddRange(); |
220 | ············Reise[] arr = m.ReisenCopyTo; |
221 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
222 | ············Assert.That((arr[0].Zweck == r.Zweck || arr[0].Zweck == r2.Zweck) && (arr[1].Zweck == r.Zweck || arr[1].Zweck == r2.Zweck), "Reisen not found"); |
223 | ········} |
224 | |
225 | ········[Test] |
226 | ········public void ReisenEquals() |
227 | ········{ |
228 | ············Object o = r; |
229 | ············AddRange(); |
230 | ············bool dummy = m.ReisenEquals(o); |
231 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
232 | ········} |
233 | |
234 | ········[Test] |
235 | ········public void ReisenEnumerator() |
236 | ········{ |
237 | ············AddRange(); |
238 | ············IEnumerator ie = m.ReisenEnumerator; |
239 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
240 | ············ie.MoveNext(); |
241 | ············Assert.That(((Reise)ie.Current).Zweck != r.Zweck ||··((Reise)ie.Current).Zweck != r2.Zweck, "Reise wrong #1"); |
242 | ············ie.MoveNext(); |
243 | ············Assert.That(((Reise)ie.Current).Zweck != r.Zweck ||··((Reise)ie.Current).Zweck != r2.Zweck, "Reise wrong #2"); |
244 | ········} |
245 | |
246 | ········[Test] |
247 | ········public void ReisenHashCode() |
248 | ········{ |
249 | ············AddRange(); |
250 | ············int result = m.ReisenHashCode(); |
251 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
252 | ········} |
253 | |
254 | ········[Test] |
255 | ········public void ReisenGetType() |
256 | ········{ |
257 | ············AddRange(); |
258 | ············Type t = m.ReisenGetType(); |
259 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
260 | ········} |
261 | |
262 | ········[Test] |
263 | ········public void ReisenIndexOf() |
264 | ········{ |
265 | ············AddRange(); |
266 | ············int result = m.ReisenIndexOf(r); |
267 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
268 | ········} |
269 | |
270 | ········//[Test] |
271 | ········//public void ReisenIsFixedSize() |
272 | ········//{ |
273 | ········//····AddRange(); |
274 | ········//····bool result = m.ReisenIsFixedSize; |
275 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
276 | ········//} |
277 | |
278 | ········//[Test] |
279 | ········//public void ReisenIsReadOnly() |
280 | ········//{ |
281 | ········//····AddRange(); |
282 | ········//····bool result = m.ReisenIsReadOnly; |
283 | //·· Assert.That(GetLoadState(), "Relation not loaded"); |
284 | ········//} |
285 | |
286 | |
287 | ········//[Test] |
288 | ········//public void ReisenIsSynchronized() |
289 | ········//{ |
290 | ········//····AddRange(); |
291 | ········//····bool b = m.ReisenIsSynchronized; |
292 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
293 | ········//} |
294 | |
295 | |
296 | ········//[Test] |
297 | ········//public void ReisenSyncRoot() |
298 | ········//{ |
299 | ········//····AddRange(); |
300 | ········//····object o = m.ReisenSyncRoot; |
301 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
302 | ········//} |
303 | |
304 | ········[Test] |
305 | ········public void ReisenRemoveAt() |
306 | ········{ |
307 | ············AddRange(); |
308 | ············m.ReisenRemoveAt(1); |
309 | ············string zweck = ((Reise)m.Reisen[0]).Zweck; |
310 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
311 | ············SaveAndReload(); |
312 | ············Assert.That(1 ==··m.Reisen.Count, "Wrong count"); |
313 | ············Assert.That(zweck ==··((Reise)m.Reisen[0]).Zweck, "Reise wrong"); |
314 | ········} |
315 | |
316 | ········[Test] |
317 | ········public void ReisenToString() |
318 | ········{ |
319 | ············AddRange(); |
320 | ············string s = m.ReisenToString; |
321 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
322 | ········} |
323 | |
324 | ········private Mitarbeiter CreateMitarbeiter(string vorname, string nachname) |
325 | ········{ |
326 | ············Mitarbeiter m = new Mitarbeiter(); |
327 | ············m.Vorname = vorname; |
328 | ············m.Nachname = nachname; |
329 | ············return m; |
330 | ········} |
331 | |
332 | ········private Reise CreateReise(string zweck) |
333 | ········{ |
334 | ············Reise r = new Reise(); |
335 | ············r.Zweck = zweck; |
336 | ············return r; |
337 | ········} |
338 | |
339 | ········private bool GetLoadState() |
340 | ········{ |
341 | ············NDO.Mapping.Relation r = pm.NDOMapping.FindClass(typeof(Mitarbeiter)).FindRelation("dieReisen"); |
342 | FieldInfo fi = typeof( NDO. Mapping. Relation) . GetField( "Ordinal", BindingFlags. NonPublic | BindingFlags. Instance) ; |
343 | Assert. That( fi != null) ; |
344 | ············object o = fi.GetValue(r); |
345 | ············Assert.That(o != null); |
346 | ············return ((IPersistenceCapable)m).NDOGetLoadState((int)o); |
347 | ········} |
348 | |
349 | ········private void SaveAndReload() |
350 | ········{ |
351 | ············pm.Save(); |
352 | ············pm.UnloadCache(); |
353 | ············NDOQuery<Mitarbeiter> q = new NDOQuery<Mitarbeiter>(pm); |
354 | ············m = (Mitarbeiter) q.ExecuteSingle(true); |
355 | ········} |
356 | |
357 | |
358 | ····} |
359 | } |
360 |
New Commit (60aa080)
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.Reflection; |
25 | using System.Collections; |
26 | using NUnit.Framework; |
27 | using NDO; |
28 | using Reisekosten; |
29 | using Reisekosten.Personal; |
30 | using NDO.Query; |
31 | using NDO.Mapping; |
32 | |
33 | namespace NdoUnitTests |
34 | { |
35 | ····[TestFixture] |
36 | ····public class ArrayListTests : NDOTest |
37 | ····{ |
38 | ········private PersistenceManager pm; |
39 | ········private Mitarbeiter m; |
40 | ········private Reise r; |
41 | ········private Reise r2; |
42 | |
43 | ········[SetUp] |
44 | ········public void Setup() |
45 | ········{ |
46 | ············pm = PmFactory.NewPersistenceManager(); |
47 | ············m = CreateMitarbeiter("Hartmut", "Kocher"); |
48 | ············pm.MakePersistent(m); |
49 | ············r = CreateReise("ADC"); |
50 | ············r2 = CreateReise("ADW"); |
51 | ········} |
52 | |
53 | ········[TearDown] |
54 | ········public void TearDown() |
55 | ········{ |
56 | ············pm.Abort(); |
57 | ············IList mitarbeiterListe = pm.GetClassExtent( typeof( Mitarbeiter ), true ); |
58 | ············pm.Delete( mitarbeiterListe ); |
59 | ············pm.Save(); |
60 | ············pm.Dispose(); |
61 | ········} |
62 | |
63 | |
64 | ········private void AddRange() |
65 | ········{ |
66 | ············ArrayList l = new ArrayList(); |
67 | ············l.Add(r); |
68 | ············l.Add(r2); |
69 | ············m.ReisenAddRange(l); |
70 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
71 | ············pm.Save(); |
72 | ············Assert.That(NDOObjectState.Persistent ==··m.NDOObjectState, "Wrong state #1"); |
73 | ············pm.MakeAllHollow(); |
74 | ············pm.UnloadCache(); |
75 | ············Assert.That(NDOObjectState.Hollow ==··m.NDOObjectState, "Wrong state #2"); |
76 | ············Assert.That(!GetLoadState(), "Relation should not be loaded"); |
77 | ········} |
78 | |
79 | |
80 | ········[Test] |
81 | ········public void TestAddRange() |
82 | ········{ |
83 | ············AddRange(); |
84 | ············NDOQuery<Mitarbeiter> q = new NDOQuery<Mitarbeiter>(pm); |
85 | ············m = q.ExecuteSingle(true); |
86 | ············Assert.That(2 ==··m.Reisen.Count, "Count of Reisen wrong"); |
87 | ········} |
88 | |
89 | ········[Test] |
90 | ········public void TestBinarySearch() |
91 | ········{ |
92 | ············AddRange(); |
93 | ············int index = m.ReisenBinarySearch(r); |
94 | ············// Don't care about the result, the object won't be fount |
95 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
96 | ········} |
97 | |
98 | ········[Test] |
99 | ········public void ReisenCapacity() |
100 | ········{ |
101 | ············AddRange(); |
102 | ············int result = m.ReisenCapacity; |
103 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
104 | ········} |
105 | |
106 | ········[Test] |
107 | ········public void ReisenGetRange() |
108 | ········{ |
109 | ············AddRange(); |
110 | ············IList l = m.ReisenGetRange(0, 2); |
111 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
112 | ············Assert.That(2 ==··l.Count, "Count is wrong"); |
113 | ········} |
114 | |
115 | ········[Test] |
116 | ········public void ReisenInsertRange() |
117 | ········{ |
118 | ············AddRange(); |
119 | ············ArrayList range = new ArrayList(); |
120 | ············range.Add(CreateReise("foo")); |
121 | ············range.Add(CreateReise("bar")); |
122 | ············m.ReisenInsertRange(1, range); |
123 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
124 | ············Assert.That(m.Reisen[1] ==··(Reise)range[0], "Wrong order"); |
125 | ············SaveAndReload(); |
126 | ············Assert.That(4 ==··m.Reisen.Count, "Count of Reisen wrong"); |
127 | ········} |
128 | |
129 | ········[Test] |
130 | ········public void ReisenLastIndexOf() |
131 | ········{ |
132 | ············AddRange(); |
133 | ············int i = m.ReisenLastIndexOf(r, 1, 2); |
134 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
135 | ········} |
136 | |
137 | ········[Test] |
138 | ········public void ReisenRemoveRange() |
139 | ········{ |
140 | ············AddRange(); |
141 | ············m.ReisenRemoveRange(0, 1); |
142 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
143 | ············Assert.That(1 ==··m.Reisen.Count, "Count of Reisen wrong #1"); |
144 | ············SaveAndReload(); |
145 | ············Assert.That(1 ==··m.Reisen.Count, "Count of Reisen wrong #2"); |
146 | ········} |
147 | |
148 | ········[Test] |
149 | ········public void ReisenReverse() |
150 | ········{ |
151 | ············AddRange(); |
152 | ············m.ReisenReverse(); |
153 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
154 | ········} |
155 | |
156 | ········//[Test] |
157 | ········//public void ReisenSetRange() |
158 | ········//{ |
159 | ········//····AddRange(); |
160 | ········//····ArrayList l = new ArrayList(); |
161 | ········//····l.Add(CreateReise("foo")); |
162 | ········//····l.Add(CreateReise("bar")); |
163 | ········//····m.ReisenSetRange(0, l); |
164 | ····//Assert.That(GetLoadState(), "Relation not loaded"); |
165 | ····//Assert.That("foo" ==··(m.Reisen[0] as Reise).Zweck, "Falsche Reise #1"); |
166 | ····//Assert.That("bar" ==··(m.Reisen[1] as Reise).Zweck, "Falsche Reise #2"); |
167 | ····//····//····SaveAndReload(); |
168 | ····//Assert.That(2 ==··m.Reisen.Count, "Count of Reisen wrong"); |
169 | ····//····//····if (((Reise)m.Reisen[0]).NDOObjectId.Id[0] is Int32) |
170 | ····//····//····{ |
171 | ····//····//········m.ReisenSort(); |
172 | ····//····Assert.That("bar" ==··(m.Reisen[0] as Reise).Zweck, "Falsche Reise #3"); |
173 | ····//····Assert.That("foo" ==··(m.Reisen[1] as Reise).Zweck, "Falsche Reise #4"); |
174 | ········//····} |
175 | ········//} |
176 | |
177 | ········[Test] |
178 | ········public void ReisenSort() |
179 | ········{ |
180 | ············AddRange(); |
181 | ············m.ReisenSort(); |
182 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
183 | ········} |
184 | |
185 | ········[Test] |
186 | ········public void ReisenToArray() |
187 | ········{ |
188 | ············AddRange(); |
189 | ············object o = m.ReisenToArray(typeof(Reise)); |
190 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
191 | ········} |
192 | |
193 | ········//[Test] |
194 | ········//public void ReisenTrimToSize() |
195 | ········//{ |
196 | ········//····AddRange(); |
197 | ········//····m.ReisenTrimToSize(); |
198 | ········//Assert.That(GetLoadState(), "Relation not loaded"); |
199 | ········//} |
200 | ········ |
201 | ········[Test] |
202 | ········public void ReisenCount() |
203 | ········{ |
204 | ············AddRange(); |
205 | ············int x = m.ReisenCount; |
206 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
207 | ········} |
208 | |
209 | ········[Test] |
210 | ········public void ReisenContains() |
211 | ········{ |
212 | ············AddRange(); |
213 | ············bool test = m.ReisenContains(r); |
214 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
215 | ········} |
216 | |
217 | ········[Test] |
218 | ········public void ReisenCopyTo() |
219 | ········{ |
220 | ············AddRange(); |
221 | ············Reise[] arr = m.ReisenCopyTo; |
222 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
223 | ············Assert.That((arr[0].Zweck == r.Zweck || arr[0].Zweck == r2.Zweck) && (arr[1].Zweck == r.Zweck || arr[1].Zweck == r2.Zweck), "Reisen not found"); |
224 | ········} |
225 | |
226 | ········[Test] |
227 | ········public void ReisenEquals() |
228 | ········{ |
229 | ············Object o = r; |
230 | ············AddRange(); |
231 | ············bool dummy = m.ReisenEquals(o); |
232 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
233 | ········} |
234 | |
235 | ········[Test] |
236 | ········public void ReisenEnumerator() |
237 | ········{ |
238 | ············AddRange(); |
239 | ············IEnumerator ie = m.ReisenEnumerator; |
240 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
241 | ············ie.MoveNext(); |
242 | ············Assert.That(((Reise)ie.Current).Zweck != r.Zweck ||··((Reise)ie.Current).Zweck != r2.Zweck, "Reise wrong #1"); |
243 | ············ie.MoveNext(); |
244 | ············Assert.That(((Reise)ie.Current).Zweck != r.Zweck ||··((Reise)ie.Current).Zweck != r2.Zweck, "Reise wrong #2"); |
245 | ········} |
246 | |
247 | ········[Test] |
248 | ········public void ReisenHashCode() |
249 | ········{ |
250 | ············AddRange(); |
251 | ············int result = m.ReisenHashCode(); |
252 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
253 | ········} |
254 | |
255 | ········[Test] |
256 | ········public void ReisenGetType() |
257 | ········{ |
258 | ············AddRange(); |
259 | ············Type t = m.ReisenGetType(); |
260 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
261 | ········} |
262 | |
263 | ········[Test] |
264 | ········public void ReisenIndexOf() |
265 | ········{ |
266 | ············AddRange(); |
267 | ············int result = m.ReisenIndexOf(r); |
268 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
269 | ········} |
270 | |
271 | ········//[Test] |
272 | ········//public void ReisenIsFixedSize() |
273 | ········//{ |
274 | ········//····AddRange(); |
275 | ········//····bool result = m.ReisenIsFixedSize; |
276 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
277 | ········//} |
278 | |
279 | ········//[Test] |
280 | ········//public void ReisenIsReadOnly() |
281 | ········//{ |
282 | ········//····AddRange(); |
283 | ········//····bool result = m.ReisenIsReadOnly; |
284 | //·· Assert.That(GetLoadState(), "Relation not loaded"); |
285 | ········//} |
286 | |
287 | |
288 | ········//[Test] |
289 | ········//public void ReisenIsSynchronized() |
290 | ········//{ |
291 | ········//····AddRange(); |
292 | ········//····bool b = m.ReisenIsSynchronized; |
293 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
294 | ········//} |
295 | |
296 | |
297 | ········//[Test] |
298 | ········//public void ReisenSyncRoot() |
299 | ········//{ |
300 | ········//····AddRange(); |
301 | ········//····object o = m.ReisenSyncRoot; |
302 | //····Assert.That(GetLoadState(), "Relation not loaded"); |
303 | ········//} |
304 | |
305 | ········[Test] |
306 | ········public void ReisenRemoveAt() |
307 | ········{ |
308 | ············AddRange(); |
309 | ············m.ReisenRemoveAt(1); |
310 | ············string zweck = ((Reise)m.Reisen[0]).Zweck; |
311 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
312 | ············SaveAndReload(); |
313 | ············Assert.That(1 ==··m.Reisen.Count, "Wrong count"); |
314 | ············Assert.That(zweck ==··((Reise)m.Reisen[0]).Zweck, "Reise wrong"); |
315 | ········} |
316 | |
317 | ········[Test] |
318 | ········public void ReisenToString() |
319 | ········{ |
320 | ············AddRange(); |
321 | ············string s = m.ReisenToString; |
322 | ············Assert.That(GetLoadState(), "Relation not loaded"); |
323 | ········} |
324 | |
325 | ········private Mitarbeiter CreateMitarbeiter(string vorname, string nachname) |
326 | ········{ |
327 | ············Mitarbeiter m = new Mitarbeiter(); |
328 | ············m.Vorname = vorname; |
329 | ············m.Nachname = nachname; |
330 | ············return m; |
331 | ········} |
332 | |
333 | ········private Reise CreateReise(string zweck) |
334 | ········{ |
335 | ············Reise r = new Reise(); |
336 | ············r.Zweck = zweck; |
337 | ············return r; |
338 | ········} |
339 | |
340 | ········private bool GetLoadState() |
341 | ········{ |
342 | ············NDO.Mapping.Relation r = pm.NDOMapping.FindClass(typeof(Mitarbeiter)).FindRelation("dieReisen"); |
343 | var lss = ( ILoadStateSupport) r; |
344 | return ( ( IPersistenceCapable) m) . NDOGetLoadState( lss. Ordinal) ; |
345 | ········} |
346 | |
347 | ········private void SaveAndReload() |
348 | ········{ |
349 | ············pm.Save(); |
350 | ············pm.UnloadCache(); |
351 | ············NDOQuery<Mitarbeiter> q = new NDOQuery<Mitarbeiter>(pm); |
352 | ············m = (Mitarbeiter) q.ExecuteSingle(true); |
353 | ········} |
354 | |
355 | |
356 | ····} |
357 | } |
358 |