Example #1
0
 public void ReadStateNextStateIsNull()
 {
     IConsole mockConsole = Substitute.For<IConsole>();
     ILog mockLog = Substitute.For<ILog>();
     ITodoList mockTodoList = Substitute.For<ITodoList>();
     ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
     Assert.IsNull(state.GetNextState());
 }
Example #2
0
        public void ReadStateReturnsNullStateWhenReadingBlankString()
        {
            IConsole mockConsole = Substitute.For<IConsole>();
            ILog mockLog = Substitute.For<ILog>();
            ITodoList mockTodoList = Substitute.For<ITodoList>();
            ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
            state.Execute();

            Assert.IsNull(state.GetNextState());
        }
Example #3
0
        public void ReadStateReadsConsoleWhenExecuted()
        {
            IConsole mockConsole = Substitute.For<IConsole>();
            ILog mockLog = Substitute.For<ILog>();
            ITodoList mockTodoList = Substitute.For<ITodoList>();
            ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
            state.Execute();

            mockConsole.Received(1).GetInput();
        }
Example #4
0
        public void ReadStateOutputsPromptCharacter()
        {
            IConsole mockConsole = Substitute.For<IConsole>();
            ILog mockLog = Substitute.For<ILog>();
            ITodoList mockTodoList = Substitute.For<ITodoList>();
            ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
            state.Execute();

            mockConsole.Received(1).Output(">");
        }
Example #5
0
        public void ReadStateReturnsCommandStateWhenReadingCommand()
        {
            IConsole mockConsole = Substitute.For<IConsole>();
            mockConsole.GetInput().Returns(">COMMANDSTRING");

            ILog mockLog = Substitute.For<ILog>();
            ITodoList mockTodoList = Substitute.For<ITodoList>();
            ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
            state.Execute();

            State nextState = state.GetNextState();
            Assert.IsInstanceOfType(nextState, typeof(CommandLogState));
            Assert.AreEqual("COMMANDSTRING", nextState.Input);
        }
Example #6
0
        public void ReadStateReturnsStoreStateWhenReadingPlainText()
        {
            const string cConsoleInput = "This is plain text";
            IConsole mockConsole = Substitute.For<IConsole>();
            mockConsole.GetInput().Returns(cConsoleInput);

            ILog mockLog = Substitute.For<ILog>();
            ITodoList mockTodoList = Substitute.For<ITodoList>();
            ReadState state = new ReadState(mockConsole, mockLog, mockTodoList);
            state.Execute();

            State nextState = state.GetNextState();
            Assert.IsInstanceOfType(nextState, typeof(StoreState));
            Assert.AreEqual(cConsoleInput, nextState.Input);
        }
Example #7
0
 public void ReadStateThrowsExceptionWhenPassedNullTodoList()
 {
     ILog mockLog = Substitute.For<ILog>();
     IConsole mockConsole = Substitute.For<IConsole>();
     ITodoList mockTodoList = Substitute.For<ITodoList>();
     State state = new ReadState(mockConsole, mockLog, null);
 }