/// <summary> /// Initializes a new <see cref="AutomatedPSycheTest"/>. /// </summary> /// <param name="script">The test script containing a test</param> /// <param name="test">The test function</param> public AutomatedPSycheTest(ITestScript script, ITestFunction test) { Name = String.Format("{0}:{1}", script.Source.Name, test.DisplayName); TestType = "Integration Test"; Storage = script.Source.Name; Identifier = _identifierFactory.CreateIdentifier(Name); }
private void OnTestStarting(ITestFunction test) { var localEvent = TestStarting; if (localEvent != null) { localEvent(this, new TestStartingEventArgs(test)); } }
/// <summary> /// Maps a <see cref="TestFunction"/> to a <see cref="TestCase"/>. /// </summary> /// <param name="test">The test to map</param> /// <returns>A Visual Studio <see cref="TestCase"/></returns> public TestCase Map(ITestFunction test) { return(new TestCase(test.UniqueName, VSTestExecutor.ExecutorUri, test.Source.File.FullName) { CodeFilePath = test.Source.File.FullName, DisplayName = test.DisplayName, LineNumber = test.Source.LineNumber }); }
private void OnTestEnded(ITestFunction test, TestResult result) { var localEvent = TestEnded; if (localEvent != null) { localEvent(this, new TestEndedEventArgs(test, result)); } }
/// <summary> /// Initializes a new <see cref="TestLocationManager"/> for a test. /// </summary> /// <param name="outputDirectory">The root working directory of a test</param> /// <param name="script">The current test script</param> /// <param name="test">The current test</param> public TestLocationManager(DirectoryInfo outputDirectory, ITestScript script, ITestFunction test) { _scriptDirectory = new DirectoryInfo(Path.Combine( outputDirectory.FullName, script.Source.Name)); if (!_scriptDirectory.Exists) _scriptDirectory.Create(); _testDirectory = _scriptDirectory.CreateSubdirectory(test.DisplayName); OutputDirectory = _testDirectory; ScriptLocation = script.Source.Directory; }
private TestResult GetTestResult(ITestFunction item, double value) { var result = new TestResult(); double error = Math.Abs(value - item.ExactValue); result.Name = item.GetType().Name; result.Value = value; result.Error = error; result.ExactValue = item.ExactValue; result.Count = item.Count; return(result); }
private void ProcessError(ITestFunction item, Exception e) { var lvi = new ListViewItem(new string[] { item.GetType().Name, "FAILED", String.Empty, String.Empty, String.Empty, String.Empty, String.Empty }); lvi.ForeColor = Color.Red; listView1.Items.Add(lvi); }
/// <summary> /// Initializes a new instance of <see cref="TestStartingEventArgs"/>. /// </summary> /// <param name="test">The test that has ended</param> /// <param name="result">The result of the test</param> public TestEndedEventArgs(ITestFunction test, TestResult result) { Test = test; Result = result; }
public MghObjectiveFunction(ITestFunction testFunction, bool use_gradient, bool use_hessian) : base(use_gradient, use_hessian) { this.TestFunction = testFunction; }
private async Task <IReadOnlyCollection <ErrorRecord> > ExecuteCoreAsync(PowerShell powershell, ITestFunction test, ITestScript script) { // Add the script's functions/variables to the pipeline. powershell.AddScript(script.Text); var scriptErrors = await powershell.InvokeAsync(_taskScheduler).ConfigureAwait(false); powershell.Commands.Clear(); // Clear the pipeline. if (scriptErrors.Any()) { return(scriptErrors); } // Now execute the test function plus setup/teardown. script.TestSetup.Apply(s => powershell.AddCommand(s.Name)); powershell.AddCommand(test.FunctionName); script.TestCleanup.Apply(s => powershell.AddCommand(s.Name)); var testErrors = await powershell.InvokeAsync(_taskScheduler).ConfigureAwait(false); if (testErrors.Any()) { return(testErrors); } return(new ErrorRecord[0]); }
/// <summary> /// Executes a test function. /// </summary> /// <param name="transaction">The current test transaction</param> /// <param name="powershell">The PowerShell instance to us</param> /// <param name="test">The test to run</param> /// <param name="script">The parent script</param> private async Task <IEnumerable <TestResult> > ExecuteAsync(ITestExecutionTransaction transaction, PowerShell powershell, ITestFunction test, ITestScript script) { var timer = _timerFactory(); try { if (test.ShouldSkip) { return(new SkippedResult(test.SkipReason).ToEnumerable()); } var testContext = InitializeTestContext(powershell, transaction.OutputDirectory); IReadOnlyCollection <ErrorRecord> errors; using (timer.Start()) { errors = await ExecuteCoreAsync(powershell, test, script).ConfigureAwait(false); } if (errors.Any()) { return(new FailedResult(timer.Elapsed, new PSScriptError(new ErrorRecordWrapper(errors.First()), test.Source.File)).ToEnumerable()); } return(new PassedResult(timer.Elapsed, testContext.Artifacts).ToEnumerable()); } catch (CmdletInvocationException cmdletException) { return(CreateFailed(timer.Elapsed, cmdletException.InnerException ?? cmdletException).ToEnumerable()); } catch (Exception exception) { _logger.Error("Exception occurred during test '{0}': {1}{2}{3}", test.UniqueName, exception.Message, Environment.NewLine, exception.StackTrace); return(CreateFailed(timer.Elapsed, exception).ToEnumerable()); } }
public double Integrate(ITestFunction testFunction, double tolerance) { return(AdaptiveMixedDasDash.Integrate(testFunction.Eval, testFunction.A, testFunction.B, tolerance, 1000)); }
public double Integrate(ITestFunction testFunction, double tolerance) { return(AdaptiveGaussLobatto.Integrate(testFunction.Eval, testFunction.A, testFunction.B, tolerance)); }
public double Integrate(ITestFunction testFunction, double tolerance) { return(NewtonCotesTrapeziumRule.IntegrateAdaptive(testFunction.Eval, testFunction.A, testFunction.B, tolerance)); }
/// <summary> /// Initializes a new instance of <see cref="TestStartingEventArgs"/>. /// </summary> /// <param name="test">The test that is starting</param> public TestStartingEventArgs(ITestFunction test) { Test = test; }