Changeset 1780 for trunk/sources/HeuristicLab.Persistence/UnitTests
- Timestamp:
- 05/11/09 16:09:29 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/UnitTests/UseCases.cs
r1779 r1780 15 15 using HeuristicLab.Persistence.Default.Decomposers; 16 16 using HeuristicLab.Persistence.Auxiliary; 17 using System.Text.RegularExpressions; 17 18 18 19 namespace HeuristicLab.Persistence.UnitTest { … … 510 511 511 512 [TestMethod] 512 public void TestSavingException() { 513 public void TestSavingException() { 513 514 List<int> list = new List<int> { 1, 2, 3 }; 514 515 XmlGenerator.Serialize(list, tempFile); … … 528 529 string shortName = 529 530 "System.Collections.Generic.List`1[[System.Int32, mscorlib]][], mscorlib"; 530 Assert.AreEqual(name, TypeNameParser.Parse(name).ToString()); 531 Assert.AreEqual(name, TypeNameParser.Parse(name).ToString()); 531 532 Assert.AreEqual(shortName, TypeNameParser.Parse(name).ToString(false)); 532 533 Assert.AreEqual(shortName, typeof(List<int>[]).VersionInvariantName()); 534 } 535 536 [TestMethod] 537 public void TestAssemblyVersionCheck() { 538 IntWrapper i = new IntWrapper(1); 539 Serializer s = new Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 540 XmlGenerator g = new XmlGenerator(); 541 StringBuilder dataString = new StringBuilder(); 542 foreach (var token in s) { 543 dataString.Append(g.Format(token)); 544 } 545 StringBuilder typeString = new StringBuilder(); 546 foreach (var line in g.Format(s.TypeCache)) 547 typeString.Append(line); 548 Deserializer d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(typeString.ToString()))); 549 XmlParser p = new XmlParser(new StringReader(dataString.ToString())); 550 IntWrapper newI = (IntWrapper)d.Deserialize(p); 551 Assert.AreEqual(i.Value, newI.Value); 552 string newTypeString = Regex.Replace(typeString.ToString(), 553 "Version=(\\d+\\.\\d+\\.\\d+\\.\\d+)", 554 "Version=9999.9999.9999.9999"); 555 try { 556 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString))); 557 Assert.Fail("Exception expected"); 558 } catch (PersistenceException) { 559 // EXPECTED 560 } 533 561 } 534 562 … … 536 564 public static void Initialize(TestContext testContext) { 537 565 ConfigurationService.Instance.Reset(); 538 } 539 } 566 } 567 } 540 568 }
Note: See TracChangeset
for help on using the changeset viewer.