public void AddHistoricalCommandAsNullTest() { var terminalState = new TerminalState(); var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(10); var isAddHistoricalCommandSuccess = terminalState.TryAddHistoricalCommand(null); Assert.IsTrue(isHistoryLimitSet); Assert.IsFalse(isAddHistoricalCommandSuccess); }
public void SetInputHistoryLimitTest() { var terminalState = new TerminalState(); var expected = 20; var isLimitSet = terminalState.TrySetCommandHistoryLimit(expected); var actual = terminalState.GetCommandHistoryLimit(); Assert.IsTrue(isLimitSet); Assert.AreEqual(expected, actual); }
public void InitializeTerminalState(TerminalState terminalState, int inputLengthCharacterLimit, int inputHistoryLimit) { Debug.Assert(inputLengthCharacterLimit > 0, "Input length character limit is invalid."); Debug.Assert(inputHistoryLimit > 0, "Input history limit is invalid."); var isInputLengthSetSuccess = terminalState.TrySetTerminalInputLengthLimit(inputLengthCharacterLimit); var isInputHistorySetSuccess = terminalState.TrySetCommandHistoryLimit(inputHistoryLimit); Debug.Assert(isInputLengthSetSuccess, "Failed to set maximum input length."); Debug.Assert(isInputHistorySetSuccess, "Failed to set maximum input history limit."); }
public void AddHistoricalCommandWithEmptyOutputTest() { var terminalState = new TerminalState(); var terminalCommand = new TerminalCommand { TerminalCommandInput = "testInput", TerminalCommandOutput = string.Empty }; var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(10); var isAddHistoricalCommandSuccess = terminalState.TryAddHistoricalCommand(terminalCommand); Assert.IsTrue(isHistoryLimitSet); Assert.IsFalse(isAddHistoricalCommandSuccess); }
public void HistoricalCommandIsVisibleByDefaultTest() { var terminalState = new TerminalState(); var terminalCommand = new TerminalCommand { TerminalCommandInput = "testInput", TerminalCommandOutput = "testOutput" }; var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(10); var isAddSuccess = terminalState.TryAddHistoricalCommand(terminalCommand); var previousCommands = terminalState.GetPreviousTerminalCommands(); var previousCommand = previousCommands.FirstOrDefault(); Assert.IsTrue(isHistoryLimitSet); Assert.IsTrue(isAddSuccess); Assert.IsTrue(previousCommand.IsVisibleInTerminal); }
public void AddHistoricalCommandTest() { var terminalState = new TerminalState(); var terminalCommand = new TerminalCommand { TerminalCommandInput = "testInput", TerminalCommandOutput = "testOutput" }; var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(10); var isAddHistoricalCommandSuccess = terminalState.TryAddHistoricalCommand(terminalCommand); var previousCommands = terminalState.GetPreviousTerminalCommands(); Assert.IsTrue(isHistoryLimitSet); Assert.IsTrue(isAddHistoricalCommandSuccess); Assert.IsNotNull(previousCommands); Assert.IsNotEmpty(previousCommands); Assert.IsTrue(previousCommands.Contains(terminalCommand)); }
public void DoNotRemoveHistoricalCommandWhenUnderLimitTest() { var terminalState = new TerminalState(); var terminalCommand = new TerminalCommand { TerminalCommandInput = "testInput", TerminalCommandOutput = "testOutput" }; var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(5); var isAddSuccess = terminalState.TryAddHistoricalCommand(terminalCommand); var isRemoveSuccess = terminalState.TryRemoveOldestHistoricalCommand(); var previousCommands = terminalState.GetPreviousTerminalCommands(); Assert.IsTrue(isHistoryLimitSet); Assert.IsTrue(isAddSuccess); Assert.IsFalse(isRemoveSuccess); Assert.IsTrue(previousCommands.Contains(terminalCommand)); Assert.IsNotEmpty(previousCommands); }
public void AddHistoricalCommandWhenAtLimitTest() { var terminalState = new TerminalState(); var underLimitTerminalCommand = new TerminalCommand { TerminalCommandInput = "underLimitInput", TerminalCommandOutput = "underLimitOutput" }; var overLimitTerminalCommand = new TerminalCommand { TerminalCommandInput = "overLimitInput", TerminalCommandOutput = "overLimitOutput" }; var isHistoryLimitSet = terminalState.TrySetCommandHistoryLimit(1); var isUnderLimitAddHistoricalCommandSuccess = terminalState.TryAddHistoricalCommand(underLimitTerminalCommand); var isOverLimitAddHistoricalCommandSuccess = terminalState.TryAddHistoricalCommand(overLimitTerminalCommand); var previousCommands = terminalState.GetPreviousTerminalCommands(); Assert.IsTrue(isHistoryLimitSet); Assert.IsTrue(isUnderLimitAddHistoricalCommandSuccess); Assert.IsFalse(isOverLimitAddHistoricalCommandSuccess); Assert.IsTrue(previousCommands.Contains(underLimitTerminalCommand)); Assert.IsFalse(previousCommands.Contains(overLimitTerminalCommand)); }