public void ToyPlaneEngine()
        {
            //Arrange
            ToyPlane tp = this.ToyPlane;
            //Act
            bool defaultEngine = tp.Engine.IsStarted;  //default should be off

            tp.StartEngine();
            bool startedEngineBeforeWind = tp.Engine.IsStarted; // This should still return true because it is not wound up yet.

            tp.WindUp();
            tp.StartEngine();
            bool startedEngineAfterWind = tp.Engine.IsStarted; // This should return true because the plane has been wound.

            tp.StopEngine();
            bool stoppedEngine = tp.Engine.IsStarted; // This should return false because the engine has been stopped.

            tp.UnWind();
            tp.StartEngine();
            bool startedEngineAfterUnwind = tp.Engine.IsStarted; // This should return false because the plane has been unwound.

            //Assert
            Assert.AreEqual(defaultEngine, false);
            Assert.AreEqual(startedEngineBeforeWind, false);
            Assert.AreEqual(startedEngineAfterWind, true);
            Assert.AreEqual(stoppedEngine, false);
            Assert.AreEqual(startedEngineAfterUnwind, false);
        }
示例#2
0
        public void TestToyPlaneAabout()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            string originalToyplaneAboutString = tp.About();

            tp.WindUp();
            tp.StartEngine();
            string engineStartToyPlaneString = tp.About();

            tp.StopEngine();
            tp.UnWind();
            string engineStopToyPlaneString = tp.About();

            //Assert
            Assert.AreEqual(originalToyplaneAboutString, engineStopToyPlaneString);
            Assert.AreNotEqual(originalToyplaneAboutString, engineStartToyPlaneString);
        }
示例#3
0
        public void TestAirPlaneStopEngine()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            bool defaultEngineState = tp.Engine.IsStarted;

            tp.WindUp();
            tp.StartEngine();
            bool testEngineOn = tp.Engine.IsStarted;

            tp.StopEngine();
            tp.UnWind();
            bool afterEngineStopped = tp.Engine.IsStarted;

            //Assert
            Assert.AreEqual(false, defaultEngineState);
            Assert.AreEqual(true, testEngineOn);
            Assert.AreEqual(afterEngineStopped, defaultEngineState);
        }
示例#4
0
        public void TestAirPlaneGetEngineString()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            string originalGetEngineString = tp.getEngineStartedString();

            tp.WindUp();
            tp.StartEngine();
            string engineTurnOnEngineString = tp.getEngineStartedString();

            tp.StopEngine();
            tp.UnWind();
            string engineTurnOffEngineString = tp.getEngineStartedString();

            //Assert
            Assert.AreEqual(originalGetEngineString, engineTurnOffEngineString);
            Assert.AreEqual("Engine is started", engineTurnOnEngineString);
            Assert.AreEqual("Engine not started", engineTurnOffEngineString);
        }
        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);
        }