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); }
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 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 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 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); }