Changeset 14928 for branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs
- Timestamp:
- 05/04/17 18:16:25 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs
r14927 r14928 36 36 using HeuristicLab.Persistence.Core.Tokens; 37 37 using HeuristicLab.Persistence.Default.CompositeSerializers; 38 using HeuristicLab.Persistence;39 38 using HeuristicLab.Persistence.Default.DebugString; 40 39 using HeuristicLab.Persistence.Default.Xml; … … 43 42 using HeuristicLab.Tests; 44 43 using Microsoft.VisualStudio.TestTools.UnitTesting; 44 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 45 45 46 46 namespace HeuristicLab.Persistence.Tests { 47 47 48 [Storable Class]48 [StorableType("8658966d-3731-4588-8a92-25740c677478")] 49 49 public class NumberTest { 50 50 [Storable] … … 95 95 } 96 96 97 [Storable Class]97 [StorableType("30315bb1-3cac-498f-9ff4-b27f0f6234a8")] 98 98 public class NonDefaultConstructorClass { 99 99 [Storable] … … 104 104 } 105 105 106 [Storable Class]106 [StorableType("42019826-a9f7-4e78-b035-19292cd34d26")] 107 107 public class IntWrapper { 108 108 … … 127 127 } 128 128 129 [Storable Class]129 [StorableType("92810c22-155c-4e61-a3ec-79533e5d3c1e")] 130 130 public class PrimitivesTest : NumberTest { 131 131 [Storable] … … 157 157 } 158 158 159 public enum TestEnum { va1, va2, va3, va8 } ; 160 161 [StorableClass] 159 [StorableType("09355759-308f-438d-95a1-63704159b833")] 160 public enum TestEnum { va1, va2, va3, va8 }; 161 162 [StorableType("92efaa22-6ae0-4004-a0a8-7bfe397d25d0")] 162 163 public class RootBase { 163 164 [Storable] … … 178 179 } 179 180 180 [Storable Class]181 [StorableType("26b42eae-7dbb-46bb-84b3-d50d357eec05")] 181 182 public class Root : RootBase { 182 183 [Storable] … … 208 209 } 209 210 211 [StorableType("b976a474-cae4-4f08-b425-e69977e1e4bf")] 210 212 public enum SimpleEnum { one, two, three } 213 [StorableType("4f41591b-e0be-42ae-af66-800c20d21356")] 211 214 public enum ComplexEnum { one = 1, two = 2, three = 3 } 212 215 [FlagsAttribute] 216 [StorableType("426bb2f4-7951-4378-a923-bc7a8ce56bd7")] 213 217 public enum TrickyEnum { zero = 0, one = 1, two = 2 } 214 218 215 [Storable Class]219 [StorableType("0fe878c9-35e6-4478-8cbe-438211b7a3a5")] 216 220 public class EnumTest { 217 221 [Storable] … … 223 227 } 224 228 225 [Storable Class]229 [StorableType("b83a36e8-7ba7-4ce4-82c3-602678c2a7a5")] 226 230 public class Custom { 227 231 [Storable] … … 233 237 } 234 238 235 [Storable Class]239 [StorableType("fe285830-9dc6-4b77-8f8b-3c09a02ef1e0")] 236 240 public class Manager { 237 241 … … 246 250 } 247 251 248 [Storable Class]252 [StorableType("49551a89-6586-4ce1-8323-a8fd4409a0f6")] 249 253 public class C { 250 254 [Storable] … … 269 273 270 274 [TestClass] 275 [StorableType("adca4c31-c835-4113-83aa-26a7a2cb3204")] 271 276 public class UseCases { 272 277 … … 486 491 } 487 492 488 [Storable Class]493 [StorableType("f4af4d3d-7ae6-4da5-ab3c-5df3ca2daca7")] 489 494 public class NestedType { 490 495 [Storable] … … 589 594 new Configuration(new XmlFormat(), 590 595 new List<IPrimitiveSerializer> { new String2XmlSerializer() }, 591 new List<ICompositeSerializer> { 596 new List<ICompositeSerializer> { 592 597 new StorableSerializer(), 593 598 new Number2StringSerializer() })); … … 690 695 l.Add(new NonSerializable()); 691 696 try { 692 Serializer s = newSerializer(l,697 var s = new HeuristicLab.Persistence.Core.Serializer(l, 693 698 ConfigurationService.Instance.GetConfiguration(new XmlFormat()), 694 699 "ROOT", true); … … 708 713 public void TestAssemblyVersionCheck() { 709 714 IntWrapper i = new IntWrapper(1); 710 Serializer s = newSerializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));715 var s = new HeuristicLab.Persistence.Core.Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 711 716 XmlGenerator g = new XmlGenerator(); 712 717 StringBuilder dataString = new StringBuilder(); … … 753 758 } 754 759 755 [Storable Class]760 [StorableType("121169c6-b68a-491b-93e7-9925d508c0f3")] 756 761 class Child { 757 762 [Storable] … … 759 764 } 760 765 761 [Storable Class]766 [StorableType("58a160dd-1851-4f78-b585-cdd05d4213f2")] 762 767 class Parent { 763 768 [Storable] … … 765 770 } 766 771 767 [Storable Class]772 [StorableType("f99dbc0d-6f4c-4165-8d94-fb749f8cee33")] 768 773 class GrandParent { 769 774 [Storable] … … 785 790 } 786 791 792 [StorableType("d4898d57-d578-4136-86f6-c8f615dbb4ab")] 787 793 struct TestStruct { 788 794 int value; … … 843 849 } 844 850 845 [Storable Class]851 [StorableType("2a354c02-5268-41d1-b80f-c68f1d9c2337")] 846 852 private class PersistenceHooks { 847 853 [Storable] … … 880 886 } 881 887 882 [Storable Class]888 [StorableType("fd155497-a299-413e-a251-220f9d21c92e")] 883 889 private class CustomConstructor { 884 890 public string Value = "none"; … … 904 910 } 905 911 906 [Storable Class]912 [StorableType("f6cbcbdd-a3a1-4a87-b2e4-413f0255b12a")] 907 913 public class ExplodingDefaultConstructor { 908 914 public ExplodingDefaultConstructor() { … … 954 960 } 955 961 956 [Storable Class]962 [StorableType("7333a419-f549-4f88-a761-a1197cf90bce")] 957 963 public class HookInheritanceTestBase { 958 964 [Storable] … … 965 971 } 966 972 967 [Storable Class]973 [StorableType("d05112d0-57db-43fc-86b2-a4da9d6cb84b")] 968 974 public class HookInheritanceTestDerivedClass : HookInheritanceTestBase { 969 975 [Storable] … … 987 993 } 988 994 989 [Storable Class(StorableClassType.AllFields)]995 [StorableType(StorableMemberSelection.AllFields, "6f92b947-032a-4455-81e6-116bf4c31f92")] 990 996 public class AllFieldsStorable { 991 997 public int Value1 = 1; … … 1018 1024 } 1019 1025 1020 [Storable Class(StorableClassType.AllProperties)]1026 [StorableType(StorableMemberSelection.AllProperties, "9e5eff24-617e-44bc-ae0f-258bfd804247")] 1021 1027 public class AllPropertiesStorable { 1022 1028 public int Value1 = 1; … … 1050 1056 } 1051 1057 1052 [Storable Class(StorableClassType.AllFieldsAndAllProperties)]1058 [StorableType(StorableMemberSelection.AllFieldsAndAllProperties, "b6e3468d-5aaf-47d9-bd87-6931b2c705cd")] 1053 1059 public class AllFieldsAndAllPropertiesStorable { 1054 1060 public int Value1 = 1; … … 1081 1087 } 1082 1088 1083 [Storable Class(StorableClassType.MarkedOnly)]1089 [StorableType(StorableMemberSelection.MarkedOnly, "1730eaa1-0507-4e08-94d8-64e213f3401d")] 1084 1090 public class MarkedOnlyStorable { 1085 1091 public int Value1 = 1; … … 1178 1184 } 1179 1185 } 1186 [StorableType("57867b53-fafd-4c4f-aa15-dcfd87fbffe7")] 1180 1187 private class IdentityComparer<T> : IEqualityComparer<T> { 1181 1188 … … 1241 1248 } 1242 1249 1243 [Storable Class]1250 [StorableType("aa595fbc-7359-49ad-a274-204ff3c97bb4")] 1244 1251 public class ReadOnlyFail { 1245 1252 [Storable] … … 1263 1270 1264 1271 1265 [Storable Class]1272 [StorableType("34008801-bb73-4810-ad1a-de9921b49a5d")] 1266 1273 public class WriteOnlyFail { 1267 1274 [Storable] … … 1284 1291 } 1285 1292 1286 [Storable Class]1293 [StorableType("38575b53-c706-4d20-a255-c567c21c99a4")] 1287 1294 public class OneWayTest { 1288 1295 public OneWayTest() { this.value = "default"; } … … 1303 1310 public void TestOneWaySerialization() { 1304 1311 var test = new OneWayTest(); 1305 var serializer = new Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));1312 var serializer = new HeuristicLab.Persistence.Core.Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 1306 1313 var it = serializer.GetEnumerator(); 1307 1314 it.MoveNext(); … … 1309 1316 Assert.AreEqual("ReadOnly", ((PrimitiveToken)it.Current).Name); it.MoveNext(); 1310 1317 Assert.AreEqual("ROOT", ((EndToken)it.Current).Name); it.MoveNext(); 1311 var deserializer = new Deserializer(new[] { 1318 var deserializer = new Deserializer(new[] { 1312 1319 new TypeMapping(0, typeof(OneWayTest).AssemblyQualifiedName, typeof(StorableSerializer).AssemblyQualifiedName), 1313 1320 new TypeMapping(1, typeof(string).AssemblyQualifiedName, typeof(String2XmlSerializer).AssemblyQualifiedName) }); … … 1411 1418 } 1412 1419 1420 [StorableType("07c965fc-8bd3-4baf-967c-374e1e9d9b31")] 1413 1421 public class G<T, T2> { 1422 [StorableType("f9b10931-841f-4e93-b5d7-3d025a9bf998")] 1414 1423 public class S { } 1424 [StorableType("a9414e79-427a-4dd2-a231-832314c834e3")] 1415 1425 public class S2<T3, T4> { } 1416 1426 } … … 1461 1471 b[2] = byte.MaxValue; 1462 1472 XmlGenerator.Serialize(b, tempFile); 1463 var newB = (byte[]) 1473 var newB = (byte[])XmlParser.Deserialize(tempFile); 1464 1474 CollectionAssert.AreEqual(b, newB); 1465 1475 } … … 1469 1479 [TestProperty("Time", "short")] 1470 1480 public void TestOptionalNumberEnumerable() { 1471 var values = new List<double?> { 0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1};1481 var values = new List<double?> { 0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1 }; 1472 1482 XmlGenerator.Serialize(values, tempFile); 1473 var newValues = (List<double?>) 1483 var newValues = (List<double?>)XmlParser.Deserialize(tempFile); 1474 1484 CollectionAssert.AreEqual(values, newValues); 1475 1485 } … … 1482 1492 DateTime.ParseExact("10.09.2014 12:21", "dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture), DateTime.MaxValue}; 1483 1493 XmlGenerator.Serialize(values, tempFile); 1484 var newValues = (List<DateTime?>) 1494 var newValues = (List<DateTime?>)XmlParser.Deserialize(tempFile); 1485 1495 CollectionAssert.AreEqual(values, newValues); 1486 1496 } … … 1490 1500 [TestProperty("Time", "short")] 1491 1501 public void TestStringEnumerable() { 1492 var values = new List<string> { "", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated"};1502 var values = new List<string> { "", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated" }; 1493 1503 XmlGenerator.Serialize(values, tempFile); 1494 var newValues = (List<String>) 1504 var newValues = (List<String>)XmlParser.Deserialize(tempFile); 1495 1505 CollectionAssert.AreEqual(values, newValues); 1496 1506 } … … 1500 1510 [TestProperty("Time", "short")] 1501 1511 public void TestUnicodeCharArray() { 1502 var s = Encoding.UTF8.GetChars(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});1512 var s = Encoding.UTF8.GetChars(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb }); 1503 1513 XmlGenerator.Serialize(s, tempFile); 1504 1514 var newS = (char[])XmlParser.Deserialize(tempFile); … … 1510 1520 [TestProperty("Time", "short")] 1511 1521 public void TestUnicode() { 1512 var s = Encoding.UTF8.GetString(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});1522 var s = Encoding.UTF8.GetString(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb }); 1513 1523 XmlGenerator.Serialize(s, tempFile); 1514 1524 var newS = XmlParser.Deserialize(tempFile); … … 1520 1530 [TestProperty("Time", "short")] 1521 1531 public void TestQueue() { 1522 var q = new Queue<int>(new[] { 1, 2, 3, 4, 0});1532 var q = new Queue<int>(new[] { 1, 2, 3, 4, 0 }); 1523 1533 XmlGenerator.Serialize(q, tempFile); 1524 1534 var newQ = (Queue<int>)XmlParser.Deserialize(tempFile);
Note: See TracChangeset
for help on using the changeset viewer.