Jens Geyer | affea7b | 2020-05-22 17:28:30 +0200 | [diff] [blame] | 1 | // 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 | |
| 18 | using System; |
| 19 | using System.Collections.Generic; |
| 20 | using System.Diagnostics; |
| 21 | using System.Linq; |
| 22 | using System.Text; |
| 23 | using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 24 | using OptReqDefTest; |
| 25 | using Thrift.Collections; |
| 26 | |
| 27 | namespace 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 | |
| 52 | private RaceDetails MakeNestedRaceDetails(int nesting) |
| 53 | { |
| 54 | if (++nesting > 1) |
| 55 | return null; |
| 56 | |
| 57 | var instance = new RaceDetails(); |
| 58 | InitializeInstance(instance,nesting); |
| 59 | return instance; |
| 60 | } |
| 61 | |
| 62 | private jack MakeNestedUnion(int nesting) |
| 63 | { |
| 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; |
| 89 | instance.Req_four = default; |
| 90 | instance.Req_five = default; |
| 91 | instance.Req_six = default; |
| 92 | instance.Req_seven = default;; |
| 93 | instance.Req_eight = default; |
| 94 | |
| 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"); |
| 120 | Assert.AreEqual("five", Encoding.UTF8.GetString(instance.Req_five_with_value)); |
| 121 | |
| 122 | Assert.IsTrue(instance.Req_six_with_value.Count == 1); |
| 123 | Assert.AreEqual(instance.Req_six_with_value[0], 6 ); |
| 124 | |
| 125 | Assert.IsTrue(instance.Req_seven_with_value.Count == 1); |
| 126 | Assert.IsTrue(instance.Req_seven_with_value.Contains(7)); |
| 127 | |
| 128 | Assert.IsTrue(instance.Req_eight_with_value.Count == 1); |
| 129 | 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 }; |
| 145 | instance.Far_set = new THashSet<Distance>() { Distance.foo, Distance.bar, Distance.baz }; |
| 146 | instance.Far_map = new Dictionary<Distance, Distance>() { [Distance.foo] = Distance.foo, [Distance.bar] = Distance.bar, [Distance.baz] = Distance.baz }; |
| 147 | |
| 148 | instance.Far_set_list = new THashSet<List<Distance>>() { new List<Distance>() { Distance.foo } }; |
| 149 | instance.Far_list_map_set = new List<Dictionary<sbyte, THashSet<Distance>>>() { new Dictionary<sbyte, THashSet<Distance>>() { [1] = new THashSet<Distance>() { Distance.baz } } }; |
| 150 | instance.Far_map_dist_to_rds = new Dictionary<Distance, List<RaceDetails>>() { [Distance.bar] = new List<RaceDetails>() { MakeNestedRaceDetails(nesting) } }; |
| 151 | |
| 152 | instance.Req_nested = MakeNestedRaceDetails(nesting); |
| 153 | Assert.IsFalse(instance.__isset.opt_nested); |
| 154 | Assert.IsFalse(instance.__isset.def_nested); |
| 155 | |
| 156 | instance.Req_union = MakeNestedUnion(nesting); |
| 157 | Assert.IsFalse(instance.__isset.opt_union); |
| 158 | Assert.IsFalse(instance.__isset.def_union); |
| 159 | } |
| 160 | |
| 161 | instance.Triplesix = (Distance)666; |
| 162 | |
| 163 | return instance; |
| 164 | } |
| 165 | |
| 166 | private void ModifyInstance(RaceDetails instance, int level) |
| 167 | { |
| 168 | if ((instance == null) || (++level > 4)) |
| 169 | return; |
| 170 | |
| 171 | instance.Opt_one = ModifyValue(instance.Opt_one); |
| 172 | instance.Opt_two = ModifyValue(instance.Opt_two); |
| 173 | instance.Opt_three = ModifyValue(instance.Opt_three); |
| 174 | instance.Opt_four = ModifyValue(instance.Opt_four); |
| 175 | instance.Opt_five = ModifyValue(instance.Opt_five); |
| 176 | instance.Opt_six = ModifyValue(instance.Opt_six); |
| 177 | instance.Opt_seven = ModifyValue(instance.Opt_seven); |
| 178 | instance.Opt_eight = ModifyValue(instance.Opt_eight); |
| 179 | |
| 180 | instance.Req_one = ModifyValue(instance.Req_one); |
| 181 | instance.Req_two = ModifyValue(instance.Req_two); |
| 182 | instance.Req_three = ModifyValue(instance.Req_three); |
| 183 | instance.Req_four = ModifyValue(instance.Req_four); |
| 184 | instance.Req_five = ModifyValue(instance.Req_five); |
| 185 | instance.Req_six = ModifyValue(instance.Req_six); |
| 186 | instance.Req_seven = ModifyValue(instance.Req_seven); |
| 187 | instance.Req_eight = ModifyValue(instance.Req_eight); |
| 188 | |
| 189 | instance.Def_one = ModifyValue(instance.Def_one); |
| 190 | instance.Def_two = ModifyValue(instance.Def_two); |
| 191 | instance.Def_three = ModifyValue(instance.Def_three); |
| 192 | instance.Def_four = ModifyValue(instance.Def_four); |
| 193 | instance.Def_five = ModifyValue(instance.Def_five); |
| 194 | instance.Def_six = ModifyValue(instance.Def_six); |
| 195 | instance.Def_seven = ModifyValue(instance.Def_seven); |
| 196 | instance.Def_eight = ModifyValue(instance.Def_eight); |
| 197 | |
| 198 | instance.Opt_one_with_value = ModifyValue(instance.Opt_one_with_value); |
| 199 | instance.Opt_two_with_value = ModifyValue(instance.Opt_two_with_value); |
| 200 | instance.Opt_three_with_value = ModifyValue(instance.Opt_three_with_value); |
| 201 | instance.Opt_four_with_value = ModifyValue(instance.Opt_four_with_value); |
| 202 | instance.Opt_five_with_value = ModifyValue(instance.Opt_five_with_value); |
| 203 | instance.Opt_six_with_value = ModifyValue(instance.Opt_six_with_value); |
| 204 | instance.Opt_seven_with_value = ModifyValue(instance.Opt_seven_with_value); |
| 205 | instance.Opt_eight_with_value = ModifyValue(instance.Opt_eight_with_value); |
| 206 | |
| 207 | instance.Req_one_with_value = ModifyValue(instance.Req_one_with_value); |
| 208 | instance.Req_two_with_value = ModifyValue(instance.Req_two_with_value); |
| 209 | instance.Req_three_with_value = ModifyValue(instance.Req_three_with_value); |
| 210 | instance.Req_four_with_value = ModifyValue(instance.Req_four_with_value); |
| 211 | instance.Req_five_with_value = ModifyValue(instance.Req_five_with_value); |
| 212 | instance.Req_six_with_value = ModifyValue(instance.Req_six_with_value); |
| 213 | instance.Req_seven_with_value = ModifyValue(instance.Req_seven_with_value); |
| 214 | instance.Req_eight_with_value = ModifyValue(instance.Req_eight_with_value); |
| 215 | |
| 216 | instance.Def_one_with_value = ModifyValue(instance.Def_one_with_value); |
| 217 | instance.Def_two_with_value = ModifyValue(instance.Def_two_with_value); |
| 218 | instance.Def_three_with_value = ModifyValue(instance.Def_three_with_value); |
| 219 | instance.Def_four_with_value = ModifyValue(instance.Def_four_with_value); |
| 220 | instance.Def_five_with_value = ModifyValue(instance.Def_five_with_value); |
| 221 | instance.Def_six_with_value = ModifyValue(instance.Def_six_with_value); |
| 222 | instance.Def_seven_with_value = ModifyValue(instance.Def_seven_with_value); |
| 223 | instance.Def_eight_with_value = ModifyValue(instance.Def_eight_with_value); |
| 224 | |
| 225 | instance.Last_of_the_mohicans = ModifyValue(instance.Last_of_the_mohicans); |
| 226 | |
| 227 | instance.Far_list = ModifyValue(instance.Far_list); |
| 228 | instance.Far_set = ModifyValue(instance.Far_set); |
| 229 | instance.Far_map = ModifyValue(instance.Far_map); |
| 230 | |
| 231 | instance.Far_set_list = ModifyValue(instance.Far_set_list); |
| 232 | instance.Far_list_map_set = ModifyValue(instance.Far_list_map_set); |
| 233 | instance.Far_map_dist_to_rds = ModifyValue(instance.Far_map_dist_to_rds, level); |
| 234 | |
| 235 | instance.Req_nested = ModifyValue(instance.Req_nested, level); |
| 236 | instance.Opt_nested = ModifyValue(instance.Opt_nested, level); |
| 237 | instance.Def_nested = ModifyValue(instance.Def_nested, level); |
| 238 | |
| 239 | instance.Req_union = ModifyValue(instance.Req_union, level); |
| 240 | instance.Opt_union = ModifyValue(instance.Opt_union, level); |
| 241 | instance.Def_union = ModifyValue(instance.Def_union, level); |
| 242 | |
| 243 | instance.Triplesix = ModifyValue(instance.Triplesix); |
| 244 | } |
| 245 | |
| 246 | private jack ModifyValue(jack value, int level) |
| 247 | { |
| 248 | if (++level > 4) |
| 249 | return value; |
| 250 | |
| 251 | if (value == null) |
| 252 | value = MakeNestedUnion(0); |
| 253 | Debug.Assert(value.As_nested_struct != null); |
| 254 | ModifyInstance(value.As_nested_struct, level); |
| 255 | return value; |
| 256 | } |
| 257 | |
| 258 | private RaceDetails ModifyValue(RaceDetails value, int level) |
| 259 | { |
| 260 | if (++level > 4) |
| 261 | return value; |
| 262 | |
| 263 | if (value == null) |
| 264 | value = new RaceDetails(); |
| 265 | ModifyInstance(value,level); |
| 266 | return value; |
| 267 | } |
| 268 | |
| 269 | private Dictionary<Distance, List<RaceDetails>> ModifyValue(Dictionary<Distance, List<RaceDetails>> value, int level) |
| 270 | { |
| 271 | if (value == null) |
| 272 | value = new Dictionary<Distance, List<RaceDetails>>(); |
| 273 | |
| 274 | if (++level > 4) |
| 275 | return value; |
| 276 | |
| 277 | var details = new RaceDetails(); |
| 278 | InitializeInstance(details); |
| 279 | value[Distance.foo] = new List<RaceDetails>() { details }; |
| 280 | |
| 281 | if (value.TryGetValue(Distance.bar, out var list) && (list.Count > 0)) |
| 282 | { |
| 283 | ModifyInstance(list[0], level); |
| 284 | list.Add(null); |
| 285 | } |
| 286 | |
| 287 | value[Distance.baz] = null; |
| 288 | |
| 289 | return value; |
| 290 | } |
| 291 | |
| 292 | private List<Dictionary<sbyte, THashSet<Distance>>> ModifyValue(List<Dictionary<sbyte, THashSet<Distance>>> value) |
| 293 | { |
| 294 | if (value == null) |
| 295 | value = new List<Dictionary<sbyte, THashSet<Distance>>>(); |
| 296 | |
| 297 | if (value.Count == 0) |
| 298 | value.Add(new Dictionary<sbyte, THashSet<Distance>>()); |
| 299 | else |
| 300 | value.Add(null); |
| 301 | |
| 302 | sbyte key = (sbyte)(value[0].Count + 10); |
| 303 | if (value[0].Count == 0) |
| 304 | value[0].Add(key, new THashSet<Distance>()); |
| 305 | else |
| 306 | value[0].Add(key, null); |
| 307 | |
| 308 | foreach (var entry in value) |
| 309 | { |
| 310 | if (entry != null) |
| 311 | { |
| 312 | foreach (var pair in entry) |
| 313 | { |
| 314 | if (pair.Value != null) |
| 315 | { |
| 316 | if (pair.Value.Contains(Distance.baz)) |
| 317 | pair.Value.Remove(Distance.baz); |
| 318 | else |
| 319 | pair.Value.Add(Distance.baz); |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | return value; |
| 326 | } |
| 327 | |
| 328 | private THashSet<List<Distance>> ModifyValue(THashSet<List<Distance>> value) |
| 329 | { |
| 330 | if (value == null) |
| 331 | value = new THashSet<List<Distance>>(); |
| 332 | |
| 333 | if (value.Count == 0) |
| 334 | value.Add(new List<Distance>()); |
| 335 | else |
| 336 | value.Add(null); |
| 337 | |
| 338 | foreach (var entry in value) |
| 339 | if( entry != null) |
| 340 | entry.Add(Distance.baz); |
| 341 | |
| 342 | return value; |
| 343 | } |
| 344 | |
| 345 | private Dictionary<Distance, Distance> ModifyValue(Dictionary<Distance, Distance> value) |
| 346 | { |
| 347 | if (value == null) |
| 348 | value = new Dictionary<Distance, Distance>(); |
| 349 | value[Distance.foo] = value.ContainsKey(Distance.foo) ? ++value[Distance.foo] : Distance.foo; |
| 350 | value[Distance.bar] = value.ContainsKey(Distance.bar) ? ++value[Distance.bar] : Distance.bar; |
| 351 | value[Distance.baz] = value.ContainsKey(Distance.baz) ? ++value[Distance.baz] : Distance.baz; |
| 352 | return value; |
| 353 | } |
| 354 | |
| 355 | private THashSet<Distance> ModifyValue(THashSet<Distance> value) |
| 356 | { |
| 357 | if (value == null) |
| 358 | value = new THashSet<Distance>(); |
| 359 | |
| 360 | if (value.Contains(Distance.foo)) |
| 361 | value.Remove(Distance.foo); |
| 362 | else |
| 363 | value.Add(Distance.foo); |
| 364 | |
| 365 | if (value.Contains(Distance.bar)) |
| 366 | value.Remove(Distance.bar); |
| 367 | else |
| 368 | value.Add(Distance.bar); |
| 369 | |
| 370 | if (value.Contains(Distance.baz)) |
| 371 | value.Remove(Distance.baz); |
| 372 | else |
| 373 | value.Add(Distance.baz); |
| 374 | |
| 375 | return value; |
| 376 | } |
| 377 | |
| 378 | private List<Distance> ModifyValue(List<Distance> value) |
| 379 | { |
| 380 | if (value == null) |
| 381 | value = new List<Distance>(); |
| 382 | value.Add(Distance.foo); |
| 383 | value.Add(Distance.bar); |
| 384 | value.Add(Distance.baz); |
| 385 | return value; |
| 386 | } |
| 387 | |
| 388 | private bool ModifyValue(bool value) |
| 389 | { |
| 390 | return !value; |
| 391 | } |
| 392 | |
| 393 | private Dictionary<sbyte, short> ModifyValue(Dictionary<sbyte, short> value) |
| 394 | { |
| 395 | if (value == null) |
| 396 | value = new Dictionary<sbyte, short>(); |
| 397 | value.Add((sbyte)(value.Count + 10), (short)value.Count); |
| 398 | return value; |
| 399 | } |
| 400 | |
| 401 | private THashSet<long> ModifyValue(THashSet<long> value) |
| 402 | { |
| 403 | if (value == null) |
| 404 | value = new THashSet<long>(); |
| 405 | value.Add(value.Count+100); |
| 406 | return value; |
| 407 | } |
| 408 | |
| 409 | private List<int> ModifyValue(List<int> value) |
| 410 | { |
| 411 | if (value == null) |
| 412 | value = new List<int>(); |
| 413 | value.Add(value.Count); |
| 414 | return value; |
| 415 | } |
| 416 | |
| 417 | private byte[] ModifyValue(byte[] value) |
| 418 | { |
| 419 | if (value == null) |
| 420 | value = new byte[1] { 0 }; |
| 421 | if (value.Length > 0) |
| 422 | value[0] = (value[0] < 0xFF) ? ++value[0] : (byte)0; |
| 423 | return value; |
| 424 | } |
| 425 | |
| 426 | private string ModifyValue(string value) |
| 427 | { |
| 428 | return value + "1"; |
| 429 | } |
| 430 | |
| 431 | private double ModifyValue(double value) |
| 432 | { |
| 433 | return value + 1.1; |
| 434 | } |
| 435 | |
| 436 | private short ModifyValue(short value) |
| 437 | { |
| 438 | return ++value; |
| 439 | } |
| 440 | |
| 441 | private Distance ModifyValue(Distance value) |
| 442 | { |
| 443 | return ++value; |
| 444 | } |
| 445 | |
| 446 | private void VerifyDifferentContent(RaceDetails first, RaceDetails second) |
| 447 | { |
| 448 | Assert.AreNotEqual(first, second); |
| 449 | |
| 450 | Assert.AreNotEqual(first.Opt_two, second.Opt_two); |
| 451 | Assert.AreNotEqual(first.Opt_three, second.Opt_three); |
| 452 | Assert.AreNotEqual(first.Opt_four, second.Opt_four); |
| 453 | Assert.IsFalse(TCollections.Equals(first.Opt_five, second.Opt_five)); |
| 454 | Assert.IsFalse(TCollections.Equals(first.Opt_six, second.Opt_six)); |
| 455 | Assert.IsFalse(TCollections.Equals(first.Opt_seven, second.Opt_seven)); |
| 456 | Assert.IsFalse(TCollections.Equals(first.Opt_eight, second.Opt_eight)); |
| 457 | |
| 458 | Assert.AreNotEqual(first.Req_one, second.Req_one); |
| 459 | Assert.AreNotEqual(first.Req_two, second.Req_two); |
| 460 | Assert.AreNotEqual(first.Req_three, second.Req_three); |
| 461 | Assert.AreNotEqual(first.Req_four, second.Req_four); |
| 462 | Assert.IsFalse(TCollections.Equals(first.Req_five, second.Req_five)); |
| 463 | Assert.IsFalse(TCollections.Equals(first.Req_six, second.Req_six)); |
| 464 | Assert.IsFalse(TCollections.Equals(first.Req_seven, second.Req_seven)); |
| 465 | Assert.IsFalse(TCollections.Equals(first.Req_eight, second.Req_eight)); |
| 466 | |
| 467 | Assert.AreNotEqual(first.Def_one, second.Def_one); |
| 468 | Assert.AreNotEqual(first.Def_two, second.Def_two); |
| 469 | Assert.AreNotEqual(first.Def_three, second.Def_three); |
| 470 | Assert.AreNotEqual(first.Def_four, second.Def_four); |
| 471 | Assert.IsFalse(TCollections.Equals(first.Def_five, second.Def_five)); |
| 472 | Assert.IsFalse(TCollections.Equals(first.Def_six, second.Def_six)); |
| 473 | Assert.IsFalse(TCollections.Equals(first.Def_seven, second.Def_seven)); |
| 474 | Assert.IsFalse(TCollections.Equals(first.Def_eight, second.Def_eight)); |
| 475 | |
| 476 | Assert.AreNotEqual(first.Opt_one_with_value, second.Opt_one_with_value); |
| 477 | Assert.AreNotEqual(first.Opt_two_with_value, second.Opt_two_with_value); |
| 478 | Assert.AreNotEqual(first.Opt_three_with_value, second.Opt_three_with_value); |
| 479 | Assert.AreNotEqual(first.Opt_four_with_value, second.Opt_four_with_value); |
| 480 | Assert.IsFalse(TCollections.Equals(first.Opt_five_with_value, second.Opt_five_with_value)); |
| 481 | Assert.IsFalse(TCollections.Equals(first.Opt_six_with_value, second.Opt_six_with_value)); |
| 482 | Assert.IsFalse(TCollections.Equals(first.Opt_seven_with_value, second.Opt_seven_with_value)); |
| 483 | Assert.IsFalse(TCollections.Equals(first.Opt_eight_with_value, second.Opt_eight_with_value)); |
| 484 | |
| 485 | Assert.AreNotEqual(first.Req_one_with_value, second.Req_one_with_value); |
| 486 | Assert.AreNotEqual(first.Req_two_with_value, second.Req_two_with_value); |
| 487 | Assert.AreNotEqual(first.Req_three_with_value, second.Req_three_with_value); |
| 488 | Assert.AreNotEqual(first.Req_four_with_value, second.Req_four_with_value); |
| 489 | Assert.IsFalse(TCollections.Equals(first.Req_five_with_value, second.Req_five_with_value)); |
| 490 | Assert.IsFalse(TCollections.Equals(first.Req_six_with_value, second.Req_six_with_value)); |
| 491 | Assert.IsFalse(TCollections.Equals(first.Req_seven_with_value, second.Req_seven_with_value)); |
| 492 | Assert.IsFalse(TCollections.Equals(first.Req_eight_with_value, second.Req_eight_with_value)); |
| 493 | |
| 494 | Assert.AreNotEqual(first.Def_one_with_value, second.Def_one_with_value); |
| 495 | Assert.AreNotEqual(first.Def_two_with_value, second.Def_two_with_value); |
| 496 | Assert.AreNotEqual(first.Def_three_with_value, second.Def_three_with_value); |
| 497 | Assert.AreNotEqual(first.Def_four_with_value, second.Def_four_with_value); |
| 498 | Assert.IsFalse(TCollections.Equals(first.Def_five_with_value, second.Def_five_with_value)); |
| 499 | Assert.IsFalse(TCollections.Equals(first.Def_six_with_value, second.Def_six_with_value)); |
| 500 | Assert.IsFalse(TCollections.Equals(first.Def_seven_with_value, second.Def_seven_with_value)); |
| 501 | Assert.IsFalse(TCollections.Equals(first.Def_eight_with_value, second.Def_eight_with_value)); |
| 502 | |
| 503 | Assert.AreNotEqual(first.Last_of_the_mohicans, second.Last_of_the_mohicans); |
| 504 | |
| 505 | Assert.IsFalse(TCollections.Equals(first.Far_list, second.Far_list)); |
| 506 | Assert.IsFalse(TCollections.Equals(first.Far_set, second.Far_set)); |
| 507 | Assert.IsFalse(TCollections.Equals(first.Far_map, second.Far_map)); |
| 508 | |
| 509 | Assert.IsFalse(TCollections.Equals(first.Far_set_list, second.Far_set_list)); |
| 510 | Assert.IsFalse(TCollections.Equals(first.Far_list_map_set, second.Far_list_map_set)); |
| 511 | Assert.IsFalse(TCollections.Equals(first.Far_map_dist_to_rds, second.Far_map_dist_to_rds)); |
| 512 | |
| 513 | Assert.AreNotEqual(first.Req_nested, second.Req_nested); |
| 514 | Assert.AreNotEqual(first.Opt_nested, second.Opt_nested); |
| 515 | Assert.AreNotEqual(first.Def_nested, second.Def_nested); |
| 516 | |
| 517 | Assert.AreNotEqual(first.Req_union, second.Req_union); |
| 518 | Assert.AreNotEqual(first.Opt_union, second.Opt_union); |
| 519 | Assert.AreNotEqual(first.Def_union, second.Def_union); |
| 520 | |
| 521 | Assert.AreNotEqual(first.Triplesix, second.Triplesix); |
| 522 | } |
| 523 | |
| 524 | private void VerifyIdenticalContent(RaceDetails first, RaceDetails second) |
| 525 | { |
| 526 | Assert.AreEqual(first, second); |
| 527 | |
| 528 | Assert.AreEqual(first.Opt_two, second.Opt_two); |
| 529 | Assert.AreEqual(first.Opt_three, second.Opt_three); |
| 530 | Assert.AreEqual(first.Opt_four, second.Opt_four); |
| 531 | Assert.IsTrue(TCollections.Equals(first.Opt_five, second.Opt_five)); |
| 532 | Assert.IsTrue(TCollections.Equals(first.Opt_six, second.Opt_six)); |
| 533 | Assert.IsTrue(TCollections.Equals(first.Opt_seven, second.Opt_seven)); |
| 534 | Assert.IsTrue(TCollections.Equals(first.Opt_eight, second.Opt_eight)); |
| 535 | |
| 536 | Assert.AreEqual(first.Req_one, second.Req_one); |
| 537 | Assert.AreEqual(first.Req_two, second.Req_two); |
| 538 | Assert.AreEqual(first.Req_three, second.Req_three); |
| 539 | Assert.AreEqual(first.Req_four, second.Req_four); |
| 540 | Assert.IsTrue(TCollections.Equals(first.Req_five, second.Req_five)); |
| 541 | Assert.IsTrue(TCollections.Equals(first.Req_six, second.Req_six)); |
| 542 | Assert.IsTrue(TCollections.Equals(first.Req_seven, second.Req_seven)); |
| 543 | Assert.IsTrue(TCollections.Equals(first.Req_eight, second.Req_eight)); |
| 544 | |
| 545 | Assert.AreEqual(first.Def_one, second.Def_one); |
| 546 | Assert.AreEqual(first.Def_two, second.Def_two); |
| 547 | Assert.AreEqual(first.Def_three, second.Def_three); |
| 548 | Assert.AreEqual(first.Def_four, second.Def_four); |
| 549 | Assert.IsTrue(TCollections.Equals(first.Def_five, second.Def_five)); |
| 550 | Assert.IsTrue(TCollections.Equals(first.Def_six, second.Def_six)); |
| 551 | Assert.IsTrue(TCollections.Equals(first.Def_seven, second.Def_seven)); |
| 552 | Assert.IsTrue(TCollections.Equals(first.Def_eight, second.Def_eight)); |
| 553 | |
| 554 | Assert.AreEqual(first.Opt_one_with_value, second.Opt_one_with_value); |
| 555 | Assert.AreEqual(first.Opt_two_with_value, second.Opt_two_with_value); |
| 556 | Assert.AreEqual(first.Opt_three_with_value, second.Opt_three_with_value); |
| 557 | Assert.AreEqual(first.Opt_four_with_value, second.Opt_four_with_value); |
| 558 | Assert.IsTrue(TCollections.Equals(first.Opt_five_with_value, second.Opt_five_with_value)); |
| 559 | Assert.IsTrue(TCollections.Equals(first.Opt_six_with_value, second.Opt_six_with_value)); |
| 560 | Assert.IsTrue(TCollections.Equals(first.Opt_seven_with_value, second.Opt_seven_with_value)); |
| 561 | Assert.IsTrue(TCollections.Equals(first.Opt_eight_with_value, second.Opt_eight_with_value)); |
| 562 | |
| 563 | Assert.AreEqual(first.Req_one_with_value, second.Req_one_with_value); |
| 564 | Assert.AreEqual(first.Req_two_with_value, second.Req_two_with_value); |
| 565 | Assert.AreEqual(first.Req_three_with_value, second.Req_three_with_value); |
| 566 | Assert.AreEqual(first.Req_four_with_value, second.Req_four_with_value); |
| 567 | Assert.IsTrue(TCollections.Equals(first.Req_five_with_value, second.Req_five_with_value)); |
| 568 | Assert.IsTrue(TCollections.Equals(first.Req_six_with_value, second.Req_six_with_value)); |
| 569 | Assert.IsTrue(TCollections.Equals(first.Req_seven_with_value, second.Req_seven_with_value)); |
| 570 | Assert.IsTrue(TCollections.Equals(first.Req_eight_with_value, second.Req_eight_with_value)); |
| 571 | |
| 572 | Assert.AreEqual(first.Def_one_with_value, second.Def_one_with_value); |
| 573 | Assert.AreEqual(first.Def_two_with_value, second.Def_two_with_value); |
| 574 | Assert.AreEqual(first.Def_three_with_value, second.Def_three_with_value); |
| 575 | Assert.AreEqual(first.Def_four_with_value, second.Def_four_with_value); |
| 576 | Assert.IsTrue(TCollections.Equals(first.Def_five_with_value, second.Def_five_with_value)); |
| 577 | Assert.IsTrue(TCollections.Equals(first.Def_six_with_value, second.Def_six_with_value)); |
| 578 | Assert.IsTrue(TCollections.Equals(first.Def_seven_with_value, second.Def_seven_with_value)); |
| 579 | Assert.IsTrue(TCollections.Equals(first.Def_eight_with_value, second.Def_eight_with_value)); |
| 580 | |
| 581 | Assert.AreEqual(first.Last_of_the_mohicans, second.Last_of_the_mohicans); |
| 582 | |
| 583 | Assert.IsTrue(TCollections.Equals(first.Far_list, second.Far_list)); |
| 584 | Assert.IsTrue(TCollections.Equals(first.Far_set, second.Far_set)); |
| 585 | Assert.IsTrue(TCollections.Equals(first.Far_map, second.Far_map)); |
| 586 | |
| 587 | Assert.IsTrue(TCollections.Equals(first.Far_set_list, second.Far_set_list)); |
| 588 | Assert.IsTrue(TCollections.Equals(first.Far_list_map_set, second.Far_list_map_set)); |
| 589 | Assert.IsTrue(TCollections.Equals(first.Far_map_dist_to_rds, second.Far_map_dist_to_rds)); |
| 590 | |
| 591 | Assert.AreEqual(first.Req_nested, second.Req_nested); |
| 592 | Assert.AreEqual(first.Opt_nested, second.Opt_nested); |
| 593 | Assert.AreEqual(first.Def_nested, second.Def_nested); |
| 594 | |
| 595 | Assert.AreEqual(first.Req_union, second.Req_union); |
| 596 | Assert.AreEqual(first.Opt_union, second.Opt_union); |
| 597 | Assert.AreEqual(first.Def_union, second.Def_union); |
| 598 | |
| 599 | Assert.AreEqual(first.Triplesix, second.Triplesix); |
| 600 | } |
| 601 | |
| 602 | } |
| 603 | } |