Exemplo n.º 1
0
    public void TestSerialize()
    {
        Memento.SampleClass cls = new Memento.SampleClass(40, "Memento");

        Memento.XMLSampleClass state = new Memento.XMLSampleClass();
        cls.GetState(state);

        XmlSerializer s = new XmlSerializer(typeof(Memento.XMLSampleClass));
        TextWriter    w = new StreamWriter(@"c:\sampleclass.xml");

        s.Serialize(w, state);
        w.Close();
    }
Exemplo n.º 2
0
    public void TestDeserialize()
    {
        Memento.SampleClass cls = new Memento.SampleClass();

        Memento.XMLSampleClass state = new Memento.XMLSampleClass();

        XmlSerializer s = new XmlSerializer(typeof(Memento.XMLSampleClass));
        TextReader    r = new StreamReader(@"c:\sampleclass.xml");

        state = (Memento.XMLSampleClass)s.Deserialize(r);
        r.Close();
        cls.SetState(state);
        Assert.AreEqual(40, cls.Value);
    }