public IEnumerator MainPowerSafeTest() // test handling edge cases { GameObject goFail = new GameObject(); goFail.AddComponent <MainPowerStatus>(); MainPowerStatus FailMPS = goFail.GetComponent <MainPowerStatus>(); // for failing to make change yield return(new WaitForFixedUpdate()); //Fail call Test Assert.AreEqual(50, FailMPS.AvailablePower); // initial FailMPS.RetrievePower(SourceTag.MainControl); // Retrieving from empty Source. shouldn't work Assert.AreNotEqual(60, FailMPS.AvailablePower); Assert.AreEqual(50, FailMPS.AvailablePower); FailMPS.TransferPower(SourceTag.MainControl, 60); // Transferring more than available. Assert.AreEqual(50, FailMPS.AvailablePower); // should be same Assert.AreNotEqual(60, FailMPS.powerDistribution[0].AvailablePower); //shouldn't have transfered FailMPS.TransferPower(SourceTag.DiningHall, 50); // Transferring more than needed. Assert.AreEqual(50, FailMPS.AvailablePower); // should be same Assert.AreNotEqual(50, FailMPS.powerDistribution[2]); Assert.AreEqual(0, FailMPS.powerDistribution[0].AvailablePower); FailMPS.RetrievePower(SourceTag.MainControl); // retrieving from empty source Assert.AreEqual(50, FailMPS.AvailablePower); Assert.AreEqual(0, FailMPS.powerDistribution[0].AvailablePower); }
public IEnumerator MainPowerEmptyTest() // test lif support edge cases { GameObject goEmpty = new GameObject(); goEmpty.AddComponent <MainPowerStatus>(); MainPowerStatus EmptyMPS = goEmpty.GetComponent <MainPowerStatus>(); // for making it empty yield return(new WaitForFixedUpdate()); //lifeSupport test Assert.AreEqual(50, EmptyMPS.AvailablePower); EmptyMPS.RetrieveLifeSupport(); // get rid of one life support Assert.AreEqual(60, EmptyMPS.AvailablePower); // more power should be available EmptyMPS.RetrieveLifeSupport(20); // getting rid of all life support Assert.AreEqual(80, EmptyMPS.AvailablePower); // Available should be Reserve now EmptyMPS.TransferPower(SourceTag.MainControl, 80); // Transferring all power to MainControl Assert.AreEqual(0, EmptyMPS.AvailablePower); Assert.AreEqual(80, EmptyMPS.powerDistribution[0].AvailablePower); EmptyMPS.RetrievePower(SourceTag.MainControl, 80); //Retrieve all power Assert.AreEqual(80, EmptyMPS.AvailablePower); Assert.AreEqual(0, EmptyMPS.powerDistribution[0].AvailablePower); }