using System.Collections; using System.Collections.Generic; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using KairoEngine.Core; namespace KairoEngine.Inventory.EditorTests { public class GenericEventsInventoryExtensionsTests { private void TestEvent(ItemContainer itemContainer, ItemRef itemRef) { Assert.NotNull(itemContainer); Assert.NotNull(itemRef); } [Test] public void GenericEvents_StartListening_ItemContainer_ItemRef() { EventManager.broadcast.StartListening("TestEvent", TestEvent); System.Action action = null; bool value = GenericEventsInventoryExtensions.list.TryGetValue("TestEvent", out action); Assert.AreEqual(true, value); } [Test] public void GenericEvents_StopListening_CharacterController() { EventManager.broadcast.StartListening("TestEvent", TestEvent); System.Action action1 = null; GenericEventsInventoryExtensions.list.TryGetValue("TestEvent", out action1); Assert.IsNotNull(action1); EventManager.broadcast.StopListening("TestEvent", TestEvent); System.Action action2 = null; GenericEventsInventoryExtensions.list.TryGetValue("TestEvent", out action2); Assert.IsNull(action2); } [Test] public void GenericEvents_Trigger_CharacterController() { EventManager.broadcast.StartListening("TestEvent", TestEvent); GameObject obj = new GameObject(); obj.AddComponent(); ItemContainer itemContainer = obj.GetComponent(); ItemRef itemRef = new ItemRef(null, 1, 1000); EventManager.broadcast.Trigger("TestEvent", itemContainer, itemRef); } [TearDown] public void TearDown() { EventManager.broadcast.StopListening("TestEvent", TestEvent); } } }