示例#1
0
        public static void Main(string[] args)
        {
            var bookmarks = new Bookmarks();

            using (var dbConn = new Mono.Data.Sqlite.SqliteConnection("Data Source=/mnt/ramdisk/test.db"))
            {
                dbConn.Open();

                var cmdGetGroups = dbConn.CreateCommand();
                cmdGetGroups.CommandText = "SELECT gid, name, IFNULL(pid,0) FROM rel JOIN groups ON rel.gid=groups.rowid WHERE depth=1";
                using (IDataReader groups = cmdGetGroups.ExecuteReader())
                {
                    ApplyRow(groups, (g) => bookmarks.GroupAdd(g.GetInt32(0), new Group {
                        Id = g.GetInt32(0), Name = g.GetString(1), Pid = g.GetInt32(2)
                    }));
                }
                var cmdGetRows = dbConn.CreateCommand();
                cmdGetRows.CommandText = "SELECT IFNULL(gid,0), key, value FROM data";
                using (IDataReader rows = cmdGetRows.ExecuteReader())
                {
                    ApplyRow(rows, (r) => bookmarks.LinkAdd(r.GetInt32(0), new LinkItem {
                        Title = r.GetString(1), Target = r.GetString(2)
                    }));
                }
            }
            var document = new XDocument();

            document.Add(bookmarks.ToXml());
            document.Save("test.xml");
        }
示例#2
0
        public void BasicStatTestNonGid()
        {
            var bookmarks = new Bookmarks();

            bookmarks.GroupAdd(200, new Group {
                Id = 200, Name = "200g", Pid = 0
            });
            bookmarks.LinkAdd(200, new LinkItem {
                Title = "First", Target = "Target!"
            });
            var stats = bookmarks.GetStats(2000);

            Assert.AreEqual(0, stats.Count);
            Assert.AreEqual("", stats.Name);
        }
示例#3
0
        public void Overwrites()
        {
            var bookmarks = new Bookmarks();

            bookmarks.LinkAdd(523, new LinkItem {
                Title = "VIP", Target = "123 Land"
            }, force: true);
            var counts = bookmarks.Counts;

            Assert.AreEqual(2, counts.Groups);
            Assert.AreEqual(1, counts.Links);
            bookmarks.GroupAdd(523, new Group {
                Id = 523, Name = "Milli", Pid = 0
            }, overwrite: true);
            counts = bookmarks.Counts;
            Assert.AreEqual(2, counts.Groups);
            Assert.AreEqual(1, counts.Links);
        }
示例#4
0
        public void BMStats()
        {
            var bookmarks = new Bookmarks();

            bookmarks.GroupAdd(200, new Group {
                Id = 200, Name = "200g", Pid = 0
            });
            for (int i = 0; i < 30; ++i)
            {
                bookmarks.LinkAdd(200, new LinkItem {
                    Title = "f" + i.ToString(), Target = "Target!"
                });
            }
            var counts = bookmarks.Counts;

            Assert.AreEqual(2, counts.Groups);
            Assert.AreEqual(30, counts.Links);
        }