public override async Task <bool> Invoke(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            var parameterizedInstance = SetUp(ctx, instance);

            if (parameterizedInstance == null)
            {
                return(false);
            }

            bool found   = false;
            bool success = true;

            while (success && parameterizedInstance.HasNext())
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                success = MoveNext(ctx, parameterizedInstance);
                if (!success)
                {
                    break;
                }

                var name = TestInstance.GetTestName(parameterizedInstance);

                bool enabled;

                var filter = parameterizedInstance.Current as ITestFilter;
                if (filter != null && filter.Filter(ctx, out enabled) && !enabled)
                {
                    var ignoredResult = new TestResult(name, TestStatus.Ignored);
                    ctx.Result.AddChild(ignoredResult);
                    continue;
                }

                found = true;

                var innerCtx = ctx.CreateChild(name, parameterizedInstance, ctx.Result);

                ctx.LogDebug(10, "InnerInvoke({0}): {1} {2} {3}", name.FullName,
                             TestLogger.Print(Host), TestLogger.Print(parameterizedInstance), Inner);

                success = await InvokeInner(innerCtx, parameterizedInstance, Inner, cancellationToken);

                ctx.LogDebug(10, "InnerInvoke({0}) done: {1} {2} {3}", name.FullName,
                             TestLogger.Print(Host), TestLogger.Print(parameterizedInstance), success);
            }

            if (success && !found)
            {
                ctx.OnTestFinished(TestStatus.Ignored);
            }

            return(success);
        }
Example #2
0
        public override async Task <bool> Invoke(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            var innerInstance = SetUp(ctx, instance);

            if (innerInstance == null)
            {
                return(false);
            }

            var innerCtx = ctx.CreateChild(TestInstance.GetTestName(innerInstance), innerInstance);

            var success = await InvokeInner(innerCtx, innerInstance, Inner, cancellationToken);

            if (!TearDown(ctx, innerInstance))
            {
                success = false;
            }

            return(success);
        }