예제 #1
0
        public void DataBoxSerializeDeserialize()
        {
            //Arrange
            var data = new DataBox("test.dat");
            var tag = data.NewTag("tag");
            var linkTag = data.NewTag("link tag", "link");
            var entry = data.NewLinkEntry("name", "description");
            var link = entry.AddLink("link", "testlink.ca");
            link.AddTag(linkTag);

            //Act
            string ser = data.Serialize();
            var deSer = DataBox.Deserialize(ser);

            //Assert
            Assert.AreEqual(data.Entries.Count, deSer.Entries.Count);
            Assert.AreEqual(data.Entries[0].Name, deSer.Entries[0].Name);
            Assert.AreEqual(((LinkEntry)data.Entries[0]).Description, ((LinkEntry)deSer.Entries[0]).Description);
            Assert.AreEqual(data.Entries[0].Tags.Count, deSer.Entries[0].Tags.Count);
            Assert.AreEqual(((LinkEntry)data.Entries[0]).Links[0].Name, ((LinkEntry)deSer.Entries[0]).Links[0].Name);
            Assert.AreEqual(((LinkEntry)data.Entries[0]).Links[0].Link, ((LinkEntry)deSer.Entries[0]).Links[0].Link);
            Assert.AreEqual(((LinkEntry)data.Entries[0]).Links[0].Tags.Count, ((LinkEntry)deSer.Entries[0]).Links[0].Tags.Count);
        }