public void ToyPlaneFlyUp()
        {
            //Arrange
            ToyPlane tp = this.ToyPlane;

            //act
            tp.WindUp();
            tp.StartEngine();
            string firstTakeoff  = tp.TakeOff();
            int    defaultHeight = tp.CurrentAltitude;

            tp.FlyUp(); // This should fail, because the AerialVehicle's FlyUp() goes up 1000 ft, while the ToyPlane has a maximum altitude of 50 ft.
            int firstAlt = tp.CurrentAltitude;

            tp.FlyUp(50);
            int secondAlt = tp.CurrentAltitude;

            tp.FlyUp(1); // This should fail and return the same value as the previous.
            int thirdAlt = tp.CurrentAltitude;

            //Assert
            Assert.AreEqual(defaultHeight, 0);
            Assert.AreEqual(firstAlt, 0);
            Assert.AreEqual(secondAlt, 50);
            Assert.AreEqual(thirdAlt, secondAlt);
        }
Beispiel #2
0
        public void TestAirPlaneFlyUpWhileEngineOn()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            int originalAltitude = tp.CurrentAltitude;

            tp.WindUp();
            tp.StartEngine();
            tp.TakeOff();
            tp.FlyUp(10);
            int afterFlyingUpDefault = tp.CurrentAltitude;

            ///Attempt To flyy up higher than max altitude
            tp.FlyUp(42); //this should not work becaause desired altitude is (40 + 42)82 ft which is higher than maxAltitude
            int attemptToFlyUpPastMaxAltitude = tp.CurrentAltitude;

            tp.FlyUp(40);                              //this should reachh 41000ft the max altitude
            int reachMaxAltitude = tp.CurrentAltitude; //plane should reach 50 ft reaching maxAltitude

            //Assert
            Assert.AreEqual(0, originalAltitude);                       //To make sure the altitude is 0
            Assert.AreEqual(10, afterFlyingUpDefault);                  //To make sure flying up went up precisely 1000ft
            Assert.AreNotEqual(afterFlyingUpDefault, originalAltitude); //to make sure the plane flew up
            ///Attempt To flyy up higher than max altitude
            Assert.AreNotEqual(83, attemptToFlyUpPastMaxAltitude);
            Assert.AreEqual(attemptToFlyUpPastMaxAltitude, afterFlyingUpDefault); //plane should not have ascended past the defauult flyUp method
            ///Reaching max Altitude
            Assert.AreEqual(50, reachMaxAltitude);
            Assert.AreNotEqual(originalAltitude, reachMaxAltitude);
        }
        public void ToyPlaneFlyUpCheck()
        {
            //arrange
            ToyPlane tp = new ToyPlane();

            //act - Engine on
            tp.WindUp();
            tp.Engine.Start();
            tp.TakeOff();
            tp.FlyUp(25);

            //assert - check if fly up works
            Assert.AreEqual(tp.CurrentAltitude, 25);

            //act - fly to max
            tp.FlyUp(25);

            //assert - check for max altitude
            Assert.AreEqual(tp.CurrentAltitude, 50);

            //act - fly above max
            tp.FlyUp(25);

            //assert - check for max altitude
            Assert.AreEqual(tp.CurrentAltitude, 50);
        }
        public void ToyPlaneFlyDown()
        {
            //Arrange
            ToyPlane tp = this.ToyPlane;

            //act
            tp.WindUp();
            tp.StartEngine();
            string firstTakeoff  = tp.TakeOff();
            int    defaultHeight = tp.CurrentAltitude;

            tp.FlyDown();
            //test is flying again
            int FlyDown = tp.CurrentAltitude;

            tp.TakeOff();
            tp.FlyDown(1);
            //test is flying again
            tp.TakeOff();
            int FlyDownOneAlreadyZero = tp.CurrentAltitude;

            tp.FlyUp(2);
            tp.FlyDown(1);
            int FlyDownOneAtTwo = tp.CurrentAltitude;

            //Assert
            Assert.AreEqual(defaultHeight, 0);
            Assert.AreEqual(FlyDown, 0);
            Assert.AreEqual(FlyDownOneAlreadyZero, 0);
            Assert.AreEqual(FlyDownOneAtTwo, 1);
        }
        public void ToyPlaneDownCheck()
        {
            //arrange
            ToyPlane tp = new ToyPlane();

            //act - Engine on
            tp.WindUp();
            tp.Engine.Start();
            tp.TakeOff();
            tp.FlyUp(25);
            tp.FlyDown(5);

            //assert - check if fly down works
            Assert.AreEqual(tp.CurrentAltitude, 20);

            //act - fly to min
            tp.FlyDown(20);

            //assert - check for min altitude
            Assert.AreEqual(tp.CurrentAltitude, 0);

            //act - fly below min
            tp.FlyDown(25);

            //assert - check for min altitude
            Assert.AreEqual(tp.CurrentAltitude, 0);
        }
