public void TestTakeOff()
        {
            ToyPlane t = new ToyPlane();

            //Defaults
            bool   isWoundUpDefault = t.isWoundUp; //should be false upon starting without winding up
            string takeOffDefault   = t.TakeOff(); //trying to take off without winding up should return error string

            //Starting wind up
            t.WindUp();//calling stuff needed to actually take off
            bool isWoundUpAfterWindUp = t.isWoundUp;

            //Starting engine
            t.StartEngine();
            bool isWoundUpAfterStartEngine = t.isWoundUp;

            //Taking off with engine started
            string takeOffWithEngineStarted = t.TakeOff();
            bool   isWoundUpAfterTakeOff    = t.isWoundUp;

            //Defaults //Calling take off without starting the engine
            Assert.AreEqual(false, isWoundUpDefault);
            Assert.AreEqual(t.GetType().Name + " cannot take off. It's engine is not started.", takeOffDefault);

            //Starting the engine
            Assert.AreEqual(true, isWoundUpAfterWindUp);
            Assert.AreEqual(true, isWoundUpAfterStartEngine);

            //Calling take off with engine started
            Assert.AreEqual(t.GetType().Name + " is flying", takeOffWithEngineStarted);
            Assert.AreEqual(false, isWoundUpAfterTakeOff);
        }
        public void ToyPlaneTakeOffTest()
        {
            // Toy Plane instance to be tested
            ToyPlane tp = new ToyPlane();

            // Setup
            string firstTakeOff = tp.TakeOff();

            tp.StartEngine();
            string noWind = tp.getWindUpString();

            tp.WindUp();
            string woundUp = tp.getWindUpString();

            tp.StartEngine();
            string secondTakeOff = tp.TakeOff();
            int    altTakeOff    = tp.CurrentAltitude;

            // Assess
            Assert.AreEqual(tp.Engine.isStarted, true);
            Assert.AreEqual(firstTakeOff, $"This {this.ToString()} can't fly it's engine is not started.");
            Assert.AreEqual(noWind, $"This {this.ToString()} has not been wound up");
            Assert.AreEqual(woundUp, $"This {this.ToString()} has been wound up");
            Assert.AreEqual(secondTakeOff, $"This {this.ToString()} is flying");
            Assert.AreEqual(altTakeOff, 0);
        }
예제 #3
0
        public void ToyPlaneTakeOff()
        {
            ToyPlane tp = toyPlane;
            bool     endWoundUp;
            bool     startWoundUp;
            bool     startIsFlying;
            bool     endIsFlying;
            bool     startEngineStatus;
            bool     endEngineStatus;

            startWoundUp      = tp.isWoundUp;
            endWoundUp        = true;
            startIsFlying     = tp.IsFlying;
            endIsFlying       = true;
            startEngineStatus = tp.Engine.IsStarted;
            endEngineStatus   = true;

            Assert.AreEqual(startIsFlying, tp.IsFlying);
            Assert.AreEqual(startWoundUp, tp.isWoundUp);
            Assert.AreEqual(startEngineStatus, tp.Engine.IsStarted);
            tp.WindUp();
            Assert.IsTrue(tp.isWoundUp);
            tp.UnWind();
            Assert.IsFalse(tp.isWoundUp);
            tp.WindUp();
            tp.TakeOff();
            Assert.IsFalse(tp.IsFlying);
            tp.StartEngine();
            Assert.IsTrue(endEngineStatus);
            tp.TakeOff();
            Assert.AreEqual(endIsFlying, tp.IsFlying);
            Assert.AreEqual(endWoundUp, tp.isWoundUp);
        }
        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);
        }
예제 #5
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 TakeOffTest()
        {
            //
            ToyPlane toy           = new ToyPlane();
            string   TakeOffString = toy.TakeOff();

            Assert.AreEqual(TakeOffString, "You need to start the engine!");
            //
            toy.windUp();
            toy.StartEngine();
            toy.TakeOff();
            TakeOffString = toy.TakeOff();
            Assert.AreEqual(TakeOffString, "You are flying");
            //
        }
예제 #7
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);
        }
예제 #8
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 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 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);
        }
        public void TestAbout()
        {
            ToyPlane t = new ToyPlane();

            //Default vars in about
            int    maxAltitudeDefault     = t.MaxAltitude;//this shouldn't change
            string windUpStringDefault    = t.GetWindUpString();
            int    defaultCurrentAltitude = t.currentAltitude;

            t.WindUp();
            //Vars after winding up
            string windUpAfterWindUp = t.GetWindUpString();

            t.StartEngine();//gotta have the engine started to fly up
            t.TakeOff();

            //vars after flying up
            string windUpStringAfterFly    = t.GetWindUpString();//making sure these are being displayed correctly as they change
            int    currentAltitudeAfterFly = t.currentAltitude;

            //Default Values
            Assert.AreEqual(50, maxAltitudeDefault);
            Assert.AreEqual("The toy plane is not wound up.", windUpStringDefault);
            Assert.AreEqual(0, defaultCurrentAltitude);

            Assert.AreEqual("The toy plane is wound up.", windUpAfterWindUp);

            Assert.AreEqual("The toy plane is not wound up.", windUpStringAfterFly);
            Assert.AreEqual(50, currentAltitudeAfterFly);
        }
        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);
        }
