示例#1
0
        public void StoreTodoStateStoresTextInTodoList()
        {
            ILog           mockLog      = Substitute.For <ILog>();
            IConsole       mockConsole  = Substitute.For <IConsole>();
            ITodoList      mockTodoList = Substitute.For <ITodoList>();
            StoreTodoState state        = new StoreTodoState(mockConsole, mockLog, mockTodoList);

            state.Input = "This is the entry text";
            state.Execute();

            mockTodoList.Received(1).AddEntry(Arg.Is <TodoEntry>(entry => entry.Text == state.Input));
        }
示例#2
0
        public void RemoveTodoItemStateRequestsItemIdToRemoveUntilValidIdIsProvided()
        {
            ILog      mockLog      = Substitute.For <ILog>();
            IConsole  mockConsole  = Substitute.For <IConsole>();
            ITodoList mockTodoList = Substitute.For <ITodoList>();

            const UInt32 cTodoItemId = 0;

            mockConsole.GetInput().Returns("", "-1", "NOT A NUMBER", cTodoItemId.ToString());

            RemoveTodoItemState state = new RemoveTodoItemState(mockConsole, mockLog, mockTodoList);

            state.Execute();

            mockConsole.Received(4).Output("Enter the item ID to remove");
            mockConsole.Received(4).GetInput();
            mockTodoList.Received(1).RemoveEntry(cTodoItemId);
        }
示例#3
0
        public void RemoveTodoItemStateRequestsItemIdToRemove()
        {
            ILog      mockLog      = Substitute.For <ILog>();
            IConsole  mockConsole  = Substitute.For <IConsole>();
            ITodoList mockTodoList = Substitute.For <ITodoList>();

            const UInt32 cTodoItemId = 0;

            mockConsole.GetInput().Returns(cTodoItemId.ToString());

            RemoveTodoItemState state = new RemoveTodoItemState(mockConsole, mockLog, mockTodoList);

            state.Execute();

            mockConsole.Received(1).Output("Enter the item ID to remove");
            mockConsole.Received(1).GetInput();
            mockTodoList.Received(1).RemoveEntry(cTodoItemId);

            Assert.IsInstanceOfType(state.GetNextState(), typeof(ReadTodoState));
        }
 public void command_should_complete_task()
 {
     command.ExecuteCommand();
     todoList.Received().CompleteTask(1);
 }
 public void command_should_rename_task()
 {
     command.ExecuteCommand();
     todoList.Received().RenameTask(1, "new task");
 }
示例#6
0
 public void command_should_clear_date()
 {
     command.ExecuteCommand();
     todoList.Received().ClearDate(1);
 }