12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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 itemContainer = obj.GetComponent<ItemContainer>();
- return itemContainer;
- }
- private ItemContainer EmptyTestItemContainer() => null;
- [Test]
- public void RequestEvents_Get_ItemContainer()
- {
- EventManager.request.Bind("TestItemContainer", TestItemContainer);
- EventResponse<ItemContainer> 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<ItemContainer> response = EventManager.request.GetItemContainer("EmptyTestItemContainer");
- Assert.IsNull(response.value);
- Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status);
- }
- [Test]
- public void RequestEvents_Get_ItemContainer_NotFound()
- {
- EventResponse<ItemContainer> 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<ItemContainer> 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);
- }
- }
- }
|