public void TestGetPreviousCommand() { var commandHistory = new CommandHistory(); commandHistory.Add("A0001"); string command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); commandHistory.Add("A0002"); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0002", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); commandHistory.Add("A0003"); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0003", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0002", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); command = commandHistory.GetPreviousCommand(); Assert.AreEqual("A0001", command); }
public void TestEmptyHistoryNavigation() { var commandHistory = new CommandHistory(); string command = commandHistory.GetPreviousCommand(); Assert.IsEmpty(command); command = commandHistory.GetNextCommand(); Assert.IsEmpty(command); }
/// <summary> /// Initializes a new instance of the CommandProcessor class. /// </summary> /// <param name="commandLineTextBox"> /// Control to input commands. /// </param> /// <param name="historyBox"> /// Control for commands and responses history. /// </param> /// <param name="communicationHelper"> /// Class that communicates with robot. /// </param> /// <param name="commandHistory"> /// Class that containts command history. /// </param> public CommandProcessor( TextBox commandLineTextBox, HistoryBox historyBox, ICommunicationHelper communicationHelper, CommandHistory commandHistory) { this.commandLineTextBox = commandLineTextBox; this.historyBox = historyBox; this.communicationHelper = communicationHelper; this.commandHistory = commandHistory; }