123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System.Collections;
- using System.Collections.Generic;
- using NUnit.Framework;
- using UnityEngine;
- using UnityEngine.TestTools;
- using KairoEngine.Core;
- using KairoEngine.Core.GameActions;
- namespace KairoEngine.Core.EditorTests.GameActions
- {
- public class ConditionalGameActionTests
- {
- private GameActionsController controller;
- private ConditionalGameAction conditional;
- private GameActionContextString stringVariable;
- private CompareStringsGameActionCondition compareStrings;
- private DebugLogGameAction debugAction1;
- private DebugLogGameAction debugAction2;
- [SetUp]
- public void Setup()
- {
- controller = new GameActionsController();
- // Create conditional action
- conditional = new ConditionalGameAction(controller);
- // Create string variable
- stringVariable = new GameActionContextString();
- stringVariable.name = "stringVariable";
- stringVariable.value = "test";
- controller.context.variables.Add(stringVariable);
- // Create compare strings condition
- compareStrings = new CompareStringsGameActionCondition();
- compareStrings.variable = "stringVariable";
- compareStrings.stringValue = "test";
- compareStrings.equals = true;
- compareStrings.controller = controller;
- conditional.conditions.Add(compareStrings);
- // Create debug action for true condition
- debugAction1 = new DebugLogGameAction(conditional.ifController);
- debugAction1.message ="if path";
- conditional.ifController.actions.Add(debugAction1);
- // Create debug action for false condition
- debugAction2 = new DebugLogGameAction(conditional.ifController);
- debugAction2.message ="else path";
- conditional.elseController.actions.Add(debugAction2);
- // Add conditional to controller and start
- controller.actions.Add(conditional);
- }
- [TearDown]
- public void TearDown()
- {
- controller = null;
- conditional = null;
- stringVariable = null;
- compareStrings = null;
- debugAction1 = null;
- debugAction2 = null;
- }
-
- [UnityTest]
- public IEnumerator ConditionalGameAction_IfPathIntegrationTest()
- {
-
- LogAssert.Expect(LogType.Log, "if path");
- controller.Start();
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- }
- [UnityTest]
- public IEnumerator ConditionalGameAction_ElsePathIntegrationTest()
- {
- compareStrings.equals = false;
- LogAssert.Expect(LogType.Log, "else path");
- controller.Start();
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- }
- [UnityTest]
- public IEnumerator ConditionalGameAction_DuplicationTest()
- {
- GameActionsController newController = controller.Duplicate();
- LogAssert.Expect(LogType.Log, "if path");
- newController.Start();
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- yield return null;
- }
- }
- }
|