Changeset 3029 for trunk/sources/HeuristicLab.Persistence/3.3/Tests
- Timestamp:
- 03/15/10 12:02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r3017 r3029 815 815 } 816 816 817 [StorableClass(StorableClassType.AllFields)] 818 public class AllFieldsStorable { 819 public int Value1 = 1; 820 [Storable] 821 public int Value2 = 2; 822 public int Value3 { get; private set; } 823 public int Value4 { get; private set; } 824 [StorableConstructor] 825 public AllFieldsStorable(bool isDeserializing) { 826 if (!isDeserializing) { 827 Value1 = 12; 828 Value2 = 23; 829 Value3 = 34; 830 Value4 = 56; 831 } 832 } 833 } 834 835 [TestMethod] 836 public void TestStorableClassDiscoveryAllFields() { 837 AllFieldsStorable afs = new AllFieldsStorable(false); 838 XmlGenerator.Serialize(afs, tempFile); 839 AllFieldsStorable newAfs = (AllFieldsStorable)XmlParser.Deserialize(tempFile); 840 Assert.AreEqual(afs.Value1, newAfs.Value1); 841 Assert.AreEqual(afs.Value2, newAfs.Value2); 842 Assert.AreEqual(0, newAfs.Value3); 843 Assert.AreEqual(0, newAfs.Value4); 844 } 845 846 [StorableClass(StorableClassType.AllProperties)] 847 public class AllPropertiesStorable { 848 public int Value1 = 1; 849 [Storable] 850 public int Value2 = 2; 851 public int Value3 { get; private set; } 852 public int Value4 { get; private set; } 853 [StorableConstructor] 854 public AllPropertiesStorable(bool isDeserializing) { 855 if (!isDeserializing) { 856 Value1 = 12; 857 Value2 = 23; 858 Value3 = 34; 859 Value4 = 56; 860 } 861 } 862 } 863 864 [TestMethod] 865 public void TestStorableClassDiscoveryAllProperties() { 866 AllPropertiesStorable afs = new AllPropertiesStorable(false); 867 XmlGenerator.Serialize(afs, tempFile); 868 AllPropertiesStorable newAfs = (AllPropertiesStorable)XmlParser.Deserialize(tempFile); 869 Assert.AreEqual(1, newAfs.Value1); 870 Assert.AreEqual(2, newAfs.Value2); 871 Assert.AreEqual(afs.Value3, newAfs.Value3); 872 Assert.AreEqual(afs.Value4, newAfs.Value4); 873 874 } 875 876 [StorableClass(StorableClassType.AllFieldsAndAllProperties)] 877 public class AllFieldsAndAllPropertiesStorable { 878 public int Value1 = 1; 879 [Storable] 880 public int Value2 = 2; 881 public int Value3 { get; private set; } 882 public int Value4 { get; private set; } 883 [StorableConstructor] 884 public AllFieldsAndAllPropertiesStorable(bool isDeserializing) { 885 if (!isDeserializing) { 886 Value1 = 12; 887 Value2 = 23; 888 Value3 = 34; 889 Value4 = 56; 890 } 891 } 892 } 893 894 [TestMethod] 895 public void TestStorableClassDiscoveryAllFieldsAndAllProperties() { 896 AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false); 897 XmlGenerator.Serialize(afs, tempFile); 898 AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)XmlParser.Deserialize(tempFile); 899 Assert.AreEqual(afs.Value1, newAfs.Value1); 900 Assert.AreEqual(afs.Value2, newAfs.Value2); 901 Assert.AreEqual(afs.Value3, newAfs.Value3); 902 Assert.AreEqual(afs.Value4, newAfs.Value4); 903 } 904 905 [StorableClass(StorableClassType.MarkedOnly)] 906 public class MarkedOnlyStorable { 907 public int Value1 = 1; 908 [Storable] 909 public int Value2 = 2; 910 public int Value3 { get; private set; } 911 public int Value4 { get; private set; } 912 [StorableConstructor] 913 public MarkedOnlyStorable(bool isDeserializing) { 914 if (!isDeserializing) { 915 Value1 = 12; 916 Value2 = 23; 917 Value3 = 34; 918 Value4 = 56; 919 } 920 } 921 } 922 923 [TestMethod] 924 public void TestStorableClassDiscoveryMarkedOnly() { 925 MarkedOnlyStorable afs = new MarkedOnlyStorable(false); 926 XmlGenerator.Serialize(afs, tempFile); 927 MarkedOnlyStorable newAfs = (MarkedOnlyStorable)XmlParser.Deserialize(tempFile); 928 Assert.AreEqual(1, newAfs.Value1); 929 Assert.AreEqual(afs.Value2, newAfs.Value2); 930 Assert.AreEqual(0, newAfs.Value3); 931 Assert.AreEqual(0, newAfs.Value4); 932 } 933 934 935 817 936 [ClassInitialize] 818 937 public static void Initialize(TestContext testContext) {
Note: See TracChangeset
for help on using the changeset viewer.