public void CustomAttributes()
        {
            var container = new BookmarkFolder
            {
                new BookmarkLink("a", "b")
                {
                    Attributes = new Dictionary <string, string> {
                        { "custom", "1" }
                    }
                },
                new BookmarkFolder("folder")
                {
                    Attributes = new Dictionary <string, string> {
                        { "custom", "2" }, { "add_date", "ę" }
                    }
                }
            };
            var writter = new NetscapeBookmarksWriter(container);
            var reader  = new NetscapeBookmarksReader();
            var write1  = writter.ToString();
            var readed  = reader.Read(write1);

            Assert.AreEqual("1", readed.AllLinks.First().Attributes["custom"]);
            Assert.AreEqual("2", readed.GetAllItems <BookmarkFolder>().First().Attributes["custom"]);
            Assert.IsFalse(readed.GetAllItems <BookmarkFolder>().First().Attributes.ContainsKey("add_date"), "add_date is ignored attribute, it must not be written");
        }
        public void EmptyContainer()
        {
            var emptyContainer = new BookmarkFolder();
            var writter        = new NetscapeBookmarksWriter(emptyContainer);
            var reader         = new NetscapeBookmarksReader();
            var write1         = writter.ToString();
            var readed         = reader.Read(write1);

            writter = new NetscapeBookmarksWriter(readed);
            var write2 = writter.ToString();

            Assert.AreEqual(write1, write2, true);
        }
        public void SimpleStructureBasic()
        {
            var bookmarks       = Helpers.GetSimpleStructure();
            var writter         = new NetscapeBookmarksWriter(bookmarks);
            var result          = writter.ToString();
            var folderTagCnt    = _folderTagsRegex.Matches(result).Count;
            var itemTagsCnt     = _linkRegex.Matches(result).Count;
            var h3Cnt           = _h3Regex.Matches(result).Count;
            var folderHeaderCnt = _folderHeaderRegex.Matches(result).Count;

            Assert.AreEqual(10, folderTagCnt);
            Assert.AreEqual(4, itemTagsCnt);
            Assert.AreEqual(4, h3Cnt);
            Assert.AreEqual(4, folderHeaderCnt);
        }
        public void SimpleStructure()
        {
            var container = Helpers.GetSimpleStructure();

            container.Add(new BookmarkLink("test", "test123")
            {
                Description = "<br>"
            });
            var writter = new NetscapeBookmarksWriter(container);
            var reader  = new NetscapeBookmarksReader();
            var write1  = writter.ToString();
            var readed  = reader.Read(write1);

            writter = new NetscapeBookmarksWriter(readed);
            var write2 = writter.ToString();

            readed = reader.Read(write2);
            Assert.AreEqual(write1, write2, true);
            Assert.IsNotNull(readed.AllLinks.FirstOrDefault(l => l.Title == "test123" && l.Description == "<br>"), "Description must be preserved between reads and writes");
        }
        public void ValidHeader()
        {
            var result = _writter.ToString();

            Assert.IsTrue(_headerRegex.IsMatch(result));
        }