GenericEventsStoryExtensionTests.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using NUnit.Framework;
  4. using UnityEngine;
  5. using UnityEngine.TestTools;
  6. namespace KairoEngine.Core.EditorTests
  7. {
  8. public class GenericEventsStoryExtensionTests
  9. {
  10. private void TestEvent(StoryStepData storyStepData)
  11. {
  12. Assert.AreEqual(storyStepData.text, "This is a test line");
  13. }
  14. [Test]
  15. public void GenericEvents_StartListening_StoryStepData()
  16. {
  17. EventManager.broadcast.StartListening("TestEvent", TestEvent);
  18. System.Action<StoryStepData> action = null;
  19. bool value = GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action);
  20. Assert.AreEqual(true, value);
  21. }
  22. [Test]
  23. public void GenericEvents_StopListening_StoryStepData()
  24. {
  25. EventManager.broadcast.StartListening("TestEvent", TestEvent);
  26. System.Action<StoryStepData> action1 = null;
  27. GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action1);
  28. Assert.IsNotNull(action1);
  29. EventManager.broadcast.StopListening("TestEvent", TestEvent);
  30. System.Action<StoryStepData> action2 = null;
  31. GenericEventsStoryExtensions.list.TryGetValue("TestEvent", out action2);
  32. Assert.IsNull(action2);
  33. }
  34. [Test]
  35. public void GenericEvents_Trigger_StoryStepData()
  36. {
  37. EventManager.broadcast.StartListening("TestEvent", TestEvent);
  38. StoryStepData storyStep = new StoryStepData(StoryStepType.Line, "This is a test line", null, null);
  39. EventManager.broadcast.Trigger("TestEvent", storyStep);
  40. }
  41. [TearDown]
  42. public void TearDown()
  43. {
  44. EventManager.broadcast.StopListening("TestEvent", TestEvent);
  45. }
  46. }
  47. }