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"); }
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); }
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); }
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); }