コード例 #1
0
        internal TestInstance CreateInstance(TestContext ctx, TestPath path, TestInstance parent)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var instance = CreateInstance(path, parent);

            instance.Initialize(ctx);
            return(instance);
        }
コード例 #2
0
        internal TestInstance CreateInstance(TestContext ctx, TestNode node, TestInstance parent)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            var instance = CreateInstance(node, parent);

            instance.Initialize(ctx);
            return(instance);
        }
コード例 #3
0
        bool MoveNext(TestContext ctx, TestInstance instance)
        {
            ctx.LogDebug(10, "MoveNext({0}): {1} {2}", ctx.Name, TestLogger.Print(Host), TestLogger.Print(instance));

            try {
                return(((ParameterizedTestInstance)instance).MoveNext(ctx));
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(false);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(false);
            }
        }
コード例 #4
0
        bool SetUp(TestContext ctx, TestInstance instance)
        {
            ctx.LogDebug(10, "SetUp({0}): {1} {2}", ctx.FriendlyName, TestLogger.Print(Builder), TestLogger.Print(instance));

            try {
                ResolveChildren(ctx);
                return(true);
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(false);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(false);
            }
        }
コード例 #5
0
ファイル: TestInstance.cs プロジェクト: Roykens/web-tests
        protected TestInstance(TestHost host, TestPath path, TestInstance parent)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            Host   = host;
            Parent = parent;
            Path   = path;
        }
コード例 #6
0
        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 path = parameterizedInstance.GetCurrentPath();

                found = true;

                var innerCtx = ctx.CreateChild(path, ctx.Result);

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

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

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

            if (success && !found)
            {
                ctx.OnTestIgnored();
            }

            return(success);
        }
コード例 #7
0
        ParameterizedTestInstance SetUp(TestContext ctx, TestInstance instance)
        {
            ctx.LogDebug(10, "SetUp({0}): {1} {2}", ctx.Name, TestLogger.Print(Host), TestLogger.Print(instance));

            try {
                var parameterizedInstance = CreateInstance(instance);
                parameterizedInstance.Initialize(ctx);
                return(parameterizedInstance);
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(null);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(null);
            }
        }
コード例 #8
0
        public override async Task <bool> Invoke(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            if (!await PreRun(ctx, instance, cancellationToken))
            {
                return(false);
            }

            var success = await InvokeInner(ctx, instance, Inner, cancellationToken);

            if (!await PostRun(ctx, instance, cancellationToken))
            {
                success = false;
            }

            return(success);
        }
コード例 #9
0
ファイル: TestInstance.cs プロジェクト: stefb965/web-tests
        protected FixtureTestInstance GetFixtureInstance()
        {
            TestInstance instance = this;

            while (instance != null)
            {
                var fixtureInstance = instance as FixtureTestInstance;
                if (fixtureInstance != null)
                {
                    return(fixtureInstance);
                }

                instance = instance.Parent;
            }

            throw new InternalErrorException();
        }
コード例 #10
0
        public sealed override async Task <bool> Invoke(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(false);
            }

            if (!SetUp(ctx, instance))
            {
                return(false);
            }

            ctx.LogDebug(10, "Invoke({0}): {1} {2} {3}", ctx.FriendlyName,
                         Flags, TestLogger.Print(instance), children.Count);

            bool success = true;

            foreach (var child in children)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                ctx.LogDebug(10, "InnerInvoke({0}): {1} {2}", ctx.FriendlyName,
                             TestLogger.Print(instance), child);

                var invoker = child.Item2;

                success = await InvokeInner(ctx, instance, invoker, cancellationToken);

                ctx.LogDebug(10, "InnerInvoke({0}) done: {1} {2}", ctx.FriendlyName,
                             TestLogger.Print(instance), success);

                if (!success)
                {
                    break;
                }
            }

            ctx.LogDebug(10, "Invoke({0}) done: {1} {2} - {3}", ctx.FriendlyName,
                         Flags, TestLogger.Print(instance), success);

            return(success);
        }
コード例 #11
0
ファイル: TestInstance.cs プロジェクト: stefb965/web-tests
        protected TestInstance(TestHost host, TestNode node, TestInstance parent)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            Host   = host;
            Node   = node;
            Parent = parent;

            ParentPath = Parent?.GetCurrentPath();
            Path       = new TestPath(ParentPath, Node);
        }