Beispiel #6
0
        public void TestAirPlaneFlyDownWhileEngineOn()
        {
            //Goal here is to make sure:
            ///1. the plane while the engine is on, won't be able to go lower than 0 feet which is whhat thhe current altitude is.
            ///2. The plane will fly up 1000ft and then descend 1000ft to make sure it descends properly.
            //Arrange
            tp = new ToyPlane();

            //Act
            int originalAltitude = tp.CurrentAltitude;

            tp.WindUp();
            tp.StartEngine();
            tp.TakeOff();
            tp.FlyDown(50);//by default is 1000ft
            int attemptToFlyDownWhenOnTheGround = tp.CurrentAltitude;

            //now will fly up 50ft
            tp.FlyUp(50);
            int flownUpFeet = tp.CurrentAltitude; //use to compare with finalDescent to make sure they aren't equal

            tp.FlyDown(50);
            int finalDescent = tp.CurrentAltitude; //final descent should be back at 0 ft. and should not equal flownUpFeet

            //Assert
            Assert.AreEqual(50, flownUpFeet);                                   //This to make sure flyUp hasn't risen up the plane
            Assert.AreEqual(0, originalAltitude);                               //This is to make sure originalAltitude is 0ft
            Assert.AreEqual(attemptToFlyDownWhenOnTheGround, originalAltitude); //This is to make sure the plane can't go lower than 0 feet which is the originalAltitude
            Assert.AreNotEqual(finalDescent, flownUpFeet);                      //This is to make sure the plane has gone up and the valuue is not 0ft
            Assert.AreEqual(finalDescent, originalAltitude);                    //This is to make sure the flyDown method works properly because it was at 1000ft(due to flyUP()), and is not at 0ft
        }
        public void ToyPlaneFlyDownTest()
        {
            // Toy Plane instance to be tested
            ToyPlane tp = new ToyPlane();

            // Setup
            tp.WindUp();
            tp.StartEngine();
            tp.FlyUp(50);
            int maxFlyUp = tp.CurrentAltitude;

            tp.FlyDown(20);
            int flyDown = tp.CurrentAltitude;

            // The value should not change as you are flying down more feet than you are up in the air
            tp.FlyDown();
            int limitFlyDown = tp.CurrentAltitude;

            tp.FlyDown(30);
            int landFlyDown = tp.CurrentAltitude;

            // Assess
            Assert.AreEqual(maxFlyUp, 50);
            Assert.AreEqual(flyDown, 30);
            Assert.AreEqual(limitFlyDown, 30);
            Assert.AreEqual(landFlyDown, 0);
        }
Beispiel #8
0
        public void ToyPlaneWindUp()
        {
            ToyPlane tp = new ToyPlane();

            bool defaultToyPlaneIsWoundUp = tp.isWoundUP;

            tp.FlyUp(10);
            string unwoundToyPlaneInfo = tp.About();

            string ToyPlaneInfoUnWound = String.Format("This OOPAerialVehicle has a max altitude of {0}" +
                                                       "\nIt's current altitude is {1} ft." +
                                                       "\n{2}", tp.MaxAltitude, tp.CurrentAltitude, tp.Engine.About());

            tp.TakeOff();
            string unwoundTakeOffToyPlane = tp.TakeOff();
            string ToyPlaneUnwoundTakeOff = String.Format("{0} can't fly it's engine is not started.", tp.GetType());

            tp.WindUp();
            bool woundUpToyPlane = tp.isWoundUP;

            tp.TakeOff();
            string woundUpTakeOffToyPlane = tp.TakeOff();
            string ToyPlaneWoundUpTakeOff = String.Format("{0} is flying", tp.GetType());


            Assert.IsFalse(defaultToyPlaneIsWoundUp);
            Assert.AreEqual(unwoundToyPlaneInfo, ToyPlaneInfoUnWound);
            Assert.AreEqual(unwoundTakeOffToyPlane, ToyPlaneUnwoundTakeOff);
            Assert.IsTrue(woundUpToyPlane);
            Assert.AreEqual(woundUpTakeOffToyPlane, ToyPlaneWoundUpTakeOff);
        }
        public void ToyPlaneFlyUpTest()
        {
            // Toy Plane instance to be tested
            ToyPlane tp = new ToyPlane();

            // Setup
            tp.WindUp();
            tp.StartEngine();
            tp.FlyUp(10);
            int firstFlyUp = tp.CurrentAltitude;

            tp.FlyUp(20);
            int nextFlyUp = tp.CurrentAltitude;

            // This should not go up at all since it's too high so it shouldn't change the altitute
            tp.FlyUp(100000);
            int limitFlyUp = tp.CurrentAltitude;

            // Assess
            Assert.AreEqual(firstFlyUp, 10);
            Assert.AreEqual(nextFlyUp, 20);
            Assert.AreEqual(limitFlyUp, 20);
        }
