Ejemplo n.º 1
0
            public void When_LandingSurfaceSizeCommand_type_returns_new_object_from_factory_with_parsed_values(
                string landingSurfaceSizeCommand, int expectedWidth, int expectedHeight)
            {
                var expectedSize = new Size(expectedWidth, expectedHeight);
                var expectedCommand = new Mock<ILandingSurfaceSizeCommand>();
                Func<Size, ILandingSurfaceSizeCommand> factory = size =>
                {
                    expectedCommand.Setup(x => x.Size).Returns(size);
                    return expectedCommand.Object;
                };
                var mockCommandMatcher = createMockCommandMatcher(CommandType.LandingSurfaceSizeCommand);

                var commandParser = new CommandParser(mockCommandMatcher.Object, factory, null, null);
                var actualCommand = (ILandingSurfaceSizeCommand) commandParser.Parse(landingSurfaceSizeCommand).First();

                Assert.AreEqual(expectedCommand.Object, actualCommand);
                Assert.AreEqual(expectedSize, actualCommand.Size);
            }
Ejemplo n.º 2
0
            public void When_RoverExploreCommand_type_returns_new_command_from_factory_with_parsed_values(
                string roverExploreCommand, Movement expectedFirstMovement, Movement expectedSecondMovement, 
                Movement expectedThirdMovement)
            {
                var expectedCommand = new Mock<IRoverExploreCommand>();
                Func<IList<Movement>, IRoverExploreCommand> factory = movements =>
                {
                    expectedCommand.Setup(x => x.Movements).Returns(movements);
                    return expectedCommand.Object;
                };
                var mockCommandMatcher = createMockCommandMatcher(CommandType.RoverExploreCommand);

                var commandParser = new CommandParser(mockCommandMatcher.Object, null, null, factory);
                var actualCommand = (IRoverExploreCommand) commandParser.Parse(roverExploreCommand).First();

                Assert.AreEqual(expectedCommand.Object, actualCommand);
                Assert.AreEqual(expectedFirstMovement, actualCommand.Movements[0]);
                Assert.AreEqual(expectedSecondMovement, actualCommand.Movements[1]);
                Assert.AreEqual(expectedThirdMovement, actualCommand.Movements[2]);
            }
Ejemplo n.º 3
0
            public void When_RoverDeployCommand_type_returns_new_command_from_factory_with_parsed_values(
                string roverDeployCommand, int expectedX, int expectedY, CardinalDirection expectedCardinalDirection)
            {
                var expectedPoint = new Point(expectedX, expectedY);
                var expectedCommand = new Mock<IRoverDeployCommand>();
                Func<Point, CardinalDirection, IRoverDeployCommand> factory = (point, direction) =>
                {
                    expectedCommand.Setup(x => x.DeployPoint).Returns(point);
                    expectedCommand.Setup(x => x.DeployDirection).Returns(direction);
                    return expectedCommand.Object;
                };
                var mockCommandMatcher = createMockCommandMatcher(CommandType.RoverDeployCommand);

                var commandParser = new CommandParser(mockCommandMatcher.Object, null, factory, null);
                var actualCommand = (IRoverDeployCommand) commandParser.Parse(roverDeployCommand).First();

                Assert.AreEqual(expectedCommand.Object, actualCommand);
                Assert.AreEqual(expectedPoint, actualCommand.DeployPoint);
                Assert.AreEqual(expectedCardinalDirection, actualCommand.DeployDirection);
            }