Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11352


Ignore:
Timestamp:
09/10/14 12:38:09 (10 years ago)
Author:
epitzer
Message:

#1802 add more test cases to ensure proper working of nullable types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs

    r11171 r11352  
    2424using System.Collections.Generic;
    2525using System.Drawing;
     26using System.Globalization;
    2627using System.IO;
    2728using System.Linq;
     
    14741475    }
    14751476
     1477    [TestMethod]
     1478    [TestCategory("Persistence")]
     1479    [TestProperty("Time", "short")]
     1480    public void TestOptionalDateTimeEnumerable() {
     1481      var values = new List<DateTime?> { DateTime.MinValue, null, DateTime.Now, DateTime.Now.Add(TimeSpan.FromDays(1)),
     1482        DateTime.ParseExact("10.09.2014 12:21", "dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture), DateTime.MaxValue};
     1483      XmlGenerator.Serialize(values, tempFile);
     1484      var newValues = (List<DateTime?>) XmlParser.Deserialize(tempFile);
     1485      CollectionAssert.AreEqual(values, newValues);
     1486    }
     1487
     1488    [TestMethod]
     1489    [TestCategory("Persistence")]
     1490    [TestProperty("Time", "short")]
     1491    public void TestStringEnumerable() {
     1492      var values = new List<string> {"", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated"};
     1493      XmlGenerator.Serialize(values, tempFile);
     1494      var newValues = (List<String>) XmlParser.Deserialize(tempFile);
     1495      CollectionAssert.AreEqual(values, newValues);
     1496    }
     1497
     1498    [TestMethod]
     1499    [TestCategory("Persistence")]
     1500    [TestProperty("Time", "short")]
     1501    public void TestUnicodeCharArray() {
     1502      var s = Encoding.UTF8.GetChars(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
     1503      XmlGenerator.Serialize(s, tempFile);
     1504      var newS = (char[])XmlParser.Deserialize(tempFile);
     1505      CollectionAssert.AreEqual(s, newS);
     1506    }
     1507
     1508    [TestMethod]
     1509    [TestCategory("Persistence")]
     1510    [TestProperty("Time", "short")]
     1511    public void TestUnicode() {
     1512      var s = Encoding.UTF8.GetString(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
     1513      XmlGenerator.Serialize(s, tempFile);
     1514      var newS = XmlParser.Deserialize(tempFile);
     1515      Assert.AreEqual(s, newS);
     1516    }
     1517
    14761518
    14771519    [ClassInitialize]
Note: See TracChangeset for help on using the changeset viewer.