using System.Collections; using System.Collections.Generic; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using KairoEngine.Core; using KairoEngine.CharacterSystem; namespace KairoEngine.CharacterSystem.EditorTests { public class RequestEventsCharacterExtensionsTests { private CharacterController TestCharacter() { GameObject obj = new GameObject(); obj.AddComponent(); CharacterController character = obj.GetComponent(); return character; } private CharacterController EmptyTestCharacter() => null; [Test] public void RequestEvents_Get_Character() { EventManager.request.Bind("TestCharacter", TestCharacter); EventResponse response = EventManager.request.GetCharacterController("TestCharacter"); Assert.AreEqual(typeof(CharacterController), response.value.GetType()); Assert.AreEqual(EventResponseStatus.OK, response.status); } [Test] public void RequestEvents_Get_Character_EmptyResponse() { EventManager.request.Bind("EmptyTestCharacter", EmptyTestCharacter); EventResponse response = EventManager.request.GetCharacterController("EmptyTestCharacter"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status); } [Test] public void RequestEvents_Get_Character_NotFound() { EventResponse response = EventManager.request.GetCharacterController("WrongTestCharacter"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } [Test] public void RequestEvents_Unbind_Character() { EventManager.request.Bind("UnbindTestCharacter", TestCharacter); EventResponse response = EventManager.request.GetCharacterController("UnbindTestCharacter"); Assert.AreEqual(true, response.value.GetType() == typeof(CharacterController)); EventManager.request.Unbind("UnbindTestCharacter", TestCharacter); response = EventManager.request.GetCharacterController("UnbindTestCharacter"); Assert.IsNull(response.value); Assert.AreEqual(EventResponseStatus.NotFound, response.status); } } }