- Timestamp:
- 03/09/10 18:14:05 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r2951 r2980 659 659 } 660 660 661 private class PersistenceHooks { 662 [Storable] 663 public int a; 664 [Storable] 665 public int b; 666 public int sum; 667 public bool WasSerialized { get; private set; } 668 [StorableHook(HookType.BeforeSerialization)] 669 void PreSerializationHook() { 670 WasSerialized = true; 671 } 672 [StorableHook(HookType.AfterDeserialization)] 673 void PostDeserializationHook() { 674 sum = a + b; 675 } 676 } 677 678 [TestMethod] 679 public void HookTest() { 680 PersistenceHooks hookTest = new PersistenceHooks(); 681 hookTest.a = 2; 682 hookTest.b = 5; 683 Assert.IsFalse(hookTest.WasSerialized); 684 Assert.AreEqual(hookTest.sum, 0); 685 XmlGenerator.Serialize(hookTest, tempFile); 686 Assert.IsTrue(hookTest.WasSerialized); 687 Assert.AreEqual(hookTest.sum, 0); 688 PersistenceHooks newHookTest = (PersistenceHooks)XmlParser.Deserialize(tempFile); 689 Assert.AreEqual(newHookTest.a, hookTest.a); 690 Assert.AreEqual(newHookTest.b, hookTest.b); 691 Assert.AreEqual(newHookTest.sum, newHookTest.a + newHookTest.b); 692 Assert.IsFalse(newHookTest.WasSerialized); 693 } 694 661 695 [ClassInitialize] 662 696 public static void Initialize(TestContext testContext) {
Note: See TracChangeset
for help on using the changeset viewer.