Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/04/09 16:43:46 (16 years ago)
Author:
epitzer
Message:

Added Serialization to stream. Do not overwrite file if serialization fails. (#603)

File:
1 edited

Legend:

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

    r1705 r1733  
    172172    [Storable]
    173173    public KeyValuePair<List<C>, C> kvpList;
     174  }
     175
     176  public class NonSerializable {
     177    int x;
    174178  }
    175179
     
    504508    }
    505509
     510    [TestMethod]
     511    public void TestSavingException() {     
     512      List<int> list = new List<int> { 1, 2, 3 };
     513      XmlGenerator.Serialize(list, tempFile);
     514      NonSerializable s = new NonSerializable();
     515      try {
     516        XmlGenerator.Serialize(s, tempFile);
     517        Assert.Fail("Exception expected");
     518      } catch (PersistenceException) { }
     519      List<int> newList = (List<int>)XmlParser.DeSerialize(tempFile);
     520      Assert.AreEqual(list[0], newList[0]);
     521      Assert.AreEqual(list[1], newList[1]);
     522    }
     523
    506524    [ClassInitialize]
    507525    public static void Initialize(TestContext testContext) {
Note: See TracChangeset for help on using the changeset viewer.