public void ReturnsAValidCoroutineInstance() { var component = new ScriptComponent {Script = TestScriptFactory.CreateScriptResource(TestScriptWithCoroutine)}; component.OnInit(Component.InitContext.Activate); var factory = Create.NewFactory(); var coroutine = component.StartCoroutine<object>("Coroutine", factory); Assert.IsNotNull(coroutine); coroutine.Step(); factory.Kernel.Step(); Assert.AreEqual(1, coroutine.Value); factory.Kernel.Step(); Assert.AreEqual(2, coroutine.Value); factory.Kernel.Step(); Assert.AreEqual(3, coroutine.Value); }
public void CallsShutdownOrSavingDependingOnContext( [Values(Component.ShutdownContext.Saving, Component.ShutdownContext.Deactivate)]Component.ShutdownContext context, [Values(false, true)]bool expectedShutdownResult, [Values(true, false)]bool expectedSavingResult) { var component = new ScriptComponent { Script = TestScriptFactory.CreateScriptResource(TestScriptWithShutdown) }; component.OnInit(Component.InitContext.Activate); component.SetScriptPropertyValue("ShutdownCalled", false); component.SetScriptPropertyValue("SavingCalled", false); component.OnShutdown(context); ((ICmpEditorUpdatable)component).OnUpdate(); Assert.AreEqual(expectedShutdownResult, (bool)component.ScriptPropertyValues["ShutdownCalled"]); Assert.AreEqual(expectedSavingResult, (bool)component.ScriptPropertyValues["SavingCalled"]); }