123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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>();
- CharacterController character = obj.GetComponent<CharacterController>();
- return character;
- }
- private CharacterController EmptyTestCharacter() => null;
-
- [Test]
- public void RequestEvents_Get_Character()
- {
- EventManager.request.Bind("TestCharacter", TestCharacter);
- EventResponse<CharacterController> 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<CharacterController> response = EventManager.request.GetCharacterController("EmptyTestCharacter");
- Assert.IsNull(response.value);
- Assert.AreEqual(EventResponseStatus.EmptyResponse, response.status);
- }
- [Test]
- public void RequestEvents_Get_Character_NotFound()
- {
- EventResponse<CharacterController> 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<CharacterController> 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);
- }
- }
- }
|