public void StreamWritting()
        {
            var encoding = Encoding.UTF32;

            _writter.OutputEncoding = encoding;
            using (var stream = new MemoryStream())
            {
                _writter.Write(stream);
                var content = encoding.GetString(stream.ToArray());
                Assert.IsTrue(_headerRegex.IsMatch(content));
            }
        }
        public void OutputEncoding1()
        {
            var encoding   = Encoding.BigEndianUnicode;
            var bookmarks  = Helpers.GetSimpleStructure();
            var unicodeStr = Helpers.RandomUnicodeString(10240);

            bookmarks.Add(new BookmarkLink("http://example.com", "Unicode title test: <" + unicodeStr));
            var writter = new NetscapeBookmarksWriter(bookmarks)
            {
                OutputEncoding = encoding
            };

            using (var stream = new MemoryStream())
            {
                writter.Write(stream);
                var content = encoding.GetString(stream.ToArray());
                Assert.IsTrue(content.Contains("&lt;" + unicodeStr));
            }
        }
        public void EmbededIconTest()
        {
            var bookmarks   = Helpers.GetSimpleStructure();
            var randomBytes = Encoding.UTF8.GetBytes(Helpers.RandomUnicodeString(4096));

            bookmarks.Add(new BookmarkLink("http://example.com", "<\">")
            {
                IconContentType = "image/png", IconData = randomBytes
            });
            var writter = new NetscapeBookmarksWriter(bookmarks);

            using (var stream = new MemoryStream())
            {
                writter.Write(stream);
                var content = writter.OutputEncoding.GetString(stream.ToArray());
                Assert.IsTrue(content.Contains("data:image/png;base64,"));
                Assert.IsTrue(content.Contains(Convert.ToBase64String(randomBytes)));
            }
        }
        public void StreamUnicode()
        {
            var container = Helpers.GetSimpleStructure();

            container.Add(new BookmarkLink("test", "ƒ"));
            var ms      = new MemoryStream();
            var writter = new NetscapeBookmarksWriter(container)
            {
                OutputEncoding = Encoding.Unicode
            };

            writter.Write(ms);
            ms = new MemoryStream(ms.GetBuffer());
            var reader = new NetscapeBookmarksReader {
                AutoDetectEncoding = true
            };
            var readed = reader.Read(ms);

            Assert.AreEqual(container.AllItems.Last().Title, readed.AllItems.Last().Title);
        }
        public void OutputEncoding2()
        {
            var encoding  = Encoding.GetEncoding(1257);
            var bookmarks = Helpers.GetSimpleStructure();

            bookmarks.Add(new BookmarkLink("http://example.com", "ASCII title test: ƒ ąčęėįšųūĄŪ"));
            var writter = new NetscapeBookmarksWriter(bookmarks)
            {
                OutputEncoding = encoding
            };

            using (var stream = new MemoryStream())
            {
                writter.Write(stream);
                var content = encoding.GetString(stream.ToArray());
                Assert.IsTrue(content.Contains("? ąčęėįšųūĄŪ"));
                content = Encoding.UTF8.GetString(stream.ToArray());
                Assert.IsFalse(content.Contains("ƒ"));
            }
        }