예제 #13
0
        public void TestTakeOff()
        {
            //arrange
            t = new ToyPlane();

            //assert
            Assert.AreEqual(t + " can't fly, it isn't wound up!", t.TakeOff()); //default string
        }
예제 #14
0
        public void TestAirPlaneTakeOff()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            string defaultTakeOffString = tp.TakeOff();
            bool   defaultFlyingState   = tp.IsFlying;

            tp.WindUp();
            tp.StartEngine();
            string afterEngineStart = tp.TakeOff();
            bool   afterFlyingState = tp.IsFlying;

            //Assert
            Assert.AreEqual("This engine can't fly until the engine is started", defaultTakeOffString);
            Assert.AreEqual(false, defaultFlyingState);
            Assert.AreEqual("This engine has started", afterEngineStart);
            Assert.AreEqual(true, afterFlyingState);
        }
        public void ToyPlaneTakeOff()
        {
            //Arrange
            ToyPlane tp = this.ToyPlane;
            //act
            string firstTakeoff            = tp.TakeOff();
            bool   windUpStatusBeforeStart = tp.IsWoundUp;
            bool   engineBeforeStart       = tp.Engine.IsStarted;

            tp.WindUp();
            tp.StartEngine();
            string secondTakeOff = tp.TakeOff();

            //Assert
            Assert.AreEqual(firstTakeoff, tp.ToString() + " can't fly, its engine is not started.");
            Assert.AreEqual(secondTakeOff, tp.ToString() + " is flying.");
            Assert.AreEqual(windUpStatusBeforeStart, false);
            Assert.AreEqual(engineBeforeStart, false);
            Assert.AreEqual(tp.Engine.IsStarted, true);
        }
예제 #16
0
        public void ToyPlaneUnWind()
        {
            ToyPlane tp = new ToyPlane();

            bool defaultToyPlaneIsWoundUp = tp.isWoundUP;

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

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

            tp.UnWind();
            bool unwoundToyPlane = tp.isWoundUP;

            Assert.IsFalse(defaultToyPlaneIsWoundUp);
            Assert.IsTrue(woundUpToyPlane);
            Assert.AreEqual(woundUpTakeOffToyPlane, ToyPlaneWoundUpTakeOff);
            Assert.IsFalse(unwoundToyPlane);
        }
        public void ToyPlaneTakeoffCheck()
        {
            //arrange
            ToyPlane tp = new ToyPlane();

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

            //assert - check if flying
            Assert.IsTrue(tp.IsFlying);
        }
        public void ToyPlaneTakeOff()
        {
            //Arrange
            bool   WoundUp;
            string afterTakeOff;

            //Act
            WoundUp      = toyplane.woundUp;
            afterTakeOff = toyplane.TakeOff();

            //Assert
            Assert.AreEqual(WoundUp, false);
            Assert.AreNotEqual(afterTakeOff, string.Empty);
        }
        public void ToyPlaneUnwindCheck()
        {
            //arrange
            ToyPlane tp = new ToyPlane();

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

            //assert - check if unwound
            Assert.IsFalse(tp.isWoundUp);

            //assert - make sure we aren't flying
            Assert.IsFalse(tp.IsFlying);

            //assert - are we grounded?
            Assert.AreEqual(tp.CurrentAltitude, 0);
        }
예제 #20
0
        public void ToyPlaneWoundUpTest()
        {
            // Arrage
            ToyPlane toyPlane = new ToyPlane();

            Assert.IsFalse(toyPlane.isWoundUp);
            //Assert.AreEqual(toyPlane.About(), $"{toyPlane} has a max altitude of {toyPlane.MaxAltitude} ft\n It's current altitude is {toyPlane.CurrentAltitude} ft\n is not started{toyPlane} is wound up");

            toyPlane.StartEngine();

            Assert.IsTrue(toyPlane.isWoundUp);
            Assert.AreEqual(toyPlane.getWindUpString(), $"{toyPlane} is winding up");

            toyPlane.TakeOff();

            Assert.AreEqual(toyPlane.CurrentAltitude, 10f);

            toyPlane.UnWind();

            Assert.IsFalse(toyPlane.isWoundUp);
        }
예제 #21
0
        public void TakeOff()
        {
            // Should not take off when the plane
            // is unwound.
            // Arrange.
            toyPlane = new ToyPlane(new Engine());
            toyPlane.StartEngine();
            // Act.
            string message = toyPlane.TakeOff();

            // Assert.
            Assert.AreEqual($"{toyPlane} can't take off. It's not wound up.", message);

            // Should take off if wound up.
            // Arrange.
            toyPlane = new ToyPlane(new Engine());
            toyPlane.WindUp();
            toyPlane.StartEngine();
            // Act.
            message = toyPlane.TakeOff();
            // Assert.
            Assert.AreNotEqual($"{toyPlane} can't take off. It's not wound up.", message);
        }
        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);
        }