using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Security.Policy; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using KairoEngine.Core; namespace KairoEngine.Core.EditorTests { public class RequestEventsTests { [Test] public void RequestEvents_Exists() { Assert.AreEqual(true, typeof(RequestEvents) != null); } public class Request_bool_with_no_args { private bool TestBool() => true; [Test] public void RequestEvents_Get_bool() { EventManager.request.Bind("TestBool", TestBool); EventResponse response = EventManager.request.GetBool("TestBool"); Assert.AreEqual(true, response.value); Assert.AreEqual(EventResponseStatus.OK, response.status); } [Test] public void RequestEvents_Get_bool_NotFound() { EventResponse response = EventManager.request.GetBool("TestEmptyBool"); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } [Test] public void RequestEvents_Unbind_bool() { EventManager.request.Bind("UnbindTest", TestBool); EventResponse response = EventManager.request.GetBool("UnbindTest"); Assert.AreEqual(true, response.value); EventManager.request.Unbind("UnbindTest", TestBool); response = EventManager.request.GetBool("UnbindTest"); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } } public class Request_GameObject_with_no_args { private GameObject TestGameObject() => GameObject.Instantiate(new GameObject()); private GameObject TestEmptyGameObject() => null; [Test] public void RequestEvents_Get_GameObject() { EventManager.request.Bind("TestGameObject", TestGameObject); EventResponse response = EventManager.request.GetGameObject("TestGameObject"); Assert.AreEqual(true, response.value.GetType() == typeof(GameObject)); Assert.AreEqual(EventResponseStatus.OK, response.status); } [Test] public void RequestEvents_Get_GameObject_EmptyResponse() { EventManager.request.Bind("TestEmptyGameObject", TestEmptyGameObject); EventResponse response = EventManager.request.GetGameObject("TestEmptyGameObject"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status); } [Test] public void RequestEvents_Get_GameObject_NotFound() { EventResponse response = EventManager.request.GetGameObject("WrongTestGameObject"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } [Test] public void RequestEvents_Unbind_GameObject() { EventManager.request.Bind("UnbindGameObjectTest", TestGameObject); EventResponse response = EventManager.request.GetGameObject("UnbindGameObjectTest"); Assert.AreEqual(true, response.value.GetType() == typeof(GameObject)); EventManager.request.Unbind("UnbindGameObjectTest", TestGameObject); response = EventManager.request.GetGameObject("UnbindGameObjectTest"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } } } }