Ejemplo n.º 1
0
        public void T18_GoToRunwayAfter3TurnsOnHangar()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Plane plane2 = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None,
                                               fuel: initialFuel, maxFuel: maxFuel, passingTime: time);

            Hangar.AddPlaneToHangar(plane);
            Hangar.AddPlaneToHangar(plane2);

            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            ControlTower tower = new ControlTower(new Runway[] { runway });

            runway.AcceptPlane(plane);

            for (int i = 0; i < 3; i++) // 9 turns have passed
            {
                time.AddTurn();
            }

            // When
            time.AddTurn();
            // Then
            Assert.IsTrue(plane.Location == PlaneLocation.OnRunway);
            Assert.IsTrue(plane2.Location == PlaneLocation.OnRunway);
        }
Ejemplo n.º 2
0
        public void T16_PlaneGetsRepairedAfter10TurnsOnRunway()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, damage: PlaneDamage.Damaged,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            runway.AcceptPlane(plane);

            for (int i = 0; i < 9; i++) // 9 turns have passed
            {
                time.AddTurn();
            }

            Assert.IsTrue(plane.Damage == PlaneDamage.Damaged);

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Damage == PlaneDamage.None);
        }
Ejemplo n.º 3
0
        public void T01_RunwayAcceptsAPlaneIfPlaneInAirAndRunwayEmpty()
        {
            // Given
            Plane  plane  = PlaneFactory.Create(PlaneLocation.InAir);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            // When
            runway.AcceptPlane(plane);

            // Then
            Assert.IsTrue(runway.Status == RunwayStatus.Full);
        }
Ejemplo n.º 4
0
        public void T02_RunwayDoesNotAcceptAPlaneIfPlaneOnRunwayAndRunwayEmpty()
        {
            // Given
            Plane  plane  = PlaneFactory.Create(location: PlaneLocation.OnRunway);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            // When
            runway.AcceptPlane(plane);

            // Then
            Assert.IsTrue(runway.Status == RunwayStatus.Empty);
        }
Ejemplo n.º 5
0
        public void T15_PlaneCannotStartIfIsDamaged()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, damage: PlaneDamage.Damaged,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            runway.AcceptPlane(plane);
            time.AddTurn();

            // When
            Plane launched = runway.LaunchPlane();

            // Then
            Assert.IsTrue(launched == null);
            Assert.IsTrue(runway.Status == RunwayStatus.Full);
        }
Ejemplo n.º 6
0
        public void T14_PlaneCannotStartIfHasLessThanHalfMaxFuel()
        {
            // Given
            int initialFuel = 10;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(name: "Omega Flight", location: PlaneLocation.InAir,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Runway runway = new Runway("runway 01", RunwayStatus.Empty);

            runway.AcceptPlane(plane);
            time.AddTurn();

            // When
            Plane launched = runway.LaunchPlane();

            // Then
            Assert.IsTrue(launched == null);
            Assert.IsTrue(runway.Status == RunwayStatus.Full);
        }
Ejemplo n.º 7
0
        public void T17_PlaneAddToHangarAfter25TurnsOnRunway()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None,
                                                    fuel: initialFuel, maxFuel: maxFuel, passingTime: time);
            Runway       runway = new Runway("runway 01", RunwayStatus.Empty);
            ControlTower tower  = new ControlTower(new Runway[] { runway });

            runway.AcceptPlane(plane);

            for (int i = 0; i < 24; i++) // 9 turns have passed
            {
                time.AddTurn();
            }

            // When
            time.AddTurn();
            // Then
            Assert.IsTrue(Hangar.Planes.Contains(plane));
        }