Beispiel #1
0
 public void InvokeAll(TestContext context, object?testObject = null)
 {
     GetMethods(context)?.ForEach(m =>
     {
         m.Invoke(testObject ?? context.CreateTestObject(), new object[] {});
     });
 }
Beispiel #2
0
        private async Task <TestResult> RunTestCase(TestContext context, TestCase testCase)
        {
            var testObject = context.CreateTestObject();
            var method     = testCase.Method;
            var testResult = new TestResult(method);

            try
            {
                if (testObject is Node node)
                {
                    _sceneTree.Root.AddChild(node);
                }

                _setupMethods.InvokeAll(context, testObject);

                object obj = method.Invoke(testObject, testCase.Parameters);

                if (obj is IEnumerator coroutine)
                {
                    while (coroutine.MoveNext())
                    {
                        await Task.Delay(10);
                    }
                }

                testCase.ExpectedResult?.With(x => Assert.AreEqual(x, obj));
            }
            catch (Exception e)
            {
                testResult = new TestResult(method, e.InnerException ?? e);
            }
            finally
            {
                _teardownMethods.InvokeAll(context, testObject);

                (testObject as Node)?.QueueFree();
            }

            return(testResult);
        }