- Timestamp:
- 05/17/11 15:10:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r6210 r6224 921 921 } 922 922 923 [StorableClass(StorableClassType.AllFields)] 924 public class AllFieldsStorable { 925 public int Value1 = 1; 926 [Storable] 927 public int Value2 = 2; 928 public int Value3 { get; private set; } 929 public int Value4 { get; private set; } 930 [StorableConstructor] 931 public AllFieldsStorable(bool isDeserializing) { 932 if (!isDeserializing) { 933 Value1 = 12; 934 Value2 = 23; 935 Value3 = 34; 936 Value4 = 56; 937 } 938 } 939 } 940 941 [TestMethod] 942 public void TestStorableClassDiscoveryAllFields() { 943 AllFieldsStorable afs = new AllFieldsStorable(false); 944 XmlGenerator.Serialize(afs, tempFile); 945 AllFieldsStorable newAfs = (AllFieldsStorable)XmlParser.Deserialize(tempFile); 946 Assert.AreEqual(afs.Value1, newAfs.Value1); 947 Assert.AreEqual(afs.Value2, newAfs.Value2); 948 Assert.AreEqual(0, newAfs.Value3); 949 Assert.AreEqual(0, newAfs.Value4); 950 } 951 952 [StorableClass(StorableClassType.AllProperties)] 953 public class AllPropertiesStorable { 954 public int Value1 = 1; 955 [Storable] 956 public int Value2 = 2; 957 public int Value3 { get; private set; } 958 public int Value4 { get; private set; } 959 [StorableConstructor] 960 public AllPropertiesStorable(bool isDeserializing) { 961 if (!isDeserializing) { 962 Value1 = 12; 963 Value2 = 23; 964 Value3 = 34; 965 Value4 = 56; 966 } 967 } 968 } 969 970 [TestMethod] 971 public void TestStorableClassDiscoveryAllProperties() { 972 AllPropertiesStorable afs = new AllPropertiesStorable(false); 973 XmlGenerator.Serialize(afs, tempFile); 974 AllPropertiesStorable newAfs = (AllPropertiesStorable)XmlParser.Deserialize(tempFile); 975 Assert.AreEqual(1, newAfs.Value1); 976 Assert.AreEqual(2, newAfs.Value2); 977 Assert.AreEqual(afs.Value3, newAfs.Value3); 978 Assert.AreEqual(afs.Value4, newAfs.Value4); 979 980 } 981 982 [StorableClass(StorableClassType.AllFieldsAndAllProperties)] 983 public class AllFieldsAndAllPropertiesStorable { 984 public int Value1 = 1; 985 [Storable] 986 public int Value2 = 2; 987 public int Value3 { get; private set; } 988 public int Value4 { get; private set; } 989 [StorableConstructor] 990 public AllFieldsAndAllPropertiesStorable(bool isDeserializing) { 991 if (!isDeserializing) { 992 Value1 = 12; 993 Value2 = 23; 994 Value3 = 34; 995 Value4 = 56; 996 } 997 } 998 } 999 1000 [TestMethod] 1001 public void TestStorableClassDiscoveryAllFieldsAndAllProperties() { 1002 AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false); 1003 XmlGenerator.Serialize(afs, tempFile); 1004 AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)XmlParser.Deserialize(tempFile); 1005 Assert.AreEqual(afs.Value1, newAfs.Value1); 1006 Assert.AreEqual(afs.Value2, newAfs.Value2); 1007 Assert.AreEqual(afs.Value3, newAfs.Value3); 1008 Assert.AreEqual(afs.Value4, newAfs.Value4); 1009 } 1010 1011 [StorableClass(StorableClassType.MarkedOnly)] 923 924 [StorableClass] 1012 925 public class MarkedOnlyStorable { 1013 926 public int Value1 = 1;
Note: See TracChangeset
for help on using the changeset viewer.