Changeset 1652 for trunk/sources/HeuristicLab.Persistence/UnitTests
- Timestamp:
- 04/24/09 13:51:57 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/UnitTests/UseCases.cs
r1644 r1652 17 17 namespace HeuristicLab.Persistence.UnitTest { 18 18 19 public class PrimitivesTest {19 public class NumberTest { 20 20 [Storable] 21 21 private bool _bool = true; … … 36 36 [Storable] 37 37 private ulong _ulong = 123456; 38 } 39 40 public class PrimitivesTest : NumberTest { 41 [Storable] 42 private char c = 'e'; 38 43 [Storable] 39 44 private long[,] _long_array = … … 41 46 [Storable] 42 47 public List<int> list = new List<int> { 1, 2, 3, 4, 5 }; 48 [Storable] 49 private object o = new object(); 43 50 } 44 51 … … 132 139 r.dict.Add("three", 3); 133 140 r.myEnum = TestEnum.va1; 141 r.i = new[] { 7, 5, 6 }; 142 r.s = "new value"; 143 r.intArray = new ArrayList { 3, 2, 1 }; 144 r.intList = new List<int> { 9, 8, 7 }; 145 r.multiDimArray = new double[,] { { 5, 4, 3 }, { 1, 4, 6 } }; 146 r.boolean = false; 147 r.dateTime = DateTime.Now; 148 r.kvp = new KeyValuePair<string, int>("string key", 321); 149 r.uninitialized = null; 134 150 XmlGenerator.Serialize(r, tempFile); 135 151 object o = XmlParser.DeSerialize(tempFile); … … 140 156 Assert.AreSame(newR, newR.selfReferences[0]); 141 157 Assert.AreNotSame(r, newR); 158 Assert.AreEqual(r.myEnum, TestEnum.va1); 159 Assert.AreEqual(r.i[0], 7); 160 Assert.AreEqual(r.i[1], 5); 161 Assert.AreEqual(r.i[2], 6); 162 Assert.AreSame(r.s, "new value"); 163 Assert.AreEqual(r.intArray[0], 3); 164 Assert.AreEqual(r.intArray[1], 2); 165 Assert.AreEqual(r.intArray[2], 1); 166 Assert.AreEqual(r.intList[0], 9); 167 Assert.AreEqual(r.intList[1], 8); 168 Assert.AreEqual(r.intList[2], 7); 169 Assert.AreEqual(r.multiDimArray[0, 0], 5); 170 Assert.AreEqual(r.multiDimArray[0, 1], 4); 171 Assert.AreEqual(r.multiDimArray[0, 2], 3); 172 Assert.AreEqual(r.multiDimArray[1, 0], 1); 173 Assert.AreEqual(r.multiDimArray[1, 1], 4); 174 Assert.AreEqual(r.multiDimArray[1, 2], 6); 175 Assert.IsFalse(r.boolean); 176 Assert.IsTrue((DateTime.Now - r.dateTime).TotalSeconds < 10); 177 Assert.AreSame(r.kvp.Key, "string key"); 178 Assert.AreEqual(r.kvp.Value, 321); 179 Assert.IsNull(r.uninitialized); 142 180 } 143 181 … … 274 312 } 275 313 276 private string formatFullMemberName(MemberInfo mi) { 314 private string formatFullMemberName(MemberInfo mi) { 277 315 return new StringBuilder() 278 316 .Append(mi.DeclaringType.Assembly.GetName().Name) … … 292 330 foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { 293 331 if (!a.GetName().Name.StartsWith("HeuristicLab")) 294 continue; 332 continue; 295 333 foreach (Type t in a.GetTypes()) { 296 334 foreach (MemberInfo mi in t.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) { … … 304 342 !mi.Name.StartsWith("set_") && 305 343 !mi.Name.StartsWith("add_") && 306 !mi.Name.StartsWith("remove_") 344 !mi.Name.StartsWith("remove_")) 307 345 lowerCaseMethodNames.Add(formatFullMemberName(mi)); 308 346 } … … 317 355 [TestMethod] 318 356 public void Number2StringDecomposer() { 319 PrimitivesTest sdt = new PrimitivesTest();357 NumberTest sdt = new NumberTest(); 320 358 XmlGenerator.Serialize(sdt, tempFile, 321 359 new Configuration(new XmlFormat(), 322 new Dictionary<Type, IFormatter> { { typeof(string), new String2XmlFormatter() } }, 323 new List<IDecomposer> { new Number2StringDecomposer() })); 324 object o = XmlParser.DeSerialize(tempFile); 360 new Dictionary<Type, IFormatter> { 361 { typeof(string), new String2XmlFormatter() } }, 362 new List<IDecomposer> { 363 new StorableDecomposer(), 364 new Number2StringDecomposer() })); 365 object o = XmlParser.DeSerialize(tempFile); 325 366 Assert.AreEqual( 326 367 DebugStringGenerator.Serialize(sdt),
Note: See TracChangeset
for help on using the changeset viewer.