public void EstimatingATask(ProjectTask task) { var controller = new ProjectTasksController(_context); "Given a new task" .x(() => task = new ProjectTask() { id = 2, status = TaskStatus.UNESTIMATED.name, title = "New task in BDD", RoomId = 1999, estimate = 0 }); "And adding the task in database" .x(async() => { await controller.CreateProjectTask(task); _context.Entry(task).State = EntityState.Detached; }); "When I select task to estimate" .x(async() => { await controller.UpdateTaskStatus(task.id, TaskStatus.VOTING.name); }); "And assign estimate" .x(async() => { await controller.PatchProjectTaskEstimate(task.id, 5); }); "Then task status is 'Estimated'" .x(() => { task = _context.ProjectTask.First(pt => pt.id == task.id); Assert.Equal(5, task.estimate); }); "And esitmate is equal to assigned one" .x(() => { Assert.Equal(TaskStatus.ESTIMATED.name, task.status); }); }
public async void Post_ShouldChangeTaskStatusToVoting() { ClearTasksFromDatabase(); var task = new ProjectTask() { title = "Zadanie testowe", RoomId = 1, status = TaskStatus.UNESTIMATED.name }; context.ProjectTask.Add(task); context.SaveChanges(); context.Entry(task).State = EntityState.Detached; var controller = new ProjectTasksController(context); var result = await controller.UpdateTaskStatus(task.id, TaskStatus.VOTING.name); var updatedTask = context.ProjectTask.First(t => t.id == task.id); var typeResult = Assert.IsType <NoContentResult>(result); Assert.Equal(204, typeResult.StatusCode); Assert.Equal(TaskStatus.VOTING.name, updatedTask.status); }