private bool Test_MultiSwapping() { // Test feature if (!Test_SwapComponents()) { TestDebug.LogTestNotStarted("Test_MultiSwapping", "Failed!"); return(false); } // Initial setup bool passed = true; _iconComponent.SetActive(true); _textComponent.SetActive(false); // Execution passed &= Test_SwapComponents(); passed &= Test_SwapComponents(); passed &= Test_SwapComponents(); // Test results passed &= !_iconComponent.activeSelf && _textComponent.activeSelf; if (!passed) { TestDebug.LogTestFail("Test_MultiSwapping", "MultiSwapping failed!"); } return(passed); }
protected override bool Inner_Test(string scriptName, string testName) { if (!IsSafe) { TestDebug.LogTestFail(testName, scriptName + "." + _name + " is null"); return(false); } return(true); }
protected override bool Inner_Test(string scriptName, string testName) { if (_testMethod == null) { TestDebug.LogTestFail(testName, scriptName + "." + _name + " is null"); return(false); } if (!_testMethod()) { TestDebug.LogTestFail(testName, scriptName + "." + _name + " didn't passed Test()"); return(false); } return(true); }
public bool Test() { string scriptName = _testUtils != null ? _testUtils.ScriptName : TestUtils.kDefaultScriptName; string testName = _testUtils != null ? _testUtils.TestName : TestUtils.kDefaultTestName; try { return(Inner_Test(scriptName, testName)); } catch { TestDebug.LogTestFail(testName, scriptName + "." + _name + " didn't passed Test(). UNHANDLED ERROR!"); return(false); } }
/// <summary> /// Get the methods that will be tested during TestMethods() /// </summary> private List <BaseTestClass> Test_GetMethods(TestUtils testUtils) { MonoBehaviour[] scriptComponents = GetComponents <MonoBehaviour>(); List <BaseTestClass> testMethods = new List <BaseTestClass>(); foreach (MonoBehaviour mono in scriptComponents) { var methods = mono.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (var method in methods) { var attributes = method.GetCustomAttributes(typeof(TestingMethodAttribute), true); if (attributes.Length > 0) { ActionTestMethod testMethod = null; // Try use alternative method name var attribute = attributes[0] as TestingMethodAttribute; if (!string.IsNullOrEmpty(attribute.AltMethodName)) { var altMethod = Array.Find(methods, x => x.Name == attribute.AltMethodName); if (altMethod != null) { testMethod = new ActionTestMethod(testUtils, altMethod.Name, () => altMethod.Invoke(mono, null)); } else { TestDebug.LogTestFail(TestUtils.kTestMethodName, "Alternative name not found for method: " + method.Name); } } // If needed, use method name if (testMethod == null) { testMethod = new ActionTestMethod(testUtils, method.Name, () => method.Invoke(mono, null)); } testMethods.Add(testMethod); } } } return(testMethods); }