public CalculatorReplLoop() { commandInputParser = new CommandInputParser(); calculator = new Calculator(); inputService = new InputService(); outputService = new OutputService(); }
public void ParseCommandInput_Test(IReadOnlyList <string> commandLineArguments, CommandInput expectedCommandInput) { // Arrange var parser = new CommandInputParser(); // Act var commandInput = parser.ParseCommandInput(commandLineArguments); // Assert commandInput.Should().BeEquivalentTo(expectedCommandInput); }
public void Run() { while (true) { string command = InputService.ReadCommand(); try { CommandTypes commandType = CommandInputParser.ParseCommand(command); Arguments arguments = InputService.ReadArguments(); OutputService.WriteResult(Calculator.Calculate(commandType, arguments).ToString()); } catch (Exception) { Console.WriteLine("Mistake!"); } } }