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); }
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); }
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); } }
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); } }
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; }
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); }
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); } }
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); }
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(); }
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); }
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); }
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); } }
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); } }
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); } }
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); }
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); } }
public ParameterizedTestInstance(ParameterizedTestHost host, TestPath path, TestInstance parent) : base(host, path, parent) { }
public ParameterizedTestInstance(ParameterizedTestHost host, TestNode node, TestInstance parent) : base(host, node, parent) { }
public HeavyTestInstance(HeavyTestHost host, TestPath path, TestInstance parent) : base(host, path, parent) { }
internal sealed override TestInstance CreateInstance(TestInstance parent) { return(new InvokableTestInstance(this, parent)); }
internal abstract ITestParameter GetParameter(TestInstance instance);
internal override ITestParameter GetParameter(TestInstance instance) { var parameterizedInstance = (ParameterizedTestInstance)instance; return(parameterizedInstance.Current.Parameter); }
internal override TestInstance CreateInstance(TestPath path, TestInstance parent) { return(new FixedParameterInstance <T> (this, path, parent)); }
internal override TestInstance CreateInstance(TestPath path, TestInstance parent) { return(new CustomTestInstance(this, path, parent, HostType, UseFixtureInstance)); }
public CustomTestInstance(CustomTestHost host, TestNode node, TestInstance parent) : base(host, node, parent) { }
internal override TestInstance CreateInstance(TestPath path, TestInstance parent) { throw new NotImplementedException(); }
public abstract Task <bool> Invoke(TestContext ctx, TestInstance instance, CancellationToken cancellationToken);
internal override ITestParameter GetParameter(TestInstance instance) { return(null); }
public FixedParameterInstance(FixedParameterHost <T> host, TestPath path, TestInstance parent) : base(host, path, parent) { }
internal abstract TestInstance CreateInstance(TestNode node, TestInstance parent);