Ejemplo n.º 1
0
        public void DataBoxAddMultiTags()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            data.NewTag("test 1");
            data.NewTag("test 2");
            data.NewTag("test 3");

            //Assert
            Assert.AreEqual(3, data.TagList.Count);
        }
Ejemplo n.º 2
0
        public void DataBoxAddTag()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            var tag = data.NewTag("Test");

            //Assert
            Assert.AreEqual(1, data.TagList.Count);
            Assert.AreEqual("Test", data.TagList.First().Name);
            Assert.AreEqual(tag, data.TagList.First());
        }
Ejemplo n.º 3
0
        public void DataBoxAddComplexTag()
        {
            //Arrange
            var data = new DataBox("test.xml");

            //Act
            var tag = data.NewTag("test", "category", "subcategory");

            //Assert
            Assert.AreEqual("test", data.TagList.First().Name);
            Assert.AreEqual("category", data.TagList.First().Category);
            Assert.AreEqual("subcategory", data.TagList.First().Subcategory);
            Assert.AreEqual(tag, data.TagList.First());
        }
Ejemplo n.º 4
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]);
        }
Ejemplo n.º 5
0
        public void DataBoxGetTagsBySubcategoryMulti()
        {
            //Arrange
            var data = new DataBox("test.dat");
            var tag = data.NewTag("tag 1", "category", "subcategory");
            var tag2 = data.NewTag("tag 2", "category", "subcategory");

            //Act
            Tag[] tags = data.GetTagsBySubcategory("category", "subcategory");

            //Assert
            Assert.IsTrue(tags.Any(x => x == tag));
            Assert.IsTrue(tags.Any(x => x == tag2));
        }
Ejemplo n.º 6
0
        public void DataBoxGetTagsBySubsategory()
        {
            //Arrange
            var data = new DataBox("test.dat");
            var tag = data.NewTag("tag", "category", "subcategory");

            //Act
            Tag[] tags = data.GetTagsBySubcategory("category", "subcategory");

            //Assert
            Assert.AreEqual(tag, tags[0]);
        }
Ejemplo n.º 7
0
        public void DataBoxGetTagsByNameMulti()
        {
            //Arrange
            var data = new DataBox("test.dat");
            var tag = data.NewTag("tag");
            var tag2 = data.NewTag("tag", "subTag");

            //Act
            Tag[] tags = data.GetTagsByName("tag");

            //Assert
            Assert.IsTrue(tags.Any(x => x == tag));
            Assert.IsTrue(tags.Any(x => x == tag2));
        }
Ejemplo n.º 8
0
        public void DataBoxGetTagsByName()
        {
            //Arrange
            var data = new DataBox("test.dat");
            var tag = data.NewTag("tag");

            //Act
            Tag[] tags = data.GetTagsByName("tag");

            //Assert
            Assert.AreEqual(tag, tags[0]);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
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));
        }