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

Add support for serialization of structs (#802)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.