Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/24/15 18:24:01 (9 years ago)
Author:
ascheibe
Message:

#2520

  • fixed duplicate guids
  • adapted/added unit tests for new persistence
Location:
branches/PersistenceOverhaul
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PersistenceOverhaul/HeuristicLab.Clients.Hive/3.3/HiveTasks/HiveTask.cs

    r13368 r13386  
    541541
    542542  [Item("Hive Task", "Represents a hive task.")]
    543   [StorableClass("967DC1A1-7B0C-4D8B-AF9F-710B1FD676DF")]
     543  [StorableClass("04AD6AF8-8248-48FB-AF3A-403A2D22F725")]
    544544  public class HiveTask<T> : HiveTask where T : ItemTask {
    545545
  • branches/PersistenceOverhaul/HeuristicLab.Collections/3.3/BidirectionalLookup.cs

    r13368 r13386  
    2626
    2727namespace HeuristicLab.Collections {
    28   [StorableClass("066A8A8B-784D-45CC-9063-F2FC8E9A4442")]
     28  [StorableClass("0BF45891-847C-428B-9F2C-FD682320066C")]
    2929  [Serializable]
    3030  public class BidirectionalLookup<TFirst, TSecond> {
  • branches/PersistenceOverhaul/HeuristicLab.Core/3.3/Collections/DirectedGraph/Arc.cs

    r13368 r13386  
    2626namespace HeuristicLab.Core {
    2727  [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")]
    2929  public class Arc : Item, IArc {
    3030    [Storable]
  • branches/PersistenceOverhaul/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs

    r13368 r13386  
    2828namespace HeuristicLab.Core {
    2929  [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")]
    3131  public class Vertex : Item, IVertex {
    3232    [Storable]
  • branches/PersistenceOverhaul/HeuristicLab.Operators/3.3/StochasticMultiBranch.cs

    r13368 r13386  
    3535  /// </summary>
    3636  [Item("StochasticMultiBranch", "Selects one of its branches (if there are any) given a list of relative probabilities.")]
    37   [StorableClass("7DE99E47-6B7D-4AE3-A8B8-0D7C9B82F3EE")]
     37  [StorableClass("7FF6CB0B-F831-4A97-A8D3-40EBF6BE78B6")]
    3838  public abstract class StochasticMultiBranch<T> : CheckedMultiOperator<T> where T : class, IOperator {
    3939    /// <summary>
  • branches/PersistenceOverhaul/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r13368 r13386  
    235235
    236236    [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")]
    238238    [NonDiscoverableType]
    239239    private sealed class EmptyUserDefinedProblemEvaluator : ParameterizedNamedItem, ISingleObjectiveEvaluator {
  • branches/PersistenceOverhaul/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicNearestNeighbourClassificationModel.cs

    r13368 r13386  
    3232  /// Represents a nearest neighbour model for regression and classification
    3333  /// </summary>
    34   [StorableClass("01561669-12E6-4C75-86BF-88C24DA53FDD")]
     34  [StorableClass("225CCF16-C932-4D18-AF5A-0745FAD8F22C")]
    3535  [Item("SymbolicNearestNeighbourClassificationModel", "Represents a nearest neighbour model for symbolic classification.")]
    3636  public sealed class SymbolicNearestNeighbourClassificationModel : SymbolicClassificationModel {
  • branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/StorableAttributeTests.cs

    r13368 r13386  
    2424namespace HeuristicLab.Persistence.Tests {
    2525
    26   [StorableClass("2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]
     26  [StorableClass("E6CE21DC-FEA3-4763-BA60-CE8EB6B8E539")]
    2727  class DemoClass {
    2828
     
    3636  }
    3737
    38   [StorableClass("2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]
     38  [StorableClass("32FDC5F4-E5AD-4119-90E0-6D14785E87FD")]
    3939  class Base {
    4040    public string baseName;
     
    4646  }
    4747
    48   [StorableClass("2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]
     48  [StorableClass("F2151C9F-FD83-4D6F-B987-08DF723158DB")]
    4949  class Override : Base {
    5050    [Storable]
     
    5555  }
    5656
    57   [StorableClass("2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]
     57  [StorableClass("647B2E77-EC1E-458F-AB9D-ACFA8248352A")]
    5858  class Intermediate : Override {
    5959  }
    6060
    61   [StorableClass("2CD1E9C4-DDBA-458D-ADDA-5649A48AD564")]
     61  [StorableClass("AEAC61FF-896F-418C-82C8-33F0548AF3B2")]
    6262  class New : Intermediate {
    6363    public string newName;
  • branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs

    r13370 r13386  
    4646namespace HeuristicLab.Persistence.Tests {
    4747
    48   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     48  [StorableClass("777E5793-7389-4109-A617-D7D6EB74A2C7")]
    4949  public class NumberTest {
    5050    [Storable]
     
    9595  }
    9696
    97   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     97  [StorableClass("2911C342-74AB-4B47-9840-87F012AEF0C1")]
    9898  public class NonDefaultConstructorClass {
    9999    [Storable]
     
    104104  }
    105105
    106   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     106  [StorableClass("8621F4FA-8711-4DA4-A50B-7D04683440B8")]
    107107  public class IntWrapper {
    108108
     
    127127  }
    128128
    129   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     129  [StorableClass("0B93C65E-1A4C-45DD-B40D-7614BA2B2ABA")]
    130130  public class PrimitivesTest : NumberTest {
    131131    [Storable]
     
    159159  public enum TestEnum { va1, va2, va3, va8 } ;
    160160
    161   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     161  [StorableClass("0DA4A6A5-0280-4F3C-80DA-0AB09461F66C")]
    162162  public class RootBase {
    163163    [Storable]
     
    178178  }
    179179
    180   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     180  [StorableClass("12CC2626-A1E2-45A5-9761-902333C88CCF")]
    181181  public class Root : RootBase {
    182182    [Storable]
     
    213213  public enum TrickyEnum { zero = 0, one = 1, two = 2 }
    214214
    215   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     215  [StorableClass("04BFD8AF-AB93-457A-B5CD-F2AB2B18874F")]
    216216  public class EnumTest {
    217217    [Storable]
     
    223223  }
    224224
    225   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     225  [StorableClass("41E5C615-82A6-4844-B6A4-4DB8ED8C03D8")]
    226226  public class Custom {
    227227    [Storable]
     
    233233  }
    234234
    235   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     235  [StorableClass("3D2455E6-0AD9-4141-B44A-759F71491443")]
    236236  public class Manager {
    237237
     
    246246  }
    247247
    248   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     248  [StorableClass("D8D40F6E-91DC-4E20-8154-F95C0AF32CC8")]
    249249  public class C {
    250250    [Storable]
     
    486486    }
    487487
    488     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     488    [StorableClass("B2C78E8F-32F9-43BE-9DED-219F102125EB")]
    489489    public class NestedType {
    490490      [Storable]
     
    692692      l.Add(new NonSerializable());
    693693      try {
    694         Serializer s = new Serializer(l,
     694        HeuristicLab.Persistence.Core.Serializer s = new HeuristicLab.Persistence.Core.Serializer(l,
    695695          ConfigurationService.Instance.GetConfiguration(new XmlFormat()),
    696696          "ROOT", true);
     
    711711    public void TestAssemblyVersionCheck() {
    712712      IntWrapper i = new IntWrapper(1);
    713       Serializer s = new Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
     713      HeuristicLab.Persistence.Core.Serializer s = new HeuristicLab.Persistence.Core.Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    714714      XmlGenerator g = new XmlGenerator();
    715715      StringBuilder dataString = new StringBuilder();
     
    758758    }
    759759
    760     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     760    [StorableClass("2B2FE809-CDA4-4BCD-BF4C-35F757678AB9")]
    761761    class Child {
    762762      [Storable]
     
    764764    }
    765765
    766     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     766    [StorableClass("C8F4E805-26DF-4129-910E-F7F51E4DDE41")]
    767767    class Parent {
    768768      [Storable]
     
    770770    }
    771771
    772     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     772    [StorableClass("0CF63740-F8C1-46EE-A3A0-7E350A8EBAA1")]
    773773    class GrandParent {
    774774      [Storable]
     
    848848    }
    849849
    850     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     850    [StorableClass("F5920537-7F03-41C4-8061-8F8D7CDDB6BE")]
    851851    private class PersistenceHooks {
    852852      [Storable]
     
    885885    }
    886886
    887     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     887    [StorableClass("935C5ECB-ACEF-48EA-93BC-4B4177DFE0A5")]
    888888    private class CustomConstructor {
    889889      public string Value = "none";
     
    909909    }
    910910
    911     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     911    [StorableClass("31D7CE01-E390-40CF-B9BF-BD79A8F850DA")]
    912912    public class ExplodingDefaultConstructor {
    913913      public ExplodingDefaultConstructor() {
     
    961961    }
    962962
    963     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     963    [StorableClass("9DEE1F8F-320C-401B-8103-65FBA6BD4F07")]
    964964    public class HookInheritanceTestBase {
    965965      [Storable]
     
    972972    }
    973973
    974     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     974    [StorableClass("97DF2931-2B23-4FAA-8E59-806FA58ADAED")]
    975975    public class HookInheritanceTestDerivedClass : HookInheritanceTestBase {
    976976      [Storable]
     
    994994    }
    995995
    996     [StorableClass(StorableClassType.AllFields, "B9AB42E8-1932-425B-B4CF-F31F07EAC599")]
     996    [StorableClass(StorableClassType.AllFields, "6207E4E1-4CFC-4890-9741-33B7E1E43F26")]
    997997    public class AllFieldsStorable {
    998998      public int Value1 = 1;
     
    10251025    }
    10261026
    1027     [StorableClass(StorableClassType.AllProperties, "CB7DC31C-AEF3-4EB8-91CA-248B767E9F92")]
     1027    [StorableClass(StorableClassType.AllProperties, "ADDB5A7C-4BA9-4E5F-BFAF-2B48C8646808")]
    10281028    public class AllPropertiesStorable {
    10291029      public int Value1 = 1;
     
    10571057    }
    10581058
    1059     [StorableClass(StorableClassType.AllFieldsAndAllProperties, "0AD8D68F-E0FF-4FA8-8A72-1148CD91A2B9")]
     1059    [StorableClass(StorableClassType.AllFieldsAndAllProperties, "9C6136CB-A9AC-4527-B41A-7A2DB50ACE53")]
    10601060    public class AllFieldsAndAllPropertiesStorable {
    10611061      public int Value1 = 1;
     
    10881088    }
    10891089
    1090     [StorableClass(StorableClassType.MarkedOnly, "0D94E6D4-64E3-4637-B1EE-DEF2B3F6E2E0")]
     1090    [StorableClass(StorableClassType.MarkedOnly, "75C9F6F0-1B2E-41E7-A327-AF9CF5C87D8D")]
    10911091    public class MarkedOnlyStorable {
    10921092      public int Value1 = 1;
     
    12481248    }
    12491249
    1250     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1250    [StorableClass("A603ABE6-86DB-46F7-AF87-C7B40E4FF169")]
    12511251    public class ReadOnlyFail {
    12521252      [Storable]
     
    12721272
    12731273
    1274     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1274    [StorableClass("7EDE1D86-C8F5-4B51-846F-1634C0FE20BB")]
    12751275    public class WriteOnlyFail {
    12761276      [Storable]
     
    12951295    }
    12961296
    1297     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1297    [StorableClass("65B13830-5D60-4C3F-8D9E-5DCDF1E3A977")]
    12981298    public class OneWayTest {
    12991299      public OneWayTest() { this.value = "default"; }
     
    13141314    public void TestOneWaySerialization() {
    13151315      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()));
    13171317      var it = serializer.GetEnumerator();
    13181318      it.MoveNext();
  • branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCasesPersistenceNew.cs

    r13370 r13386  
    2929using System.Reflection;
    3030using System.Text;
    31 using System.Text.RegularExpressions;
    3231using System.Threading.Tasks;
    3332using HeuristicLab.Algorithms.GeneticAlgorithm;
     33using HeuristicLab.Persistence;
    3434using HeuristicLab.Persistence.Auxiliary;
    3535using HeuristicLab.Persistence.Core;
    36 using HeuristicLab.Persistence.Core.Tokens;
    37 using HeuristicLab.Persistence.Default.CompositeSerializers;
    3836using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3937using HeuristicLab.Persistence.Default.DebugString;
    4038using HeuristicLab.Persistence.Default.Xml;
    41 using HeuristicLab.Persistence.Default.Xml.Primitive;
    42 using HeuristicLab.Persistence.Interfaces;
     39using HeuristicLab.Persistence.Tests;
    4340using HeuristicLab.Tests;
    4441using Microsoft.VisualStudio.TestTools.UnitTesting;
    4542
    46 namespace HeuristicLab.Persistence.Tests {
    47 
    48   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     43namespace HeuristicLab.PersistenceNew.Tests {
     44  #region Test Classes
     45  [StorableClass("7D9672BD-703D-42BB-9080-9929885D4580")]
    4946  public class NumberTest {
    5047    [Storable]
     
    9592  }
    9693
    97   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     94  [StorableClass("EEB19599-D5AC-48ED-A56B-CF213DFAF2E4")]
    9895  public class NonDefaultConstructorClass {
    9996    [Storable]
     
    104101  }
    105102
    106   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     103  [StorableClass("EE43FE7A-6D07-4D52-9338-C21B3485F82A")]
    107104  public class IntWrapper {
    108105
     
    127124  }
    128125
    129   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     126  [StorableClass("00A8E48E-8E8A-443C-A327-9F6ACCBE7E80")]
    130127  public class PrimitivesTest : NumberTest {
    131128    [Storable]
     
    159156  public enum TestEnum { va1, va2, va3, va8 } ;
    160157
    161   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     158  [StorableClass("26BA37F6-926D-4665-A10A-1F39E1CF6468")]
    162159  public class RootBase {
    163160    [Storable]
     
    178175  }
    179176
    180   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     177  [StorableClass("F6BCB436-B5F2-40F6-8E2F-7A018CD1CBA0")]
    181178  public class Root : RootBase {
    182179    [Storable]
     
    213210  public enum TrickyEnum { zero = 0, one = 1, two = 2 }
    214211
    215   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     212  [StorableClass("2F6326ED-023A-415F-B5C7-9F9241940D05")]
    216213  public class EnumTest {
    217214    [Storable]
     
    223220  }
    224221
    225   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     222  [StorableClass("92365E2A-1184-4280-B763-4853C7ADF3E3")]
    226223  public class Custom {
    227224    [Storable]
     
    233230  }
    234231
    235   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     232  [StorableClass("7CF19EBC-1EC4-4FBE-BCA9-DA48E3CFE30D")]
    236233  public class Manager {
    237234
     
    246243  }
    247244
    248   [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     245  [StorableClass("9092C705-F5E9-4BA9-9750-4357DB29AABF")]
    249246  public class C {
    250247    [Storable]
     
    267264  }
    268265
     266  #endregion
    269267
    270268  [TestClass]
    271   public class UseCases {
    272 
     269  public class UseCasesPersistenceNew {
     270    #region Helpers
    273271    private string tempFile;
     272
     273    [ClassInitialize]
     274    public static void Initialize(TestContext testContext) {
     275      ConfigurationService.Instance.Reset();
     276    }
    274277
    275278    [TestInitialize()]
     
    285288      File.Delete(tempFile);
    286289    }
    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
    288320    [TestMethod]
    289321    [TestCategory("Persistence")]
    290322    [TestProperty("Time", "short")]
    291323    public void ComplexStorable() {
     324      ProtoBufSerializer serializer = new ProtoBufSerializer();
    292325      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);
    295328      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       }
    308329    }
    309330
     
    391412    [TestProperty("Time", "short")]
    392413    public void SelfReferences() {
     414      ProtoBufSerializer serializer = new ProtoBufSerializer();
    393415      C c = new C();
    394416      C[][] cs = new C[2][];
     
    397419      c.allCs = cs;
    398420      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);
    401423      Assert.AreEqual(
    402424        DebugStringGenerator.Serialize(cs),
     
    418440    [TestProperty("Time", "short")]
    419441    public void ArrayCreation() {
     442      ProtoBufSerializer serializer = new ProtoBufSerializer();
    420443      ArrayList[] arrayListArray = new ArrayList[4];
    421444      arrayListArray[0] = new ArrayList();
     
    431454                              new[] { 1, 2 }, new[] { 3, 4 });
    432455      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);
    435458      Assert.AreEqual(
    436459        DebugStringGenerator.Serialize(arrayListArray),
     
    447470    [TestProperty("Time", "short")]
    448471    public void CustomSerializationProperty() {
     472      ProtoBufSerializer serializer = new ProtoBufSerializer();
    449473      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);
    452476      Assert.AreNotEqual(
    453477        DebugStringGenerator.Serialize(m),
     
    463487    [TestProperty("Time", "short")]
    464488    public void Primitives() {
     489      ProtoBufSerializer serializer = new ProtoBufSerializer();
    465490      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);
    468493      Assert.AreEqual(
    469494        DebugStringGenerator.Serialize(sdt),
     
    475500    [TestProperty("Time", "short")]
    476501    public void MultiDimensionalArray() {
     502      ProtoBufSerializer serializer = new ProtoBufSerializer();
    477503      string[,] mDimString = new string[,] {
    478504        {"ora", "et", "labora"},
    479505        {"Beten", "und", "Arbeiten"}
    480506      };
    481       XmlGenerator.Serialize(mDimString, tempFile);
    482       object o = XmlParser.Deserialize(tempFile);
     507      serializer.Serialize(mDimString, tempFile);
     508      object o = serializer.Deserialize(tempFile);
    483509      Assert.AreEqual(
    484510        DebugStringGenerator.Serialize(mDimString),
     
    486512    }
    487513
    488     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     514    [StorableClass("87A331AF-14DC-48B3-B577-D49065743BE6")]
    489515    public class NestedType {
    490516      [Storable]
     
    505531    [TestProperty("Time", "short")]
    506532    public void NestedTypeTest() {
     533      ProtoBufSerializer serializer = new ProtoBufSerializer();
    507534      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);
    510537      Assert.AreEqual(
    511538        DebugStringGenerator.Serialize(t),
     
    519546    [TestProperty("Time", "short")]
    520547    public void SimpleArray() {
     548      ProtoBufSerializer serializer = new ProtoBufSerializer();
    521549      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);
    524552      Assert.AreEqual(
    525553        DebugStringGenerator.Serialize(strings),
     
    531559    [TestProperty("Time", "short")]
    532560    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);
    535564      Assert.AreEqual(
    536565        DebugStringGenerator.Serialize(12.3f),
     
    584613    [TestCategory("Persistence")]
    585614    [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")]
    604615    public void Enums() {
     616      ProtoBufSerializer serializer = new ProtoBufSerializer();
    605617      EnumTest et = new EnumTest();
    606618      et.simpleEnum = SimpleEnum.two;
    607619      et.complexEnum = ComplexEnum.three;
    608620      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);
    611623      Assert.AreEqual(et.simpleEnum, SimpleEnum.two);
    612624      Assert.AreEqual(et.complexEnum, ComplexEnum.three);
     
    618630    [TestProperty("Time", "short")]
    619631    public void TestAliasingWithOverriddenEquals() {
     632      ProtoBufSerializer serializer = new ProtoBufSerializer();
    620633      List<IntWrapper> ints = new List<IntWrapper>();
    621634      ints.Add(new IntWrapper(1));
     
    623636      Assert.AreEqual(ints[0], ints[1]);
    624637      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);
    627640      Assert.AreEqual(newInts[0].Value, 1);
    628641      Assert.AreEqual(newInts[1].Value, 1);
     
    635648    [TestProperty("Time", "short")]
    636649    public void NonDefaultConstructorTest() {
     650      ProtoBufSerializer serializer = new ProtoBufSerializer();
    637651      NonDefaultConstructorClass c = new NonDefaultConstructorClass(1);
    638652      try {
    639         XmlGenerator.Serialize(c, tempFile);
     653        serializer.Serialize(c, tempFile);
    640654        Assert.Fail("Exception not thrown");
    641655      }
     
    648662    [TestProperty("Time", "short")]
    649663    public void TestSavingException() {
     664      ProtoBufSerializer serializer = new ProtoBufSerializer();
    650665      List<int> list = new List<int> { 1, 2, 3 };
    651       XmlGenerator.Serialize(list, tempFile);
     666      serializer.Serialize(list, tempFile);
    652667      NonSerializable s = new NonSerializable();
    653668      try {
    654         XmlGenerator.Serialize(s, tempFile);
     669        serializer.Serialize(s, tempFile);
    655670        Assert.Fail("Exception expected");
    656671      }
    657672      catch (PersistenceException) { }
    658       List<int> newList = (List<int>)XmlParser.Deserialize(tempFile);
     673      List<int> newList = (List<int>)serializer.Deserialize(tempFile);
    659674      Assert.AreEqual(list[0], newList[0]);
    660675      Assert.AreEqual(list[1], newList[1]);
     
    686701    [TestCategory("Persistence")]
    687702    [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")]
    752703    public void InheritanceTest() {
     704      ProtoBufSerializer serializer = new ProtoBufSerializer();
    753705      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);
    756708      Assert.AreEqual(n.Name, nn.Name);
    757709      Assert.AreEqual(((Override)n).Name, ((Override)nn).Name);
    758710    }
    759711
    760     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     712    [StorableClass("B963EF51-12B4-432E-8C54-88F026F9ACE2")]
    761713    class Child {
    762714      [Storable]
     
    764716    }
    765717
    766     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     718    [StorableClass("E66E9606-967A-4C35-A361-F6F0D21C064A")]
    767719    class Parent {
    768720      [Storable]
     
    770722    }
    771723
    772     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     724    [StorableClass("34D3893A-57AD-4F72-878B-81D6FA3F14A9")]
    773725    class GrandParent {
    774726      [Storable]
     
    780732    [TestProperty("Time", "short")]
    781733    public void InstantiateParentChainReference() {
     734      ProtoBufSerializer serializer = new ProtoBufSerializer();
    782735      GrandParent gp = new GrandParent();
    783736      gp.parent = new Parent();
     
    785738      gp.parent.child.grandParent = gp;
    786739      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);
    789742      Assert.AreSame(newGp, newGp.parent.child.grandParent);
    790743    }
     
    804757    [TestProperty("Time", "short")]
    805758    public void StructTest() {
     759      ProtoBufSerializer serializer = new ProtoBufSerializer();
    806760      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);
    809763      Assert.AreEqual(s, newS);
    810764    }
     
    814768    [TestProperty("Time", "short")]
    815769    public void PointTest() {
     770      ProtoBufSerializer serializer = new ProtoBufSerializer();
    816771      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);
    819774      Assert.AreEqual(p, newP);
    820775    }
     
    824779    [TestProperty("Time", "short")]
    825780    public void NullableValueTypes() {
     781      ProtoBufSerializer serializer = new ProtoBufSerializer();
    826782      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);
    829785      Assert.AreEqual(d[0], newD[0]);
    830786      Assert.AreEqual(d[1], newD[1]);
     
    837793    [TestProperty("Time", "short")]
    838794    public void BitmapTest() {
     795      ProtoBufSerializer serializer = new ProtoBufSerializer();
    839796      Icon icon = System.Drawing.SystemIcons.Hand;
    840797      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);
    843800
    844801      Assert.AreEqual(bitmap.Size, newBitmap.Size);
     
    848805    }
    849806
    850     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     807    [StorableClass("E846BC49-20F3-4D3F-A3F3-73D4F2DB1C2E")]
    851808    private class PersistenceHooks {
    852809      [Storable]
     
    870827    [TestProperty("Time", "short")]
    871828    public void HookTest() {
     829      ProtoBufSerializer serializer = new ProtoBufSerializer();
    872830      PersistenceHooks hookTest = new PersistenceHooks();
    873831      hookTest.a = 2;
     
    875833      Assert.IsFalse(hookTest.WasSerialized);
    876834      Assert.AreEqual(hookTest.sum, 0);
    877       XmlGenerator.Serialize(hookTest, tempFile);
     835      serializer.Serialize(hookTest, tempFile);
    878836      Assert.IsTrue(hookTest.WasSerialized);
    879837      Assert.AreEqual(hookTest.sum, 0);
    880       PersistenceHooks newHookTest = (PersistenceHooks)XmlParser.Deserialize(tempFile);
     838      PersistenceHooks newHookTest = (PersistenceHooks)serializer.Deserialize(tempFile);
    881839      Assert.AreEqual(newHookTest.a, hookTest.a);
    882840      Assert.AreEqual(newHookTest.b, hookTest.b);
     
    885843    }
    886844
    887     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     845    [StorableClass("A35D71DF-397F-4910-A950-ED6923BE9483")]
    888846    private class CustomConstructor {
    889847      public string Value = "none";
     
    902860    [TestProperty("Time", "short")]
    903861    public void TestCustomConstructor() {
     862      ProtoBufSerializer serializer = new ProtoBufSerializer();
    904863      CustomConstructor cc = new CustomConstructor();
    905864      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);
    908867      Assert.AreEqual(newCC.Value, "persistence");
    909868    }
    910869
    911     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     870    [StorableClass("D276E825-1F35-4BAC-8937-9ABC91D5C316")]
    912871    public class ExplodingDefaultConstructor {
    913872      public ExplodingDefaultConstructor() {
     
    922881    [TestProperty("Time", "short")]
    923882    public void TestConstructorExceptionUnwrapping() {
     883      ProtoBufSerializer serializer = new ProtoBufSerializer();
    924884      ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password");
    925       XmlGenerator.Serialize(x, tempFile);
     885      serializer.Serialize(x, tempFile);
    926886      try {
    927         ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile);
     887        ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)serializer.Deserialize(tempFile);
    928888        Assert.Fail("Exception expected");
    929889      }
     
    937897    [TestProperty("Time", "short")]
    938898    public void TestRejectionJustifications() {
     899      ProtoBufSerializer serializer = new ProtoBufSerializer();
    939900      NonSerializable ns = new NonSerializable();
    940901      try {
    941         XmlGenerator.Serialize(ns, tempFile);
     902        serializer.Serialize(ns, tempFile);
    942903        Assert.Fail("PersistenceException expected");
    943904      }
     
    951912    [TestProperty("Time", "short")]
    952913    public void TestStreaming() {
     914      ProtoBufSerializer serializer = new ProtoBufSerializer();
    953915      using (MemoryStream stream = new MemoryStream()) {
    954916        Root r = InitializeComplexStorable();
    955         XmlGenerator.Serialize(r, stream);
     917        serializer.Serialize(r, stream);
    956918        using (MemoryStream stream2 = new MemoryStream(stream.ToArray())) {
    957           Root newR = (Root)XmlParser.Deserialize(stream2);
     919          Root newR = (Root)serializer.Deserialize(stream2);
    958920          CompareComplexStorables(r, newR);
    959921        }
     
    961923    }
    962924
    963     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     925    [StorableClass("4921031B-CB61-4677-97AD-9236A4CEC200")]
    964926    public class HookInheritanceTestBase {
    965927      [Storable]
     
    972934    }
    973935
    974     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     936    [StorableClass("321CEE0A-5201-4CE2-B135-2343890D96BF")]
    975937    public class HookInheritanceTestDerivedClass : HookInheritanceTestBase {
    976938      [Storable]
     
    987949    [TestProperty("Time", "short")]
    988950    public void TestLinkInheritance() {
     951      ProtoBufSerializer serializer = new ProtoBufSerializer();
    989952      HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass();
    990953      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);
    993956      Assert.AreSame(c.b, c.link);
    994957    }
     
    1016979    [TestProperty("Time", "short")]
    1017980    public void TestStorableClassDiscoveryAllFields() {
     981      ProtoBufSerializer serializer = new ProtoBufSerializer();
    1018982      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);
    1021985      Assert.AreEqual(afs.Value1, newAfs.Value1);
    1022986      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    10471011    [TestProperty("Time", "short")]
    10481012    public void TestStorableClassDiscoveryAllProperties() {
     1013      ProtoBufSerializer serializer = new ProtoBufSerializer();
    10491014      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);
    10521017      Assert.AreEqual(1, newAfs.Value1);
    10531018      Assert.AreEqual(2, newAfs.Value2);
     
    10791044    [TestProperty("Time", "short")]
    10801045    public void TestStorableClassDiscoveryAllFieldsAndAllProperties() {
     1046      ProtoBufSerializer serializer = new ProtoBufSerializer();
    10811047      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);
    10841050      Assert.AreEqual(afs.Value1, newAfs.Value1);
    10851051      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    11101076    [TestProperty("Time", "short")]
    11111077    public void TestStorableClassDiscoveryMarkedOnly() {
     1078      ProtoBufSerializer serializer = new ProtoBufSerializer();
    11121079      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);
    11151082      Assert.AreEqual(1, newAfs.Value1);
    11161083      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    11231090    [TestProperty("Time", "short")]
    11241091    public void TestLineEndings() {
     1092      ProtoBufSerializer serializer = new ProtoBufSerializer();
    11251093      List<string> lineBreaks = new List<string> { "\r\n", "\n", "\r", "\n\r", Environment.NewLine };
    11261094      List<string> lines = new List<string>();
    11271095      foreach (var br in lineBreaks)
    11281096        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);
    11311099      Assert.AreEqual(lines.Count, newLines.Count);
    11321100      for (int i = 0; i < lineBreaks.Count; i++) {
     
    11391107    [TestProperty("Time", "short")]
    11401108    public void TestSpecialNumbers() {
     1109      ProtoBufSerializer serializer = new ProtoBufSerializer();
    11411110      List<double> specials = new List<double>() { 1.0 / 0, -1.0 / 0, 0.0 / 0 };
    11421111      Assert.IsTrue(double.IsPositiveInfinity(specials[0]));
    11431112      Assert.IsTrue(double.IsNegativeInfinity(specials[1]));
    11441113      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);
    11471116      Assert.IsTrue(double.IsPositiveInfinity(newSpecials[0]));
    11481117      Assert.IsTrue(double.IsNegativeInfinity(newSpecials[1]));
     
    11621131    }
    11631132
    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     }
    11871133    private class IdentityComparer<T> : IEqualityComparer<T> {
    11881134
     
    12001146    [TestProperty("Time", "short")]
    12011147    public void TestHashSetSerializer() {
     1148      ProtoBufSerializer serializer = new ProtoBufSerializer();
    12021149      var hashSets = new List<HashSet<int>>() {
    12031150        new HashSet<int>(new[] { 1, 2, 3 }),
    12041151        new HashSet<int>(new[] { 4, 5, 6 }, new IdentityComparer<int>()),
    12051152      };
    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);
    12081155      Assert.IsTrue(newHashSets[0].Contains(1));
    12091156      Assert.IsTrue(newHashSets[0].Contains(2));
     
    12201167    [TestProperty("Time", "short")]
    12211168    public void TestConcreteDictionarySerializer() {
     1169      ProtoBufSerializer serializer = new ProtoBufSerializer();
    12221170      var dictionaries = new List<Dictionary<int, int>>() {
    12231171        new Dictionary<int, int>(),
     
    12301178      dictionaries[1].Add(5, 5);
    12311179      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);
    12341182      Assert.IsTrue(newDictionaries[0].ContainsKey(1));
    12351183      Assert.IsTrue(newDictionaries[0].ContainsKey(2));
     
    12481196    }
    12491197
    1250     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1198    [StorableClass("A9B0D7FB-0CAF-4DD7-9045-EA136F9176F7")]
    12511199    public class ReadOnlyFail {
    12521200      [Storable]
     
    12601208    [TestProperty("Time", "short")]
    12611209    public void TestReadOnlyFail() {
     1210      ProtoBufSerializer serializer = new ProtoBufSerializer();
    12621211      try {
    1263         XmlGenerator.Serialize(new ReadOnlyFail(), tempFile);
     1212        serializer.Serialize(new ReadOnlyFail(), tempFile);
    12641213        Assert.Fail("Exception expected");
    12651214      }
     
    12721221
    12731222
    1274     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1223    [StorableClass("2C9CC576-6823-4784-817B-37C8AF0B1C29")]
    12751224    public class WriteOnlyFail {
    12761225      [Storable]
     
    12841233    [TestProperty("Time", "short")]
    12851234    public void TestWriteOnlyFail() {
     1235      ProtoBufSerializer serializer = new ProtoBufSerializer();
    12861236      try {
    1287         XmlGenerator.Serialize(new WriteOnlyFail(), tempFile);
     1237        serializer.Serialize(new WriteOnlyFail(), tempFile);
    12881238        Assert.Fail("Exception expected");
    12891239      }
     
    12951245    }
    12961246
    1297     [StorableClass("3B2B27A5-3F0A-44ED-8672-0E89C9618026")]
     1247    [StorableClass("8052D9E3-6DDD-4AE1-9B5B-67C6D5436512")]
    12981248    public class OneWayTest {
    12991249      public OneWayTest() { this.value = "default"; }
     
    13091259    }
    13101260
    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     }*/
    13491279
    13501280    [TestMethod]
     
    13661296    [TestProperty("Time", "short")]
    13671297    public void FontTest() {
     1298      ProtoBufSerializer serializer = new ProtoBufSerializer();
    13681299      List<Font> fonts = new List<Font>() {
    13691300        new Font(FontFamily.GenericSansSerif, 12),
     
    13721303        new Font("Helvetica", 21, FontStyle.Strikeout, GraphicsUnit.Inch, 0, true),
    13731304      };
    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);
    13761307      Assert.AreEqual(fonts[0], newFonts[0]);
    13771308      Assert.AreEqual(fonts[1], newFonts[1]);
     
    13841315    [TestProperty("Time", "medium")]
    13851316    public void ConcurrencyTest() {
     1317      ProtoBufSerializer serializer = new ProtoBufSerializer();
    13861318      int n = 20;
    13871319      Task[] tasks = new Task[n];
     
    13901322          byte[] data;
    13911323          using (var stream = new MemoryStream()) {
    1392             XmlGenerator.Serialize(new GeneticAlgorithm(), stream);
     1324            serializer.Serialize(new GeneticAlgorithm(), stream);
    13931325            data = stream.ToArray();
    13941326          }
     
    14021334    [TestProperty("Time", "medium")]
    14031335    public void ConcurrentBitmapTest() {
     1336      ProtoBufSerializer serializer = new ProtoBufSerializer();
    14041337      Bitmap b = new Bitmap(300, 300);
    14051338      System.Random r = new System.Random();
     
    14141347        tasks[i] = Task.Factory.StartNew((idx) => {
    14151348          using (var stream = new MemoryStream()) {
    1416             XmlGenerator.Serialize(b, stream);
     1349            serializer.Serialize(b, stream);
    14171350            datas[(int)idx] = stream.ToArray();
    14181351          }
     
    14271360    }
    14281361
    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     }
    14541362
    14551363    [TestMethod]
     
    14571365    [TestProperty("Time", "short")]
    14581366    public void TestSpecialCharacters() {
     1367      ProtoBufSerializer serializer = new ProtoBufSerializer();
    14591368      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);
    14621371      Assert.AreEqual(s, newS);
    14631372    }
     
    14671376    [TestProperty("Time", "short")]
    14681377    public void TestByteArray() {
     1378      ProtoBufSerializer serializer = new ProtoBufSerializer();
    14691379      var b = new byte[3];
    14701380      b[0] = 0;
    14711381      b[1] = 200;
    14721382      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);
    14751385      CollectionAssert.AreEqual(b, newB);
    14761386    }
     
    14801390    [TestProperty("Time", "short")]
    14811391    public void TestOptionalNumberEnumerable() {
     1392      ProtoBufSerializer serializer = new ProtoBufSerializer();
    14821393      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);
    14851396      CollectionAssert.AreEqual(values, newValues);
    14861397    }
     
    14901401    [TestProperty("Time", "short")]
    14911402    public void TestOptionalDateTimeEnumerable() {
     1403      ProtoBufSerializer serializer = new ProtoBufSerializer();
    14921404      var values = new List<DateTime?> { DateTime.MinValue, null, DateTime.Now, DateTime.Now.Add(TimeSpan.FromDays(1)),
    14931405        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);
    14961408      CollectionAssert.AreEqual(values, newValues);
    14971409    }
     
    15011413    [TestProperty("Time", "short")]
    15021414    public void TestStringEnumerable() {
     1415      ProtoBufSerializer serializer = new ProtoBufSerializer();
    15031416      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);
    15061419      CollectionAssert.AreEqual(values, newValues);
    15071420    }
     
    15111424    [TestProperty("Time", "short")]
    15121425    public void TestUnicodeCharArray() {
     1426      ProtoBufSerializer serializer = new ProtoBufSerializer();
    15131427      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);
    15161430      CollectionAssert.AreEqual(s, newS);
    15171431    }
     
    15211435    [TestProperty("Time", "short")]
    15221436    public void TestUnicode() {
     1437      ProtoBufSerializer serializer = new ProtoBufSerializer();
    15231438      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);
    15261441      Assert.AreEqual(s, newS);
    15271442    }
     
    15311446    [TestProperty("Time", "short")]
    15321447    public void TestQueue() {
     1448      ProtoBufSerializer serializer = new ProtoBufSerializer();
    15331449      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);
    15361452      CollectionAssert.AreEqual(q, newQ);
    15371453    }
    1538 
    1539 
    1540 
    1541     [ClassInitialize]
    1542     public static void Initialize(TestContext testContext) {
    1543       ConfigurationService.Instance.Reset();
    1544     }
     1454    #endregion
    15451455  }
    15461456}
  • branches/PersistenceOverhaul/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r13266 r13386  
    257257      <HintPath>..\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
    258258      <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>
    259263    </Reference>
    260264    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
     
    552556    <Compile Include="HeuristicLab.Persistence-3.3\StorableAttributeTests.cs" />
    553557    <Compile Include="HeuristicLab.Persistence-3.3\UseCases.cs" />
     558    <Compile Include="HeuristicLab.Persistence-3.3\UseCasesPersistenceNew.cs" />
    554559    <Compile Include="HeuristicLab.PluginInfraStructure-3.3\InstallationManagerTest.cs" />
    555560    <Compile Include="HeuristicLab.PluginInfraStructure-3.3\TypeExtensionsTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.