Ejemplo n.º 1
0
        public void DataBoxSaveOpenEncrypted()
        {
            //Arrange
            var data = new DataBox("encrypt.dat");
            var tag = data.NewTag("tag");
            var linkTag = data.NewTag("link tag", "link");
            var entry = data.NewLinkEntry("name", "description");
            entry.AddTag(tag);
            var link = entry.AddLink("link", "testlink.ca");
            link.AddTag(linkTag);

            //Act
            data.Save("pass");
            var deSer = DataBox.Open("encrypt.dat", "pass");

            //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);
        }