示例#1
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 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);
        }
示例#3
0
        public void Unwind()
        {
            ToyPlane plane = new ToyPlane();

            plane.WindUp();

            plane.UnWind();
            Assert.IsFalse(plane.isWoundUP);
        }
示例#4
0
        public void GetWindUpString()
        {
            ToyPlane plane = new ToyPlane();

            plane.WindUp();

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

            plane.UnWind();

            Assert.AreEqual(plane.getWindUpString(), "The toy plane is not wound up");
        }
示例#5
0
        public void TestUnwind()
        {
            //arrange
            t = new ToyPlane();

            //act
            t.isWoundUP = true; //wound up beings as true
            bool originalIsWoundUp = t.isWoundUP;

            t.UnWind();

            //assert
            Assert.AreNotEqual(originalIsWoundUp, t.isWoundUP); //should no longer be the same
        }
        public void TestWindUpAndUnwind()
        {
            ToyPlane t = new ToyPlane();

            bool defaultIsWound = t.isWoundUp;//should start false

            t.WindUp();
            bool isWoundAfterWindUp = t.isWoundUp;//wind should make it true

            t.UnWind();
            bool isWoundAfterUnwind = t.isWoundUp;//unwind should make it false

            Assert.AreEqual(false, defaultIsWound);
            Assert.AreEqual(true, isWoundAfterWindUp);
            Assert.AreEqual(false, isWoundAfterUnwind);
        }
示例#7
0
        public void TestToyPlaneUnwind()
        {
            //Arrange
            tp = new ToyPlane();
            //Act
            bool defaultWindUpState = tp.IsWoundUp;

            tp.WindUp();
            bool afterWindUPMethod = tp.IsWoundUp;

            tp.UnWind();
            bool afterWindDown = tp.IsWoundUp;

            //Assert
            Assert.AreEqual(false, defaultWindUpState);
            Assert.AreEqual(true, afterWindUPMethod);
            Assert.AreEqual(afterWindDown, defaultWindUpState);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
0
        public void StartEngine()
        {
            // Engine should not start when the
            // toy plane is in unwound state.
            // Arrange.
            toyPlane = new ToyPlane(new Engine());
            // Act.
            toyPlane.StartEngine();
            bool engineStarted = toyPlane.Engine.IsStarted;

            // Assert.
            Assert.AreEqual(false, engineStarted);

            // Engine should start when the toy
            // plane is in the wound up state.
            // Arrange.
            toyPlane = new ToyPlane(new Engine());
            toyPlane.WindUp();
            // Act.
            toyPlane.StartEngine();
            engineStarted = toyPlane.Engine.IsStarted;
            // Assert.
            Assert.AreEqual(true, engineStarted);

            // If the plane is unwound again, the engine
            // should not start.
            // Arrange.
            toyPlane = new ToyPlane(new Engine());
            toyPlane.WindUp();
            toyPlane.UnWind();
            // Act.
            toyPlane.StartEngine();
            engineStarted = toyPlane.Engine.IsStarted;
            // Assert.
            Assert.AreEqual(false, engineStarted);
        }