Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
BastianBlokland committed Jul 23, 2019
1 parent bd83ba0 commit 4f0e866
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/playmode/ComponentExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,36 @@ public IEnumerator RunnerDestroysItselfWhenComponentIsDestroyed()
Assert.AreEqual(0, go.GetComponents<MonoBehaviour>().Length);

// Cleanup.
Object.Destroy(go);

async Task TestAsync()
{
await Task.Yield();
await Task.Yield();
}
}

[UnityTest]
public IEnumerator RunnerDestroysItselfWhenDisabledComponentIsDestroyed()
{
var go = new GameObject("TestGameObject");
var comp = go.AddComponent<MockComponent>();
comp.StartTask(TestAsync);

// Disable component.
comp.enabled = false;

// Assert that runner was created.
Assert.AreEqual(2, go.GetComponents<MonoBehaviour>().Length);

// Destroy component.
Object.DestroyImmediate(comp);
yield return null;

// Assert that runner has destroyed itself.
Assert.AreEqual(0, go.GetComponents<MonoBehaviour>().Length);

// Cleanup.
Object.Destroy(go);

async Task TestAsync()
Expand Down

0 comments on commit 4f0e866

Please sign in to comment.