Exemplo n.º 1
0
        public void RoverShouldKeepTrackOfItsCurrentPosition()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            var currentPosition = sut.CurrentPosition;

            Assert.Pass();
        }
Exemplo n.º 2
0
        public void RoverShouldAcceptDirectionInstructionsAsString()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            sut.ReceiveDirectionInstructions("");

            Assert.Pass();
        }
Exemplo n.º 3
0
        public void RoverShouldKeepTrackOfItsCurrentHeading()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            var heading = sut.CurrentHeading;

            Assert.Pass();
        }
Exemplo n.º 4
0
        public void RoverShouldCallATranslatorWithTheReceivedInstructionsToGetTheInput()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            sut.ReceiveDirectionInstructions("LMLMLMLMM");

            Assert.AreEqual("LMLMLMLMM", mockTranslator.TranslateMethodParameterValue);
        }
Exemplo n.º 5
0
        public void RoverShouldCallATranslatorToTranslateTheRecevievedInput()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            sut.ReceiveDirectionInstructions("LMLMLMLMM");

            Assert.IsTrue(mockTranslator.TranslateMethodWasCalled);
            Assert.IsInstanceOf<string>(mockTranslator.TranslateMethodParameterValue);
        }
Exemplo n.º 6
0
        public void RoverShouldCallTranslatorWithTheReceivedInstructionsAndStoreTheReturnedRoverInput()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            mockTranslator.TranslateReturnObject = new NavigationCommand(new List<InputCommand> { InputCommand.Left, InputCommand.Move });

            sut.ReceiveDirectionInstructions("LM");

            Assert.IsInstanceOf<NavigationCommand>(sut.Input);
            Assert.AreEqual(mockTranslator.TranslateReturnObject, sut.Input);
        }
Exemplo n.º 7
0
        public void RoverShouldNotExecuteAnInputCommandIfItWillTakeItBelowTheLowerBoundsOfThePlateau()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("0 0", "S", "2 2", mockTranslator);
            mockTranslator.TranslateReturnObject = new NavigationCommand(new List<InputCommand> { InputCommand.Move, InputCommand.Move, InputCommand.Left, InputCommand.Move });

            var returnedPosition = sut.ReceiveDirectionInstructions("MMRM");

            Assert.AreEqual("1 0 E", returnedPosition);
        }
Exemplo n.º 8
0
 public void RoverShouldBeInitializedWithUpperBoundsOfPlateau()
 {
     var mockTranslator = new MockTranslator();
     var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
     Assert.Pass();
 }
Exemplo n.º 9
0
        public void ShouldBeAbleToInitializeRoverCurrentPositionAndHeading()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            Assert.IsNotNull(sut.CurrentHeading);
            Assert.IsNotNull(sut.CurrentPosition);
        }
Exemplo n.º 10
0
        public void RoverShouldUpdateCurrentPositionGivenASetOfInstructions()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            mockTranslator.TranslateReturnObject = new NavigationCommand(new List<InputCommand>{ InputCommand.Left,InputCommand.Move,InputCommand.Left,InputCommand.Move,InputCommand.Left,InputCommand.Move,InputCommand.Left,InputCommand.Move,InputCommand.Move });

            sut.ReceiveDirectionInstructions("LMLMLMLMM");

            var position = sut.CurrentPosition;
            var expectedPosition = new ClassLibrary2.Position(2, 3);

            Assert.AreEqual(expectedPosition.X, position.X);
            Assert.AreEqual(expectedPosition.Y, position.Y);
        }
Exemplo n.º 11
0
        public void RoverShouldUpdateCurrentHeadingGivenASetOfInstructions()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            mockTranslator.TranslateReturnObject = new NavigationCommand(new List<InputCommand> { InputCommand.Left, InputCommand.Move });

            sut.ReceiveDirectionInstructions("LM");

            var heading = sut.CurrentHeading;
            var expectedHeading = HeadingEnum.West;

            Assert.AreEqual(expectedHeading, heading.HeadingEnum);
        }
Exemplo n.º 12
0
        public void RoverShouldSetItsCurrentPositionAfterACompletedMove()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            sut.ReceiveDirectionInstructions("");

            Assert.IsNotNull(sut.CurrentPosition);
        }
Exemplo n.º 13
0
        public void RoverShouldReturnItsNewPositionAsAString()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            var newPosition = sut.ReceiveDirectionInstructions("");

            Assert.IsInstanceOf<string>(newPosition);
        }
Exemplo n.º 14
0
        public void RoverShouldReturnItsCurrentPositionAsAStringAfterProcessingASetOfInstructions()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);
            mockTranslator.TranslateReturnObject = new NavigationCommand(new List<InputCommand> { InputCommand.Left, InputCommand.Move });

            var returnedPosition = sut.ReceiveDirectionInstructions("LM");

            Assert.AreEqual("1 2 W", returnedPosition);
        }
Exemplo n.º 15
0
        public void RoverShouldParseThePlateauUpperBoundsDuringInitialization()
        {
            var mockTranslator = new MockTranslator();
            var sut = new ClassLibrary2.Rover("2 2", "N", "5 5", mockTranslator);

            var parsedBounds = sut.PlanetPlateau;

            Assert.IsInstanceOf<IPlateau>(parsedBounds);
            Assert.AreEqual(5, parsedBounds.UpperX);
            Assert.AreEqual(5, parsedBounds.UpperY);
        }