public IEnumerator CreatingRunnerOnDestroyedComponentThrows() { var go = new GameObject("TestGameObject"); var comp = go.AddComponent <MockComponent>(); Object.DestroyImmediate(comp); Assert.Throws <MissingReferenceException>(() => ComponentExtensions.GetTaskRunner(comp)); Assert.Throws <MissingReferenceException>(() => ComponentExtensions.StartTask(comp, () => Task.CompletedTask)); // Cleanup. yield return(null); Object.Destroy(go); }
public IEnumerator StartingTaskOnDisabledComponentThrows() { var go = new GameObject("TestGameObject"); var comp = go.AddComponent <MockComponent>(); // Disable the component. comp.enabled = false; Assert.Throws <InactiveComponentException>(() => ComponentExtensions.StartTask(comp, () => Task.CompletedTask)); // Cleanup. yield return(null); Object.Destroy(go); }
public IEnumerator NullComponentThrowsArgumentNullException() { Assert.Throws <System.ArgumentNullException>(() => ComponentExtensions.GetTaskRunner(null)); Assert.Throws <System.ArgumentNullException>(() => ComponentExtensions.StartTask(null, () => Task.CompletedTask)); yield break; }