Esempio n. 1
0
        public void ShouldThrowExceptionIfLandingOutOfBounds()
        {
            LandingArea plateau = new LandingArea(10, 10);
            RoverPosition landingCoordinates = new RoverPosition(1, 20, RoverPosition.Direction.S);

            Assert.That(() => plateau.LandRover(landingCoordinates), Throws.Exception.TypeOf<ArgumentOutOfRangeException>());
        }
Esempio n. 2
0
        public void LandRover(RoverPosition landingCoordinates)
        {
            if (!CoordinatesAreWithinLimits(landingCoordinates))
                throw new ArgumentOutOfRangeException("landingCoordinates");

            Rover newRover = new Rover(this, landingCoordinates);
            Rovers.Add(newRover);
        }
Esempio n. 3
0
 private Boolean CoordinatesAreWithinLimits(RoverPosition coordinates)
 {
     if (coordinates.X > Width)
         return false;
     else if (coordinates.Y > Depth)
         return false;
     else
         return true;
 }
Esempio n. 4
0
        public void RoverShouldContainReferenceToLandingArea()
        {
            LandingArea plateau = new LandingArea(10, 10);
            RoverPosition landingCoordinates = new RoverPosition(1, 2, RoverPosition.Direction.S);

            plateau.LandRover(landingCoordinates);
            Rover landedRover = plateau.Rovers.FirstOrDefault();

            Assert.That(landedRover.Plateau, Is.SameAs(plateau));
        }
Esempio n. 5
0
        public void ARoverShouldHaveLanded()
        {
            LandingArea plateau = new LandingArea(10, 10);
            RoverPosition landingCoordinates = new RoverPosition(1, 2, RoverPosition.Direction.S);

            plateau.LandRover(landingCoordinates);
            Rover landedRover = plateau.Rovers.FirstOrDefault();

            Assert.That(landedRover, Is.Not.Null);
        }
Esempio n. 6
0
        public void CoordinatesAndHeadingShouldMatch()
        {
            LandingArea plateau = new LandingArea(10, 10);
            RoverPosition landingCoordinates = new RoverPosition(1, 2, RoverPosition.Direction.S);

            plateau.LandRover(landingCoordinates);
            Rover landedRover = plateau.Rovers.FirstOrDefault();

            Assert.That(landedRover.Position.X, Is.EqualTo(landingCoordinates.X));
            Assert.That(landedRover.Position.Y, Is.EqualTo(landingCoordinates.Y));
            Assert.That(landedRover.Position.Heading, Is.EqualTo(landingCoordinates.Heading));
        }
Esempio n. 7
0
 public Rover(LandingArea plateau, RoverPosition initialPosition)
 {
     Plateau = plateau;
     Position = initialPosition;
 }
Esempio n. 8
0
 private void InitializeRoverBottomLeft()
 {
     LandingArea _plateau = new LandingArea(10, 10);
     RoverPosition landingCoordinates = new RoverPosition(1, 1, RoverPosition.Direction.N);
     _plateau.LandRover(landingCoordinates);
     _testRover = _plateau.Rovers.FirstOrDefault();
 }