예제 #1
0
        public void Initialization()
        {
            // Arrange
            var nullAction      = ActionStrategyFabric.GetAction('_');
            var forwardAction   = ActionStrategyFabric.GetAction('F');
            var turnLeftAction  = ActionStrategyFabric.GetAction('L');
            var turnRightAction = ActionStrategyFabric.GetAction('R');

            // Act

            // Assert
            Assert.Null(nullAction);
            Assert.IsType <ForwardAction>(forwardAction);
            Assert.IsType <TurnLeftAction>(turnLeftAction);
            Assert.IsType <TurnRightAction>(turnRightAction);
        }
예제 #2
0
        public void ForwardAction()
        {
            // Arrange
            var fieldMock = new Mock <IField>();

            fieldMock.Setup(f => f.IsMovementAvailable(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <RobotDirections>())).Returns(true);

            var robot         = new Robot(fieldMock.Object, 0, 0, "N", "");
            var robot1        = new Robot(fieldMock.Object, 0, 0, "E", "");
            var forwardAction = ActionStrategyFabric.GetAction('F');

            // Act
            forwardAction.DoAction(fieldMock.Object, robot);
            forwardAction.DoAction(fieldMock.Object, robot1);
            // Assert
            // first robot moves North(Y axis)
            Assert.Equal(0, robot.CurrentX);
            Assert.Equal(1, robot.CurrentY);
            // first robot moves North(X axis)
            Assert.Equal(1, robot1.CurrentX);
            Assert.Equal(0, robot1.CurrentY);
        }