Ejemplo n.º 1
0
        public void SerializeToXmlBinary()
        {
            ChildBusinessList result;
            var list = ChildBusinessList.GetEditableRootList(1);

            System.IO.File.Delete("c:\\temp\\test2.xml");

            Assert.AreEqual(typeof(ChildType1), list[0].GetType());
            Assert.AreEqual(typeof(ChildType2), list[1].GetType());

            var serialized = MobileFormatter.SerializeToDTO(list);
            var writer     = new CslaXmlBinaryWriter();
            var streamOut  = new System.IO.FileStream("c:\\temp\\test2.xml", FileMode.OpenOrCreate);

            writer.Write(streamOut, serialized);
            streamOut.Close();

            Thread.Sleep(500);

            var streamIn     = new System.IO.FileStream("c:\\temp\\test2.xml", FileMode.Open);
            var reader       = new CslaXmlBinaryReader();
            var deserialized = reader.Read(streamIn);

            result = (ChildBusinessList)MobileFormatter.DeserializeFromDTO(deserialized);

            Assert.AreEqual(list.Count, result.Count);
        }
Ejemplo n.º 2
0
        public void GetEditableRootListTest()
        {
            var list = ChildBusinessList.GetEditableRootList(1);

            Assert.AreEqual(typeof(ChildType1), list[0].GetType());
            Assert.AreEqual(typeof(ChildType2), list[1].GetType());

            list.BeginEdit();
            list.Add(new ChildType2(3, "Test", "UK"));
            list.CancelEdit();

            Assert.AreEqual(2, list.Count);
        }