Ejemplo n.º 1
0
        public void T11_MakingSurePlaneWorksProperly()
        {
            // Given
            int initialFuel = 100;
            int fuelBurn    = 1;
            int fuelGain    = 3;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, fuel: initialFuel, passingTime: time);

            time.AddTurn();
            time.AddTurn();
            time.AddTurn();
            time.AddTurn();

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

            plane.TryLandOn(runway);

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Fuel == initialFuel - 4 * fuelBurn + 1 * fuelGain);
        }
Ejemplo n.º 2
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.º 3
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.º 4
0
        public void T10_PlaneRefuelsOnGround()
        {
            // Given
            int initialFuel = 100;
            int fuelGain    = 3;

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

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Fuel == initialFuel + fuelGain);
        }
Ejemplo n.º 5
0
        public void T09_PlaneLosesFuelInAir()
        {
            // Given
            int initialFuel = 100;
            int fuelBurn    = 1;

            PassingTime time  = new PassingTime();
            Plane       plane = PlaneFactory.Create(location: PlaneLocation.InAir, fuel: initialFuel, passingTime: time);

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Fuel == initialFuel - fuelBurn);
        }
Ejemplo n.º 6
0
        public void T12_PlaneHasMaxFuel()
        {
            // Given
            int initialFuel = 100;
            int maxFuel     = 100;

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

            // When
            time.AddTurn();

            // Then
            Assert.IsTrue(plane.Fuel == initialFuel);
        }
Ejemplo n.º 7
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.º 8
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.º 9
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));
        }
Ejemplo n.º 10
0
 public static Plane Create(PlaneLocation location, int fuel, int maxFuel,
                            PassingTime passingTime, PlaneDamage damage, string name = "default")
 {
     return(new Plane(name: name, location: location, damage: damage,
                      fuel: fuel, maxFuel: maxFuel, passingTime: passingTime));
 }
Ejemplo n.º 11
0
 public static Plane Create(PlaneLocation location, int fuel, PassingTime passingTime)
 {
     return(Create(name: "default", location: location, fuel: fuel,
                   maxFuel: int.MaxValue, passingTime: passingTime, damage: PlaneDamage.None));
 }