Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/10 14:08:55 (14 years ago)
Author:
epitzer
Message:

Add support for serialization of structs (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/UnitTests/UseCases.cs

    r2873 r2939  
    1717using System.Text.RegularExpressions;
    1818using HeuristicLab.Persistence.Test;
     19using System.Drawing;
    1920
    2021namespace HeuristicLab.Persistence.UnitTest {
     
    608609    }
    609610
     611    struct TestStruct {
     612      int value;
     613      int PropertyValue { get; set; }
     614      public TestStruct(int value)
     615        : this() {
     616        this.value = value;
     617        PropertyValue = value;
     618      }
     619    }
     620
     621    [TestMethod]
     622    public void StructTest() {
     623      TestStruct s = new TestStruct(10);
     624      XmlGenerator.Serialize(s, tempFile);
     625      TestStruct newS = (TestStruct)XmlParser.Deserialize(tempFile);
     626      Assert.AreEqual(s, newS);
     627    }
     628
     629    [TestMethod]
     630    public void PointTest() {
     631      Point p = new Point(12, 34);
     632      XmlGenerator.Serialize(p, tempFile);
     633      Point newP = (Point)XmlParser.Deserialize(tempFile);
     634      Assert.AreEqual(p, newP);
     635    }
     636
     637    [TestMethod]
     638    public void NullableValueTypes() {
     639      double?[] d = new double?[] { null, 1, 2, 3 };
     640      XmlGenerator.Serialize(d, tempFile);
     641      double?[] newD = (double?[])XmlParser.Deserialize(tempFile);
     642      Assert.AreEqual(d[0], newD[0]);
     643      Assert.AreEqual(d[1], newD[1]);
     644      Assert.AreEqual(d[2], newD[2]);
     645      Assert.AreEqual(d[3], newD[3]);
     646    }
     647
    610648    [ClassInitialize]
    611649    public static void Initialize(TestContext testContext) {
Note: See TracChangeset for help on using the changeset viewer.