Exemplo n.º 1
0
            public void Command_ForwardThenBackward_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('F');
                rover.Command('B');

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('N', rover.Heading);
            }
Exemplo n.º 2
0
            public void Command_ForwardFromNonOrigin_Valid()
            {
                var rover = new Rover(1, 1, 'N');

                rover.Command('F');

                Assert.AreEqual(1, rover.X);
                Assert.AreEqual(2, rover.Y);
                Assert.AreEqual('N', rover.Heading);
            }
Exemplo n.º 3
0
            public void Command_Turn_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('R');

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('E', rover.Heading);
            }
Exemplo n.º 4
0
            public void Command_SequenceVaryingGridSize_Valid()
            {
                var rover = new Rover(0, 0, 'N', 200, 200);

                rover.Command("RRFF");

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(199, rover.Y);
                Assert.AreEqual('S', rover.Heading);
            }
Exemplo n.º 5
0
            public void Command_Sequence_WithObstacles_Throws()
            {
                var obstacles = new List<Obstacle> { new Obstacle { X = 0, Y = 2 } };
                var rover = new Rover(0, 0, 'N', 200, 200, obstacles);

                Assert.Throws<ObstacleException>(() => rover.Command("FF"));

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(1, rover.Y);
                Assert.AreEqual('N', rover.Heading);
            }
Exemplo n.º 6
0
            public void Command_TurnLeftFromNorthThreeTimes_MoveBackwardsTwice_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('L');
                rover.Command('L');
                rover.Command('L');
                rover.Command('B');
                rover.Command('B');

                Assert.AreEqual(99, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('E', rover.Heading);
            }
Exemplo n.º 7
0
            public void Command_Sequence_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command("FFRFF");

                Assert.AreEqual(2, rover.X);
                Assert.AreEqual(2, rover.Y);
                Assert.AreEqual('E', rover.Heading);
            }
Exemplo n.º 8
0
            public void Command_TurnLeftFromNorth_MoveBackward_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('L');
                rover.Command('B');
                rover.Command('B');

                Assert.AreEqual(2, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('W', rover.Heading);
            }
Exemplo n.º 9
0
            public void Command_TurnRightFromNorthThreeTimes_MoveForwardTwice_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('R');
                rover.Command('R');
                rover.Command('R');
                rover.Command('F');
                rover.Command('F');

                Assert.AreEqual(99, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('W', rover.Heading);
            }
Exemplo n.º 10
0
            public void Command_TurnRightFromNorth_MoveForward_Valid()
            {
                var rover = new Rover(0, 0, 'N');

                rover.Command('R');
                rover.Command('F');
                rover.Command('F');

                Assert.AreEqual(2, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('E', rover.Heading);
            }
Exemplo n.º 11
0
            public void Command_TurnLeftFromEast_Valid()
            {
                var rover = new Rover(0, 0, 'E');

                rover.Command('L');

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('N', rover.Heading);
            }
Exemplo n.º 12
0
            public void Command_TurnRightFromWest_Valid()
            {
                var rover = new Rover(0, 0, 'W');

                rover.Command('R');

                Assert.AreEqual(0, rover.X);
                Assert.AreEqual(0, rover.Y);
                Assert.AreEqual('N', rover.Heading);
            }