public IAssertionResult WarningInTheScene() { IAssertionResult result = null; if (this.WarningTextObject == null) { result = new AssertionResultRetry("No warning on the scene"); } else if (!this.WarningTextObject.activeSelf) { result = new AssertionResultRetry("No visible warning on the scene"); } else { Text text = this.WarningTextObject.GetComponent <Text>(); if (text.text.Equals(this.ExpectedWarningText)) { result = new AssertionResultSuccessful(); } else { result = new AssertionResultFailed("The warning message has not the expected text: \"" + text.text + "\" instead of \"" + this.ExpectedWarningText); } } return(result); }
public IAssertionResult TheNewObjectAppears() { IAssertionResult result = null; GameObject cube = GameObject.FindWithTag(CubeTag); if (cube == null || !cube.name.Equals(CubeName)) { result = new AssertionResultRetry("\"" + CubeName + "\" not found"); } else if (cube != null && cube.activeSelf) { result = new AssertionResultSuccessful(); } return(result); }
public IAssertionResult OnlyACubeInTheScene() { IAssertionResult result = null; GameObject[] cubes = GameObject.FindGameObjectsWithTag(CubeTag); if (this.listOfCubesInTheScene.SequenceEqual(cubes) == false) { result = new AssertionResultFailed("The objects in the scene are changed!"); } else { result = new AssertionResultSuccessful(); } return(result); }
public IAssertionResult TheCubeDisappears() { IAssertionResult result = null; GameObject cube = GameObject.FindWithTag(CubeTag); if (cube != null && cube.activeSelf) { result = new AssertionResultRetry("\"object for test\" found and Active"); } else if (cube != null) { result = new AssertionResultRetry("\"object for test\" found inactive"); } else { result = new AssertionResultSuccessful(); } return(result); }
public IAssertionResult StartedAndWaitingForInput() { IAssertionResult result = null; GameObject cube = GameObject.FindWithTag(CubeTag); GameObject buttonCreate = GameObject.FindWithTag(ButtonCreateTag); if (buttonCreate == null) { result = new AssertionResultRetry("Button Create not found"); } else if (cube != null) { result = new AssertionResultFailed("There is an unexpected cube in the scene."); } else if (buttonCreate != null && buttonCreate.activeSelf) { result = new AssertionResultSuccessful(); } return(result); }
/// <summary> /// Invokes the <paramref name="methodDescription"/> method. /// </summary> /// <param name="businessLogic">The business logic.</param> /// <param name="methodDescription">The method description.</param> /// <param name="gameObject">The game object.</param> /// <returns>True if the method is executed or false if the method still has to be executed.</returns> public virtual bool InvokeMethod(ExtensionRunnerBusinessLogic businessLogic, FullMethodDescription methodDescription, GameObject gameObject) { bool performed = false; if (businessLogic.DateTimeNow().Subtract(businessLogic.StartDelayTime).TotalMilliseconds >= methodDescription.Delay) { if (businessLogic.StartTimoutTime == null) { businessLogic.StartTimoutTime = businessLogic.DateTimeNow(); } if (methodDescription.Method != null && !methodDescription.Method.Equals(string.Empty)) { MethodInfo method = methodDescription.Method; Component component = methodDescription.ComponentObject; object[] parameters = businessLogic.GetParametersValues(methodDescription); IAssertionResult executionResult = null; object executionResultObject = method.Invoke(component, parameters); if (executionResultObject == null) { string errorText = "The Step Method return null."; string scenarioText = businessLogic.GetScenarioTextForErrorInSpecificMethod(businessLogic.MethodsDescription, methodDescription); string bddMethodLocation = businessLogic.GetbddMethodLocationForSpecificMethod(businessLogic.MethodsDescription, methodDescription); businessLogic.InvokeAssertionFailed(errorText, scenarioText, bddMethodLocation, gameObject); return(true); } if (typeof(AssertionResultSuccessful).IsAssignableFrom(executionResultObject.GetType()) || typeof(AssertionResultFailed).IsAssignableFrom(executionResultObject.GetType()) || typeof(AssertionResultRetry).IsAssignableFrom(executionResultObject.GetType())) { executionResult = (IAssertionResult)executionResultObject; } else { string errorText = "The return value of the Step Method is not a valid IAssertionResult implementation."; string scenarioText = businessLogic.GetScenarioTextForErrorInSpecificMethod(businessLogic.MethodsDescription, methodDescription); string bddMethodLocation = businessLogic.GetbddMethodLocationForSpecificMethod(businessLogic.MethodsDescription, methodDescription); businessLogic.InvokeAssertionFailed(errorText, scenarioText, bddMethodLocation, gameObject); return(true); } if (executionResult is AssertionResultSuccessful) { performed = true; } else if (executionResult is AssertionResultFailed) { string errorText = ((AssertionResultFailed)executionResult).Text; string scenarioText = businessLogic.GetScenarioTextForErrorInSpecificMethod(businessLogic.MethodsDescription, methodDescription); string bddMethodLocation = businessLogic.GetbddMethodLocationForSpecificMethod(businessLogic.MethodsDescription, methodDescription); businessLogic.InvokeAssertionFailed(errorText, scenarioText, bddMethodLocation, gameObject); performed = true; } else if (executionResult is AssertionResultRetry) { if (businessLogic.DateTimeNow().Subtract(businessLogic.StartTimoutTime ?? DateTime.MaxValue).TotalMilliseconds >= methodDescription.TimeOut) { string errorText = ((AssertionResultRetry)executionResult).Text; string scenarioText = businessLogic.GetScenarioTextForErrorInSpecificMethod(businessLogic.MethodsDescription, methodDescription); string bddMethodLocation = businessLogic.GetbddMethodLocationForSpecificMethod(businessLogic.MethodsDescription, methodDescription); businessLogic.InvokeAssertionFailed(errorText, scenarioText, bddMethodLocation, gameObject); performed = true; } performed = false; } } else { performed = true; businessLogic.StartTimoutTime = null; } } return(performed); }