public void GetCommands_ReadFileWithOneCommand_GetOneCommand()
        {
            //Arrange
            var commandsFile   = @"PLACE 1,1,NORTH";
            var mockFileReader = new Mock <IFileReader>();

            mockFileReader.Setup(mockFileReader => mockFileReader.ReadAllText(It.IsAny <string>(), It.IsAny <string>())).Returns(commandsFile);
            CommandsReader commandsReader = new CommandsReader(mockFileReader.Object);

            //Act
            string[] commands = commandsReader.GetCommands("directory", "filePath");

            //Assert
            Assert.AreEqual(1, commands.Length);
            Assert.AreEqual("PLACE 1,1,NORTH", commands[0]);
        }
Пример #2
0
        static void Main(string[] args)
        {
            IErrorReporter errorReporter = new ErrorReporter();

            try
            {
                var      commandsReader = new CommandsReader(new SystemIoFileReader());
                string[] commands       = commandsReader.GetCommands("Resources", "commands.txt");

                IPlaceManager placeManager      = new PlaceManager();
                var           toyRobotSimulator = new Simulator(placeManager, errorReporter);
                toyRobotSimulator.Run(commands);
            }
            catch (Exception exception)
            {
                errorReporter.Send(exception);
            }
            Console.Read();
        }
        public void GetCommands_NoDirectory_ThrowsException()
        {
            //Arrange
            var            mockFileReader = new Mock <IFileReader>();
            CommandsReader commandsReader = new CommandsReader(mockFileReader.Object);

            //Act and Assert
            ArgumentNullException exception = Assert.Throws <ArgumentNullException>(() => commandsReader.GetCommands(null, null));

            Assert.AreEqual("Value cannot be null. (Parameter 'directory')", exception.Message);
        }