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); }
public void DataBoxAddMultiItems() { //Arrange var data = new DataBox("test.xml"); //Act LinkEntry entry1 = data.NewLinkEntry("name 1", "description"); LinkEntry entry2 = data.NewLinkEntry("name 2", "description"); LinkEntry entry3 = data.NewLinkEntry("name 3", "description"); //Assert Assert.AreEqual(3, data.Entries.Count); Assert.AreEqual(entry1, data.Entries[0]); Assert.AreEqual(entry2, data.Entries[1]); Assert.AreEqual(entry3, data.Entries[2]); }
public void DataBoxGetEntries() { //Arrange var data = new DataBox("test.dat"); var entry = data.NewLinkEntry("entry", "description"); //Act var entries = data.GetEntriesByName("entry"); //Assert Assert.AreEqual(entry, entries[0]); }
public void DataBoxAddItem() { //Arrange var data = new DataBox("test.xml"); //Act LinkEntry entry = data.NewLinkEntry("name", "description"); //Assert Assert.AreEqual(1, data.Entries.Count); Assert.AreEqual("name", data.Entries[0].Name); Assert.AreEqual("description", ((LinkEntry)data.Entries[0]).Description); Assert.AreEqual(entry, data.Entries[0]); }
public void DataBoxGetEntriesByLinkTag() { //Arrange var data = new DataBox("test.dat"); var entry = data.NewLinkEntry("entry", "description"); entry.AddLink("link", "test.ca").AddTag(data.NewTag("tag", "link")); //Act var entries = data.GetEntriesByLinkTag(data.GetTagsByName("tag", "link")[0]); //Assert Assert.AreEqual(entry, entries[0]); }
public void DataBoxAddItemWithLink() { //Arrange var data = new DataBox("test.xml"); //Act LinkEntry entry = data.NewLinkEntry("name", "description"); LinkItem link = entry.AddLink("link", "http://testlink.ca"); //Assert Assert.AreEqual(1, data.Entries.Count); Assert.AreEqual("link", ((LinkEntry)data.Entries[0]).Links[0].Name); Assert.AreEqual("http://testlink.ca", ((LinkEntry)data.Entries[0]).Links[0].Link); Assert.AreEqual(link, ((LinkEntry)data.Entries[0]).Links[0]); }
public void DataBoxAddItemWithTag() { //Arrange var data = new DataBox("test.xml"); var tag = data.NewTag("Test"); //Act LinkEntry entry = data.NewLinkEntry("name", "description"); entry.AddTag(tag); //Assert Assert.AreEqual(1, data.Entries.Count); Assert.AreEqual("name", data.Entries[0].Name); Assert.AreEqual("description", ((LinkEntry)data.Entries[0]).Description); Assert.AreEqual("Test", data.Entries[0].Tags.First().Name); Assert.AreEqual(entry, data.Entries[0]); Assert.IsTrue(data.Entries[0].Tags.Contains(tag)); }
public void DataBoxAddItemWithLinkWithTag() { //Arrange var data = new DataBox("test.xml"); var tag = data.NewTag("test", "link"); //Act LinkEntry entry = data.NewLinkEntry("name", "description"); LinkItem link = entry.AddLink("link", "http://testlink.ca"); link.AddTag(tag); //Assert Assert.AreEqual(1, data.Entries.Count); Assert.AreEqual("link", ((LinkEntry)data.Entries[0]).Links[0].Name); Assert.AreEqual("http://testlink.ca", ((LinkEntry)data.Entries[0]).Links[0].Link); Assert.IsTrue(((LinkEntry)data.Entries[0]).Links[0].Tags.Any(x => x.Name == "test")); Assert.AreEqual(link, ((LinkEntry)data.Entries[0]).Links[0]); Assert.IsTrue(((LinkEntry)data.Entries[0]).Links[0].Tags.Contains(tag)); }
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); }