Ejemplo n.º 1
0
 public void Antenna_Move_InvalidInstructionInSet_Exception()
 {
     Assert.Throws <Exception>(() =>
     {
         var antenna = new Antenna(_mockNavigationConfig.Object, _mockRoverEngine.Object);
         var result  = antenna.Move("FBWL");
     }, "There's an invalid instruction in set FBWL!");
 }
Ejemplo n.º 2
0
        public void Antenna_Move_InstructionsEmpty_Exception()
        {
            Assert.Throws <Exception>(() =>
            {
                var antenna = new Antenna(_mockNavigationConfig.Object, _mockRoverEngine.Object);

                var result = antenna.Move(" ");
            }, "The instructions cannot be empty!");
        }
Ejemplo n.º 3
0
        public void Antenna_Move_L_CallTurnLeft()
        {
            _mockRoverEngine.Setup(m => m.TurnLeft()).Returns(new MoveResult(new Position(1, 1, EDirection.W), false));

            var antenna = new Antenna(_mockNavigationConfig.Object, _mockRoverEngine.Object);

            antenna.Move("L");

            _mockRoverEngine.Verify(m => m.TurnLeft(), Times.Once);
        }
Ejemplo n.º 4
0
        public void Antenna_Move_VerifySequentialOrder()
        {
            var instructions = "BLFR";
            var callOrder    = 0;

            var dummyResult     = new MoveResult(new Position(2, 2, EDirection.S), false);
            var finalMoveResult = new MoveResult(new Position(1, 1, EDirection.N), false);

            _mockRoverEngine.Setup(m => m.MoveBack()).Callback(() => Assert.That(callOrder++ == 0)).Returns(dummyResult);
            _mockRoverEngine.Setup(m => m.TurnLeft()).Callback(() => Assert.That(callOrder++ == 1)).Returns(dummyResult);
            _mockRoverEngine.Setup(m => m.MoveForward()).Callback(() => Assert.That(callOrder++ == 2)).Returns(dummyResult);
            _mockRoverEngine.Setup(m => m.TurnRight()).Callback(() => Assert.That(callOrder++ == 3)).Returns(finalMoveResult);

            var antenna = new Antenna(_mockNavigationConfig.Object, _mockRoverEngine.Object);

            var result = antenna.Move(instructions);

            Assert.IsNotNull(result);
            Assert.AreEqual(finalMoveResult, result);
        }