Ejemplo n.º 1
0
        public void ReceiveCommand_Forward_FaceWest()
        {
            Planet     planet = new Planet();
            PlutoRover rover  = new PlutoRover(new Position(4, 4, Orientation.W));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.F);
            Assert.AreEqual(rover.GetPosition(), new Position(3, 4, Orientation.W));
            rover.ProcessCommand(PlutoCommand.B);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W));
        }
Ejemplo n.º 2
0
        public void ReceiveCommand_Forward_FaceEast()
        {
            Planet     planet = new Planet();
            PlutoRover rover  = new PlutoRover(new Position(4, 4, Orientation.E));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.F);
            Assert.IsTrue(rover.GetPosition() == (new Position(5, 4, Orientation.E)));
            rover.ProcessCommand(PlutoCommand.B);
            Assert.IsTrue(rover.GetPosition().Equals(new Position(4, 4, Orientation.E)));
        }
Ejemplo n.º 3
0
        public void ReceiveCommand_MoveOffGrid_West()
        {
            Planet     planet = new Planet(10, 10);
            PlutoRover rover  = new PlutoRover(new Position(0, 3, Orientation.W));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.F);
            Assert.AreEqual(rover.GetPosition(), new Position(9, 3, Orientation.W));
        }
Ejemplo n.º 4
0
        public void ReceiveCommand_Obstacle_FaceSouth()
        {
            Planet planet = new Planet();
            Rock   rock   = new Rock(new Position(4, 3, Orientation.N));

            planet.AddObject(rock);
            PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.S));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.F);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S));
        }
Ejemplo n.º 5
0
        public void ReceiveCommand_Obstacle_FaceEast()
        {
            Planet planet = new Planet();
            Rock   rock   = new Rock(new Position(5, 4, Orientation.N));

            planet.AddObject(rock);
            PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.E));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.F);
            Assert.IsTrue(rover.GetPosition() == (new Position(4, 4, Orientation.E)));
        }
Ejemplo n.º 6
0
        public void ReceiveCommand_Turning()
        {
            Planet     planet = new Planet();
            PlutoRover rover  = new PlutoRover(new Position(4, 4, Orientation.N));

            planet.AddObject(rover);
            rover.ProcessCommand(PlutoCommand.L);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W));
            rover.ProcessCommand(PlutoCommand.L);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S));
            rover.ProcessCommand(PlutoCommand.L);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.E));
            rover.ProcessCommand(PlutoCommand.L);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.N));
            rover.ProcessCommand(PlutoCommand.R);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.E));
            rover.ProcessCommand(PlutoCommand.R);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S));
            rover.ProcessCommand(PlutoCommand.R);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W));
            rover.ProcessCommand(PlutoCommand.R);
            Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.N));
        }