public void Execute(McNxtBrick brick, SortRail sortRail, BallPosition position)
        {
            int tacho = sortRail.GetTachoToPosition(position);
            MotorDirection motorDirection = MotorDirection.Forward;

            if (tacho < 0)
            {
                motorDirection = MotorDirection.Backward;
            }

            var absTacho = (uint)Math.Abs(tacho);

            if (absTacho != 0)
            {

                Debug.WriteLine("Heading for position {0} with tacho {1}",
                                position,
                                tacho);

                int resultTacho = MotorHelper.RunAndWaitOnCompletion(
                    (McNxtMotor)brick.MotorA,
                    absTacho,
                    motorDirection);

                sortRail.CurrentTacho += resultTacho;
            }
        }
 public RobotSwapBallsCommandSequence(SortRobot robot, SortRail sortRail, BallPosition leftBallPosition,
                                      BallPosition rightBallPosition)
 {
     _robot = robot;
     _sortRail = sortRail;
     _leftBallPosition = leftBallPosition;
     _rightBallPosition = rightBallPosition;
 }
            public void ShouldFailOnPosition15()
            {
                // Arange
                var sortRail = new SortRail();

                // Act
                SortRailLegoPosition result = sortRail[(BallPosition) 15];

                // Assert
                // Expected exception
            }
            public void ShouldFailOnPosition15()
            {
                // Arange
                var sortRail = new SortRail();

                // Act
                sortRail.GetTachoToPosition((BallPosition) 15);

                // Assert
                // Expected exception thrown
            }
            public void ShouldReturnPositionTacho45OnBallPivot()
            {
                // Arange
                var sortRail = new SortRail();
                const int excpected = 45;

                // Act
                SortRailLegoPosition result = sortRail[BallPosition.Swap];

                // Assert
                Assert.AreEqual(excpected, result.Position);
            }
            public void ShouldReturnPositionTacho0OnBallHome()
            {
                // Arange
                var sortRail = new SortRail();
                const int excpected = 0;

                // Act
                SortRailLegoPosition result = sortRail[BallPosition.Home];

                // Assert
                Assert.AreEqual(excpected, result.Position);
            }
            public void ShouldHold15Positions()
            {
                // Arange
                var sortRail = new SortRail();
                const int expected = 15;

                // Act
                // None

                // Assert
                Assert.AreEqual(expected, sortRail.Count);
            }
            public void ShouldHaveCurrentTachoZero()
            {
                // Arange
                var sortRail = new SortRail();
                const int expected = 0;

                // Act
                // None

                // Assert
                Assert.AreEqual(expected, sortRail.CurrentTacho);
            }
            public void ShouldReturn1000ForBall6ByCurrentTacho1640()
            {
                // Arange
                var sortRail = new SortRail {CurrentTacho = 1640};
                const int expected = 1000;

                // Act
                int result = sortRail.GetTachoToPosition(BallPosition.Six);

                // Assert
                Assert.AreEqual(expected, result);
            }
            public void ShouldReturn0ForBallPivotByCurrentTacho4950()
            {
                // Arange
                var sortRail = new SortRail {CurrentTacho = 4950};
                const int expected = 0;

                // Act
                int result = sortRail.GetTachoToPosition(BallPosition.Swap);

                // Assert
                Assert.AreEqual(expected, result);
            }
            //[TestMethod]
            public void ShouldBe4950WhenCurrentTachoIsSetAbove4950()
            {
                // Arange
                var sortRail = new SortRail();
                const int tooHighTachoValue = 4951;
                const int expected = 4950;

                // Act
                sortRail.CurrentTacho = tooHighTachoValue;

                // Assert
                Assert.AreEqual(expected, sortRail.CurrentTacho);
            }
            public void ShouldBe1000WhenCurrentTachoIsSetTo1000()
            {
                // Arange
                var sortRail = new SortRail();
                const int setValue = 1000;
                const int expected = 1000;

                // Act
                sortRail.CurrentTacho += setValue;

                // Assert
                Assert.AreEqual(expected, sortRail.CurrentTacho);
            }
            //[TestMethod]
            public void Should0WhenCurrentTachoIsSetBelowZero()
            {
                // Arange
                var sortRail = new SortRail();
                const int tooLowTachoValue = -1;
                const int expected = 0;

                // Act
                sortRail.CurrentTacho = tooLowTachoValue;

                // Assert
                Assert.AreEqual(expected, sortRail.CurrentTacho);
            }
Exemplo n.º 14
0
 public void InitRobot()
 {
     _robot = new SortRobot();
     _sortRail = new SortRail();
 }
 public RobotMoveToPosition(SortRobot robot, SortRail sortRail, BallPosition position)
 {
     _robot = robot;
     _sortRail = sortRail;
     _position = position;
 }
 public RobotScanAllColorsCommandSequence(SortRobot robot, SortRail sortRail)
 {
     _robot = robot;
     _sortRail = sortRail;
 }