Пример #1
0
        public void Factory_ShouldReturnPlaceCommandWithParams()
        {
            // Arrange
            CommandFactory factory = new CommandFactory();

            // Act
            ICommand command = factory.create("PLACE 2,3,NORTH");

            // Assert
            Assert.AreEqual(typeof(PlaceCommand), command.GetType());
        }
Пример #2
0
        public void Factory_ShouldReturnRightCommand()
        {
            // Arrange
            CommandFactory factory = new CommandFactory();

            // Act
            ICommand command = factory.create("RIGHT");

            // Assert
            Assert.AreEqual(typeof(RightCommand), command.GetType());
        }
Пример #3
0
        public IEnumerable<ICommand> Parse(string commandString,CommandFactory factory)
        {
            List<ICommand> commandList = new List<ICommand>();
            string[] commandLines = commandString.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            foreach (string commandline in commandLines)
            {
                commandList.Add(factory.create(commandline));
            }
            return commandList;
        }
Пример #4
0
        public void Factory_withBadParamsShouldThrowException()
        {
            // Arrange
            CommandFactory factory = new CommandFactory();

            // Act
            ICommand command = factory.create("PLACE 2,3,NOdRTH");

            // Assert
            // Should throw exeption
        }