Esempio n. 1
0
        public void Spin(Direction startingDirection, SpinCommand spinCommand, Direction expectedDirection)
        {
            marsRover = new MarsRover(1, 1, startingDirection);

            marsRover.Spin(spinCommand);

            Assert.AreEqual(expectedDirection, marsRover.FacingDirection);
        }
Esempio n. 2
0
        /// <summary>Turns Spinning on and off</summary>
        /// <param name="shouldSpin">True to enable spinning</param>
        void ControlSpinning(SpinCommand spinCommand)
        {
            if (spinCommand == SpinCommand.SpinUp)
            {
                switch (theSpinState)
                {
                case SpinState.NotSpinning:

                    BeginSpinningAnimation();
                    SetValue(SpinningPropertyKey, true);     // Spinning = true;
                    break;

                case SpinState.Decelerating:

                    spinAnimation.Completed -= RemoveAnimation;
                    spinAnimation.Completed += ReBeginAnimation;

                    break;

                case SpinState.Accelerating:
                case SpinState.Running:
                    break;
                }
            }
            else if (spinCommand == SpinCommand.SpinDown)
            {
                switch (theSpinState)
                {
                case SpinState.NotSpinning:
                    break;

                case SpinState.Decelerating:
                    break;

                case SpinState.Accelerating:

                    spinAnimation.Completed -= SpinContinuously;

                    DecelerateAndStopTheAnimation();
                    break;

                case SpinState.Running:

                    DecelerateAndStopTheAnimation();
                    break;
                }
            }
            else
            {
            }
        }
Esempio n. 3
0
 private bool ExecuteInternal(char character, IRobotWars robot, IValidateCommand validation)
 {
     if (validation.IsMoveCommand(character.ToString(CultureInfo.InvariantCulture)))
     {
         ICommand command = new MoveCommand();
         command.Execute(character, robot);
     }
     else
     {
         ICommand command = new SpinCommand();
         command.Execute(character, robot);
     }
     return(true);
 }
Esempio n. 4
0
        public void Spin(SpinCommand command)
        {
            int spinValue = 0;

            if (command == SpinCommand.LEFT)
            {
                spinValue = (int)FacingDirection - 1 == -1 ? 3 : (int)FacingDirection - 1;
            }

            if (command == SpinCommand.RIGHT)
            {
                spinValue = (int)FacingDirection + 1 == 4 ? 0 : (int)FacingDirection + 1;
            }
            FacingDirection = (Direction)spinValue;
        }
Esempio n. 5
0
 public override void Setup()
 {
     base.Setup();
     this.command = new SpinCommand();
 }
        /// <summary>Turns Spinning on and off</summary>
        /// <param name="shouldSpin">True to enable spinning</param>
        void ControlSpinning(SpinCommand spinCommand)
        {
            if (spinCommand == SpinCommand.SpinUp)
            {
                switch (theSpinState)
                {
                    case SpinState.NotSpinning:

                        BeginSpinningAnimation();
                        SetValue(SpinningPropertyKey, true); // Spinning = true;
                        break;

                    case SpinState.Decelerating:

                        spinAnimation.Completed -= RemoveAnimation;
                        spinAnimation.Completed += ReBeginAnimation;

                        break;

                    case SpinState.Accelerating:
                    case SpinState.Running:
                        break;
                }
            }
            else if (spinCommand == SpinCommand.SpinDown)
            {
                switch (theSpinState)
                {
                    case SpinState.NotSpinning:
                        break;

                    case SpinState.Decelerating:
                        break;

                    case SpinState.Accelerating:

                        spinAnimation.Completed -= SpinContinuously;

                        DecelerateAndStopTheAnimation();
                        break;

                    case SpinState.Running:

                        DecelerateAndStopTheAnimation();
                        break;
                }
            }
            else
            {
            }
        }
        /// <summary>Turns Spinning on and off</summary>
        /// <param name="shouldSpin">True to enable spinning</param>
        void ControlSpinning(SpinCommand spinCommand)
        {
            if (spinCommand == SpinCommand.SpinUp)
            {
                switch (theSpinState)
                {
                case SpinState.NotSpinning:
                    Assert.That(spinAnimation, Is.Null);
                    Assert.That(Spinning, Is.False);

                    BeginSpinningAnimation();
                    SetValue(SpinningPropertyKey, true);     // Spinning = true;
                    break;

                case SpinState.Decelerating:
                    Assert.That(spinAnimation, Is.Not.Null);
                    Assert.That(Spinning, Is.True);

                    spinAnimation.Completed -= RemoveAnimation;
                    spinAnimation.Completed += ReBeginAnimation;

                    break;

                case SpinState.Accelerating:
                case SpinState.Running:
                    Assert.That(spinAnimation, Is.Not.Null);
                    Assert.That(Spinning, Is.True);
                    break;
                }
            }
            else if (spinCommand == SpinCommand.SpinDown)
            {
                switch (theSpinState)
                {
                case SpinState.NotSpinning:
                    Assert.That(spinAnimation, Is.Null);
                    Assert.That(Spinning, Is.False);
                    break;

                case SpinState.Decelerating:
                    Assert.That(spinAnimation, Is.Not.Null);
                    Assert.That(Spinning, Is.True);
                    break;

                case SpinState.Accelerating:
                    Assert.That(spinAnimation, Is.Not.Null);
                    Assert.That(Spinning, Is.True);

                    spinAnimation.Completed -= SpinContinuously;

                    DecelerateAndStopTheAnimation();
                    break;

                case SpinState.Running:
                    Assert.That(spinAnimation, Is.Not.Null);
                    Assert.That(Spinning, Is.True);

                    DecelerateAndStopTheAnimation();
                    break;
                }
            }
            else
            {
                Assert.That(false, string.Format("spinCommand is not a valid value - it is {0}", (int)spinCommand));
            }
        }