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); }
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); }
public void StartEngine() { ToyPlane plane = new ToyPlane(); Assert.AreEqual(plane.StartEngine(), "The toy plane has to be wound up first"); plane.WindUp(); Assert.AreEqual(plane.StartEngine(), "Sprint_0_Warm_Up.ToyPlane is flying"); }
public void StartEngineTest() { // ToyPlane toy = new ToyPlane(); toy.StartEngine(); Assert.AreEqual(toy.Engine.isStarted, false); // toy.windUp(); toy.StartEngine(); Assert.AreEqual(toy.Engine.isStarted, true); }
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 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 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 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 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 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 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); }
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 ToyPlaneStartEngine() { //Arrange test = new ToyPlane(); //Act test.StartEngine(); string engineNoWindup = test.About(); test.WindUp(); test.StartEngine(); string engineWindup = test.About(); //Assert Assert.AreEqual(engineNoWindup, $"This {test.ToString()} has a max altitude of 50 ft.\nIt's current altitude is 0 ft.\n{test.Engine.ToString()} is not started."); Assert.AreEqual(engineWindup, $"This {test.ToString()} has a max altitude of 50 ft.\nIt's current altitude is 0 ft.\n{test.Engine.ToString()} is started."); }
public void TestStartEngine() { //arrange t = new ToyPlane(); //act t.isWoundUP = true; t.StartEngine(); //assert Assert.AreEqual(true, t.Engine.IsStarted); //engine should start after plane is wound }
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"); // }
public void TestAirPlaneStartEngine() { //Arrange tp = new ToyPlane(); //Act bool defaultEngineState = tp.Engine.IsStarted; tp.WindUp(); tp.StartEngine(); bool afterEngineStart = tp.Engine.IsStarted; //Assert Assert.AreEqual(false, defaultEngineState); Assert.AreEqual(true, afterEngineStart); }
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); }
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 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); }
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); }
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 TestStartEngine() { ToyPlane t = new ToyPlane(); bool isWoundUpBeforeWindUp = t.isWoundUp; t.WindUp(); bool isWoundUpAfterWindUp = t.isWoundUp;//check to see that winding it up changes the bool to true bool engineStartedBeforeStartEngine = t.Engine.IsStarted; t.StartEngine(); bool engineStartedAfterStartEngine = t.Engine.IsStarted; //StartEngineTesting Assert.AreEqual(false, isWoundUpBeforeWindUp); Assert.AreEqual(true, isWoundUpAfterWindUp); Assert.AreEqual(false, engineStartedBeforeStartEngine); Assert.AreEqual(true, engineStartedAfterStartEngine); }
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); }
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 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); }
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); }
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); }