public void UpdateTask() { var controller = new TasksController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); DAL.Task tsk = new DAL.Task { end_date = DateTime.Now.AddDays(20), start_date = DateTime.Now, task1 = "Test task3", project_id = 1, parent_id = 1, user_id = 1, priority = 20, task_id = 3 }; IHttpActionResult actionResult = controller.PutTask(3, tsk); var createdResult = actionResult as StatusCodeResult; // Assert Assert.IsNotNull(createdResult); Assert.AreEqual(HttpStatusCode.NoContent, createdResult.StatusCode); }
public void AddTask() { var controller = new TasksController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); DAL.Task tsk = new DAL.Task { end_date = DateTime.Now.AddDays(20), start_date = DateTime.Now, task1 = "Test task3", project_id = 1, parent_id = 1, user_id = 1, priority = 20 }; IHttpActionResult actionResult = controller.PostTask(tsk); var createdResult = actionResult as CreatedAtRouteNegotiatedContentResult <DAL.Task>; // Assert Assert.IsNotNull(createdResult); Assert.AreEqual("DefaultApi", createdResult.RouteName); Assert.IsNotNull(createdResult.RouteValues["id"]); }