public void TestAddProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; Assert.IsTrue (db.AddProject (p1)); Assert.IsTrue (File.Exists (Path.Combine (dbdir, p1.ID.ToString()))); Assert.IsTrue (db.AddProject (p1)); Assert.AreEqual (db.Count, 1); db = new DataBase (dbdir); Assert.AreEqual (db.Count, 1); }
public void TestDBWithErrorProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); db.AddProject (new ProjectLongoMatch {Description = new ProjectDescriptionLongoMatch()}); var writer = File.CreateText (Path.Combine (dbdir, "wrongfile")); writer.WriteLine("TEST&%&$&%"); writer.WriteLine("}~4"); writer.Flush(); writer.Close(); File.Delete (Path.Combine (dbdir, "test.ldb")); db = new DataBase (dbdir); Assert.AreEqual (db.Count, 1); }
public void TestUpdateProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; DateTime lastModified = p1.Description.LastModified; Assert.IsTrue (db.AddProject (p1)); Assert.IsTrue (db.UpdateProject (p1)); Assert.AreNotEqual (p1.Description.LastModified, lastModified); }
public void TestReloadDB() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); db.AddProject (new ProjectLongoMatch {Description = new ProjectDescriptionLongoMatch()}); File.Delete (Path.Combine (dbdir, "test.ldb")); db = new DataBase (dbdir); Assert.IsTrue (File.Exists (Path.Combine (dbdir, "test.ldb"))); Assert.AreEqual (db.Count, 1); }
public void TestGetProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; db.AddProject (p1); ProjectLongoMatch p2 = db.GetProject (p1.ID); Assert.AreEqual (p1.ID, p2.ID); Assert.IsNull (db.GetProject (new Guid())); }
public void TestGetAllProjects() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectDescriptionLongoMatch pd2 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; ProjectLongoMatch p2 = new ProjectLongoMatch {Description = pd2}; db.AddProject (p1); db.AddProject (p2); Assert.AreEqual (db.Count, 2); List<ProjectDescriptionLongoMatch> projects = db.GetAllProjects (); Assert.AreEqual (db.Count, 2); Assert.AreEqual (projects.Count, 2); Assert.AreEqual (projects[0], pd1); Assert.AreEqual (projects[1], pd2); }
public void TestExists() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescriptionLongoMatch pd1 = new ProjectDescriptionLongoMatch (); ProjectLongoMatch p1 = new ProjectLongoMatch {Description = pd1}; Assert.IsFalse (db.Exists (p1)); db.AddProject (p1); Assert.IsTrue (db.Exists (p1)); }
public void TestRemoveProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; Assert.IsTrue (db.AddProject (p1)); Assert.IsTrue (File.Exists (Path.Combine (dbdir, p1.ID.ToString()))); Assert.AreEqual (db.Count, 1); Assert.IsTrue (db.RemoveProject (p1.ID)); Assert.IsFalse (File.Exists (Path.Combine (dbdir, p1.ID.ToString()))); Assert.AreEqual (db.Count, 0); Assert.IsFalse (db.RemoveProject (p1.ID)); db = new DataBase (dbdir); Assert.AreEqual (db.Count, 0); }