public void Test_DueDate_GetDueDate()
        {
            //Arrange
            Task testTask = new Task("Mow the lawn", 1, "2017-03-02");

            testTask.Save();
            string expected = ("2017-03-02");

            //Act
            string foundDueDate = testTask.GetDueDate();

            //Assert
            Assert.Equal(expected, foundDueDate);
        }
Beispiel #2
0
 public override bool Equals(System.Object otherTask)
 {
     if (!(otherTask is Task))
     {
         return(false);
     }
     else
     {
         Task newTask             = (Task)otherTask;
         bool dueDateEquality     = (this.GetDueDate() == newTask.GetDueDate());
         bool descriptionEquality = (this.GetDescription() == newTask.GetDescription());
         bool categoryEquality    = (this.GetCategoryId() == newTask.GetCategoryId());
         return(descriptionEquality && dueDateEquality && categoryEquality);
     }
 }
 public override bool Equals(System.Object otherTask)
 {
     if (!(otherTask is Task))
     {
         return(false);
     }
     else
     {
         Task newTask             = (Task)otherTask;
         bool idEquality          = this.GetId() == newTask.GetId();
         bool descriptionEquality = this.GetDescription() == newTask.GetDescription();
         bool dueDateEquality     = this.GetDueDate() == newTask.GetDueDate();
         bool doneEquality        = this.GetDone() == newTask.GetDone();
         return(idEquality && descriptionEquality && dueDateEquality);
     }
 }
Beispiel #4
0
 public override bool Equals(Object otherTask)
 {
     if (!(otherTask is Task))
     {
         return(false);
     }
     else
     {
         Task newTask             = (Task)otherTask;
         bool idEquality          = (this.GetId() == newTask.GetId());
         bool descriptionEquality = (this.GetDescription() == newTask.GetDescription());
         bool completedEquality   = (this.GetCompleted() == newTask.GetCompleted());
         bool dueDateEquality     = (this.GetDueDate() == newTask.GetDueDate());
         return(idEquality && descriptionEquality && completedEquality && dueDateEquality);
     }
 }
        public void Test_DueDate_SavesInRightFormat()
        {
            //Arrange
            string testDate = "2017-02-17";
            string taskDate;
            Task   testTask = new Task("Mow the lawn", "2017-02-17");

            testTask.Save();

            //Act
            Task foundTask = Task.Find(testTask.GetId());

            taskDate = foundTask.GetDueDate();
            //Assert
            Assert.Equal(testDate, taskDate);
        }
Beispiel #6
0
        public static Task Find(int id)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand   cmd             = new SqlCommand("SELECT * FROM tasks WHERE id = @TaskId;", conn);
            SqlParameter taskIdParameter = new SqlParameter();

            taskIdParameter.ParameterName = "@TaskId";
            taskIdParameter.Value         = id.ToString();
            cmd.Parameters.Add(taskIdParameter);
            SqlDataReader rdr = cmd.ExecuteReader();

            int    foundTaskId          = 0;
            string foundTaskDescription = null;
            string foundDueDate         = null;
            int    foundTaskCategoryId  = 0;

            while (rdr.Read())
            {
                foundTaskId          = rdr.GetInt32(0);
                foundTaskDescription = rdr.GetString(1);
                foundDueDate         = rdr.GetString(2);
                foundTaskCategoryId  = rdr.GetInt32(3);
            }
            Task foundTask = new Task(foundTaskDescription, foundDueDate, foundTaskCategoryId, foundTaskId);

            if (rdr != null)
            {
                rdr.Close();
            }
            if (conn != null)
            {
                conn.Close();
            }
            Console.WriteLine(foundTask.GetDueDate());
            return(foundTask);
        }