示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#4
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));
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }