コード例 #1
0
        public void RobotSimulator_Run_Movement_test_File_ExecuteAsExpected(string fileName)
        {
            // Arrange

            // Act
            List <string[]> commandsInput = inputProcessor.ReadCommandsFromFile(fileName);

            // Assert
            Assert.True(commandsInput != null);
        }
コード例 #2
0
        /// <summary>Runs simulator with data from the specified input file.</summary>
        /// <param name="inputFile">The input file name.</param>
        /// <exception cref="ArgumentNullException">Input text file must be provided.</exception>
        public void Run(string inputFile)
        {
            if (string.IsNullOrEmpty(inputFile))
            {
                throw new ArgumentNullException("Input text file must be provided.");
            }
            try
            {
                List <string[]> commandList = new List <string[]>();
                commandList = _userInput.ReadCommandsFromFile(inputFile);

                if (commandList == null || commandList.Count == 0)
                {
                    Console.WriteLine($"Unable to retrieve commands from the text file {inputFile}.");
                    return;
                }

                Console.WriteLine("\n================================");
                foreach (var command in commandList)
                {
                    ExecuteCommand(command);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }
        }