コード例 #12
0
        protected async Task <bool> InvokeInner(
            TestContext ctx, TestInstance instance, TestInvoker invoker,
            CancellationToken cancellationToken)
        {
            ctx.LogDebug(10, "Running({0}): {1}", ctx.Name, invoker);

            try {
                cancellationToken.ThrowIfCancellationRequested();
                var success = await invoker.Invoke(ctx, instance, cancellationToken);

                return(success || ContinueOnError);
            } catch (OperationCanceledException) {
                ctx.OnTestFinished(TestStatus.Canceled);
                return(false);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(false);
            }
        }
コード例 #13
0
        async Task <HeavyTestInstance> SetUp(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            ctx.LogDebug(10, "SetUp({0}): {1} {2}", ctx.FriendlyName, TestLogger.Print(Host), TestLogger.Print(instance));

            try {
                cancellationToken.ThrowIfCancellationRequested();
                var childInstance = (HeavyTestInstance)Host.CreateInstance(ctx, Node, instance);
                await childInstance.Initialize(ctx, cancellationToken);

                return(childInstance);
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(null);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(null);
            }
        }
コード例 #14
0
        TestBuilderInstance SetUp(TestContext ctx, TestInstance instance)
        {
            ctx.LogDebug(10, "SetUp({0}): {1} {2}", ctx.FriendlyName, TestLogger.Print(Host), TestLogger.Print(instance));

            try {
                if (!Filter(ctx))
                {
                    ctx.OnTestIgnored();
                    return(null);
                }
                return((TestBuilderInstance)Host.CreateInstance(ctx, Node, instance));
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(null);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(null);
            }
        }
コード例 #15
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);
        }
コード例 #16
0
        async Task <bool> PostRun(
            TestContext ctx, TestInstance instance, CancellationToken cancellationToken)
        {
            ctx.LogDebug(10, "PostRun({0}): {1}", ctx.Name, TestLogger.Print(instance));

            try {
                for (var current = instance; current != null; current = current.Parent)
                {
                    var heavy = current as HeavyTestInstance;
                    if (heavy != null)
                    {
                        await heavy.PostRun(ctx, cancellationToken);
                    }
                }
                return(true);
            } catch (OperationCanceledException) {
                ctx.OnTestCanceled();
                return(false);
            } catch (Exception ex) {
                ctx.OnError(ex);
                return(false);
            }
        }
コード例 #17
0
 public ParameterizedTestInstance(ParameterizedTestHost host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
コード例 #18
0
 public ParameterizedTestInstance(ParameterizedTestHost host, TestNode node, TestInstance parent)
     : base(host, node, parent)
 {
 }
コード例 #19
0
 public HeavyTestInstance(HeavyTestHost host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
コード例 #20
0
 internal sealed override TestInstance CreateInstance(TestInstance parent)
 {
     return(new InvokableTestInstance(this, parent));
 }
コード例 #21
0
 internal abstract ITestParameter GetParameter(TestInstance instance);
コード例 #22
0
        internal override ITestParameter GetParameter(TestInstance instance)
        {
            var parameterizedInstance = (ParameterizedTestInstance)instance;

            return(parameterizedInstance.Current.Parameter);
        }
コード例 #23
0
 internal override TestInstance CreateInstance(TestPath path, TestInstance parent)
 {
     return(new FixedParameterInstance <T> (this, path, parent));
 }
コード例 #24
0
 internal override TestInstance CreateInstance(TestPath path, TestInstance parent)
 {
     return(new CustomTestInstance(this, path, parent, HostType, UseFixtureInstance));
 }
コード例 #25
0
 public CustomTestInstance(CustomTestHost host, TestNode node, TestInstance parent)
     : base(host, node, parent)
 {
 }
コード例 #26
0
ファイル: ForkedTestHost.cs プロジェクト: Roykens/web-tests
 internal override TestInstance CreateInstance(TestPath path, TestInstance parent)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
 public abstract Task <bool> Invoke(TestContext ctx, TestInstance instance, CancellationToken cancellationToken);
コード例 #28
0
ファイル: ForkedTestHost.cs プロジェクト: Roykens/web-tests
 internal override ITestParameter GetParameter(TestInstance instance)
 {
     return(null);
 }
コード例 #29
0
 public FixedParameterInstance(FixedParameterHost <T> host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
コード例 #30
0
 internal abstract TestInstance CreateInstance(TestNode node, TestInstance parent);