コード例 #1
0
        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;
            }
        }
コード例 #2
0
 public RobotSwapBallsCommandSequence(SortRobot robot, SortRail sortRail, BallPosition leftBallPosition,
                                      BallPosition rightBallPosition)
 {
     _robot = robot;
     _sortRail = sortRail;
     _leftBallPosition = leftBallPosition;
     _rightBallPosition = rightBallPosition;
 }
コード例 #3
0
            public void ShouldFailOnPosition15()
            {
                // Arange
                var sortRail = new SortRail();

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

                // Assert
                // Expected exception
            }
コード例 #4
0
            public void ShouldFailOnPosition15()
            {
                // Arange
                var sortRail = new SortRail();

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

                // Assert
                // Expected exception thrown
            }
コード例 #5
0
            public void ShouldReturnPositionTacho45OnBallPivot()
            {
                // Arange
                var sortRail = new SortRail();
                const int excpected = 45;

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

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

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

                // Assert
                Assert.AreEqual(excpected, result.Position);
            }
コード例 #7
0
            public void ShouldHold15Positions()
            {
                // Arange
                var sortRail = new SortRail();
                const int expected = 15;

                // Act
                // None

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

                // Act
                // None

                // Assert
                Assert.AreEqual(expected, sortRail.CurrentTacho);
            }
コード例 #9
0
            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);
            }
コード例 #10
0
            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);
            }
コード例 #11
0
            //[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);
            }
コード例 #12
0
            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);
            }
コード例 #13
0
            //[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);
            }
コード例 #14
0
 public void InitRobot()
 {
     _robot = new SortRobot();
     _sortRail = new SortRail();
 }
コード例 #15
0
 public RobotMoveToPosition(SortRobot robot, SortRail sortRail, BallPosition position)
 {
     _robot = robot;
     _sortRail = sortRail;
     _position = position;
 }
コード例 #16
0
 public RobotScanAllColorsCommandSequence(SortRobot robot, SortRail sortRail)
 {
     _robot = robot;
     _sortRail = sortRail;
 }