using System.Collections; using System.Collections.Generic; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; namespace KairoEngine.Core.EditorTests { public class GenericEventsStoryExtensionTests { private void TestEvent(StoryStepData storyStepData) { Assert.AreEqual(storyStepData.text, "This is a test line"); } [Test] public void GenericEvents_StartListening_StoryStepData() { EventManager.broadcast.StartListening("TestEvent", TestEvent); System.Action action = null; bool value = GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action); Assert.AreEqual(true, value); } [Test] public void GenericEvents_StopListening_StoryStepData() { EventManager.broadcast.StartListening("TestEvent", TestEvent); System.Action action1 = null; GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action1); Assert.IsNotNull(action1); EventManager.broadcast.StopListening("TestEvent", TestEvent); System.Action action2 = null; GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action2); Assert.IsNull(action2); } [Test] public void GenericEvents_Trigger_StoryStepData() { EventManager.broadcast.StartListening("TestEvent", TestEvent); StoryStepData storyStep = new StoryStepData(StoryStepType.Line, "This is a test line", null, null); EventManager.broadcast.Trigger("TestEvent", storyStep); } [TearDown] public void TearDown() { EventManager.broadcast.StopListening("TestEvent", TestEvent); } } }