public MethodResult Execute(object testClass) { object sandboxedClass = null; if (testClass != null) { var testClassType = testClass.GetType(); if (!typeof(MarshalByRefObject).IsAssignableFrom(testClassType)) { throw new InvalidOperationException( string.Format( "In order to use the partial trust attributes here, '{0}' must derive from MarshalByRefObject.", testClassType.FullName)); } sandboxedClass = PartialTrustSandbox.Default.CreateInstance(testClassType); ApplyFixtures(sandboxedClass); } else { Assert.IsType <SkipCommand>(_command); } return(_command.Execute(sandboxedClass)); }
/// <inheritdoc/> public MethodResult Execute(object testClass) { Frame.Initialize(testClass, this); // execute delegated test command return(_proxy.Execute(testClass)); }
public MethodResult Execute(object testClass) { using (var testFixtureScope = _testFixtureFactory.Create()) { return(_testCommand.Execute(testFixtureScope.Fixture)); } }
public void Invoke(object instance) { var methodResult = testCommand.Execute(testClassCommand.ObjectUnderTest); var failedResult = methodResult as ExceptionResult; if (failedResult != null) { throw new TargetInvocationException(failedResult.Exception); } }
public MethodResult Execute(object testClass) { if (testClass is Specification) { var specification = (Specification)testClass; specification.Given(); specification.When(); } return(_innerCommand.Execute(testClass)); }
public override MethodResult Execute(object testClass) { var testType = testClass.GetType(); var browserProp = SeleniumBrowserAttribute.GetBrowserProperty(testType); using (var browser = _creator()) { browserProp.SetValue(testClass, browser); return(_inner.Execute(testClass)); } }
public MethodResult Execute(object testClass) { try { return(inner.Execute(testClass)); } catch (SkipException e) { return(new SkipResult(method, DisplayName, e.Reason)); } }
private async Task <ITestCommandResult> RunCommand(TestRun testRun, Test test, ITestCommand command, TestContext context) { this.logger.LogInformation($"Starting execution of command {command.Id} for test {test.Id}."); try { return(await command.Execute(context, CancellationToken.None)); } catch (Exception ex) { this.logger.LogError(ex, $"Unexpected error executing command {command.Id}."); throw; } }
/// <inheritdoc/> public override MethodResult Execute(object testClass) { if (testClass != null) { throw new InvalidOperationException("testClass is unexpectedly not null"); } var bootstrapper = GetContainer(); using (var lifetimeScope = bootstrapper.CreateScope()) { testClass = lifetimeScope.GetType(testMethod.Class.Type); return(_innerCommand.Execute(testClass)); } }
public MethodResult Execute(object testClass) { var dbTestClass = testClass as DbTestCase; if (dbTestClass == null) { throw new InvalidOperationException( string.Format( "Expected {0} to be derived from {1}", testClass.GetType().FullName, typeof(DbTestCase).FullName)); } dbTestClass.Init(_provider, _language); return(_innerCommand.Execute(testClass)); }
public override MethodResult Execute(object testClass) { MethodResult result = null; System.Threading.Tasks.Parallel.For(0, _count, i => { var temp = _inner.Execute(testClass); if (result == null || temp is FailedResult) { result = temp; } }); return(result); }
public MethodResult Execute(object testClass) { try { if (testClass == null) { return(null); } var testClassType = testClass.GetType(); if (!typeof(MarshalByRefObject).IsAssignableFrom(testClassType)) { throw new InvalidOperationException( string.Format("Test class attribute '{0}' must derive from MarshalByRefObject.", testClassType.FullName)); } object sandboxedClass = null; var mediumTrustSandbox = new MediumTrustDomain(); var partialTrustDomain = mediumTrustSandbox.CreatePartialTrustAppDomain(); sandboxedClass = partialTrustDomain.CreateInstanceAndUnwrap(testClassType.Assembly.FullName, testClassType.FullName); if (_fixtures != null) { foreach (var fixture in _fixtures) { fixture.Key.Invoke(sandboxedClass, new object[] { fixture.Value }); } } var result = _command.Execute(sandboxedClass); mediumTrustSandbox.Dispose(); return(result); } catch (Exception ex) { if (ex.Message.Equals("Assembly is still loading")) { //This case is when our assembly was not found. } } return(null); }
public MethodResult Execute(object testClass) { object sandboxedClass = null; try { if (testClass != null) { var testClassType = testClass.GetType(); if (!typeof(MarshalByRefObject).IsAssignableFrom(testClassType)) { throw new InvalidOperationException( string.Format( "In order to use the partial trust attributes here, '{0}' must derive from MarshalByRefObject.", testClassType.FullName)); } sandboxedClass = PartialTrustSandbox.Default.CreateInstance(testClassType); ApplyFixtures(sandboxedClass); if (FunctionalTestsConfiguration.SuspendExecutionStrategy) { var defaultSandboxed = sandboxedClass as IUseDefaultExecutionStrategy; if (defaultSandboxed != null) { defaultSandboxed.UseDefaultExecutionStrategy(); } } } else { Assert.IsType <SkipCommand>(_command); } return(_command.Execute(sandboxedClass)); } finally { var asDisposable = sandboxedClass as IDisposable; if (asDisposable != null) { asDisposable.Dispose(); } } }
public MethodResult Execute(object testClass) { if (_methodInfo.MethodInfo.DeclaringType != testClass.GetType()) { return(new PassedResult(_methodInfo, null)); } if (testClass is Specification) { var specification = (Specification)testClass; specification.Given(); specification.When(); } var methodResult = _innerCommand.Execute(testClass); return(methodResult); }
private static async Task RunTest(IClusterClient client, ITestCommand command) { int iteration = 0; int batch = 1; Stopwatch stopwatch = Stopwatch.StartNew(); while (true) { #region Handle Stop if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Escape) { Console.CursorLeft = 0; Console.WriteLine("==> Exiting stress test."); break; } #endregion int partitionNumber = iteration % 100; try { await command.Execute(client, partitionNumber, iteration); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine($"==> Caught exception {ex.Message}"); Console.WriteLine(); } if (partitionNumber == 99) { long milliseconds = stopwatch.ElapsedMilliseconds; Console.WriteLine($"==> Batch {batch++}: Average completion time of last 100 tasks: {milliseconds / 100}ms."); stopwatch.Restart(); } iteration++; } stopwatch.Stop(); }
public MethodResult Execute(object testClass) { var parameters = MethodInfo.GetParameters(); if (parameters == null || parameters.Length == 0) { return(_testCommand.Execute(testClass)); } else { var dependencyResolver = ContainerResolver.GetDependencyResolver(Class.Type); var arrparameters = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { arrparameters[i] = dependencyResolver.GetType(parameters[i].ParameterType); } Invoke(testClass, arrparameters); return(new PassedResult(_method, DisplayName)); } }
/// <summary> /// Executes the specified test class. /// </summary> /// <param name="testClass">The test class.</param> /// <returns> /// The method result of the xUnit.net test execution. /// </returns> public override MethodResult Execute(object testClass) { var specification = testClass as ISpecification; try { if (specification == null) { throw new InvalidOperationException("Instance doesn't implement ISpecification"); } specification.Initialize(); return(_innerCommand.Execute(testClass)); } finally { if (specification != null) { specification.Cleanup(); } } }
public MethodResult Execute(object testClass) { action(testClass); return(inner.Execute(testClass)); }
public async Task <ActionResult> Hello() { var name = await testCommand.Execute(); return(Ok(name)); }