AddProject() 공개 메소드

public AddProject ( Project project ) : void
project Project
리턴 void
예제 #1
0
 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);
 }
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
 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()));
 }
예제 #6
0
 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);
 }
예제 #7
0
 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));
 }
예제 #8
0
 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);
 }