Ejemplo n.º 1
0
 public void TestDeleteAll()
 {
     Task task1 = new Task("Darbas", DateTime.Now, "sourceId|15");
     task1.Save();
     Task task2 = new Task("Darbas2", DateTime.Now, "sourceId|15");
     task2.Save();
     Task.DeleteAll();
 }
Ejemplo n.º 2
0
 public void SaveNewTask(string dataEntered, AbstractMainForm form)
 {
     Task task = new Task().ParseString(dataEntered);
     if (task != null)
     {
         task.Save();
         form.MTextBox.Text = string.Empty;
         m_log.DebugFormat("New task was saved. Name {0}, date {1}", task.Text,
                       DBTypesConverter.ToFullDateStringByCultureInfo(task.DateRemainder));
     }
 }
Ejemplo n.º 3
0
        public void TestDelete()
        {
            Task task = new Task("Darbas", DateTime.Now, "sourceId|15");
            task.Save();
            task.Delete();

            using (IConnection con = new ConnectionCollector().GetConnection())
            {
                IDataReader reader = con.ExecuteReader("SELECT NAME, DATE_REMAINDER, SOURCE_ID FROM TASK");
                Assert.IsTrue(reader.Read());
            }
        }
Ejemplo n.º 4
0
        public void TestLoadTasksForShowing()
        {
            Task task1 = new Task("Darbas", DateTime.Now.AddSeconds(-1), "sourceId|sekundė-1");
            task1.Save();
            Task task2 = new Task("Darbas2", DateTime.Now.AddMonths(-1), "sourceId|mėnuo-1");
            task2.Save();
            Task task3 = new Task("Darbas3", DateTime.Now.AddMinutes(1), "sourceId|mintė+1");
            task3.Save();

            using (IConnection con = new ConnectionCollector().GetConnection())
            {
                List<Task> tasks = new DbHelper().LoadTasksForShowing();
                Assert.AreEqual(2, tasks.Count);
            }
        }
Ejemplo n.º 5
0
        public void TestUpdate()
        {
            DateTime now = DateTime.Now;
            Task task = new Task("Darbas", now, "sourceId|15");
            task.Save();

            task.DateRemainder = now.AddYears(1);
            task.Text = "Krabas";
            task.Showed = true;
            task.SourceId = "skriptas";
            task.Update();

            using (IConnection con = new ConnectionCollector().GetConnection())
            {
                IDataReader reader = con.ExecuteReader("SELECT NAME, DATE_REMAINDER, SOURCE_ID, SHOWED FROM TASK");
                Assert.IsTrue(reader.Read());
                Assert.AreEqual(task.Text, reader.GetString(0));
                Assert.AreEqual(DBTypesConverter.ToFullDateStringByCultureInfo(task.DateRemainder), reader.GetString(1));
                Assert.AreEqual(task.SourceId, reader.GetString(2));
                Assert.AreEqual(1, reader.GetInt32(3));
            }
        }