17 #if !ExcludeAskowlTests 29 private static string scenePath =
"Health";
33 [InitializeOnLoadMethod]
private static void AddSceneToBuildSettings() => AddSceneToBuildSettings(scenePath);
37 [UnityTest]
public IEnumerator HeathBarTestsWithEnumeratorPasses() {
38 yield
return LoadScene(scenePath);
40 var slider = Component<Slider>(
"Testing Slider");
41 var foreground = Component<RectTransform>(
"Foreground");
43 slider.value = foreground.localScale.x;
46 IEnumerator setAndCheck(
float health) {
47 slider.value = health;
48 yield
return new WaitForSeconds(0.1f);
49 var scale = foreground.localScale.x;
50 Assert.AreApproximatelyEqual(health, scale, 0.01f);
54 yield
return setAndCheck(0);
55 yield
return setAndCheck(1);
57 for (
float health = 0; health <= 1; health += 0.05f) yield
return setAndCheck(health);
59 for (
int i = 0; i < 20; i++) yield
return setAndCheck(Random.Range(0f, 1f));
64 //- I guess you will want to see the test running...