12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 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<bool> response = EventManager.request.GetBool("TestBool");
- Assert.AreEqual(true, response.value);
- Assert.AreEqual(EventResponseStatus.OK, response.status);
- }
- [Test]
- public void RequestEvents_Get_bool_NotFound()
- {
- EventResponse<bool> response = EventManager.request.GetBool("TestEmptyBool");
- Assert.AreEqual(EventResponseStatus.NotFound, response.status);
- }
- [Test]
- public void RequestEvents_Unbind_bool()
- {
- EventManager.request.Bind("UnbindTest", TestBool);
- EventResponse<bool> 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<GameObject> 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<GameObject> response = EventManager.request.GetGameObject("TestEmptyGameObject");
- Assert.IsNull(response.value);
- Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status);
- }
- [Test]
- public void RequestEvents_Get_GameObject_NotFound()
- {
- EventResponse<GameObject> 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<GameObject> 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);
- }
- }
-
- }
- }
|