Changeset 3057 for trunk/sources/HeuristicLab.Persistence
- Timestamp:
- 03/16/10 10:21:41 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/HeuristicLab.Persistence-3.3.Tests.csproj
r2951 r3057 30 30 <ErrorReport>prompt</ErrorReport> 31 31 <WarningLevel>4</WarningLevel> 32 <TreatWarningsAsErrors>true</TreatWarningsAsErrors> 32 33 </PropertyGroup> 33 34 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/StorableAttributeTests.cs
r3025 r3057 12 12 13 13 [Storable(Name = "TestProperty", DefaultValue = 12)] 14 public object o ;14 public object o = null; 15 15 16 16 [Storable] 17 17 public int x = 2; 18 18 19 public int y; 20 19 public int y = 0; 21 20 } 22 21 -
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3029 r3057 41 41 [Storable] 42 42 private ulong _ulong = 123456; 43 public override bool Equals(object obj) { 44 NumberTest nt = obj as NumberTest; 45 if (nt == null) 46 throw new NotSupportedException(); 47 return 48 nt._bool == _bool && 49 nt._byte == _byte && 50 nt._sbyte == _sbyte && 51 nt._short == _short && 52 nt._ushort == _ushort && 53 nt._int == _int && 54 nt._uint == _uint && 55 nt._long == _long && 56 nt._ulong == _ulong; 57 } 58 public override int GetHashCode() { 59 return 60 _bool.GetHashCode() ^ 61 _byte.GetHashCode() ^ 62 _sbyte.GetHashCode() ^ 63 _short.GetHashCode() ^ 64 _short.GetHashCode() ^ 65 _int.GetHashCode() ^ 66 _uint.GetHashCode() ^ 67 _long.GetHashCode() ^ 68 _ulong.GetHashCode(); 69 } 43 70 } 44 71 … … 86 113 [Storable] 87 114 private object o = new object(); 115 public override bool Equals(object obj) { 116 PrimitivesTest pt = obj as PrimitivesTest; 117 if (pt == null) 118 throw new NotSupportedException(); 119 return base.Equals(obj) && 120 c == pt.c && 121 _long_array == pt._long_array && 122 list == pt.list && 123 o == pt.o; 124 } 125 public override int GetHashCode() { 126 return base.GetHashCode() ^ 127 c.GetHashCode() ^ 128 _long_array.GetHashCode() ^ 129 list.GetHashCode() ^ 130 o.GetHashCode(); 131 } 88 132 } 89 133 … … 96 140 [Storable] 97 141 public TestEnum myEnum = TestEnum.va3; 142 public override bool Equals(object obj) { 143 RootBase rb = obj as RootBase; 144 if (rb == null) 145 throw new NotSupportedException(); 146 return baseString == rb.baseString && 147 myEnum == rb.myEnum; 148 } 149 public override int GetHashCode() { 150 return baseString.GetHashCode() ^ 151 myEnum.GetHashCode(); 152 } 98 153 } 99 154 … … 175 230 176 231 public class NonSerializable { 177 int x; 232 int x = 0; 233 public override bool Equals(object obj) { 234 NonSerializable ns = obj as NonSerializable; 235 if (ns == null) 236 throw new NotSupportedException(); 237 return ns.x == x; 238 } 239 public override int GetHashCode() { 240 return x.GetHashCode(); 241 } 178 242 } 179 243 … … 377 441 [Storable] 378 442 private string value = "value"; 443 public override bool Equals(object obj) { 444 NestedType nt = obj as NestedType; 445 if (nt == null) 446 throw new NotSupportedException(); 447 return nt.value == value; 448 } 449 public override int GetHashCode() { 450 return value.GetHashCode(); 451 } 379 452 } 380 453 … … 387 460 DebugStringGenerator.Serialize(t), 388 461 DebugStringGenerator.Serialize(o)); 462 Assert.IsTrue(t.Equals(o)); 389 463 } 390 464 … … 465 539 DebugStringGenerator.Serialize(sdt), 466 540 DebugStringGenerator.Serialize(o)); 541 Assert.IsTrue(sdt.Equals(o)); 467 542 } 468 543
Note: See TracChangeset
for help on using the changeset viewer.