Changeset 13386 for branches/PersistenceOverhaul
- Timestamp:
- 11/24/15 18:24:01 (9 years ago)
- Location:
- branches/PersistenceOverhaul
- Files:
-
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceOverhaul/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs
r13368 r13386 541 541 542 542 [Item("Hive Task", "Represents a hive task.")] 543 [StorableClass(" 967DC1A1-7B0C-4D8B-AF9F-710B1FD676DF")]543 [StorableClass("04AD6AF8-8248-48FB-AF3A-403A2D22F725")] 544 544 public class HiveTask<T> : HiveTask where T : ItemTask { 545 545 -
branches/PersistenceOverhaul/HeuristicLab.Collections/3.3/BidirectionalLookup.cs
r13368 r13386 26 26 27 27 namespace HeuristicLab.Collections { 28 [StorableClass("0 66A8A8B-784D-45CC-9063-F2FC8E9A4442")]28 [StorableClass("0BF45891-847C-428B-9F2C-FD682320066C")] 29 29 [Serializable] 30 30 public class BidirectionalLookup<TFirst, TSecond> { -
branches/PersistenceOverhaul/HeuristicLab.Core/3.3/Collections/DirectedGraph/Arc.cs
r13368 r13386 26 26 namespace HeuristicLab.Core { 27 27 [Item("Arc", "A graph arc connecting two graph vertices, that can have a weight, label, and data object for holding additional info")] 28 [StorableClass(" 9C41B31C-E208-46A2-87FC-45A9F0A9A928")]28 [StorableClass("B9E1D948-BCEF-4B07-AADD-2E39A80F15DF")] 29 29 public class Arc : Item, IArc { 30 30 [Storable] -
branches/PersistenceOverhaul/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs
r13368 r13386 28 28 namespace HeuristicLab.Core { 29 29 [Item("Vertex", "An object representing a vertex in the graph. It can have a text label, a weight, and an additional data object.")] 30 [StorableClass(" 0B8261A0-8829-4BB8-B7EF-940A9A0AB1D9")]30 [StorableClass("DC0C1D1F-82DF-4150-94CC-A10FD3667F72")] 31 31 public class Vertex : Item, IVertex { 32 32 [Storable] -
branches/PersistenceOverhaul/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs
r13368 r13386 35 35 /// </summary> 36 36 [Item("StochasticMultiBranch", "Selects one of its branches (if there are any) given a list of relative probabilities.")] 37 [StorableClass("7 DE99E47-6B7D-4AE3-A8B8-0D7C9B82F3EE")]37 [StorableClass("7FF6CB0B-F831-4A97-A8D3-40EBF6BE78B6")] 38 38 public abstract class StochasticMultiBranch<T> : CheckedMultiOperator<T> where T : class, IOperator { 39 39 /// <summary> -
branches/PersistenceOverhaul/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs
r13368 r13386 235 235 236 236 [Item("EmptyUserDefinedProblemEvaluator", "A dummy evaluator that will throw an exception when executed.")] 237 [StorableClass(" F3DF503B-3FCA-4A80-B5E8-776699E6F13E")]237 [StorableClass("00D4B39A-2E69-4842-9045-6E9D8F01F6EB")] 238 238 [NonDiscoverableType] 239 239 private sealed class EmptyUserDefinedProblemEvaluator : ParameterizedNamedItem, ISingleObjectiveEvaluator { -
branches/PersistenceOverhaul/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicNearestNeighbourClassificationModel.cs
r13368 r13386 32 32 /// Represents a nearest neighbour model for regression and classification 33 33 /// </summary> 34 [StorableClass(" 01561669-12E6-4C75-86BF-88C24DA53FDD")]34 [StorableClass("225CCF16-C932-4D18-AF5A-0745FAD8F22C")] 35 35 [Item("SymbolicNearestNeighbourClassificationModel", "Represents a nearest neighbour model for symbolic classification.")] 36 36 public sealed class SymbolicNearestNeighbourClassificationModel : SymbolicClassificationModel { -
branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/StorableAttributeTests.cs
r13368 r13386 24 24 namespace HeuristicLab.Persistence.Tests { 25 25 26 [StorableClass(" 2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]26 [StorableClass("E6CE21DC-FEA3-4763-BA60-CE8EB6B8E539")] 27 27 class DemoClass { 28 28 … … 36 36 } 37 37 38 [StorableClass(" 2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]38 [StorableClass("32FDC5F4-E5AD-4119-90E0-6D14785E87FD")] 39 39 class Base { 40 40 public string baseName; … … 46 46 } 47 47 48 [StorableClass(" 2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]48 [StorableClass("F2151C9F-FD83-4D6F-B987-08DF723158DB")] 49 49 class Override : Base { 50 50 [Storable] … … 55 55 } 56 56 57 [StorableClass(" 2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]57 [StorableClass("647B2E77-EC1E-458F-AB9D-ACFA8248352A")] 58 58 class Intermediate : Override { 59 59 } 60 60 61 [StorableClass(" 2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]61 [StorableClass("AEAC61FF-896F-418C-82C8-33F0548AF3B2")] 62 62 class New : Intermediate { 63 63 public string newName; -
branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs
r13370 r13386 46 46 namespace HeuristicLab.Persistence.Tests { 47 47 48 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]48 [StorableClass("777E5793-7389-4109-A617-D7D6EB74A2C7")] 49 49 public class NumberTest { 50 50 [Storable] … … 95 95 } 96 96 97 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]97 [StorableClass("2911C342-74AB-4B47-9840-87F012AEF0C1")] 98 98 public class NonDefaultConstructorClass { 99 99 [Storable] … … 104 104 } 105 105 106 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]106 [StorableClass("8621F4FA-8711-4DA4-A50B-7D04683440B8")] 107 107 public class IntWrapper { 108 108 … … 127 127 } 128 128 129 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]129 [StorableClass("0B93C65E-1A4C-45DD-B40D-7614BA2B2ABA")] 130 130 public class PrimitivesTest : NumberTest { 131 131 [Storable] … … 159 159 public enum TestEnum { va1, va2, va3, va8 } ; 160 160 161 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]161 [StorableClass("0DA4A6A5-0280-4F3C-80DA-0AB09461F66C")] 162 162 public class RootBase { 163 163 [Storable] … … 178 178 } 179 179 180 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]180 [StorableClass("12CC2626-A1E2-45A5-9761-902333C88CCF")] 181 181 public class Root : RootBase { 182 182 [Storable] … … 213 213 public enum TrickyEnum { zero = 0, one = 1, two = 2 } 214 214 215 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]215 [StorableClass("04BFD8AF-AB93-457A-B5CD-F2AB2B18874F")] 216 216 public class EnumTest { 217 217 [Storable] … … 223 223 } 224 224 225 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]225 [StorableClass("41E5C615-82A6-4844-B6A4-4DB8ED8C03D8")] 226 226 public class Custom { 227 227 [Storable] … … 233 233 } 234 234 235 [StorableClass("3 B2B27A5-3F0A-44ED-8672-0E89C9618026")]235 [StorableClass("3D2455E6-0AD9-4141-B44A-759F71491443")] 236 236 public class Manager { 237 237 … … 246 246 } 247 247 248 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]248 [StorableClass("D8D40F6E-91DC-4E20-8154-F95C0AF32CC8")] 249 249 public class C { 250 250 [Storable] … … 486 486 } 487 487 488 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]488 [StorableClass("B2C78E8F-32F9-43BE-9DED-219F102125EB")] 489 489 public class NestedType { 490 490 [Storable] … … 692 692 l.Add(new NonSerializable()); 693 693 try { 694 Serializer s = newSerializer(l,694 HeuristicLab.Persistence.Core.Serializer s = new HeuristicLab.Persistence.Core.Serializer(l, 695 695 ConfigurationService.Instance.GetConfiguration(new XmlFormat()), 696 696 "ROOT", true); … … 711 711 public void TestAssemblyVersionCheck() { 712 712 IntWrapper i = new IntWrapper(1); 713 Serializer s = newSerializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));713 HeuristicLab.Persistence.Core.Serializer s = new HeuristicLab.Persistence.Core.Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 714 714 XmlGenerator g = new XmlGenerator(); 715 715 StringBuilder dataString = new StringBuilder(); … … 758 758 } 759 759 760 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]760 [StorableClass("2B2FE809-CDA4-4BCD-BF4C-35F757678AB9")] 761 761 class Child { 762 762 [Storable] … … 764 764 } 765 765 766 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]766 [StorableClass("C8F4E805-26DF-4129-910E-F7F51E4DDE41")] 767 767 class Parent { 768 768 [Storable] … … 770 770 } 771 771 772 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]772 [StorableClass("0CF63740-F8C1-46EE-A3A0-7E350A8EBAA1")] 773 773 class GrandParent { 774 774 [Storable] … … 848 848 } 849 849 850 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]850 [StorableClass("F5920537-7F03-41C4-8061-8F8D7CDDB6BE")] 851 851 private class PersistenceHooks { 852 852 [Storable] … … 885 885 } 886 886 887 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]887 [StorableClass("935C5ECB-ACEF-48EA-93BC-4B4177DFE0A5")] 888 888 private class CustomConstructor { 889 889 public string Value = "none"; … … 909 909 } 910 910 911 [StorableClass("3 B2B27A5-3F0A-44ED-8672-0E89C9618026")]911 [StorableClass("31D7CE01-E390-40CF-B9BF-BD79A8F850DA")] 912 912 public class ExplodingDefaultConstructor { 913 913 public ExplodingDefaultConstructor() { … … 961 961 } 962 962 963 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]963 [StorableClass("9DEE1F8F-320C-401B-8103-65FBA6BD4F07")] 964 964 public class HookInheritanceTestBase { 965 965 [Storable] … … 972 972 } 973 973 974 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]974 [StorableClass("97DF2931-2B23-4FAA-8E59-806FA58ADAED")] 975 975 public class HookInheritanceTestDerivedClass : HookInheritanceTestBase { 976 976 [Storable] … … 994 994 } 995 995 996 [StorableClass(StorableClassType.AllFields, " B9AB42E8-1932-425B-B4CF-F31F07EAC599")]996 [StorableClass(StorableClassType.AllFields, "6207E4E1-4CFC-4890-9741-33B7E1E43F26")] 997 997 public class AllFieldsStorable { 998 998 public int Value1 = 1; … … 1025 1025 } 1026 1026 1027 [StorableClass(StorableClassType.AllProperties, " CB7DC31C-AEF3-4EB8-91CA-248B767E9F92")]1027 [StorableClass(StorableClassType.AllProperties, "ADDB5A7C-4BA9-4E5F-BFAF-2B48C8646808")] 1028 1028 public class AllPropertiesStorable { 1029 1029 public int Value1 = 1; … … 1057 1057 } 1058 1058 1059 [StorableClass(StorableClassType.AllFieldsAndAllProperties, " 0AD8D68F-E0FF-4FA8-8A72-1148CD91A2B9")]1059 [StorableClass(StorableClassType.AllFieldsAndAllProperties, "9C6136CB-A9AC-4527-B41A-7A2DB50ACE53")] 1060 1060 public class AllFieldsAndAllPropertiesStorable { 1061 1061 public int Value1 = 1; … … 1088 1088 } 1089 1089 1090 [StorableClass(StorableClassType.MarkedOnly, " 0D94E6D4-64E3-4637-B1EE-DEF2B3F6E2E0")]1090 [StorableClass(StorableClassType.MarkedOnly, "75C9F6F0-1B2E-41E7-A327-AF9CF5C87D8D")] 1091 1091 public class MarkedOnlyStorable { 1092 1092 public int Value1 = 1; … … 1248 1248 } 1249 1249 1250 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1250 [StorableClass("A603ABE6-86DB-46F7-AF87-C7B40E4FF169")] 1251 1251 public class ReadOnlyFail { 1252 1252 [Storable] … … 1272 1272 1273 1273 1274 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1274 [StorableClass("7EDE1D86-C8F5-4B51-846F-1634C0FE20BB")] 1275 1275 public class WriteOnlyFail { 1276 1276 [Storable] … … 1295 1295 } 1296 1296 1297 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1297 [StorableClass("65B13830-5D60-4C3F-8D9E-5DCDF1E3A977")] 1298 1298 public class OneWayTest { 1299 1299 public OneWayTest() { this.value = "default"; } … … 1314 1314 public void TestOneWaySerialization() { 1315 1315 var test = new OneWayTest(); 1316 var serializer = new Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));1316 var serializer = new HeuristicLab.Persistence.Core.Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 1317 1317 var it = serializer.GetEnumerator(); 1318 1318 it.MoveNext(); -
branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs
r13370 r13386 29 29 using System.Reflection; 30 30 using System.Text; 31 using System.Text.RegularExpressions;32 31 using System.Threading.Tasks; 33 32 using HeuristicLab.Algorithms.GeneticAlgorithm; 33 using HeuristicLab.Persistence; 34 34 using HeuristicLab.Persistence.Auxiliary; 35 35 using HeuristicLab.Persistence.Core; 36 using HeuristicLab.Persistence.Core.Tokens;37 using HeuristicLab.Persistence.Default.CompositeSerializers;38 36 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 39 37 using HeuristicLab.Persistence.Default.DebugString; 40 38 using HeuristicLab.Persistence.Default.Xml; 41 using HeuristicLab.Persistence.Default.Xml.Primitive; 42 using HeuristicLab.Persistence.Interfaces; 39 using HeuristicLab.Persistence.Tests; 43 40 using HeuristicLab.Tests; 44 41 using Microsoft.VisualStudio.TestTools.UnitTesting; 45 42 46 namespace HeuristicLab.Persistence .Tests {47 48 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]43 namespace HeuristicLab.PersistenceNew.Tests { 44 #region Test Classes 45 [StorableClass("7D9672BD-703D-42BB-9080-9929885D4580")] 49 46 public class NumberTest { 50 47 [Storable] … … 95 92 } 96 93 97 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]94 [StorableClass("EEB19599-D5AC-48ED-A56B-CF213DFAF2E4")] 98 95 public class NonDefaultConstructorClass { 99 96 [Storable] … … 104 101 } 105 102 106 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]103 [StorableClass("EE43FE7A-6D07-4D52-9338-C21B3485F82A")] 107 104 public class IntWrapper { 108 105 … … 127 124 } 128 125 129 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]126 [StorableClass("00A8E48E-8E8A-443C-A327-9F6ACCBE7E80")] 130 127 public class PrimitivesTest : NumberTest { 131 128 [Storable] … … 159 156 public enum TestEnum { va1, va2, va3, va8 } ; 160 157 161 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]158 [StorableClass("26BA37F6-926D-4665-A10A-1F39E1CF6468")] 162 159 public class RootBase { 163 160 [Storable] … … 178 175 } 179 176 180 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]177 [StorableClass("F6BCB436-B5F2-40F6-8E2F-7A018CD1CBA0")] 181 178 public class Root : RootBase { 182 179 [Storable] … … 213 210 public enum TrickyEnum { zero = 0, one = 1, two = 2 } 214 211 215 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]212 [StorableClass("2F6326ED-023A-415F-B5C7-9F9241940D05")] 216 213 public class EnumTest { 217 214 [Storable] … … 223 220 } 224 221 225 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]222 [StorableClass("92365E2A-1184-4280-B763-4853C7ADF3E3")] 226 223 public class Custom { 227 224 [Storable] … … 233 230 } 234 231 235 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]232 [StorableClass("7CF19EBC-1EC4-4FBE-BCA9-DA48E3CFE30D")] 236 233 public class Manager { 237 234 … … 246 243 } 247 244 248 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]245 [StorableClass("9092C705-F5E9-4BA9-9750-4357DB29AABF")] 249 246 public class C { 250 247 [Storable] … … 267 264 } 268 265 266 #endregion 269 267 270 268 [TestClass] 271 public class UseCases {272 269 public class UseCasesPersistenceNew { 270 #region Helpers 273 271 private string tempFile; 272 273 [ClassInitialize] 274 public static void Initialize(TestContext testContext) { 275 ConfigurationService.Instance.Reset(); 276 } 274 277 275 278 [TestInitialize()] … … 285 288 File.Delete(tempFile); 286 289 } 287 290 #endregion 291 292 #region Persistence 4.0 test methods 293 [TestMethod] 294 [TestCategory("Persistence")] 295 [TestProperty("Time", "short")] 296 public void TestBool() { 297 bool test = true; 298 ProtoBufSerializer serializer = new ProtoBufSerializer(); 299 serializer.Serialize(test, tempFile); 300 object o = serializer.Deserialize(tempFile); 301 bool result = (bool)o; 302 Assert.AreEqual(test, result); 303 } 304 305 [TestMethod] 306 [TestCategory("Persistence")] 307 [TestProperty("Time", "short")] 308 public void TestInt() { 309 int test = 42; 310 ProtoBufSerializer serializer = new ProtoBufSerializer(); 311 serializer.Serialize(test, tempFile); 312 object o = serializer.Deserialize(tempFile); 313 int result = (int)o; 314 Assert.AreEqual(test, result); 315 } 316 #endregion 317 318 319 #region Old persistence test methods 288 320 [TestMethod] 289 321 [TestCategory("Persistence")] 290 322 [TestProperty("Time", "short")] 291 323 public void ComplexStorable() { 324 ProtoBufSerializer serializer = new ProtoBufSerializer(); 292 325 Root r = InitializeComplexStorable(); 293 XmlGenerator.Serialize(r, tempFile);294 Root newR = (Root) XmlParser.Deserialize(tempFile);326 serializer.Serialize(r, tempFile); 327 Root newR = (Root)serializer.Deserialize(tempFile); 295 328 CompareComplexStorables(r, newR); 296 }297 298 [TestMethod]299 [TestCategory("Persistence")]300 [TestProperty("Time", "short")]301 public void ComplexEasyStorable() {302 Root r = InitializeComplexStorable();303 ReadableXmlGenerator.Serialize(r, tempFile);304 using (var reader = new StreamReader(tempFile)) {305 string text = reader.ReadToEnd();306 Assert.IsTrue(text.StartsWith("<Root"));307 }308 329 } 309 330 … … 391 412 [TestProperty("Time", "short")] 392 413 public void SelfReferences() { 414 ProtoBufSerializer serializer = new ProtoBufSerializer(); 393 415 C c = new C(); 394 416 C[][] cs = new C[2][]; … … 397 419 c.allCs = cs; 398 420 c.kvpList = new KeyValuePair<List<C>, C>(new List<C> { c }, c); 399 XmlGenerator.Serialize(cs, tempFile);400 object o = XmlParser.Deserialize(tempFile);421 serializer.Serialize(cs, tempFile); 422 object o = serializer.Deserialize(tempFile); 401 423 Assert.AreEqual( 402 424 DebugStringGenerator.Serialize(cs), … … 418 440 [TestProperty("Time", "short")] 419 441 public void ArrayCreation() { 442 ProtoBufSerializer serializer = new ProtoBufSerializer(); 420 443 ArrayList[] arrayListArray = new ArrayList[4]; 421 444 arrayListArray[0] = new ArrayList(); … … 431 454 new[] { 1, 2 }, new[] { 3, 4 }); 432 455 arrayListArray[2].Add(a); 433 XmlGenerator.Serialize(arrayListArray, tempFile);434 object o = XmlParser.Deserialize(tempFile);456 serializer.Serialize(arrayListArray, tempFile); 457 object o = serializer.Deserialize(tempFile); 435 458 Assert.AreEqual( 436 459 DebugStringGenerator.Serialize(arrayListArray), … … 447 470 [TestProperty("Time", "short")] 448 471 public void CustomSerializationProperty() { 472 ProtoBufSerializer serializer = new ProtoBufSerializer(); 449 473 Manager m = new Manager(); 450 XmlGenerator.Serialize(m, tempFile);451 Manager newM = (Manager) XmlParser.Deserialize(tempFile);474 serializer.Serialize(m, tempFile); 475 Manager newM = (Manager)serializer.Deserialize(tempFile); 452 476 Assert.AreNotEqual( 453 477 DebugStringGenerator.Serialize(m), … … 463 487 [TestProperty("Time", "short")] 464 488 public void Primitives() { 489 ProtoBufSerializer serializer = new ProtoBufSerializer(); 465 490 PrimitivesTest sdt = new PrimitivesTest(); 466 XmlGenerator.Serialize(sdt, tempFile);467 object o = XmlParser.Deserialize(tempFile);491 serializer.Serialize(sdt, tempFile); 492 object o = serializer.Deserialize(tempFile); 468 493 Assert.AreEqual( 469 494 DebugStringGenerator.Serialize(sdt), … … 475 500 [TestProperty("Time", "short")] 476 501 public void MultiDimensionalArray() { 502 ProtoBufSerializer serializer = new ProtoBufSerializer(); 477 503 string[,] mDimString = new string[,] { 478 504 {"ora", "et", "labora"}, 479 505 {"Beten", "und", "Arbeiten"} 480 506 }; 481 XmlGenerator.Serialize(mDimString, tempFile);482 object o = XmlParser.Deserialize(tempFile);507 serializer.Serialize(mDimString, tempFile); 508 object o = serializer.Deserialize(tempFile); 483 509 Assert.AreEqual( 484 510 DebugStringGenerator.Serialize(mDimString), … … 486 512 } 487 513 488 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]514 [StorableClass("87A331AF-14DC-48B3-B577-D49065743BE6")] 489 515 public class NestedType { 490 516 [Storable] … … 505 531 [TestProperty("Time", "short")] 506 532 public void NestedTypeTest() { 533 ProtoBufSerializer serializer = new ProtoBufSerializer(); 507 534 NestedType t = new NestedType(); 508 XmlGenerator.Serialize(t, tempFile);509 object o = XmlParser.Deserialize(tempFile);535 serializer.Serialize(t, tempFile); 536 object o = serializer.Deserialize(tempFile); 510 537 Assert.AreEqual( 511 538 DebugStringGenerator.Serialize(t), … … 519 546 [TestProperty("Time", "short")] 520 547 public void SimpleArray() { 548 ProtoBufSerializer serializer = new ProtoBufSerializer(); 521 549 string[] strings = { "ora", "et", "labora" }; 522 XmlGenerator.Serialize(strings, tempFile);523 object o = XmlParser.Deserialize(tempFile);550 serializer.Serialize(strings, tempFile); 551 object o = serializer.Deserialize(tempFile); 524 552 Assert.AreEqual( 525 553 DebugStringGenerator.Serialize(strings), … … 531 559 [TestProperty("Time", "short")] 532 560 public void PrimitiveRoot() { 533 XmlGenerator.Serialize(12.3f, tempFile); 534 object o = XmlParser.Deserialize(tempFile); 561 ProtoBufSerializer serializer = new ProtoBufSerializer(); 562 serializer.Serialize(12.3f, tempFile); 563 object o = serializer.Deserialize(tempFile); 535 564 Assert.AreEqual( 536 565 DebugStringGenerator.Serialize(12.3f), … … 584 613 [TestCategory("Persistence")] 585 614 [TestProperty("Time", "short")] 586 public void Number2StringDecomposer() {587 NumberTest sdt = new NumberTest();588 XmlGenerator.Serialize(sdt, tempFile,589 new Configuration(new XmlFormat(),590 new List<IPrimitiveSerializer> { new String2XmlSerializer() },591 new List<ICompositeSerializer> {592 new StorableSerializer(),593 new Number2StringSerializer() }));594 object o = XmlParser.Deserialize(tempFile);595 Assert.AreEqual(596 DebugStringGenerator.Serialize(sdt),597 DebugStringGenerator.Serialize(o));598 Assert.IsTrue(sdt.Equals(o));599 }600 601 [TestMethod]602 [TestCategory("Persistence")]603 [TestProperty("Time", "short")]604 615 public void Enums() { 616 ProtoBufSerializer serializer = new ProtoBufSerializer(); 605 617 EnumTest et = new EnumTest(); 606 618 et.simpleEnum = SimpleEnum.two; 607 619 et.complexEnum = ComplexEnum.three; 608 620 et.trickyEnum = TrickyEnum.two | TrickyEnum.one; 609 XmlGenerator.Serialize(et, tempFile);610 EnumTest newEt = (EnumTest) XmlParser.Deserialize(tempFile);621 serializer.Serialize(et, tempFile); 622 EnumTest newEt = (EnumTest)serializer.Deserialize(tempFile); 611 623 Assert.AreEqual(et.simpleEnum, SimpleEnum.two); 612 624 Assert.AreEqual(et.complexEnum, ComplexEnum.three); … … 618 630 [TestProperty("Time", "short")] 619 631 public void TestAliasingWithOverriddenEquals() { 632 ProtoBufSerializer serializer = new ProtoBufSerializer(); 620 633 List<IntWrapper> ints = new List<IntWrapper>(); 621 634 ints.Add(new IntWrapper(1)); … … 623 636 Assert.AreEqual(ints[0], ints[1]); 624 637 Assert.AreNotSame(ints[0], ints[1]); 625 XmlGenerator.Serialize(ints, tempFile);626 List<IntWrapper> newInts = (List<IntWrapper>) XmlParser.Deserialize(tempFile);638 serializer.Serialize(ints, tempFile); 639 List<IntWrapper> newInts = (List<IntWrapper>)serializer.Deserialize(tempFile); 627 640 Assert.AreEqual(newInts[0].Value, 1); 628 641 Assert.AreEqual(newInts[1].Value, 1); … … 635 648 [TestProperty("Time", "short")] 636 649 public void NonDefaultConstructorTest() { 650 ProtoBufSerializer serializer = new ProtoBufSerializer(); 637 651 NonDefaultConstructorClass c = new NonDefaultConstructorClass(1); 638 652 try { 639 XmlGenerator.Serialize(c, tempFile);653 serializer.Serialize(c, tempFile); 640 654 Assert.Fail("Exception not thrown"); 641 655 } … … 648 662 [TestProperty("Time", "short")] 649 663 public void TestSavingException() { 664 ProtoBufSerializer serializer = new ProtoBufSerializer(); 650 665 List<int> list = new List<int> { 1, 2, 3 }; 651 XmlGenerator.Serialize(list, tempFile);666 serializer.Serialize(list, tempFile); 652 667 NonSerializable s = new NonSerializable(); 653 668 try { 654 XmlGenerator.Serialize(s, tempFile);669 serializer.Serialize(s, tempFile); 655 670 Assert.Fail("Exception expected"); 656 671 } 657 672 catch (PersistenceException) { } 658 List<int> newList = (List<int>) XmlParser.Deserialize(tempFile);673 List<int> newList = (List<int>)serializer.Deserialize(tempFile); 659 674 Assert.AreEqual(list[0], newList[0]); 660 675 Assert.AreEqual(list[1], newList[1]); … … 686 701 [TestCategory("Persistence")] 687 702 [TestProperty("Time", "short")] 688 public void TestMultipleFailure() {689 List<NonSerializable> l = new List<NonSerializable>();690 l.Add(new NonSerializable());691 l.Add(new NonSerializable());692 l.Add(new NonSerializable());693 try {694 Serializer s = new Serializer(l,695 ConfigurationService.Instance.GetConfiguration(new XmlFormat()),696 "ROOT", true);697 StringBuilder tokens = new StringBuilder();698 foreach (var token in s) {699 tokens.Append(token.ToString());700 }701 Assert.Fail("Exception expected");702 }703 catch (PersistenceException px) {704 Assert.AreEqual(3, px.Data.Count);705 }706 }707 708 [TestMethod]709 [TestCategory("Persistence")]710 [TestProperty("Time", "short")]711 public void TestAssemblyVersionCheck() {712 IntWrapper i = new IntWrapper(1);713 Serializer s = new Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));714 XmlGenerator g = new XmlGenerator();715 StringBuilder dataString = new StringBuilder();716 foreach (var token in s) {717 dataString.Append(g.Format(token));718 }719 StringBuilder typeString = new StringBuilder();720 foreach (var line in g.Format(s.TypeCache))721 typeString.Append(line);722 Deserializer d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(typeString.ToString())));723 XmlParser p = new XmlParser(new StringReader(dataString.ToString()));724 IntWrapper newI = (IntWrapper)d.Deserialize(p);725 Assert.AreEqual(i.Value, newI.Value);726 727 string newTypeString = Regex.Replace(typeString.ToString(),728 "Version=\\d+\\.\\d+\\.\\d+\\.\\d+",729 "Version=0.0.9999.9999");730 try {731 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));732 Assert.Fail("Exception expected");733 }734 catch (PersistenceException x) {735 Assert.IsTrue(x.Message.Contains("incompatible"));736 }737 newTypeString = Regex.Replace(typeString.ToString(),738 "Version=(\\d+\\.\\d+)\\.\\d+\\.\\d+",739 "Version=$1.9999.9999");740 try {741 d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));742 Assert.Fail("Exception expected");743 }744 catch (PersistenceException x) {745 Assert.IsTrue(x.Message.Contains("newer"));746 }747 }748 749 [TestMethod]750 [TestCategory("Persistence")]751 [TestProperty("Time", "short")]752 703 public void InheritanceTest() { 704 ProtoBufSerializer serializer = new ProtoBufSerializer(); 753 705 New n = new New(); 754 XmlGenerator.Serialize(n, tempFile);755 New nn = (New) XmlParser.Deserialize(tempFile);706 serializer.Serialize(n, tempFile); 707 New nn = (New)serializer.Deserialize(tempFile); 756 708 Assert.AreEqual(n.Name, nn.Name); 757 709 Assert.AreEqual(((Override)n).Name, ((Override)nn).Name); 758 710 } 759 711 760 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]712 [StorableClass("B963EF51-12B4-432E-8C54-88F026F9ACE2")] 761 713 class Child { 762 714 [Storable] … … 764 716 } 765 717 766 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]718 [StorableClass("E66E9606-967A-4C35-A361-F6F0D21C064A")] 767 719 class Parent { 768 720 [Storable] … … 770 722 } 771 723 772 [StorableClass("3 B2B27A5-3F0A-44ED-8672-0E89C9618026")]724 [StorableClass("34D3893A-57AD-4F72-878B-81D6FA3F14A9")] 773 725 class GrandParent { 774 726 [Storable] … … 780 732 [TestProperty("Time", "short")] 781 733 public void InstantiateParentChainReference() { 734 ProtoBufSerializer serializer = new ProtoBufSerializer(); 782 735 GrandParent gp = new GrandParent(); 783 736 gp.parent = new Parent(); … … 785 738 gp.parent.child.grandParent = gp; 786 739 Assert.AreSame(gp, gp.parent.child.grandParent); 787 XmlGenerator.Serialize(gp, tempFile);788 GrandParent newGp = (GrandParent) XmlParser.Deserialize(tempFile);740 serializer.Serialize(gp, tempFile); 741 GrandParent newGp = (GrandParent)serializer.Deserialize(tempFile); 789 742 Assert.AreSame(newGp, newGp.parent.child.grandParent); 790 743 } … … 804 757 [TestProperty("Time", "short")] 805 758 public void StructTest() { 759 ProtoBufSerializer serializer = new ProtoBufSerializer(); 806 760 TestStruct s = new TestStruct(10); 807 XmlGenerator.Serialize(s, tempFile);808 TestStruct newS = (TestStruct) XmlParser.Deserialize(tempFile);761 serializer.Serialize(s, tempFile); 762 TestStruct newS = (TestStruct)serializer.Deserialize(tempFile); 809 763 Assert.AreEqual(s, newS); 810 764 } … … 814 768 [TestProperty("Time", "short")] 815 769 public void PointTest() { 770 ProtoBufSerializer serializer = new ProtoBufSerializer(); 816 771 Point p = new Point(12, 34); 817 XmlGenerator.Serialize(p, tempFile);818 Point newP = (Point) XmlParser.Deserialize(tempFile);772 serializer.Serialize(p, tempFile); 773 Point newP = (Point)serializer.Deserialize(tempFile); 819 774 Assert.AreEqual(p, newP); 820 775 } … … 824 779 [TestProperty("Time", "short")] 825 780 public void NullableValueTypes() { 781 ProtoBufSerializer serializer = new ProtoBufSerializer(); 826 782 double?[] d = new double?[] { null, 1, 2, 3 }; 827 XmlGenerator.Serialize(d, tempFile);828 double?[] newD = (double?[]) XmlParser.Deserialize(tempFile);783 serializer.Serialize(d, tempFile); 784 double?[] newD = (double?[])serializer.Deserialize(tempFile); 829 785 Assert.AreEqual(d[0], newD[0]); 830 786 Assert.AreEqual(d[1], newD[1]); … … 837 793 [TestProperty("Time", "short")] 838 794 public void BitmapTest() { 795 ProtoBufSerializer serializer = new ProtoBufSerializer(); 839 796 Icon icon = System.Drawing.SystemIcons.Hand; 840 797 Bitmap bitmap = icon.ToBitmap(); 841 XmlGenerator.Serialize(bitmap, tempFile);842 Bitmap newBitmap = (Bitmap) XmlParser.Deserialize(tempFile);798 serializer.Serialize(bitmap, tempFile); 799 Bitmap newBitmap = (Bitmap)serializer.Deserialize(tempFile); 843 800 844 801 Assert.AreEqual(bitmap.Size, newBitmap.Size); … … 848 805 } 849 806 850 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]807 [StorableClass("E846BC49-20F3-4D3F-A3F3-73D4F2DB1C2E")] 851 808 private class PersistenceHooks { 852 809 [Storable] … … 870 827 [TestProperty("Time", "short")] 871 828 public void HookTest() { 829 ProtoBufSerializer serializer = new ProtoBufSerializer(); 872 830 PersistenceHooks hookTest = new PersistenceHooks(); 873 831 hookTest.a = 2; … … 875 833 Assert.IsFalse(hookTest.WasSerialized); 876 834 Assert.AreEqual(hookTest.sum, 0); 877 XmlGenerator.Serialize(hookTest, tempFile);835 serializer.Serialize(hookTest, tempFile); 878 836 Assert.IsTrue(hookTest.WasSerialized); 879 837 Assert.AreEqual(hookTest.sum, 0); 880 PersistenceHooks newHookTest = (PersistenceHooks) XmlParser.Deserialize(tempFile);838 PersistenceHooks newHookTest = (PersistenceHooks)serializer.Deserialize(tempFile); 881 839 Assert.AreEqual(newHookTest.a, hookTest.a); 882 840 Assert.AreEqual(newHookTest.b, hookTest.b); … … 885 843 } 886 844 887 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]845 [StorableClass("A35D71DF-397F-4910-A950-ED6923BE9483")] 888 846 private class CustomConstructor { 889 847 public string Value = "none"; … … 902 860 [TestProperty("Time", "short")] 903 861 public void TestCustomConstructor() { 862 ProtoBufSerializer serializer = new ProtoBufSerializer(); 904 863 CustomConstructor cc = new CustomConstructor(); 905 864 Assert.AreEqual(cc.Value, "default"); 906 XmlGenerator.Serialize(cc, tempFile);907 CustomConstructor newCC = (CustomConstructor) XmlParser.Deserialize(tempFile);865 serializer.Serialize(cc, tempFile); 866 CustomConstructor newCC = (CustomConstructor)serializer.Deserialize(tempFile); 908 867 Assert.AreEqual(newCC.Value, "persistence"); 909 868 } 910 869 911 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]870 [StorableClass("D276E825-1F35-4BAC-8937-9ABC91D5C316")] 912 871 public class ExplodingDefaultConstructor { 913 872 public ExplodingDefaultConstructor() { … … 922 881 [TestProperty("Time", "short")] 923 882 public void TestConstructorExceptionUnwrapping() { 883 ProtoBufSerializer serializer = new ProtoBufSerializer(); 924 884 ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password"); 925 XmlGenerator.Serialize(x, tempFile);885 serializer.Serialize(x, tempFile); 926 886 try { 927 ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor) XmlParser.Deserialize(tempFile);887 ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)serializer.Deserialize(tempFile); 928 888 Assert.Fail("Exception expected"); 929 889 } … … 937 897 [TestProperty("Time", "short")] 938 898 public void TestRejectionJustifications() { 899 ProtoBufSerializer serializer = new ProtoBufSerializer(); 939 900 NonSerializable ns = new NonSerializable(); 940 901 try { 941 XmlGenerator.Serialize(ns, tempFile);902 serializer.Serialize(ns, tempFile); 942 903 Assert.Fail("PersistenceException expected"); 943 904 } … … 951 912 [TestProperty("Time", "short")] 952 913 public void TestStreaming() { 914 ProtoBufSerializer serializer = new ProtoBufSerializer(); 953 915 using (MemoryStream stream = new MemoryStream()) { 954 916 Root r = InitializeComplexStorable(); 955 XmlGenerator.Serialize(r, stream);917 serializer.Serialize(r, stream); 956 918 using (MemoryStream stream2 = new MemoryStream(stream.ToArray())) { 957 Root newR = (Root) XmlParser.Deserialize(stream2);919 Root newR = (Root)serializer.Deserialize(stream2); 958 920 CompareComplexStorables(r, newR); 959 921 } … … 961 923 } 962 924 963 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]925 [StorableClass("4921031B-CB61-4677-97AD-9236A4CEC200")] 964 926 public class HookInheritanceTestBase { 965 927 [Storable] … … 972 934 } 973 935 974 [StorableClass("3 B2B27A5-3F0A-44ED-8672-0E89C9618026")]936 [StorableClass("321CEE0A-5201-4CE2-B135-2343890D96BF")] 975 937 public class HookInheritanceTestDerivedClass : HookInheritanceTestBase { 976 938 [Storable] … … 987 949 [TestProperty("Time", "short")] 988 950 public void TestLinkInheritance() { 951 ProtoBufSerializer serializer = new ProtoBufSerializer(); 989 952 HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass(); 990 953 c.a = new object(); 991 XmlGenerator.Serialize(c, tempFile);992 HookInheritanceTestDerivedClass newC = (HookInheritanceTestDerivedClass) XmlParser.Deserialize(tempFile);954 serializer.Serialize(c, tempFile); 955 HookInheritanceTestDerivedClass newC = (HookInheritanceTestDerivedClass)serializer.Deserialize(tempFile); 993 956 Assert.AreSame(c.b, c.link); 994 957 } … … 1016 979 [TestProperty("Time", "short")] 1017 980 public void TestStorableClassDiscoveryAllFields() { 981 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1018 982 AllFieldsStorable afs = new AllFieldsStorable(false); 1019 XmlGenerator.Serialize(afs, tempFile);1020 AllFieldsStorable newAfs = (AllFieldsStorable) XmlParser.Deserialize(tempFile);983 serializer.Serialize(afs, tempFile); 984 AllFieldsStorable newAfs = (AllFieldsStorable)serializer.Deserialize(tempFile); 1021 985 Assert.AreEqual(afs.Value1, newAfs.Value1); 1022 986 Assert.AreEqual(afs.Value2, newAfs.Value2); … … 1047 1011 [TestProperty("Time", "short")] 1048 1012 public void TestStorableClassDiscoveryAllProperties() { 1013 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1049 1014 AllPropertiesStorable afs = new AllPropertiesStorable(false); 1050 XmlGenerator.Serialize(afs, tempFile);1051 AllPropertiesStorable newAfs = (AllPropertiesStorable) XmlParser.Deserialize(tempFile);1015 serializer.Serialize(afs, tempFile); 1016 AllPropertiesStorable newAfs = (AllPropertiesStorable)serializer.Deserialize(tempFile); 1052 1017 Assert.AreEqual(1, newAfs.Value1); 1053 1018 Assert.AreEqual(2, newAfs.Value2); … … 1079 1044 [TestProperty("Time", "short")] 1080 1045 public void TestStorableClassDiscoveryAllFieldsAndAllProperties() { 1046 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1081 1047 AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false); 1082 XmlGenerator.Serialize(afs, tempFile);1083 AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable) XmlParser.Deserialize(tempFile);1048 serializer.Serialize(afs, tempFile); 1049 AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)serializer.Deserialize(tempFile); 1084 1050 Assert.AreEqual(afs.Value1, newAfs.Value1); 1085 1051 Assert.AreEqual(afs.Value2, newAfs.Value2); … … 1110 1076 [TestProperty("Time", "short")] 1111 1077 public void TestStorableClassDiscoveryMarkedOnly() { 1078 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1112 1079 MarkedOnlyStorable afs = new MarkedOnlyStorable(false); 1113 XmlGenerator.Serialize(afs, tempFile);1114 MarkedOnlyStorable newAfs = (MarkedOnlyStorable) XmlParser.Deserialize(tempFile);1080 serializer.Serialize(afs, tempFile); 1081 MarkedOnlyStorable newAfs = (MarkedOnlyStorable)serializer.Deserialize(tempFile); 1115 1082 Assert.AreEqual(1, newAfs.Value1); 1116 1083 Assert.AreEqual(afs.Value2, newAfs.Value2); … … 1123 1090 [TestProperty("Time", "short")] 1124 1091 public void TestLineEndings() { 1092 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1125 1093 List<string> lineBreaks = new List<string> { "\r\n", "\n", "\r", "\n\r", Environment.NewLine }; 1126 1094 List<string> lines = new List<string>(); 1127 1095 foreach (var br in lineBreaks) 1128 1096 lines.Add("line1" + br + "line2"); 1129 XmlGenerator.Serialize(lines, tempFile);1130 List<string> newLines = XmlParser.Deserialize<List<string>>(tempFile);1097 serializer.Serialize(lines, tempFile); 1098 List<string> newLines = (List<string>)serializer.Deserialize(tempFile); 1131 1099 Assert.AreEqual(lines.Count, newLines.Count); 1132 1100 for (int i = 0; i < lineBreaks.Count; i++) { … … 1139 1107 [TestProperty("Time", "short")] 1140 1108 public void TestSpecialNumbers() { 1109 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1141 1110 List<double> specials = new List<double>() { 1.0 / 0, -1.0 / 0, 0.0 / 0 }; 1142 1111 Assert.IsTrue(double.IsPositiveInfinity(specials[0])); 1143 1112 Assert.IsTrue(double.IsNegativeInfinity(specials[1])); 1144 1113 Assert.IsTrue(double.IsNaN(specials[2])); 1145 XmlGenerator.Serialize(specials, tempFile);1146 List<double> newSpecials = XmlParser.Deserialize<List<double>>(tempFile);1114 serializer.Serialize(specials, tempFile); 1115 List<double> newSpecials = (List<double>)serializer.Deserialize(tempFile); 1147 1116 Assert.IsTrue(double.IsPositiveInfinity(newSpecials[0])); 1148 1117 Assert.IsTrue(double.IsNegativeInfinity(newSpecials[1])); … … 1162 1131 } 1163 1132 1164 [TestMethod]1165 [TestCategory("Persistence")]1166 [TestProperty("Time", "medium")]1167 public void TestCompactNumberArraySerializer() {1168 System.Random r = new System.Random();1169 double[] a = new double[CompactNumberArray2StringSerializer.SPLIT_THRESHOLD * 2 + 1];1170 for (int i = 0; i < a.Length; i++)1171 a[i] = r.Next(10);1172 var config = ConfigurationService.Instance.GetDefaultConfig(new XmlFormat());1173 config = new Configuration(config.Format,1174 config.PrimitiveSerializers.Where(s => s.SourceType != typeof(double[])),1175 config.CompositeSerializers);1176 XmlGenerator.Serialize(a, tempFile, config);1177 double[] newA = XmlParser.Deserialize<double[]>(tempFile);1178 Assert.AreEqual(a.Length, newA.Length);1179 for (int i = 0; i < a.Rank; i++) {1180 Assert.AreEqual(a.GetLength(i), newA.GetLength(i));1181 Assert.AreEqual(a.GetLowerBound(i), newA.GetLowerBound(i));1182 }1183 for (int i = 0; i < a.Length; i++) {1184 Assert.AreEqual(a[i], newA[i]);1185 }1186 }1187 1133 private class IdentityComparer<T> : IEqualityComparer<T> { 1188 1134 … … 1200 1146 [TestProperty("Time", "short")] 1201 1147 public void TestHashSetSerializer() { 1148 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1202 1149 var hashSets = new List<HashSet<int>>() { 1203 1150 new HashSet<int>(new[] { 1, 2, 3 }), 1204 1151 new HashSet<int>(new[] { 4, 5, 6 }, new IdentityComparer<int>()), 1205 1152 }; 1206 XmlGenerator.Serialize(hashSets, tempFile);1207 var newHashSets = XmlParser.Deserialize<List<HashSet<int>>>(tempFile);1153 serializer.Serialize(hashSets, tempFile); 1154 var newHashSets = (List<HashSet<int>>)serializer.Deserialize(tempFile); 1208 1155 Assert.IsTrue(newHashSets[0].Contains(1)); 1209 1156 Assert.IsTrue(newHashSets[0].Contains(2)); … … 1220 1167 [TestProperty("Time", "short")] 1221 1168 public void TestConcreteDictionarySerializer() { 1169 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1222 1170 var dictionaries = new List<Dictionary<int, int>>() { 1223 1171 new Dictionary<int, int>(), … … 1230 1178 dictionaries[1].Add(5, 5); 1231 1179 dictionaries[1].Add(6, 6); 1232 XmlGenerator.Serialize(dictionaries, tempFile, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));1233 var newDictionaries = XmlParser.Deserialize<List<Dictionary<int, int>>>(tempFile);1180 serializer.Serialize(dictionaries, tempFile); 1181 var newDictionaries = (List<Dictionary<int, int>>)serializer.Deserialize(tempFile); 1234 1182 Assert.IsTrue(newDictionaries[0].ContainsKey(1)); 1235 1183 Assert.IsTrue(newDictionaries[0].ContainsKey(2)); … … 1248 1196 } 1249 1197 1250 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1198 [StorableClass("A9B0D7FB-0CAF-4DD7-9045-EA136F9176F7")] 1251 1199 public class ReadOnlyFail { 1252 1200 [Storable] … … 1260 1208 [TestProperty("Time", "short")] 1261 1209 public void TestReadOnlyFail() { 1210 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1262 1211 try { 1263 XmlGenerator.Serialize(new ReadOnlyFail(), tempFile);1212 serializer.Serialize(new ReadOnlyFail(), tempFile); 1264 1213 Assert.Fail("Exception expected"); 1265 1214 } … … 1272 1221 1273 1222 1274 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1223 [StorableClass("2C9CC576-6823-4784-817B-37C8AF0B1C29")] 1275 1224 public class WriteOnlyFail { 1276 1225 [Storable] … … 1284 1233 [TestProperty("Time", "short")] 1285 1234 public void TestWriteOnlyFail() { 1235 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1286 1236 try { 1287 XmlGenerator.Serialize(new WriteOnlyFail(), tempFile);1237 serializer.Serialize(new WriteOnlyFail(), tempFile); 1288 1238 Assert.Fail("Exception expected"); 1289 1239 } … … 1295 1245 } 1296 1246 1297 [StorableClass(" 3B2B27A5-3F0A-44ED-8672-0E89C9618026")]1247 [StorableClass("8052D9E3-6DDD-4AE1-9B5B-67C6D5436512")] 1298 1248 public class OneWayTest { 1299 1249 public OneWayTest() { this.value = "default"; } … … 1309 1259 } 1310 1260 1311 [TestMethod] 1312 [TestCategory("Persistence")] 1313 [TestProperty("Time", "short")] 1314 public void TestOneWaySerialization() { 1315 var test = new OneWayTest(); 1316 var serializer = new Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat())); 1317 var it = serializer.GetEnumerator(); 1318 it.MoveNext(); 1319 Assert.AreEqual("ROOT", ((BeginToken)it.Current).Name); it.MoveNext(); 1320 Assert.AreEqual("ReadOnly", ((PrimitiveToken)it.Current).Name); it.MoveNext(); 1321 Assert.AreEqual("ROOT", ((EndToken)it.Current).Name); it.MoveNext(); 1322 var deserializer = new Deserializer(new[] { 1323 new TypeMapping(0, typeof(OneWayTest).AssemblyQualifiedName, typeof(StorableSerializer).AssemblyQualifiedName), 1324 new TypeMapping(1, typeof(string).AssemblyQualifiedName, typeof(String2XmlSerializer).AssemblyQualifiedName) }); 1325 var newTest = (OneWayTest)deserializer.Deserialize(new ISerializationToken[] { 1326 new BeginToken("ROOT", 0, 0), 1327 new PrimitiveToken("WriteOnly", 1, 1, new XmlString("<![CDATA[serial data]]>")), 1328 new EndToken("ROOT", 0, 0) 1329 }); 1330 Assert.AreEqual("serial data", newTest.value); 1331 } 1332 1333 [TestMethod] 1334 [TestCategory("Persistence")] 1335 [TestProperty("Time", "short")] 1336 public void TestTypeCacheExport() { 1337 var test = new List<List<int>>(); 1338 test.Add(new List<int>() { 1, 2, 3 }); 1339 IEnumerable<Type> types; 1340 using (var stream = new MemoryStream()) { 1341 XmlGenerator.Serialize(test, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types); 1342 } 1343 List<Type> t = new List<Type>(types); 1344 // Assert.IsTrue(t.Contains(typeof(int))); not serialized as an int list is directly transformed into a string 1345 Assert.IsTrue(t.Contains(typeof(List<int>))); 1346 Assert.IsTrue(t.Contains(typeof(List<List<int>>))); 1347 Assert.AreEqual(t.Count, 2); 1348 } 1261 //TODO 1262 /* [TestMethod] 1263 [TestCategory("Persistence")] 1264 [TestProperty("Time", "short")] 1265 public void TestTypeCacheExport() { 1266 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1267 var test = new List<List<int>>(); 1268 test.Add(new List<int>() { 1, 2, 3 }); 1269 IEnumerable<Type> types; 1270 using (var stream = new MemoryStream()) { 1271 XmlGenerator.Serialize(test, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types); 1272 } 1273 List<Type> t = new List<Type>(types); 1274 // Assert.IsTrue(t.Contains(typeof(int))); not serialized as an int list is directly transformed into a string 1275 Assert.IsTrue(t.Contains(typeof(List<int>))); 1276 Assert.IsTrue(t.Contains(typeof(List<List<int>>))); 1277 Assert.AreEqual(t.Count, 2); 1278 }*/ 1349 1279 1350 1280 [TestMethod] … … 1366 1296 [TestProperty("Time", "short")] 1367 1297 public void FontTest() { 1298 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1368 1299 List<Font> fonts = new List<Font>() { 1369 1300 new Font(FontFamily.GenericSansSerif, 12), … … 1372 1303 new Font("Helvetica", 21, FontStyle.Strikeout, GraphicsUnit.Inch, 0, true), 1373 1304 }; 1374 XmlGenerator.Serialize(fonts, tempFile);1375 var newFonts = XmlParser.Deserialize<List<Font>>(tempFile);1305 serializer.Serialize(fonts, tempFile); 1306 var newFonts = (List<Font>)serializer.Deserialize(tempFile); 1376 1307 Assert.AreEqual(fonts[0], newFonts[0]); 1377 1308 Assert.AreEqual(fonts[1], newFonts[1]); … … 1384 1315 [TestProperty("Time", "medium")] 1385 1316 public void ConcurrencyTest() { 1317 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1386 1318 int n = 20; 1387 1319 Task[] tasks = new Task[n]; … … 1390 1322 byte[] data; 1391 1323 using (var stream = new MemoryStream()) { 1392 XmlGenerator.Serialize(new GeneticAlgorithm(), stream);1324 serializer.Serialize(new GeneticAlgorithm(), stream); 1393 1325 data = stream.ToArray(); 1394 1326 } … … 1402 1334 [TestProperty("Time", "medium")] 1403 1335 public void ConcurrentBitmapTest() { 1336 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1404 1337 Bitmap b = new Bitmap(300, 300); 1405 1338 System.Random r = new System.Random(); … … 1414 1347 tasks[i] = Task.Factory.StartNew((idx) => { 1415 1348 using (var stream = new MemoryStream()) { 1416 XmlGenerator.Serialize(b, stream);1349 serializer.Serialize(b, stream); 1417 1350 datas[(int)idx] = stream.ToArray(); 1418 1351 } … … 1427 1360 } 1428 1361 1429 [TestMethod]1430 [TestCategory("Persistence")]1431 [TestProperty("Time", "short")]1432 public void TestInternalClassOfGeneric() {1433 var s = new G<int, char>.S();1434 var typeName = s.GetType().AssemblyQualifiedName;1435 Assert.AreEqual(1436 "UseCases.G<Int32,Char>.S",1437 TypeNameParser.Parse(typeName).GetTypeNameInCode(false));1438 XmlGenerator.Serialize(s, tempFile);1439 var s1 = XmlParser.Deserialize(tempFile);1440 }1441 1442 [TestMethod]1443 [TestCategory("Persistence")]1444 [TestProperty("Time", "short")]1445 public void TestInternalClassOfGeneric2() {1446 var s = new G<int, float>.S2<int, char>();1447 var typeName = s.GetType().AssemblyQualifiedName;1448 Assert.AreEqual(1449 "UseCases.G<Int32,Single>.S2<Int32,Char>",1450 TypeNameParser.Parse(typeName).GetTypeNameInCode(false));1451 XmlGenerator.Serialize(s, tempFile);1452 var s1 = XmlParser.Deserialize(tempFile);1453 }1454 1362 1455 1363 [TestMethod] … … 1457 1365 [TestProperty("Time", "short")] 1458 1366 public void TestSpecialCharacters() { 1367 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1459 1368 var s = "abc" + "\x15" + "def"; 1460 XmlGenerator.Serialize(s, tempFile);1461 var newS = XmlParser.Deserialize(tempFile);1369 serializer.Serialize(s, tempFile); 1370 var newS = serializer.Deserialize(tempFile); 1462 1371 Assert.AreEqual(s, newS); 1463 1372 } … … 1467 1376 [TestProperty("Time", "short")] 1468 1377 public void TestByteArray() { 1378 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1469 1379 var b = new byte[3]; 1470 1380 b[0] = 0; 1471 1381 b[1] = 200; 1472 1382 b[2] = byte.MaxValue; 1473 XmlGenerator.Serialize(b, tempFile);1474 var newB = (byte[]) XmlParser.Deserialize(tempFile);1383 serializer.Serialize(b, tempFile); 1384 var newB = (byte[])serializer.Deserialize(tempFile); 1475 1385 CollectionAssert.AreEqual(b, newB); 1476 1386 } … … 1480 1390 [TestProperty("Time", "short")] 1481 1391 public void TestOptionalNumberEnumerable() { 1392 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1482 1393 var values = new List<double?> { 0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1 }; 1483 XmlGenerator.Serialize(values, tempFile);1484 var newValues = (List<double?>) XmlParser.Deserialize(tempFile);1394 serializer.Serialize(values, tempFile); 1395 var newValues = (List<double?>)serializer.Deserialize(tempFile); 1485 1396 CollectionAssert.AreEqual(values, newValues); 1486 1397 } … … 1490 1401 [TestProperty("Time", "short")] 1491 1402 public void TestOptionalDateTimeEnumerable() { 1403 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1492 1404 var values = new List<DateTime?> { DateTime.MinValue, null, DateTime.Now, DateTime.Now.Add(TimeSpan.FromDays(1)), 1493 1405 DateTime.ParseExact("10.09.2014 12:21", "dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture), DateTime.MaxValue}; 1494 XmlGenerator.Serialize(values, tempFile);1495 var newValues = (List<DateTime?>) XmlParser.Deserialize(tempFile);1406 serializer.Serialize(values, tempFile); 1407 var newValues = (List<DateTime?>)serializer.Deserialize(tempFile); 1496 1408 CollectionAssert.AreEqual(values, newValues); 1497 1409 } … … 1501 1413 [TestProperty("Time", "short")] 1502 1414 public void TestStringEnumerable() { 1415 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1503 1416 var values = new List<string> { "", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated" }; 1504 XmlGenerator.Serialize(values, tempFile);1505 var newValues = (List<String>) XmlParser.Deserialize(tempFile);1417 serializer.Serialize(values, tempFile); 1418 var newValues = (List<String>)serializer.Deserialize(tempFile); 1506 1419 CollectionAssert.AreEqual(values, newValues); 1507 1420 } … … 1511 1424 [TestProperty("Time", "short")] 1512 1425 public void TestUnicodeCharArray() { 1426 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1513 1427 var s = Encoding.UTF8.GetChars(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb }); 1514 XmlGenerator.Serialize(s, tempFile);1515 var newS = (char[]) XmlParser.Deserialize(tempFile);1428 serializer.Serialize(s, tempFile); 1429 var newS = (char[])serializer.Deserialize(tempFile); 1516 1430 CollectionAssert.AreEqual(s, newS); 1517 1431 } … … 1521 1435 [TestProperty("Time", "short")] 1522 1436 public void TestUnicode() { 1437 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1523 1438 var s = Encoding.UTF8.GetString(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb }); 1524 XmlGenerator.Serialize(s, tempFile);1525 var newS = XmlParser.Deserialize(tempFile);1439 serializer.Serialize(s, tempFile); 1440 var newS = serializer.Deserialize(tempFile); 1526 1441 Assert.AreEqual(s, newS); 1527 1442 } … … 1531 1446 [TestProperty("Time", "short")] 1532 1447 public void TestQueue() { 1448 ProtoBufSerializer serializer = new ProtoBufSerializer(); 1533 1449 var q = new Queue<int>(new[] { 1, 2, 3, 4, 0 }); 1534 XmlGenerator.Serialize(q, tempFile);1535 var newQ = (Queue<int>) XmlParser.Deserialize(tempFile);1450 serializer.Serialize(q, tempFile); 1451 var newQ = (Queue<int>)serializer.Deserialize(tempFile); 1536 1452 CollectionAssert.AreEqual(q, newQ); 1537 1453 } 1538 1539 1540 1541 [ClassInitialize] 1542 public static void Initialize(TestContext testContext) { 1543 ConfigurationService.Instance.Reset(); 1544 } 1454 #endregion 1545 1455 } 1546 1456 } -
branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r13266 r13386 257 257 <HintPath>..\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 258 258 <Private>False</Private> 259 </Reference> 260 <Reference Include="HeuristicLab.Persistence-4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 261 <SpecificVersion>False</SpecificVersion> 262 <HintPath>..\bin\HeuristicLab.Persistence-4.0.dll</HintPath> 259 263 </Reference> 260 264 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> … … 552 556 <Compile Include="HeuristicLab.Persistence-3.3\StorableAttributeTests.cs" /> 553 557 <Compile Include="HeuristicLab.Persistence-3.3\UseCases.cs" /> 558 <Compile Include="HeuristicLab.Persistence-3.3\UseCasesPersistenceNew.cs" /> 554 559 <Compile Include="HeuristicLab.PluginInfraStructure-3.3\InstallationManagerTest.cs" /> 555 560 <Compile Include="HeuristicLab.PluginInfraStructure-3.3\TypeExtensionsTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.