public void InitializeTest() { SqliteStorage Storage = new SqliteStorage("Data Source=:memory:", true); bool Status = Storage.Initialize(); Assert.IsTrue(Status); }
public void ActivityFromStringTest() { SqliteStorage Storage = new SqliteStorage("Data Source=:memory:"); Storage.Initialize(); Activity act1 = new Activity("Test activity 1", Storage); Assert.AreEqual(0, act1.ActivityId); Assert.AreEqual("Test activity 1", act1.Name); Assert.AreEqual("", act1.Description); Assert.AreEqual("", act1.Tags); Activity act2 = new Activity("Test activity 2@Project name", Storage); Assert.AreEqual("Test activity 2", act2.Name); Assert.AreEqual("", act2.Description); Assert.AreEqual("", act2.Tags); Activity act3 = new Activity("Test activity 3@Project name;tag1,tag2", Storage); Assert.AreEqual("Test activity 3", act3.Name); Assert.AreEqual("", act3.Description); Assert.AreEqual("tag1,tag2", act3.Tags); Activity act4 = new Activity("Test activity 4@Project name;tag1,tag2,tag3#Some description", Storage); Assert.AreEqual("Test activity 4", act4.Name); Assert.AreEqual("Some description", act4.Description); Assert.AreEqual("tag1,tag2,tag3", act4.Tags); Activity act5 = new Activity("Test activity 5;tag1,tag2", Storage); Assert.AreEqual("Test activity 5", act5.Name); Assert.AreEqual("", act5.Description); Assert.AreEqual("tag1,tag2", act5.Tags); Activity act6 = new Activity("Test activity 6;tag3#Some description", Storage); Assert.AreEqual("Test activity 6", act6.Name); Assert.AreEqual("Some description", act6.Description); Assert.AreEqual("tag3", act6.Tags); Activity act7 = new Activity("Test activity 7@Project name#Some description", Storage); Assert.AreEqual("Test activity 7", act7.Name); Assert.AreEqual("Some description", act7.Description); Assert.AreEqual("", act7.Tags); Activity act8 = new Activity("Test activity 8#Some description", Storage); Assert.AreEqual("Test activity 8", act8.Name); Assert.AreEqual("Some description", act8.Description); Assert.AreEqual("", act8.Tags); }
public void InsertTest() { SqliteStorage Storage = new SqliteStorage("Data Source=:memory:", true); Storage.Initialize(); List <Project> lp = Storage.SelectProjects(); Assert.AreEqual(1, lp.Count); // Insert old activity without own project Activity a1 = new Activity(); a1.Name = "Test activity"; a1.Created = DateTime.Parse("2015-01-01 01:00:00"); a1.Stopped = DateTime.Parse("2015-01-01 01:30:00"); Assert.AreEqual(0, a1.ActivityId); a1 = Storage.InsertActivity(a1); Assert.AreEqual(1, a1.ActivityId); //Assert.AreNotEqual(a1.ActivityId, au1.ActivityId); Assert.AreEqual(1, a1.ProjectId); Assert.AreEqual("Test activity", a1.Name); Assert.AreEqual("", a1.Description); Assert.AreEqual("", a1.Tags); Assert.AreEqual(DateTime.Parse("2015-01-01 01:00:00"), a1.Created); Assert.AreEqual(DateTime.Parse("2015-01-01 01:30:00"), a1.Stopped); Assert.IsFalse(a1.IsRunning()); // Insert running activity with project (should be created). Activity a2 = new Activity("Second test activity@Test project", Storage); Assert.AreEqual(0, a2.ActivityId); a2 = Storage.InsertActivity(a2); Assert.AreEqual(2, a2.ActivityId); Assert.IsTrue(a2.IsRunning()); }