Пример #1
0
 public Task CreateNewTask()
 {
     //TO DO: need to add identifier to task
     Task task = new Task();
     task.Number = context.Tasks.Count() + 1;
     context.Tasks.Add(task);
     return task;
 }
Пример #2
0
 public void SaveTask_WhenGivenATask_ShouldSaveItViaContext()
 {
     // Arrange
     var task = new Task();
     var taskHandler = GetTaskHandler();
     // Act
     taskHandler.SaveTasks();
     // Assert
     context.Verify(x => x.SaveChanges());
 }
 public void Execute_WhenGivenACreateNewTaskCommand_ShouldAddTheAffectedTaskToTheCommand()
 {
     // Arrange
     var newTask = new Task();
     var command = new Command
     {
         Verb = "create new task",
         Argument = "do the laundry",
         Line = "create new task do the laundry",
         Response = "created new task!",
         IsValid = true
     };
     taskHandler.Setup(t => t.CreateNewTask()).Returns(newTask);
     var executer = GetExecuter();
     // Act
     executer.Execute(command);
     // Assert
     Assert.AreSame(expected: newTask, actual: command.AffectedTask);
 }
 public void Execute_WhenGivenCompleteTaskCommand_ShouldCompleteTheTaskViaTheTaskHandler()
 {
     // Arrange
     var taskToComplete = new Task();
     var command = new Command
         {
             Verb = "complete task",
             Argument = "do the laundry",
             Line = "complete task do the laundry",
             Response = "task completed!",
             IsValid = true
         };
     taskHandler.Setup(x => x.FindTask(command.Argument)).Returns(taskToComplete);
     taskHandler.Setup(x => x.CompleteTask(taskToComplete));
     // Act
     GetExecuter().Execute(command);
     // Assert
     taskHandler.Verify(x => x.FindTask(command.Argument));
     taskHandler.Verify(x => x.CompleteTask(taskToComplete));
 }
 public void Execute_WhenGivenACreateNewTaskCommand_ShouldCreateANewTaskViaTheTaskHandler()
 {
     // Arrange
     var newTask = new Task();
     var command = new Command
         {
             Verb = "create new task",
             Argument = "do the laundry",
             Line = "create new task do the laundry",
             Response = "created new task!",
             IsValid = true
         };
     taskHandler.Setup(t => t.CreateNewTask()).Returns(newTask);
     var executer = GetExecuter();
     // Act
     executer.Execute(command);
     // Assert
     taskHandler.Verify(t => t.CreateNewTask());
     taskHandler.Verify(t => t.SaveTasks());
 }
Пример #6
0
 public void CompleteTask(Task task)
 {
     task.Status = Status.Completed;
 }