Beispiel #10
0
        public void TestAirPlaneFlyUpWhileEngineOff()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            int originalAltitude = tp.CurrentAltitude;

            tp.FlyUp();
            int afterAltitude = tp.CurrentAltitude;

            //Assert
            Assert.AreEqual(afterAltitude, originalAltitude); //This is to see if the afterAltitude is equal to the originalAltitude while the engine off
            Assert.AreNotEqual(50, afterAltitude);            //This to make sure flyUp hasn't risen up the plane
            Assert.AreEqual(0, originalAltitude);             //This is to make sure originalAltitude is 0ft
        }
        public void TestToyPlane()
        {
            // Arrange

            toy = new ToyPlane();

            // Act

            string initialAbout = toy.About();

            int  planeGroundHeight = toy.currentAltitude; // 0 ft
            bool planePreWindUp    = toy.isWoundUp;

            // Test before winding up or starting engine
            toy.FlyUp();
            int planeHeightPreStartUp = toy.currentAltitude; // 0 ft

            toy.FlyDown();
            int planeHeightPreStartDown = toy.currentAltitude; // 0 ft

            bool   EngineStatusPreStart = toy.engine.isStarted;
            string TakeoffPreStart      = toy.TakeOff();

            // Test after winding up but before starting engine
            toy.WindUp();
            bool planePostWindUp = toy.isWoundUp;

            toy.FlyUp();
            int planeHeightPreWindUp = toy.currentAltitude;

            toy.FlyDown();
            int planeHeightPreWindDown = toy.currentAltitude;

            // Test after starting engine but before taking off
            toy.StartEngine();
            bool EngineStatusPostStart = toy.engine.isStarted;

            toy.FlyUp();
            int planeHeightPreTakeoffUp = toy.currentAltitude; // 0 ft

            toy.FlyDown();
            int planeHeightPreTakeOffDown = toy.currentAltitude; // 0 ft

            // Test after starting engine and after taking off
            string confirmTakeOff = toy.TakeOff();

            toy.FlyUp();
            int planeHeightPostStartUp = toy.currentAltitude; // 10 ft

            toy.FlyUp(20);
            int planeHeightPostStartUpX = toy.currentAltitude; // 30 ft

            toy.FlyUp(50000);
            int planeHeightPostStartUpMax = toy.currentAltitude; // maxAltitude

            toy.FlyDown();
            int planeHeightPostStartDown = toy.currentAltitude; // maxAltitude - 10 ft

            string planeFlightAbout = toy.About();

            toy.FlyDown(50000);
            int planeHeightPostStartDownMax = toy.currentAltitude; // same as above

            toy.FlyDown(15);
            int planeHeightPostStartDownX = toy.currentAltitude; // maxAltitude - 25 ft

            toy.StopEngine();
            bool EngineStatusPostStop = toy.engine.isStarted;

            string planeMidflightEngineOff = toy.About();

            toy.FlyDown(toy.currentAltitude);
            bool planeLand = toy.isFlying;

            // Assert
            Assert.AreEqual("This " + toy.ToString() + " has a max altitude of " + toy.maxAltitude + " ft.\n" +
                            "It's current altitude is " + "0 ft.\n" +
                            toy.ToString() + "Engine is started = False", initialAbout);

            Assert.AreEqual(0, planeGroundHeight);
            Assert.AreEqual(0, planeHeightPreStartUp);
            Assert.AreEqual(0, planeHeightPreStartDown);
            Assert.AreEqual(EngineStatusPreStart, false);
            Assert.AreEqual(toy.ToString() + " cannot fly, its' engine is not started.", TakeoffPreStart);
            Assert.AreEqual(true, EngineStatusPostStart);

            Assert.AreEqual(true, planePostWindUp);
            Assert.AreEqual(0, planeHeightPreWindUp);
            Assert.AreEqual(0, planeHeightPreWindDown);

            Assert.AreEqual(0, planeHeightPreTakeoffUp);
            Assert.AreEqual(0, planeHeightPreTakeOffDown);

            Assert.AreEqual(toy.ToString() + " is flying.", confirmTakeOff);
            Assert.AreEqual(10, planeHeightPostStartUp);
            Assert.AreEqual(30, planeHeightPostStartUpX);
            Assert.AreEqual(toy.maxAltitude, planeHeightPostStartUpMax);
            Assert.AreEqual(toy.maxAltitude - 10, planeHeightPostStartDown);

            Assert.AreEqual("This " + toy.ToString() + " has a max altitude of " + toy.maxAltitude + " ft.\n" +
                            "It's current altitude is " + (toy.maxAltitude - 10) + " ft.\n" +
                            toy.ToString() + "Engine is started = True", planeFlightAbout);

            Assert.AreEqual(toy.maxAltitude - 10, planeHeightPostStartDownMax);
            Assert.AreEqual(toy.maxAltitude - 25, planeHeightPostStartDownX);
            Assert.AreEqual(false, EngineStatusPostStop);
            Assert.AreEqual("This " + toy.ToString() + " has a max altitude of " + toy.maxAltitude + " ft.\n" +
                            "It's current altitude is " + (toy.maxAltitude - 25) + " ft.\n" +
                            toy.ToString() + "Engine is started = False", planeMidflightEngineOff);

            Assert.AreEqual(false, planeLand);
        }