public IEnumerator CompleteWhenItIsDoneOnStart() { // Setup object with mocked grabbed property and activate GameObject obj = new GameObject("T1"); obj.AddComponent <TouchedConditionTests.TouchablePropertyMock>(); UsablePropertyMock mockedProperty = obj.AddComponent <UsablePropertyMock>(); mockedProperty.SetUsed(true); yield return(null); UsedCondition condition = new UsedCondition(mockedProperty); condition.LifeCycle.Activate(); while (condition.IsCompleted == false) { yield return(null); condition.Update(); } // Assert that condition is now completed due IsGrabbed is true Assert.IsTrue(condition.IsCompleted); }
public IEnumerator FastForwardDoesNotCompleteCondition() { // Given an used condition, GameObject obj = new GameObject("T1"); obj.AddComponent <TouchedConditionTests.TouchablePropertyMock>(); UsablePropertyMock mockedProperty = obj.AddComponent <UsablePropertyMock>(); bool wasUsageStarted = false; bool wasUsageStopped = false; mockedProperty.UsageStarted += (sender, args) => { wasUsageStarted = true; mockedProperty.UsageStopped += (o, eventArgs) => wasUsageStopped = true; }; UsedCondition condition = new UsedCondition(mockedProperty); // When you activate it, condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } // When you fast-forward it condition.LifeCycle.MarkToFastForward(); // Then nothing happens. Assert.AreEqual(Stage.Active, condition.LifeCycle.Stage); Assert.IsFalse(condition.IsCompleted); Assert.IsFalse(wasUsageStarted); Assert.IsFalse(wasUsageStopped); }
public IEnumerator AutoCompleteActive() { // Given an used condition, GameObject obj = new GameObject("T1"); obj.AddComponent <TouchedConditionTests.TouchablePropertyMock>(); UsablePropertyMock mockedProperty = obj.AddComponent <UsablePropertyMock>(); bool wasUsageStarted = false; bool wasUsageStopped = false; mockedProperty.UsageStarted += (sender, args) => { wasUsageStarted = true; mockedProperty.UsageStopped += (o, eventArgs) => wasUsageStopped = true; }; UsedCondition condition = new UsedCondition(mockedProperty); // When you activate and autocomplete it, condition.LifeCycle.Activate(); while (condition.LifeCycle.Stage != Stage.Active) { yield return(null); condition.Update(); } condition.Autocomplete(); // Then condition is completed. Assert.AreEqual(Stage.Active, condition.LifeCycle.Stage); Assert.IsTrue(condition.IsCompleted); Assert.IsTrue(wasUsageStarted); Assert.IsTrue(wasUsageStopped); }