public void CurrentEfficiencyTest1() { string[] dependencies = { "Lighting", "Water", "Temperature", "Fertiliser" }; foreach (PlantRates pr in plantRates) { foreach (string dep in dependencies) { DependenceAttribute depObj = pr.GetDepComp(dep); depObj.maxValue = 2000f; depObj.minValue = 1000f; depObj.optimumPercentage = 0.5f; //optimum is 1500 depObj.currValue = 1250f; depObj.dependencyAmount = 0.25f; depObj.UpdateEfficiency(); } } foreach (PlantRates pr in plantRates) { float effic = pr.GetCurrentEfficiency(pr.allDependencies); Assert.IsTrue(effic >= .5f && effic < .5009f, String.Format("Efficiency should be 0.5, got '{0}'", effic)); } }
public void CurrentEfficiencyTest3() { string[] dependencies = { "Lighting", "Water", "Temperature", "Fertiliser" }; foreach (PlantRates pr in plantRates) { foreach (string dep in dependencies) { DependenceAttribute depObj = pr.GetDepComp(dep); depObj.maxValue = 0f; depObj.minValue = 0f; depObj.optimumPercentage = 0.8f; //optimum is 4400 depObj.currValue = 1023.5f; depObj.dependencyAmount = 0.25f; depObj.UpdateEfficiency(); Debug.Log(pr.gameObject.name + ": " + dep + " " + depObj.dependencyEfficiency.ToString()); } } foreach (PlantRates pr in plantRates) { float effic = pr.GetCurrentEfficiency(pr.allDependencies); Assert.IsTrue(effic == 0f, String.Format("Efficiency should be 0, got '{0}'", effic)); } }