Ejemplo n.º 1
0
        public void AddRoversToPlateauAndTestForCollissions()
        {
            Plateau.SetPlateauBounds(10, 10);

            var positionA = new Position(5, 5);
            var headingA = new Heading('N');
            var pathA = new List<char> {'M', 'M'};
            var roverA = new Rover(positionA, headingA, new Guid(), pathA);

            var positionB = new Position(4, 4);
            var headingB = new Heading('N');
            var pathB = new List<char> {'M', 'M'};
            var roverB = new Rover(positionB, headingB, new Guid(), pathB);

            var positionC = new Position(3, 3);
            var headingC = new Heading('N');
            var pathC = new List<char> {'M', 'M'};
            var roverC = new Rover(positionC, headingC, new Guid(), pathC);

            var positionD = new Position(2, 2);

            Plateau.AddRoverToPosition(positionA, roverA);
            Plateau.AddRoverToPosition(positionB, roverB);
            Plateau.AddRoverToPosition(positionC, roverC);

            Plateau.RoverAtPosition(positionA).Should().BeTrue();
            Plateau.RoverAtPosition(positionB).Should().BeTrue();
            Plateau.RoverAtPosition(positionC).Should().BeTrue();
            Plateau.RoverAtPosition(positionD).Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void CreateRoversAndGetPositionsAndHeadings()
        {
            var positionA = new Position(5, 5);
            var headingA = new Heading('N');
            var pathA = new List<char> { 'M', 'M' };
            var roverA = new Rover(positionA, headingA, new Guid(), pathA);

            var positionB = new Position(4, 4);
            var headingB = new Heading('S');
            var pathB = new List<char> { 'M', 'M' };
            var roverB = new Rover(positionB, headingB, new Guid(), pathB);

            roverA.GetHeading().Should().Be('N');
            roverB.Position.ShouldBeEquivalentTo(new Position(4, 4));
        }
Ejemplo n.º 3
0
        public void MoveRover()
        {
            Plateau.SetPlateauBounds(10, 10);

            var positionA = new Position(5, 5);
            var headingA = new Heading('N');
            var pathA = new List<char> { 'M', 'M', 'L' };
            var roverA = new Rover(positionA, headingA, new Guid(), pathA);

            var successA = roverA.FollowPath();
            successA.Should().BeTrue();
            roverA.GetHeading().Should().Be('W');
            roverA.Position.ShouldBeEquivalentTo(new Position(5, 7));

            var positionB = new Position(4, 4);
            var headingB = new Heading('S');
            var pathB = new List<char> { 'M', 'M', 'M', 'M', 'M' };
            var roverB = new Rover(positionB, headingB, new Guid(), pathB);
            var successB = roverB.FollowPath();
            successB.Should().BeFalse();
            roverB.GetHeading().Should().Be('S');
            roverB.Position.ShouldBeEquivalentTo(new Position(4, -1));
        }
Ejemplo n.º 4
0
 public static void AddRoverToPosition(Position position, Rover rover)
 {
     RoverPositions.Add(position, rover);
 }
Ejemplo n.º 5
0
 public static void AddRoverToPosition(Position position, Rover rover)
 {
     RoverPositions.Add(position, rover);
 }