Changeset 3005 for trunk/sources/HeuristicLab.Persistence/3.3/Tests
- Timestamp:
- 03/11/10 15:50:50 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r2994 r3005 199 199 [TestMethod] 200 200 public void ComplexStorable() { 201 Root r = new Root(); 202 r.intStack.Push(1); 203 r.intStack.Push(2); 204 r.intStack.Push(3); 205 r.selfReferences = new List<Root> { r, r }; 206 r.c = new Custom { r = r }; 207 r.dict.Add("one", 1); 208 r.dict.Add("two", 2); 209 r.dict.Add("three", 3); 210 r.myEnum = TestEnum.va1; 211 r.i = new[] { 7, 5, 6 }; 212 r.s = "new value"; 213 r.intArray = new ArrayList { 3, 2, 1 }; 214 r.intList = new List<int> { 9, 8, 7 }; 215 r.multiDimArray = new double[,] { { 5, 4, 3 }, { 1, 4, 6 } }; 216 r.boolean = false; 217 r.dateTime = DateTime.Now; 218 r.kvp = new KeyValuePair<string, int>("string key", 321); 219 r.uninitialized = null; 201 Root r = InitializeComplexStorable(); 220 202 XmlGenerator.Serialize(r, tempFile); 221 203 Root newR = (Root)XmlParser.Deserialize(tempFile); 204 CompareComplexStorables(r, newR); 205 } 206 207 private static void CompareComplexStorables(Root r, Root newR) { 222 208 Assert.AreEqual( 223 209 DebugStringGenerator.Serialize(r), … … 274 260 } 275 261 262 private static Root InitializeComplexStorable() { 263 Root r = new Root(); 264 r.intStack.Push(1); 265 r.intStack.Push(2); 266 r.intStack.Push(3); 267 r.selfReferences = new List<Root> { r, r }; 268 r.c = new Custom { r = r }; 269 r.dict.Add("one", 1); 270 r.dict.Add("two", 2); 271 r.dict.Add("three", 3); 272 r.myEnum = TestEnum.va1; 273 r.i = new[] { 7, 5, 6 }; 274 r.s = "new value"; 275 r.intArray = new ArrayList { 3, 2, 1 }; 276 r.intList = new List<int> { 9, 8, 7 }; 277 r.multiDimArray = new double[,] { { 5, 4, 3 }, { 1, 4, 6 } }; 278 r.boolean = false; 279 r.dateTime = DateTime.Now; 280 r.kvp = new KeyValuePair<string, int>("string key", 321); 281 r.uninitialized = null; 282 283 return r; 284 } 285 276 286 [TestMethod] 277 287 public void SelfReferences() { … … 762 772 } 763 773 774 [TestMethod] 775 public void TestStreaming() { 776 using (MemoryStream stream = new MemoryStream()) { 777 Root r = InitializeComplexStorable(); 778 XmlGenerator.Serialize(r, stream); 779 using (MemoryStream stream2 = new MemoryStream(stream.ToArray())) { 780 Root newR = (Root)XmlParser.Deserialize(stream2); 781 CompareComplexStorables(r, newR); 782 } 783 } 784 } 785 764 786 [ClassInitialize] 765 787 public static void Initialize(TestContext testContext) {
Note: See TracChangeset
for help on using the changeset viewer.