コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public IEnumerator NullComponentThrowsArgumentNullException()
 {
     Assert.Throws <System.ArgumentNullException>(() => ComponentExtensions.GetTaskRunner(null));
     Assert.Throws <System.ArgumentNullException>(() => ComponentExtensions.StartTask(null, () => Task.CompletedTask));
     yield break;
 }