public void ParseString_CanThrowOnAbortInput() { // Arrange var userInputMock = GetSetupUserInput(Constants.AbortGamePhrase); var systemUnderTest = new UserInputParser(userInputMock, _userOutputMock); // Act Action action = () => systemUnderTest.TryGetNotEmptyString( FieldName, out _, Constants.AbortGamePhrase); // Assert action.Should().Throw <GameAbortException>(); }
public void ParseChar_CanHandleInvalidInput(string inputString) { // Arrange var userInputMock = GetSetupUserInput(inputString); var systemUnderTest = new UserInputParser(userInputMock, _userOutputMock); // Act var isParsed = systemUnderTest.TryGetCharLetter(FieldName, out _); // Assert isParsed.Should() .BeFalse(); }
// Initialization public void Start() { _fileSystemState = new FileSystemState(); _terminalState = new TerminalState(); _commandState = new CommandState(); _directoryController = new DirectoryController(); _fileController = new FileController(); _permissionController = new PermissionController(); _userInterfaceController = new UserInterfaceController(); _commandController = new CommandController(); _terminalStateInitializer = new TerminalStateInitializer(); _fileSystemStateInitializer = new FileSystemStateInitializer(); _commandStateInitializer = new CommandStateInitializer(); _userInterfaceInitializer = new UserInterfaceInitializer(); _userInputParser = new UserInputParser(); // Initialize the state of each system piece for game start _terminalStateInitializer.InitializeTerminalState(_terminalState, InputLengthCharacterLimit, InputHistoryLimit); _terminalStateInitializer.ClearTerminalState(_terminalState); var commandsInitialized = _commandStateInitializer.InitializeCommandState( _commandState, _terminalState, _fileSystemState, _directoryController); _fileSystemStateInitializer.InitializeFileSystemState( _fileSystemState, _permissionController, _directoryController); _fileSystemStateInitializer.InitializeCommandsInFileSystemState( _fileSystemState, _permissionController, _directoryController, _fileController, commandsInitialized); _userInterfaceInitializer.InitializeConsoleText( _userInterfaceController, _fileSystemState, _directoryController, InputTextObject, OutputTextObject); }
public void ParseChar_CanParseCorrectChar(string inputString, char expectedChar) { // Arrange var userInputMock = GetSetupUserInput(inputString); var systemUnderTest = new UserInputParser(userInputMock, _userOutputMock); // Act var isParsed = systemUnderTest.TryGetCharLetter(FieldName, out var parsedValue); // Assert isParsed.Should() .BeTrue(); parsedValue.Should() .Be(expectedChar); }
public void ParseString_CanHandleEmptyString(string inputString) { // Arrange var userInputMock = GetSetupUserInput(inputString); var systemUnderTest = new UserInputParser(userInputMock, _userOutputMock); // Act var isParsed = systemUnderTest.TryGetNotEmptyString(FieldName, out var parsedValue); // Assert isParsed.Should() .BeFalse(); parsedValue.Should() .Be(string.Empty); }
public void Save(ITaskList list, UserInputParser input) { string saveFileName = _fileName; while (string.IsNullOrWhiteSpace(saveFileName)) { Console.WriteLine("Please enter the filename that you would like to save to:"); saveFileName = input.GetString(); } try { _storage.Save(saveFileName, list); _fileName = saveFileName; Console.WriteLine(string.Format("Task List saved to {0}.", saveFileName)); } catch (Exception e) { Console.WriteLine(string.Format("Unable to save task data. {0}", e.Message)); } }
public void TestInitialize() { mockAppSettings = new Mock <IAppSettings>(); userInputParser = new UserInputParser(mockAppSettings.Object); }
public void Setup() { _userInputParser = new UserInputParser(); }