using System.Collections; using System.Collections.Generic; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using KairoEngine.Core; using KairoEngine.Inventory; namespace KairoEngine.Inventory.EditorTests { public class RequestEventsInventoryExtensionTests { private ItemContainer TestItemContainer() { GameObject obj = new GameObject(); obj.AddComponent(); ItemContainer itemContainer = obj.GetComponent(); return itemContainer; } private ItemContainer EmptyTestItemContainer() => null; [Test] public void RequestEvents_Get_ItemContainer() { EventManager.request.Bind("TestItemContainer", TestItemContainer); EventResponse response = EventManager.request.GetItemContainer("TestItemContainer"); Assert.AreEqual(typeof(ItemContainer), response.value.GetType()); Assert.AreEqual(EventResponseStatus.OK, response.status); } [Test] public void RequestEvents_Get_ItemContainer_EmptyResponse() { EventManager.request.Bind("EmptyTestItemContainer", EmptyTestItemContainer); EventResponse response = EventManager.request.GetItemContainer("EmptyTestItemContainer"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status); } [Test] public void RequestEvents_Get_ItemContainer_NotFound() { EventResponse response = EventManager.request.GetItemContainer("WrongTestItemContainer"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } [Test] public void RequestEvents_Unbind_ItemContainer() { EventManager.request.Bind("UnbindTestItemContainer", TestItemContainer); EventResponse response = EventManager.request.GetItemContainer("UnbindTestItemContainer"); Assert.AreEqual(true, response.value.GetType() == typeof(ItemContainer)); EventManager.request.Unbind("UnbindTestItemContainer", TestItemContainer); response = EventManager.request.GetItemContainer("UnbindTestItemContainer"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } } }