public void Think_ProducesResults() { var bay = new ResearchBay(null, 4, 5, new List <Knowledge> { Physics }, 100, PowerGrid(10000000), 1000000); bay.AddResearcher(PhysicsWorker); bay.AddResearcher(PhysicsWorker); bay.AddResearcher(PhysicsWorker); bay.AddResearcher(PhysicsWorker); bay.AddResearcher(PhysicsWorker); bay.Research(Physics); Func <bool> AllResearchersHaveEnergy = () => bay.Researchers.TrueForAll(wk => wk.Energy.Quantity > 0); while (!bay.IsResearched(Physics)) { if (IPowerableUtils.PowerAvailable(bay.EnergySources) == 0) { Assert.Fail("Test is faulty. Not enough energy in station to complete."); return; } if (!AllResearchersHaveEnergy( )) { Assert.Fail("Test is faulty. Not enough energy in workers to complete."); return; } bay.Think( ); } bay.Researchers.ForEach(wk => Assert.IsTrue(wk.Skills.Contains(Physics.Unlocks), "Did not give the physics skill to the researchers")); Assert.IsTrue(bay.IsResearched(Physics), "Did not complete research, but finished anyways"); }
public void ExpendEnergyFromActive_DoesProperAmount() { var bay = PhysicsBay; Active.SetValue(bay, PhysicsProg, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null); bay.ExpendEnergyFromActive( ); var avail = IPowerableUtils.PowerAvailable(bay.EnergySources); Assert.IsTrue(avail == 999, $"Expected energy to drop to 999, actually {avail}"); }