blob: afffed5f6d434e5bd4b3cbf38780f10e4b784c7b [file] [log] [blame]
Jens Geyeraffea7b2020-05-22 17:28:30 +02001// Licensed to the Apache Software Foundation(ASF) under one
2// or more contributor license agreements.See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18using System;
19using System.Collections.Generic;
20using System.Diagnostics;
21using System.Linq;
22using System.Text;
23using Microsoft.VisualStudio.TestTools.UnitTesting;
24using OptReqDefTest;
25using Thrift.Collections;
26
27namespace Thrift.Tests.DataModel
28{
29 // ReSharper disable once InconsistentNaming
30 [TestClass]
31 public class DeepCopyTests
32 {
33 [TestMethod]
34 public void Test_Complex_DeepCopy()
35 {
36 var first = InitializeInstance(new RaceDetails());
37 VerifyIdenticalContent(first, InitializeInstance(new RaceDetails()));
38
39 var second = first.DeepCopy();
40 VerifyIdenticalContent(first, second);
41 ModifyInstance(second,0);
42 VerifyDifferentContent(first, second);
43 VerifyIdenticalContent(first, InitializeInstance(new RaceDetails()));
44
45 var third = second.DeepCopy();
46 VerifyIdenticalContent(second, third);
47 ModifyInstance(third,0);
48 VerifyDifferentContent(second, third);
49 VerifyIdenticalContent(first, InitializeInstance(new RaceDetails()));
50 }
51
Jens Geyer3cac3202022-01-31 18:04:35 +010052 private RaceDetails? MakeNestedRaceDetails(int nesting)
Jens Geyeraffea7b2020-05-22 17:28:30 +020053 {
54 if (++nesting > 1)
55 return null;
56
57 var instance = new RaceDetails();
58 InitializeInstance(instance,nesting);
59 return instance;
60 }
61
Jens Geyer3cac3202022-01-31 18:04:35 +010062 private jack? MakeNestedUnion(int nesting)
Jens Geyeraffea7b2020-05-22 17:28:30 +020063 {
64 if (++nesting > 1)
65 return null;
66
67 var details = new RaceDetails();
68 InitializeInstance(details,nesting);
69 return new jack.nested_struct(details);
70 }
71
72
73 private RaceDetails InitializeInstance(RaceDetails instance, int nesting = 0)
74 {
75 // at init, we intentionally leave all non-required fields unset
76 Assert.IsFalse(instance.__isset.opt_one);
77 Assert.IsFalse(instance.__isset.opt_two);
78 Assert.IsFalse(instance.__isset.opt_three);
79 Assert.IsFalse(instance.__isset.opt_four);
80 Assert.IsFalse(instance.__isset.opt_five);
81 Assert.IsFalse(instance.__isset.opt_six);
82 Assert.IsFalse(instance.__isset.opt_seven);
83 Assert.IsFalse(instance.__isset.opt_eight);
84
85 // set all required to null/default
86 instance.Req_one = default;
87 instance.Req_two = default;
88 instance.Req_three = default;
Jens Geyer3cac3202022-01-31 18:04:35 +010089 Assert.IsNotNull(instance.Req_four);
90 Assert.IsNotNull(instance.Req_five);
Jens Geyeraffea7b2020-05-22 17:28:30 +020091 instance.Req_six = default;
92 instance.Req_seven = default;;
Jens Geyer3cac3202022-01-31 18:04:35 +010093 instance.Req_eight = default;
Jens Geyeraffea7b2020-05-22 17:28:30 +020094
95 // leave non-required fields unset again
96 Assert.IsFalse(instance.__isset.def_one);
97 Assert.IsFalse(instance.__isset.def_two);
98 Assert.IsFalse(instance.__isset.def_three);
99 Assert.IsFalse(instance.__isset.def_four);
100 Assert.IsFalse(instance.__isset.def_five);
101 Assert.IsFalse(instance.__isset.def_six);
102 Assert.IsFalse(instance.__isset.def_seven);
103 Assert.IsFalse(instance.__isset.def_eight);
104
105 // these should have IDL defaults set
106
107 Assert.IsTrue(instance.__isset.opt_one_with_value);
108 Assert.IsTrue(instance.__isset.opt_two_with_value);
109 Assert.IsTrue(instance.__isset.opt_three_with_value);
110 Assert.IsTrue(instance.__isset.opt_four_with_value);
111 Assert.IsTrue(instance.__isset.opt_five_with_value);
112 Assert.IsTrue(instance.__isset.opt_six_with_value);
113 Assert.IsTrue(instance.__isset.opt_seven_with_value);
114 Assert.IsTrue(instance.__isset.opt_eight_with_value);
115
116 Assert.AreEqual(instance.Req_one_with_value, (Distance)1);
117 Assert.AreEqual(instance.Req_two_with_value, 2.22);
118 Assert.AreEqual(instance.Req_three_with_value, 3);
119 Assert.AreEqual(instance.Req_four_with_value, "four");
Jens Geyer3cac3202022-01-31 18:04:35 +0100120 Assert.AreEqual("five", Encoding.UTF8.GetString(instance.Req_five_with_value!));
Jens Geyeraffea7b2020-05-22 17:28:30 +0200121
Jens Geyer3cac3202022-01-31 18:04:35 +0100122 Assert.IsTrue(instance.Req_six_with_value!.Count == 1);
Jens Geyeraffea7b2020-05-22 17:28:30 +0200123 Assert.AreEqual(instance.Req_six_with_value[0], 6 );
124
Jens Geyer3cac3202022-01-31 18:04:35 +0100125 Assert.IsTrue(instance.Req_seven_with_value!.Count == 1);
Jens Geyeraffea7b2020-05-22 17:28:30 +0200126 Assert.IsTrue(instance.Req_seven_with_value.Contains(7));
127
Jens Geyer3cac3202022-01-31 18:04:35 +0100128 Assert.IsTrue(instance.Req_eight_with_value!.Count == 1);
Jens Geyeraffea7b2020-05-22 17:28:30 +0200129 Assert.IsTrue(instance.Req_eight_with_value[8] == 8);
130
131 Assert.IsTrue(instance.__isset.def_one_with_value);
132 Assert.IsTrue(instance.__isset.def_two_with_value);
133 Assert.IsTrue(instance.__isset.def_three_with_value);
134 Assert.IsTrue(instance.__isset.def_four_with_value);
135 Assert.IsTrue(instance.__isset.def_five_with_value);
136 Assert.IsTrue(instance.__isset.def_six_with_value);
137 Assert.IsTrue(instance.__isset.def_seven_with_value);
138 Assert.IsTrue(instance.__isset.def_eight_with_value);
139
140 instance.Last_of_the_mohicans = true;
141
142 if (nesting < 2)
143 {
144 instance.Far_list = new List<Distance>() { Distance.foo, Distance.bar, Distance.baz };
Jens Geyer3cac3202022-01-31 18:04:35 +0100145 instance.Far_set = new HashSet<Distance>() { Distance.foo, Distance.bar, Distance.baz };
Jens Geyeraffea7b2020-05-22 17:28:30 +0200146 instance.Far_map = new Dictionary<Distance, Distance>() { [Distance.foo] = Distance.foo, [Distance.bar] = Distance.bar, [Distance.baz] = Distance.baz };
147
Jens Geyer3cac3202022-01-31 18:04:35 +0100148 instance.Far_set_list = new HashSet<List<Distance>>() { new List<Distance>() { Distance.foo } };
149 instance.Far_list_map_set = new List<Dictionary<sbyte, HashSet<Distance>>>() { new Dictionary<sbyte, HashSet<Distance>>() { [1] = new HashSet<Distance>() { Distance.baz } } };
150
151 instance.Far_map_dist_to_rds = new Dictionary<Distance, List<RaceDetails>>() { [Distance.bar] = new List<RaceDetails>() };
152 var details = MakeNestedRaceDetails(nesting);
153 if (details != null)
154 instance.Far_map_dist_to_rds[Distance.bar].Add(details);
Jens Geyeraffea7b2020-05-22 17:28:30 +0200155
156 instance.Req_nested = MakeNestedRaceDetails(nesting);
157 Assert.IsFalse(instance.__isset.opt_nested);
158 Assert.IsFalse(instance.__isset.def_nested);
159
160 instance.Req_union = MakeNestedUnion(nesting);
161 Assert.IsFalse(instance.__isset.opt_union);
162 Assert.IsFalse(instance.__isset.def_union);
163 }
164
165 instance.Triplesix = (Distance)666;
166
167 return instance;
168 }
169
170 private void ModifyInstance(RaceDetails instance, int level)
171 {
172 if ((instance == null) || (++level > 4))
173 return;
174
175 instance.Opt_one = ModifyValue(instance.Opt_one);
176 instance.Opt_two = ModifyValue(instance.Opt_two);
177 instance.Opt_three = ModifyValue(instance.Opt_three);
178 instance.Opt_four = ModifyValue(instance.Opt_four);
179 instance.Opt_five = ModifyValue(instance.Opt_five);
180 instance.Opt_six = ModifyValue(instance.Opt_six);
181 instance.Opt_seven = ModifyValue(instance.Opt_seven);
182 instance.Opt_eight = ModifyValue(instance.Opt_eight);
183
184 instance.Req_one = ModifyValue(instance.Req_one);
185 instance.Req_two = ModifyValue(instance.Req_two);
186 instance.Req_three = ModifyValue(instance.Req_three);
187 instance.Req_four = ModifyValue(instance.Req_four);
188 instance.Req_five = ModifyValue(instance.Req_five);
189 instance.Req_six = ModifyValue(instance.Req_six);
190 instance.Req_seven = ModifyValue(instance.Req_seven);
191 instance.Req_eight = ModifyValue(instance.Req_eight);
192
193 instance.Def_one = ModifyValue(instance.Def_one);
194 instance.Def_two = ModifyValue(instance.Def_two);
195 instance.Def_three = ModifyValue(instance.Def_three);
196 instance.Def_four = ModifyValue(instance.Def_four);
197 instance.Def_five = ModifyValue(instance.Def_five);
198 instance.Def_six = ModifyValue(instance.Def_six);
199 instance.Def_seven = ModifyValue(instance.Def_seven);
200 instance.Def_eight = ModifyValue(instance.Def_eight);
201
202 instance.Opt_one_with_value = ModifyValue(instance.Opt_one_with_value);
203 instance.Opt_two_with_value = ModifyValue(instance.Opt_two_with_value);
204 instance.Opt_three_with_value = ModifyValue(instance.Opt_three_with_value);
205 instance.Opt_four_with_value = ModifyValue(instance.Opt_four_with_value);
206 instance.Opt_five_with_value = ModifyValue(instance.Opt_five_with_value);
207 instance.Opt_six_with_value = ModifyValue(instance.Opt_six_with_value);
208 instance.Opt_seven_with_value = ModifyValue(instance.Opt_seven_with_value);
209 instance.Opt_eight_with_value = ModifyValue(instance.Opt_eight_with_value);
210
211 instance.Req_one_with_value = ModifyValue(instance.Req_one_with_value);
212 instance.Req_two_with_value = ModifyValue(instance.Req_two_with_value);
213 instance.Req_three_with_value = ModifyValue(instance.Req_three_with_value);
214 instance.Req_four_with_value = ModifyValue(instance.Req_four_with_value);
215 instance.Req_five_with_value = ModifyValue(instance.Req_five_with_value);
216 instance.Req_six_with_value = ModifyValue(instance.Req_six_with_value);
217 instance.Req_seven_with_value = ModifyValue(instance.Req_seven_with_value);
218 instance.Req_eight_with_value = ModifyValue(instance.Req_eight_with_value);
219
220 instance.Def_one_with_value = ModifyValue(instance.Def_one_with_value);
221 instance.Def_two_with_value = ModifyValue(instance.Def_two_with_value);
222 instance.Def_three_with_value = ModifyValue(instance.Def_three_with_value);
223 instance.Def_four_with_value = ModifyValue(instance.Def_four_with_value);
224 instance.Def_five_with_value = ModifyValue(instance.Def_five_with_value);
225 instance.Def_six_with_value = ModifyValue(instance.Def_six_with_value);
226 instance.Def_seven_with_value = ModifyValue(instance.Def_seven_with_value);
227 instance.Def_eight_with_value = ModifyValue(instance.Def_eight_with_value);
228
229 instance.Last_of_the_mohicans = ModifyValue(instance.Last_of_the_mohicans);
230
231 instance.Far_list = ModifyValue(instance.Far_list);
232 instance.Far_set = ModifyValue(instance.Far_set);
233 instance.Far_map = ModifyValue(instance.Far_map);
234
235 instance.Far_set_list = ModifyValue(instance.Far_set_list);
236 instance.Far_list_map_set = ModifyValue(instance.Far_list_map_set);
237 instance.Far_map_dist_to_rds = ModifyValue(instance.Far_map_dist_to_rds, level);
238
239 instance.Req_nested = ModifyValue(instance.Req_nested, level);
240 instance.Opt_nested = ModifyValue(instance.Opt_nested, level);
241 instance.Def_nested = ModifyValue(instance.Def_nested, level);
242
243 instance.Req_union = ModifyValue(instance.Req_union, level);
244 instance.Opt_union = ModifyValue(instance.Opt_union, level);
245 instance.Def_union = ModifyValue(instance.Def_union, level);
246
247 instance.Triplesix = ModifyValue(instance.Triplesix);
248 }
249
Jens Geyer3cac3202022-01-31 18:04:35 +0100250 private jack? ModifyValue(jack? value, int level)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200251 {
252 if (++level > 4)
253 return value;
254
255 if (value == null)
256 value = MakeNestedUnion(0);
Jens Geyer3cac3202022-01-31 18:04:35 +0100257 Debug.Assert(value?.As_nested_struct != null);
Jens Geyeraffea7b2020-05-22 17:28:30 +0200258 ModifyInstance(value.As_nested_struct, level);
259 return value;
260 }
261
Jens Geyer3cac3202022-01-31 18:04:35 +0100262 private RaceDetails? ModifyValue(RaceDetails? value, int level)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200263 {
264 if (++level > 4)
265 return value;
266
267 if (value == null)
268 value = new RaceDetails();
269 ModifyInstance(value,level);
270 return value;
271 }
272
Jens Geyer3cac3202022-01-31 18:04:35 +0100273 private Dictionary<Distance, List<RaceDetails>> ModifyValue(Dictionary<Distance, List<RaceDetails>>? value, int level)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200274 {
275 if (value == null)
276 value = new Dictionary<Distance, List<RaceDetails>>();
277
278 if (++level > 4)
279 return value;
280
281 var details = new RaceDetails();
282 InitializeInstance(details);
283 value[Distance.foo] = new List<RaceDetails>() { details };
284
285 if (value.TryGetValue(Distance.bar, out var list) && (list.Count > 0))
286 {
287 ModifyInstance(list[0], level);
Jens Geyer3cac3202022-01-31 18:04:35 +0100288 //list.Add(null); -- Thrift does not allow null values in containers
Jens Geyeraffea7b2020-05-22 17:28:30 +0200289 }
290
Jens Geyer3cac3202022-01-31 18:04:35 +0100291 // Thrift does not allow null values in containers
292 //value[Distance.baz] = null;
Jens Geyeraffea7b2020-05-22 17:28:30 +0200293
294 return value;
295 }
296
Jens Geyer3cac3202022-01-31 18:04:35 +0100297 private static List<Dictionary<sbyte, HashSet<Distance>>> ModifyValue(List<Dictionary<sbyte, HashSet<Distance>>>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200298 {
299 if (value == null)
Jens Geyer3cac3202022-01-31 18:04:35 +0100300 value = new List<Dictionary<sbyte, HashSet<Distance>>>();
Jens Geyeraffea7b2020-05-22 17:28:30 +0200301
302 if (value.Count == 0)
Jens Geyer3cac3202022-01-31 18:04:35 +0100303 value.Add(new Dictionary<sbyte, HashSet<Distance>>());
304 //else
305 //value.Add(null); --Thrift does not allow null values in containers
Jens Geyeraffea7b2020-05-22 17:28:30 +0200306
307 sbyte key = (sbyte)(value[0].Count + 10);
308 if (value[0].Count == 0)
Jens Geyer3cac3202022-01-31 18:04:35 +0100309 value[0].Add(key, new HashSet<Distance>());
310 //else
311 //value[0].Add(key, null); --Thrift does not allow null values in containers
Jens Geyeraffea7b2020-05-22 17:28:30 +0200312
313 foreach (var entry in value)
314 {
315 if (entry != null)
316 {
317 foreach (var pair in entry)
318 {
319 if (pair.Value != null)
320 {
321 if (pair.Value.Contains(Distance.baz))
322 pair.Value.Remove(Distance.baz);
323 else
324 pair.Value.Add(Distance.baz);
325 }
326 }
327 }
328 }
329
330 return value;
331 }
332
Jens Geyer3cac3202022-01-31 18:04:35 +0100333 private static HashSet<List<Distance>> ModifyValue(HashSet<List<Distance>>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200334 {
335 if (value == null)
Jens Geyer3cac3202022-01-31 18:04:35 +0100336 value = new HashSet<List<Distance>>();
Jens Geyeraffea7b2020-05-22 17:28:30 +0200337
338 if (value.Count == 0)
339 value.Add(new List<Distance>());
Jens Geyer3cac3202022-01-31 18:04:35 +0100340 //else
341 //value.Add(null); -- Thrift does not allow null values in containers
Jens Geyeraffea7b2020-05-22 17:28:30 +0200342
343 foreach (var entry in value)
344 if( entry != null)
345 entry.Add(Distance.baz);
346
347 return value;
348 }
349
Jens Geyer3cac3202022-01-31 18:04:35 +0100350 private static Dictionary<Distance, Distance> ModifyValue(Dictionary<Distance, Distance>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200351 {
352 if (value == null)
353 value = new Dictionary<Distance, Distance>();
354 value[Distance.foo] = value.ContainsKey(Distance.foo) ? ++value[Distance.foo] : Distance.foo;
355 value[Distance.bar] = value.ContainsKey(Distance.bar) ? ++value[Distance.bar] : Distance.bar;
356 value[Distance.baz] = value.ContainsKey(Distance.baz) ? ++value[Distance.baz] : Distance.baz;
357 return value;
358 }
359
Jens Geyer3cac3202022-01-31 18:04:35 +0100360 private static HashSet<Distance> ModifyValue(HashSet<Distance>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200361 {
362 if (value == null)
Jens Geyer3cac3202022-01-31 18:04:35 +0100363 value = new HashSet<Distance>();
Jens Geyeraffea7b2020-05-22 17:28:30 +0200364
365 if (value.Contains(Distance.foo))
366 value.Remove(Distance.foo);
367 else
368 value.Add(Distance.foo);
369
370 if (value.Contains(Distance.bar))
371 value.Remove(Distance.bar);
372 else
373 value.Add(Distance.bar);
374
375 if (value.Contains(Distance.baz))
376 value.Remove(Distance.baz);
377 else
378 value.Add(Distance.baz);
379
380 return value;
381 }
382
Jens Geyer3cac3202022-01-31 18:04:35 +0100383 private static List<Distance> ModifyValue(List<Distance>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200384 {
385 if (value == null)
386 value = new List<Distance>();
387 value.Add(Distance.foo);
388 value.Add(Distance.bar);
389 value.Add(Distance.baz);
390 return value;
391 }
392
Jens Geyer98a23252022-01-09 16:50:52 +0100393 private static bool ModifyValue(bool value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200394 {
395 return !value;
396 }
397
Jens Geyer3cac3202022-01-31 18:04:35 +0100398 private static Dictionary<sbyte, short> ModifyValue(Dictionary<sbyte, short>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200399 {
400 if (value == null)
401 value = new Dictionary<sbyte, short>();
402 value.Add((sbyte)(value.Count + 10), (short)value.Count);
403 return value;
404 }
405
Jens Geyer3cac3202022-01-31 18:04:35 +0100406 private static HashSet<long> ModifyValue(HashSet<long>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200407 {
408 if (value == null)
Jens Geyer3cac3202022-01-31 18:04:35 +0100409 value = new HashSet<long>();
Jens Geyeraffea7b2020-05-22 17:28:30 +0200410 value.Add(value.Count+100);
411 return value;
412 }
413
Jens Geyer3cac3202022-01-31 18:04:35 +0100414 private static List<int> ModifyValue(List<int>? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200415 {
416 if (value == null)
417 value = new List<int>();
418 value.Add(value.Count);
419 return value;
420 }
421
Jens Geyer3cac3202022-01-31 18:04:35 +0100422 private static byte[] ModifyValue(byte[]? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200423 {
424 if (value == null)
425 value = new byte[1] { 0 };
426 if (value.Length > 0)
427 value[0] = (value[0] < 0xFF) ? ++value[0] : (byte)0;
Jens Geyer3cac3202022-01-31 18:04:35 +0100428 else
429 value = new byte[1] { 0 };
Jens Geyeraffea7b2020-05-22 17:28:30 +0200430 return value;
431 }
432
Jens Geyer3cac3202022-01-31 18:04:35 +0100433 private static string ModifyValue(string? value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200434 {
435 return value + "1";
436 }
437
Jens Geyer98a23252022-01-09 16:50:52 +0100438 private static double ModifyValue(double value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200439 {
440 return value + 1.1;
441 }
442
Jens Geyer98a23252022-01-09 16:50:52 +0100443 private static short ModifyValue(short value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200444 {
445 return ++value;
446 }
447
Jens Geyer98a23252022-01-09 16:50:52 +0100448 private static Distance ModifyValue(Distance value)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200449 {
450 return ++value;
451 }
452
Jens Geyer98a23252022-01-09 16:50:52 +0100453 private static void VerifyDifferentContent(RaceDetails first, RaceDetails second)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200454 {
455 Assert.AreNotEqual(first, second);
456
457 Assert.AreNotEqual(first.Opt_two, second.Opt_two);
458 Assert.AreNotEqual(first.Opt_three, second.Opt_three);
459 Assert.AreNotEqual(first.Opt_four, second.Opt_four);
460 Assert.IsFalse(TCollections.Equals(first.Opt_five, second.Opt_five));
461 Assert.IsFalse(TCollections.Equals(first.Opt_six, second.Opt_six));
462 Assert.IsFalse(TCollections.Equals(first.Opt_seven, second.Opt_seven));
463 Assert.IsFalse(TCollections.Equals(first.Opt_eight, second.Opt_eight));
464
465 Assert.AreNotEqual(first.Req_one, second.Req_one);
466 Assert.AreNotEqual(first.Req_two, second.Req_two);
467 Assert.AreNotEqual(first.Req_three, second.Req_three);
468 Assert.AreNotEqual(first.Req_four, second.Req_four);
469 Assert.IsFalse(TCollections.Equals(first.Req_five, second.Req_five));
470 Assert.IsFalse(TCollections.Equals(first.Req_six, second.Req_six));
471 Assert.IsFalse(TCollections.Equals(first.Req_seven, second.Req_seven));
472 Assert.IsFalse(TCollections.Equals(first.Req_eight, second.Req_eight));
473
474 Assert.AreNotEqual(first.Def_one, second.Def_one);
475 Assert.AreNotEqual(first.Def_two, second.Def_two);
476 Assert.AreNotEqual(first.Def_three, second.Def_three);
477 Assert.AreNotEqual(first.Def_four, second.Def_four);
478 Assert.IsFalse(TCollections.Equals(first.Def_five, second.Def_five));
479 Assert.IsFalse(TCollections.Equals(first.Def_six, second.Def_six));
480 Assert.IsFalse(TCollections.Equals(first.Def_seven, second.Def_seven));
481 Assert.IsFalse(TCollections.Equals(first.Def_eight, second.Def_eight));
482
483 Assert.AreNotEqual(first.Opt_one_with_value, second.Opt_one_with_value);
484 Assert.AreNotEqual(first.Opt_two_with_value, second.Opt_two_with_value);
485 Assert.AreNotEqual(first.Opt_three_with_value, second.Opt_three_with_value);
486 Assert.AreNotEqual(first.Opt_four_with_value, second.Opt_four_with_value);
487 Assert.IsFalse(TCollections.Equals(first.Opt_five_with_value, second.Opt_five_with_value));
488 Assert.IsFalse(TCollections.Equals(first.Opt_six_with_value, second.Opt_six_with_value));
489 Assert.IsFalse(TCollections.Equals(first.Opt_seven_with_value, second.Opt_seven_with_value));
490 Assert.IsFalse(TCollections.Equals(first.Opt_eight_with_value, second.Opt_eight_with_value));
491
492 Assert.AreNotEqual(first.Req_one_with_value, second.Req_one_with_value);
493 Assert.AreNotEqual(first.Req_two_with_value, second.Req_two_with_value);
494 Assert.AreNotEqual(first.Req_three_with_value, second.Req_three_with_value);
495 Assert.AreNotEqual(first.Req_four_with_value, second.Req_four_with_value);
496 Assert.IsFalse(TCollections.Equals(first.Req_five_with_value, second.Req_five_with_value));
497 Assert.IsFalse(TCollections.Equals(first.Req_six_with_value, second.Req_six_with_value));
498 Assert.IsFalse(TCollections.Equals(first.Req_seven_with_value, second.Req_seven_with_value));
499 Assert.IsFalse(TCollections.Equals(first.Req_eight_with_value, second.Req_eight_with_value));
500
501 Assert.AreNotEqual(first.Def_one_with_value, second.Def_one_with_value);
502 Assert.AreNotEqual(first.Def_two_with_value, second.Def_two_with_value);
503 Assert.AreNotEqual(first.Def_three_with_value, second.Def_three_with_value);
504 Assert.AreNotEqual(first.Def_four_with_value, second.Def_four_with_value);
505 Assert.IsFalse(TCollections.Equals(first.Def_five_with_value, second.Def_five_with_value));
506 Assert.IsFalse(TCollections.Equals(first.Def_six_with_value, second.Def_six_with_value));
507 Assert.IsFalse(TCollections.Equals(first.Def_seven_with_value, second.Def_seven_with_value));
508 Assert.IsFalse(TCollections.Equals(first.Def_eight_with_value, second.Def_eight_with_value));
509
510 Assert.AreNotEqual(first.Last_of_the_mohicans, second.Last_of_the_mohicans);
511
512 Assert.IsFalse(TCollections.Equals(first.Far_list, second.Far_list));
513 Assert.IsFalse(TCollections.Equals(first.Far_set, second.Far_set));
514 Assert.IsFalse(TCollections.Equals(first.Far_map, second.Far_map));
515
516 Assert.IsFalse(TCollections.Equals(first.Far_set_list, second.Far_set_list));
517 Assert.IsFalse(TCollections.Equals(first.Far_list_map_set, second.Far_list_map_set));
518 Assert.IsFalse(TCollections.Equals(first.Far_map_dist_to_rds, second.Far_map_dist_to_rds));
519
520 Assert.AreNotEqual(first.Req_nested, second.Req_nested);
521 Assert.AreNotEqual(first.Opt_nested, second.Opt_nested);
522 Assert.AreNotEqual(first.Def_nested, second.Def_nested);
523
524 Assert.AreNotEqual(first.Req_union, second.Req_union);
525 Assert.AreNotEqual(first.Opt_union, second.Opt_union);
526 Assert.AreNotEqual(first.Def_union, second.Def_union);
527
528 Assert.AreNotEqual(first.Triplesix, second.Triplesix);
529 }
530
Jens Geyer98a23252022-01-09 16:50:52 +0100531 private static void VerifyIdenticalContent(RaceDetails first, RaceDetails second)
Jens Geyeraffea7b2020-05-22 17:28:30 +0200532 {
533 Assert.AreEqual(first, second);
534
535 Assert.AreEqual(first.Opt_two, second.Opt_two);
536 Assert.AreEqual(first.Opt_three, second.Opt_three);
537 Assert.AreEqual(first.Opt_four, second.Opt_four);
538 Assert.IsTrue(TCollections.Equals(first.Opt_five, second.Opt_five));
539 Assert.IsTrue(TCollections.Equals(first.Opt_six, second.Opt_six));
540 Assert.IsTrue(TCollections.Equals(first.Opt_seven, second.Opt_seven));
541 Assert.IsTrue(TCollections.Equals(first.Opt_eight, second.Opt_eight));
542
543 Assert.AreEqual(first.Req_one, second.Req_one);
544 Assert.AreEqual(first.Req_two, second.Req_two);
545 Assert.AreEqual(first.Req_three, second.Req_three);
546 Assert.AreEqual(first.Req_four, second.Req_four);
547 Assert.IsTrue(TCollections.Equals(first.Req_five, second.Req_five));
548 Assert.IsTrue(TCollections.Equals(first.Req_six, second.Req_six));
549 Assert.IsTrue(TCollections.Equals(first.Req_seven, second.Req_seven));
550 Assert.IsTrue(TCollections.Equals(first.Req_eight, second.Req_eight));
551
552 Assert.AreEqual(first.Def_one, second.Def_one);
553 Assert.AreEqual(first.Def_two, second.Def_two);
554 Assert.AreEqual(first.Def_three, second.Def_three);
555 Assert.AreEqual(first.Def_four, second.Def_four);
556 Assert.IsTrue(TCollections.Equals(first.Def_five, second.Def_five));
557 Assert.IsTrue(TCollections.Equals(first.Def_six, second.Def_six));
558 Assert.IsTrue(TCollections.Equals(first.Def_seven, second.Def_seven));
559 Assert.IsTrue(TCollections.Equals(first.Def_eight, second.Def_eight));
560
561 Assert.AreEqual(first.Opt_one_with_value, second.Opt_one_with_value);
562 Assert.AreEqual(first.Opt_two_with_value, second.Opt_two_with_value);
563 Assert.AreEqual(first.Opt_three_with_value, second.Opt_three_with_value);
564 Assert.AreEqual(first.Opt_four_with_value, second.Opt_four_with_value);
565 Assert.IsTrue(TCollections.Equals(first.Opt_five_with_value, second.Opt_five_with_value));
566 Assert.IsTrue(TCollections.Equals(first.Opt_six_with_value, second.Opt_six_with_value));
567 Assert.IsTrue(TCollections.Equals(first.Opt_seven_with_value, second.Opt_seven_with_value));
568 Assert.IsTrue(TCollections.Equals(first.Opt_eight_with_value, second.Opt_eight_with_value));
569
570 Assert.AreEqual(first.Req_one_with_value, second.Req_one_with_value);
571 Assert.AreEqual(first.Req_two_with_value, second.Req_two_with_value);
572 Assert.AreEqual(first.Req_three_with_value, second.Req_three_with_value);
573 Assert.AreEqual(first.Req_four_with_value, second.Req_four_with_value);
574 Assert.IsTrue(TCollections.Equals(first.Req_five_with_value, second.Req_five_with_value));
575 Assert.IsTrue(TCollections.Equals(first.Req_six_with_value, second.Req_six_with_value));
576 Assert.IsTrue(TCollections.Equals(first.Req_seven_with_value, second.Req_seven_with_value));
577 Assert.IsTrue(TCollections.Equals(first.Req_eight_with_value, second.Req_eight_with_value));
578
579 Assert.AreEqual(first.Def_one_with_value, second.Def_one_with_value);
580 Assert.AreEqual(first.Def_two_with_value, second.Def_two_with_value);
581 Assert.AreEqual(first.Def_three_with_value, second.Def_three_with_value);
582 Assert.AreEqual(first.Def_four_with_value, second.Def_four_with_value);
583 Assert.IsTrue(TCollections.Equals(first.Def_five_with_value, second.Def_five_with_value));
584 Assert.IsTrue(TCollections.Equals(first.Def_six_with_value, second.Def_six_with_value));
585 Assert.IsTrue(TCollections.Equals(first.Def_seven_with_value, second.Def_seven_with_value));
586 Assert.IsTrue(TCollections.Equals(first.Def_eight_with_value, second.Def_eight_with_value));
587
588 Assert.AreEqual(first.Last_of_the_mohicans, second.Last_of_the_mohicans);
589
590 Assert.IsTrue(TCollections.Equals(first.Far_list, second.Far_list));
591 Assert.IsTrue(TCollections.Equals(first.Far_set, second.Far_set));
592 Assert.IsTrue(TCollections.Equals(first.Far_map, second.Far_map));
593
594 Assert.IsTrue(TCollections.Equals(first.Far_set_list, second.Far_set_list));
595 Assert.IsTrue(TCollections.Equals(first.Far_list_map_set, second.Far_list_map_set));
596 Assert.IsTrue(TCollections.Equals(first.Far_map_dist_to_rds, second.Far_map_dist_to_rds));
597
598 Assert.AreEqual(first.Req_nested, second.Req_nested);
599 Assert.AreEqual(first.Opt_nested, second.Opt_nested);
600 Assert.AreEqual(first.Def_nested, second.Def_nested);
601
602 Assert.AreEqual(first.Req_union, second.Req_union);
603 Assert.AreEqual(first.Opt_union, second.Opt_union);
604 Assert.AreEqual(first.Def_union, second.Def_union);
605
606 Assert.AreEqual(first.Triplesix, second.Triplesix);
607 }
608
609 }
610}