Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2937 for branches


Ignore:
Timestamp:
03/05/10 13:53:54 (15 years ago)
Author:
epitzer
Message:

Add support for serialization of structs (#802)

Location:
branches/Persistence Test/HeuristicLab.Persistence
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Persistence Test/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r1958 r2937  
    117117    <Compile Include="Default\CompositeSerializers\Storable\StorableAttribute.cs" />
    118118    <Compile Include="Default\CompositeSerializers\Storable\StorableSerializer.cs" />
     119    <Compile Include="Default\CompositeSerializers\StructSerializer.cs" />
    119120    <Compile Include="Default\CompositeSerializers\TypeSerializer.cs" />
    120121    <Compile Include="Default\DebugString\DebugString.cs" />
  • branches/Persistence Test/HeuristicLab.Persistence/UnitTests/HeuristicLab.Persistence.UnitTest.csproj

    r1614 r2937  
    6969      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    7070    </Reference>
     71    <Reference Include="System.Drawing" />
    7172  </ItemGroup>
    7273  <ItemGroup>
  • branches/Persistence Test/HeuristicLab.Persistence/UnitTests/UseCases.cs

    r2858 r2937  
    1717using System.Text.RegularExpressions;
    1818using HeuristicLab.Persistence.Test;
     19using System.Drawing;
    1920
    2021namespace HeuristicLab.Persistence.UnitTest {
     
    581582    }
    582583
     584    struct TestStruct {
     585      int value;
     586      int PropertyValue { get; set; }
     587      public TestStruct(int value) : this() {
     588        this.value = value;
     589        PropertyValue = value;
     590      }     
     591    }
     592
     593    [TestMethod]
     594    public void StructTest() {
     595      TestStruct s = new TestStruct(10);
     596      XmlGenerator.Serialize(s, tempFile);
     597      TestStruct newS = (TestStruct)XmlParser.Deserialize(tempFile);
     598      Assert.AreEqual(s, newS);
     599    }
     600   
     601    [TestMethod]
     602    public void PointTest() {
     603      Point p = new Point(12, 34);
     604      XmlGenerator.Serialize(p, tempFile);
     605      Point newP = (Point)XmlParser.Deserialize(tempFile);
     606      Assert.AreEqual(p, newP);
     607    }
     608
     609    [TestMethod]
     610    public void NullableValueTypes() {
     611      double?[] d = new double?[] { null, 1, 2, 3 };     
     612      XmlGenerator.Serialize(d, tempFile);
     613      double?[] newD = (double?[])XmlParser.Deserialize(tempFile);
     614      Assert.AreEqual(d[0], newD[0]);
     615      Assert.AreEqual(d[1], newD[1]);
     616      Assert.AreEqual(d[2], newD[2]);
     617      Assert.AreEqual(d[3], newD[3]);
     618    }
     619
    583620    [ClassInitialize]
    584621    public static void Initialize(TestContext testContext) {
Note: See TracChangeset for help on using the changeset viewer.