12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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<StoryStepData> 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<StoryStepData> action1 = null;
- GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action1);
- Assert.IsNotNull(action1);
- EventManager.broadcast.StopListening("TestEvent", TestEvent);
- System.Action<StoryStepData> 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);
- }
- }
- }
|