Exemplo n.º 1
0
        public void Test_MultipleMoveCommands_AddPositionMethodCalledCorrectly()
        {
            //Arrange
            var positionContextMock = new Mock <IRobotPositioningContext>();

            positionContextMock.Setup(x => x.GetCurrentPosition()).Returns(new Position(10, 40));
            Command moveNorthCommand = new MoveNorthCommand(2, positionContextMock.Object);

            // Act
            moveNorthCommand.Execute();
            Command moveSouthCommand = new MoveEastCommand(4, positionContextMock.Object);

            moveSouthCommand.Execute();

            // Assert
            positionContextMock.Verify(x => x.AddPosition(It.IsAny <Position>()), Times.Exactly(6));
        }
Exemplo n.º 2
0
        public void IncrementXAxisOfPosition()
        {
            var testTrackingModule = new TrackingModule()
            {
                GridMaximumX = 2,
                GridMaximumY = 2,
                Position = new Position(1, 1, Orientation.E)
            };

            var testMoveEastCommand = new MoveEastCommand();

            testMoveEastCommand.Execute(testTrackingModule);

            var position = testTrackingModule.Position;

            position.Y.Should().Be(1);
            position.X.Should().Be(2);
            position.Orientation.Should().Be(Orientation.E);
        }