internal TestCaseViewModel(string assemblyFileName, ITestCase testCase) { AssemblyFileName = assemblyFileName ?? throw new ArgumentNullException(nameof(assemblyFileName)); TestCase = testCase ?? throw new ArgumentNullException(nameof(testCase)); Result = TestState.NotRun; RunStatus = RunStatus.NotRun; Message = "🔷 not run"; // Create an initial result representing not run _testResult = new TestResultViewModel(this, null); }
async void MakeTestResultViewModel(ITestResultMessage testResult, TestState outcome) { var tcs = new TaskCompletionSource <TestResultViewModel>(TaskCreationOptions.RunContinuationsAsynchronously); if (!_testCases.TryGetValue(testResult.TestCase, out TestCaseViewModel? testCase)) { // no matching reference, search by Unique ID as a fallback testCase = _testCases.FirstOrDefault(kvp => kvp.Key.UniqueID?.Equals(testResult.TestCase.UniqueID) ?? false).Value; if (testCase == null) { return; } } // Create the result VM on the UI thread as it updates properties _context.Post(_ => { var result = new TestResultViewModel(testCase, testResult) { Duration = TimeSpan.FromSeconds((double)testResult.ExecutionTime) }; if (outcome == TestState.Failed) { result.ErrorMessage = ExceptionUtility.CombineMessages((ITestFailed)testResult); result.ErrorStackTrace = ExceptionUtility.CombineStackTraces((ITestFailed)testResult); } tcs.TrySetResult(result); }, null); var r = await tcs.Task; _listener.RecordResult(r); // bring it back to the threadpool thread }
public void RecordResult(TestResultViewModel result) { _logger.LogTestResult(result); }