From 4f1ede1b6499e9916ec51af4a99aa8b4a6ea2374 Mon Sep 17 00:00:00 2001 From: Jakub Chocholowicz Date: Mon, 22 Jun 2020 21:41:33 +0200 Subject: [PATCH] More changes --- .../MultiTestRunFinalizationManager.cs | 45 ++++-- ...ltiTestRunFinalizationCompleteEventArgs.cs | 10 +- ...ltiTestRunFinalizationProgressEventArgs.cs | 10 +- .../IDataCollectorAttachments.cs | 3 +- .../CodeCoverageDataAttachmentsHandler.cs | 29 ++-- .../VsTestConsoleRequestSender.cs | 2 +- .../CodeCoverageTests.cs | 23 +-- ...tiTestRunFinalizationEventsHandlerTests.cs | 4 +- .../MultiTestRunFinalizationManagerTests.cs | 131 +++++++++--------- ...CodeCoverageDataAttachmentsHandlerTests.cs | 28 +++- .../VsTestConsoleRequestSenderTests.cs | 18 +-- 11 files changed, 185 insertions(+), 118 deletions(-) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs index 0d64c60b39..af23cbcaee 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/MultiTestRunFinalization/MultiTestRunFinalizationManager.cs @@ -14,6 +14,7 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.MultiTestRunFinalization { @@ -72,12 +73,12 @@ private async Task> InternalFinalizeMultiTestRunAsync( if (completedTask == task) { - return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(false, false, null), await task, stopwatch, eventHandler); + return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(false, null), await task, stopwatch, eventHandler); } else { eventHandler?.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Informational, "Finalization was cancelled."); - return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(true, false, null), attachments, stopwatch, eventHandler); + return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); } } } @@ -87,14 +88,14 @@ private async Task> InternalFinalizeMultiTestRunAsync( { EqtTrace.Warning("MultiTestRunFinalizationManager: operation was cancelled."); } - return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(true, false, null), attachments, stopwatch, eventHandler); + return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(true, null), attachments, stopwatch, eventHandler); } catch (Exception e) { EqtTrace.Error("MultiTestRunFinalizationManager: Exception in FinalizeMultiTestRunAsync: " + e); eventHandler?.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, e.Message); - return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(false, true, e), attachments, stopwatch, eventHandler); + return FinalizeOperation(requestData, new MultiTestRunFinalizationCompleteEventArgs(false, e), attachments, stopwatch, eventHandler); } } @@ -102,10 +103,11 @@ private Collection ProcessAttachments(Collection a { if (attachments == null || !attachments.Any()) return attachments; + var logger = CreateMessageLogger(eventsHandler); + for (int i = 0; i < dataCollectorAttachmentsHandlers.Length; i++) { IDataCollectorAttachments dataCollectorAttachmentsHandler = dataCollectorAttachmentsHandlers[i]; - string attachmentsHandlerName = dataCollectorAttachmentsHandler.GetType().FullName; int attachmentsHandlerIndex = i + 1; Uri attachementUri = dataCollectorAttachmentsHandler.GetExtensionUri(); @@ -121,9 +123,9 @@ private Collection ProcessAttachments(Collection a IProgress progressReporter = new Progress((int progress) => eventsHandler?.HandleMultiTestRunFinalizationProgress( - new MultiTestRunFinalizationProgressEventArgs(attachmentsHandlerIndex, attachmentsHandlerName, progress, dataCollectorAttachmentsHandlers.Length))); + new MultiTestRunFinalizationProgressEventArgs(attachmentsHandlerIndex, dataCollectorAttachmentsHandler.GetExtensionUri(), progress, dataCollectorAttachmentsHandlers.Length))); - ICollection processedAttachments = dataCollectorAttachmentsHandler.HandleDataCollectionAttachmentSets(new Collection(attachmentsToBeProcessed), progressReporter, cancellationToken); + ICollection processedAttachments = dataCollectorAttachmentsHandler.HandleDataCollectionAttachmentSets(new Collection(attachmentsToBeProcessed), progressReporter, logger, cancellationToken); foreach (var attachment in processedAttachments) { @@ -140,7 +142,7 @@ private Collection FinalizeOperation(IRequestData requestData, Mu { testPlatformEventSource.MultiTestRunFinalizationStop(attachments.Count); requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAttachmentsAfterFinalization, attachments.Count); - requestData.MetricsCollection.Add(TelemetryDataConstants.FinalizationState, completeArgs.IsAborted ? FinalizationFailed : completeArgs.IsCanceled ? FinalizationCanceled : FinalizationCompleted); + requestData.MetricsCollection.Add(TelemetryDataConstants.FinalizationState, completeArgs.Error != null ? FinalizationFailed : completeArgs.IsCanceled ? FinalizationCanceled : FinalizationCompleted); stopwatch.Stop(); requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecForFinalization, stopwatch.Elapsed.TotalSeconds); @@ -150,5 +152,32 @@ private Collection FinalizeOperation(IRequestData requestData, Mu return attachments; } + + private IMessageLogger CreateMessageLogger(IMultiTestRunFinalizationEventsHandler eventsHandler) + { + return eventsHandler != null ? (IMessageLogger)new FinalizationMessageLogger(eventsHandler) : new NullMessageLogger(); + } + + private class FinalizationMessageLogger : IMessageLogger + { + private readonly IMultiTestRunFinalizationEventsHandler eventsHandler; + + public FinalizationMessageLogger(IMultiTestRunFinalizationEventsHandler eventsHandler) + { + this.eventsHandler = eventsHandler ?? throw new ArgumentNullException(nameof(eventsHandler)); + } + + public void SendMessage(TestMessageLevel testMessageLevel, string message) + { + eventsHandler.HandleLogMessage(testMessageLevel, message); + } + } + + private class NullMessageLogger : IMessageLogger + { + public void SendMessage(TestMessageLevel testMessageLevel, string message) + { + } + } } } diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationCompleteEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationCompleteEventArgs.cs index db61554c9d..4f73073caa 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationCompleteEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationCompleteEventArgs.cs @@ -14,21 +14,13 @@ public class MultiTestRunFinalizationCompleteEventArgs : EventArgs /// Default constructor. /// /// Specifies whether the finalization is canceled. - /// Specifies whether the finalization is aborted. /// Specifies the error encountered during the execution of the finalization. - public MultiTestRunFinalizationCompleteEventArgs(bool isCanceled, bool isAborted, Exception error) + public MultiTestRunFinalizationCompleteEventArgs(bool isCanceled, Exception error) { this.IsCanceled = isCanceled; - this.IsAborted = isAborted; this.Error = error; } - /// - /// Gets a value indicating whether the finalization is aborted or not. - /// - [DataMember] - public bool IsAborted { get; private set; } - /// /// Gets a value indicating whether the finalization is canceled or not. /// diff --git a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationProgressEventArgs.cs b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationProgressEventArgs.cs index 760987ec4a..529be7baaf 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationProgressEventArgs.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Client/Events/MultiTestRunFinalizationProgressEventArgs.cs @@ -13,13 +13,13 @@ public class MultiTestRunFinalizationProgressEventArgs : EventArgs /// Default constructor. /// /// Specifies current handler index. - /// Specifies current handler name. + /// Specifies current handler Uri. /// Specifies current handler progress. /// Specifies the overall number of handlers. - public MultiTestRunFinalizationProgressEventArgs(long currentHandlerIndex, string currentHandlerName, long currentHandlerProgress, long handlersCount) + public MultiTestRunFinalizationProgressEventArgs(long currentHandlerIndex, Uri currentHandlerUri, long currentHandlerProgress, long handlersCount) { CurrentHandlerIndex = currentHandlerIndex; - CurrentHandlerName = currentHandlerName; + CurrentHandlerUri = currentHandlerUri; CurrentHandlerProgress = currentHandlerProgress; HandlersCount = handlersCount; } @@ -31,10 +31,10 @@ public MultiTestRunFinalizationProgressEventArgs(long currentHandlerIndex, strin public long CurrentHandlerIndex { get; private set; } /// - /// Gets a current handler name. + /// Gets a current handler URI. /// [DataMember] - public string CurrentHandlerName { get; private set; } + public Uri CurrentHandlerUri { get; private set; } /// /// Gets a current handler progress. diff --git a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs index 4c1d2bdabf..cd9124743b 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/DataCollector/IDataCollectorAttachments.cs @@ -3,6 +3,7 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection { + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using System; using System.Collections.Generic; using System.Threading; @@ -25,7 +26,7 @@ public interface IDataCollectorAttachments /// Progress reporter. Accepts integers from 0 to 100 /// Cancellation token /// Gets the attachment set after Test Run Session - ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, IProgress progressReporter, CancellationToken cancellationToken); + ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken); /// /// Gets the attachment Uri, which is handled by current Collector diff --git a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs index a603bd0569..d31fda0a56 100644 --- a/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs +++ b/src/Microsoft.TestPlatform.Utilities/CodeCoverageDataAttachmentsHandler.cs @@ -9,10 +9,10 @@ namespace Microsoft.VisualStudio.TestPlatform.Utilities using System.IO; using System.Linq; using System.Reflection; - using System.Resources; using System.Threading; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; + using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; public class CodeCoverageDataAttachmentsHandler : IDataCollectorAttachments @@ -34,10 +34,10 @@ public Uri GetExtensionUri() public ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments) { - return HandleDataCollectionAttachmentSets(dataCollectionAttachments, null, CancellationToken.None); + return HandleDataCollectionAttachmentSets(dataCollectionAttachments, null, null, CancellationToken.None); } - public ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, IProgress progressReporter, CancellationToken cancellationToken) + public ICollection HandleDataCollectionAttachmentSets(ICollection dataCollectionAttachments, IProgress progressReporter, IMessageLogger logger, CancellationToken cancellationToken) { if (dataCollectionAttachments != null && dataCollectionAttachments.Any()) { @@ -60,10 +60,15 @@ public ICollection HandleDataCollectionAttachmentSets(ICollection private string MergeCodeCoverageFiles(IList files, IProgress progressReporter, CancellationToken cancellationToken) { - string fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + CoverageFileExtension); + if(files.Count == 1) + { + return files[0]; + } + + string tempFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + CoverageFileExtension); string outputfileName = files[0]; - File.Create(fileName).Dispose(); + File.Create(tempFileName).Dispose(); var assemblyPath = Path.Combine(Path.GetDirectoryName(typeof(CodeCoverageDataAttachmentsHandler).GetTypeInfo().Assembly.GetAssemblyLocation()), CodeCoverageAnalysisAssemblyName + ".dll"); try @@ -76,19 +81,27 @@ private string MergeCodeCoverageFiles(IList files, IProgress progre if (methodInfo != null) { + IList filesToDelete = new List(files.Count) { tempFileName }; + for (int i = 1; i < files.Count; i++) { cancellationToken.ThrowIfCancellationRequested(); progressReporter?.Report(100 * i / files.Count); cancellationToken.ThrowIfCancellationRequested(); - methodInfo.Invoke(null, new object[] { files[i], outputfileName, fileName, true }); + methodInfo.Invoke(null, new object[] { files[i], outputfileName, tempFileName, true }); cancellationToken.ThrowIfCancellationRequested(); - File.Copy(fileName, outputfileName, true); + File.Copy(tempFileName, outputfileName, true); + + filesToDelete.Add(files[i]); } - File.Delete(fileName); + cancellationToken.ThrowIfCancellationRequested(); + foreach (string fileName in filesToDelete) + { + File.Delete(fileName); + } } progressReporter?.Report(100); diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs index 783c254c95..556c875d17 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleRequestSender.cs @@ -782,7 +782,7 @@ private async Task SendMessageAndListenAndReportFinalizationResultAsync(IEnumera { EqtTrace.Error("Aborting Test Session End Operation: {0}", exception); eventHandler.HandleLogMessage(TestMessageLevel.Error, TranslationLayerResources.AbortedMultiTestRunFinalization); - eventHandler.HandleMultiTestRunFinalizationComplete(new MultiTestRunFinalizationCompleteEventArgs(false, true, exception), null); + eventHandler.HandleMultiTestRunFinalizationComplete(new MultiTestRunFinalizationCompleteEventArgs(false, exception), null); // Earlier we were closing the connection with vstest.console in case of exceptions // Removing that code because vstest.console might be in a healthy state and letting the client diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs index e8848d57f4..8030f48881 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/TranslationLayerTests/CodeCoverageTests.cs @@ -112,7 +112,6 @@ public async Task TestRunWithCodeCoverageAndFinalization(RunnerInfo runnerInfo) AssertCoverageResults(this.multiTestRunFinalizationEventHandler.Attachments); - Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsAborted); Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error); @@ -121,7 +120,7 @@ public async Task TestRunWithCodeCoverageAndFinalization(RunnerInfo runnerInfo) { VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentHandlerIndex); - Assert.AreEqual("Microsoft.VisualStudio.TestPlatform.Utilities.CodeCoverageDataAttachmentsHandler", progressArgs.CurrentHandlerName); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri); Assert.AreEqual(1, progressArgs.HandlersCount); Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress); } @@ -130,6 +129,9 @@ public async Task TestRunWithCodeCoverageAndFinalization(RunnerInfo runnerInfo) Assert.AreEqual(2L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForFinalization]); Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 1L : 2L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterFinalization]); Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForFinalization)); + + Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsTrue(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath) != testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework)); } [TestMethod] @@ -156,7 +158,6 @@ public async Task TestRunWithCodeCoverageAndFinalizationNoMetrics(RunnerInfo run AssertCoverageResults(this.multiTestRunFinalizationEventHandler.Attachments); - Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsAborted); Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error); @@ -165,12 +166,15 @@ public async Task TestRunWithCodeCoverageAndFinalizationNoMetrics(RunnerInfo run { VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentHandlerIndex); - Assert.AreEqual("Microsoft.VisualStudio.TestPlatform.Utilities.CodeCoverageDataAttachmentsHandler", progressArgs.CurrentHandlerName); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri); Assert.AreEqual(1, progressArgs.HandlersCount); Assert.AreEqual(i == 0 ? 50 : 100, progressArgs.CurrentHandlerProgress); } Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.Metrics.IsNullOrEmpty()); + + Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsTrue(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath) != testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework)); } [TestMethod] @@ -198,7 +202,6 @@ public async Task TestRunWithCodeCoverageAndFinalizationModuleDuplicated(RunnerI AssertCoverageResults(this.multiTestRunFinalizationEventHandler.Attachments); - Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsAborted); Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error); @@ -207,7 +210,7 @@ public async Task TestRunWithCodeCoverageAndFinalizationModuleDuplicated(RunnerI { VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentHandlerIndex); - Assert.AreEqual("Microsoft.VisualStudio.TestPlatform.Utilities.CodeCoverageDataAttachmentsHandler", progressArgs.CurrentHandlerName); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri); Assert.AreEqual(1, progressArgs.HandlersCount); Assert.AreEqual(i == 0 ? 33 : i == 1 ? 66 : 100, progressArgs.CurrentHandlerProgress); } @@ -216,6 +219,9 @@ public async Task TestRunWithCodeCoverageAndFinalizationModuleDuplicated(RunnerI Assert.AreEqual(3L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForFinalization]); Assert.AreEqual(testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework) ? 1L : 3L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterFinalization]); Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForFinalization)); + + Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); + Assert.IsTrue(File.Exists(runEventHandler.Attachments.Last().Attachments.First().Uri.LocalPath) != testEnvironment.RunnerFramework.Equals(IntegrationTestBase.DesktopRunnerFramework)); } [TestMethod] @@ -262,7 +268,6 @@ public async Task TestRunWithCodeCoverageAndFinalizationCancelled(RunnerInfo run Assert.AreEqual(1000, this.multiTestRunFinalizationEventHandler.Attachments.Count); - Assert.IsFalse(multiTestRunFinalizationEventHandler.CompleteArgs.IsAborted); Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.IsCanceled); Assert.IsNull(multiTestRunFinalizationEventHandler.CompleteArgs.Error); @@ -271,7 +276,7 @@ public async Task TestRunWithCodeCoverageAndFinalizationCancelled(RunnerInfo run { VisualStudio.TestPlatform.ObjectModel.Client.MultiTestRunFinalizationProgressEventArgs progressArgs = multiTestRunFinalizationEventHandler.ProgressArgs[i]; Assert.AreEqual(1, progressArgs.CurrentHandlerIndex); - Assert.AreEqual("Microsoft.VisualStudio.TestPlatform.Utilities.CodeCoverageDataAttachmentsHandler", progressArgs.CurrentHandlerName); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", progressArgs.CurrentHandlerUri.AbsoluteUri); Assert.AreEqual(1, progressArgs.HandlersCount); if (i == 5) @@ -288,6 +293,8 @@ public async Task TestRunWithCodeCoverageAndFinalizationCancelled(RunnerInfo run Assert.AreEqual(1000L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsSentForFinalization]); Assert.AreEqual(1000L, multiTestRunFinalizationEventHandler.CompleteArgs.Metrics[TelemetryDataConstants.NumberOfAttachmentsAfterFinalization]); Assert.IsTrue(multiTestRunFinalizationEventHandler.CompleteArgs.Metrics.ContainsKey(TelemetryDataConstants.TimeTakenInSecForFinalization)); + + Assert.IsTrue(File.Exists(runEventHandler.Attachments.First().Attachments.First().Uri.LocalPath)); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationEventsHandlerTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationEventsHandlerTests.cs index be9a766e63..a15f47e09e 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationEventsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationEventsHandlerTests.cs @@ -38,7 +38,7 @@ public void EventsHandlerHandleLogMessageShouldSendTestMessage() public void EventsHandlerHandleMultiTestRunFinalizationCompleteShouldSendFinalizationCompleteMessage() { var attachments = new[] { new AttachmentSet(new System.Uri("http://www.bing.com/"), "code coverage") }; - var args = new MultiTestRunFinalizationCompleteEventArgs(false, false, null); + var args = new MultiTestRunFinalizationCompleteEventArgs(false, null); handler.HandleMultiTestRunFinalizationComplete(args, attachments); @@ -48,7 +48,7 @@ public void EventsHandlerHandleMultiTestRunFinalizationCompleteShouldSendFinaliz [TestMethod] public void EventsHandlerHandleMultiTestRunFinalizationProgressShouldSendFinalizationProgressMessage() { - var args = new MultiTestRunFinalizationProgressEventArgs(1, "CC", 90, 2); + var args = new MultiTestRunFinalizationProgressEventArgs(1, new System.Uri("http://www.bing.com/"), 90, 2); handler.HandleMultiTestRunFinalizationProgress(args); diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationManagerTests.cs index 8eaedf817d..70ceea583b 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/MultiTestRunFinalization/MultiTestRunFinalizationManagerTests.cs @@ -63,16 +63,16 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(false, false, false); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsAborted && !a.IsCanceled), It.Is>(c => c.Count == 0))); + VerifyCompleteEvent(false, false); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsCanceled), It.Is>(c => c.Count == 0))); mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockEventSource.Verify(s => s.MultiTestRunFinalizationStart(0)); mockEventSource.Verify(s => s.MultiTestRunFinalizationStop(0)); mockAttachmentHandler1.Verify(h => h.GetExtensionUri(), Times.Never); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(0, 0); } @@ -90,8 +90,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnNoAttachments_IfNoAttach Assert.AreEqual(0, result.Count); mockAttachmentHandler1.Verify(h => h.GetExtensionUri(), Times.Never); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(0, 0); } @@ -109,13 +109,13 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturn1NotProcessedAttachmentT await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(false, false, false, inputAttachments[0]); + VerifyCompleteEvent(false, false, inputAttachments[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1); } @@ -137,8 +137,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturn1NotProcessedAttachment_ Assert.IsTrue(result.Contains(inputAttachments[0])); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1); } @@ -157,19 +157,19 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturn1ProcessedAttachmentThro new AttachmentSet(new Uri(uri1), "uri1_output") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachments); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachments); // act await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(false, false, false, outputAttachments[0]); + VerifyCompleteEvent(false, false, outputAttachments[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1); } @@ -188,7 +188,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturn1ProcessedAttachment_IfR new AttachmentSet(new Uri(uri1), "uri1_output") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachments); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachments); // act var result = await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, cancellationTokenSource.Token); @@ -200,8 +200,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturn1ProcessedAttachment_IfR mockEventSource.Verify(s => s.MultiTestRunFinalizationStop(1)); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1); } @@ -215,19 +215,19 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug new AttachmentSet(new Uri(uri1), "uri1_input") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Throws(new Exception("exception message")); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(new Exception("exception message")); // act await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(true, false, true, inputAttachments[0]); + VerifyCompleteEvent(false, true, inputAttachments[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "exception message"), Times.Once); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Failed"); } @@ -241,7 +241,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfRel new AttachmentSet(new Uri(uri1), "uri1_input") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Throws(new Exception("exception message")); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Throws(new Exception("exception message")); // act var result = await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, cancellationTokenSource.Token); @@ -251,8 +251,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfRel Assert.IsTrue(result.Contains(inputAttachments[0])); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Failed"); } @@ -271,12 +271,12 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(false, true, false, inputAttachments[0]); + VerifyCompleteEvent(true, false, inputAttachments[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockAttachmentHandler1.Verify(h => h.GetExtensionUri(), Times.Never); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Canceled"); } @@ -299,8 +299,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfOpe Assert.IsTrue(result.Contains(inputAttachments[0])); mockAttachmentHandler1.Verify(h => h.GetExtensionUri(), Times.Never); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Canceled"); } @@ -328,20 +328,20 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnProcessedAttachmentsThro new AttachmentSet(new Uri(uri2), "uri2_output") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachmentsForHandler1); - mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachmentsForHandler2); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachmentsForHandler1); + mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachmentsForHandler2); // act await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, cancellationTokenSource.Token); // assert - VerifyCompleteEvent(false, false, false, inputAttachments[4], outputAttachmentsForHandler1.First(), outputAttachmentsForHandler2.First()); + VerifyCompleteEvent(false, false, inputAttachments[4], outputAttachmentsForHandler1.First(), outputAttachmentsForHandler2.First()); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Never); mockEventsHandler.Verify(h => h.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), cancellationTokenSource.Token)); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); VerifyMetrics(5, 3); } @@ -369,8 +369,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnProcessedAttachments_IfR new AttachmentSet(new Uri(uri2), "uri2_output") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachmentsForHandler1); - mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns(outputAttachmentsForHandler2); + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachmentsForHandler1); + mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns(outputAttachmentsForHandler2); // act var result = await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, cancellationTokenSource.Token); @@ -382,8 +382,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnProcessedAttachments_IfR Assert.IsTrue(result.Contains(outputAttachmentsForHandler2[0])); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), cancellationTokenSource.Token)); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); VerifyMetrics(5, 3); } @@ -404,7 +404,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug var innerTaskCompletionSource = new TaskCompletionSource(); - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns((ICollection i1, IProgress progress, CancellationToken cancellation) => + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns((ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { try { @@ -412,6 +412,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug { Task.Delay(100).Wait(); Console.WriteLine($"Iteration: {i}"); + logger.SendMessage(TestMessageLevel.Informational, $"Iteration: {i}"); cancellation.ThrowIfCancellationRequested(); progress.Report(i + 1); @@ -437,7 +438,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug await innerTaskCompletionSource.Task; // assert - VerifyCompleteEvent(false, true, false, inputAttachments[0]); + VerifyCompleteEvent(true, false, inputAttachments[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Exactly(4)); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgs(a, 1)))); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgs(a, 2)))); @@ -446,8 +447,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachmentsThroug mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "Finalization was cancelled.")); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Canceled"); } @@ -468,7 +469,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfOpe var innerTaskCompletionSource = new TaskCompletionSource(); - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns((ICollection i1, IProgress p, CancellationToken cancellation) => + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns((ICollection i1, IProgress p, IMessageLogger logger, CancellationToken cancellation) => { try { @@ -476,6 +477,7 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfOpe { Task.Delay(100).Wait(); Console.WriteLine($"Iteration: {i}"); + logger.SendMessage(TestMessageLevel.Informational, $"Iteration: {i}"); cancellation.ThrowIfCancellationRequested(); @@ -505,8 +507,8 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnInitialAttachments_IfOpe Assert.IsTrue(result.Contains(inputAttachments[0])); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri(), Times.Never); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), cancellationTokenSource.Token)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny()), Times.Never); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), cancellationTokenSource.Token)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); VerifyMetrics(1, 1, "Canceled"); } @@ -531,18 +533,20 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnProperlySendProgressEven new AttachmentSet(new Uri(uri2), "uri2_output") }; - mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns((ICollection i1, IProgress progress, CancellationToken cancellation) => + mockAttachmentHandler1.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns((ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { progress.Report(25); progress.Report(50); progress.Report(75); + logger.SendMessage(TestMessageLevel.Error, "error"); progress.Report(100); return outputAttachments1; }); - mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny())).Returns((ICollection i1, IProgress progress, CancellationToken cancellation) => + mockAttachmentHandler2.Setup(h => h.HandleDataCollectionAttachmentSets(It.IsAny>(), It.IsAny>(), It.IsAny(), It.IsAny())).Returns((ICollection i1, IProgress progress, IMessageLogger logger, CancellationToken cancellation) => { progress.Report(50); + logger.SendMessage(TestMessageLevel.Informational, "info"); progress.Report(100); return outputAttachments2; }); @@ -551,18 +555,21 @@ public async Task FinalizeMultiTestRunAsync_ShouldReturnProperlySendProgressEven await manager.FinalizeMultiTestRunAsync(mockRequestData.Object, inputAttachments, mockEventsHandler.Object, CancellationToken.None); // assert - VerifyCompleteEvent(false, false, false, outputAttachments1[0], outputAttachments2[0]); + VerifyCompleteEvent(false, false, outputAttachments1[0], outputAttachments2[0]); mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.IsAny()), Times.Exactly(6)); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 25)))); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 50)))); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 75)))); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 100)))); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 50)))); - mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 100)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 25, uri1)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 50, uri1)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 75, uri1)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 1, 100, uri1)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 50, uri2)))); + mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationProgress(It.Is(a => VerifyProgressArgsForTwoHandlers(a, 2, 100, uri2)))); mockAttachmentHandler1.Verify(h => h.GetExtensionUri()); mockAttachmentHandler2.Verify(h => h.GetExtensionUri()); - mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), CancellationToken.None)); - mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[1])), It.IsAny>(), CancellationToken.None)); + mockAttachmentHandler1.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny>(), It.IsAny(), CancellationToken.None)); + mockAttachmentHandler2.Verify(h => h.HandleDataCollectionAttachmentSets(It.Is>(c => c.Count == 1 && c.Contains(inputAttachments[1])), It.IsAny>(), It.IsAny(), CancellationToken.None)); + + mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "info")); + mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "error")); VerifyMetrics(2, 2, "Completed"); } @@ -578,10 +585,10 @@ private void VerifyMetrics(int inputCount, int outputCount, string status = "Com mockMetricsCollection.Verify(m => m.Add(TelemetryDataConstants.TimeTakenInSecForFinalization, It.IsAny())); } - private void VerifyCompleteEvent(bool isAborted, bool isCanceled, bool containsError, params AttachmentSet[] expectedSets) + private void VerifyCompleteEvent(bool isCanceled, bool containsError, params AttachmentSet[] expectedSets) { mockEventsHandler.Verify(h => h.HandleMultiTestRunFinalizationComplete( - It.Is(a => a.IsAborted == isAborted && a.IsCanceled == isCanceled && (a.Error != null) == containsError), + It.Is(a => a.IsCanceled == isCanceled && (a.Error != null) == containsError), It.Is>(c => c.Count == expectedSets.Length && expectedSets.All(e => c.Contains(e))))); } @@ -589,13 +596,13 @@ private bool VerifyProgressArgs(MultiTestRunFinalizationProgressEventArgs args, { Assert.AreEqual(1, args.CurrentHandlerIndex); Assert.AreEqual(2, args.HandlersCount); - Assert.IsTrue(args.CurrentHandlerName.StartsWith("Castle.Proxies.ObjectProxy")); + Assert.AreEqual(uri1, args.CurrentHandlerUri.AbsoluteUri); return progress == args.CurrentHandlerProgress; } - private bool VerifyProgressArgsForTwoHandlers(MultiTestRunFinalizationProgressEventArgs args, long handlerIndex, long progress) + private bool VerifyProgressArgsForTwoHandlers(MultiTestRunFinalizationProgressEventArgs args, long handlerIndex, long progress, string uri) { - return progress == args.CurrentHandlerProgress && args.CurrentHandlerIndex == handlerIndex && args.CurrentHandlerName.StartsWith("Castle.Proxies.ObjectProxy") && args.HandlersCount == 2; + return progress == args.CurrentHandlerProgress && args.CurrentHandlerIndex == handlerIndex && args.CurrentHandlerUri.AbsoluteUri == uri && args.HandlersCount == 2; } } } diff --git a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs index 145c86993a..06a55ac0cb 100644 --- a/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs +++ b/test/Microsoft.TestPlatform.Utilities.UnitTests/CodeCoverageDataAttachmentsHandlerTests.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; + using System.Linq; using System.Threading; [TestClass] @@ -26,12 +27,12 @@ public void HandleDataCollectionAttachmentSetsShouldReturnEmptySetWhenNoAttachme { Collection attachment = new Collection(); ICollection resultAttachmentSets = - coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, CancellationToken.None); + coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, null, CancellationToken.None); Assert.IsNotNull(resultAttachmentSets); Assert.IsTrue(resultAttachmentSets.Count == 0); - resultAttachmentSets = coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(null, mockProgressReporter.Object, CancellationToken.None); + resultAttachmentSets = coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(null, mockProgressReporter.Object, null, CancellationToken.None); Assert.IsNotNull(resultAttachmentSets); Assert.IsTrue(resultAttachmentSets.Count == 0); @@ -39,6 +40,22 @@ public void HandleDataCollectionAttachmentSetsShouldReturnEmptySetWhenNoAttachme mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); } + [TestMethod] + public void HandleDataCollectionAttachmentSetsShouldReturnInputIfOnly1Attachment() + { + var attachmentSet = new AttachmentSet(new Uri("//badrui//"), string.Empty); + attachmentSet.Attachments.Add(new UriDataAttachment(new Uri("C:\\temp\\aa"), "coverage")); + + Collection attachment = new Collection { attachmentSet }; + ICollection resultAttachmentSets = + coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, null, CancellationToken.None); + + Assert.IsNotNull(resultAttachmentSets); + Assert.IsTrue(resultAttachmentSets.Count == 1); + Assert.AreEqual("datacollector://microsoft/CodeCoverage/2.0", resultAttachmentSets.First().Uri.AbsoluteUri); + Assert.AreEqual("file:///C:/temp/aa", resultAttachmentSets.First().Attachments.First().Uri.AbsoluteUri); + } + [TestMethod] public void HandleDataCollectionAttachmentSetsShouldThrowIfCancellationRequested() { @@ -49,12 +66,13 @@ public void HandleDataCollectionAttachmentSetsShouldThrowIfCancellationRequested Collection attachment = new Collection { + attachmentSet, attachmentSet }; - Assert.ThrowsException(() => coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, cts.Token)); + Assert.ThrowsException(() => coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, null, cts.Token)); - Assert.AreEqual(1, attachment.Count); + Assert.AreEqual(2, attachment.Count); mockProgressReporter.Verify(p => p.Report(It.IsAny()), Times.Never); } @@ -76,7 +94,7 @@ public void HandleDataCollectionAttachmentSetsShouldReturnExistingAttachmentsIfF attachmentSet2 }; - var result = coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, cts.Token); + var result = coverageDataAttachmentsHandler.HandleDataCollectionAttachmentSets(attachment, mockProgressReporter.Object, null, cts.Token); Assert.AreEqual(2, result.Count); Assert.IsTrue(result.Contains(attachmentSet1)); diff --git a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs index 3658178a24..d23c9b84e4 100644 --- a/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs +++ b/test/TranslationLayer.UnitTests/VsTestConsoleRequestSenderTests.cs @@ -1904,7 +1904,7 @@ public async Task FinalizeTestsShouldCompleteWithZeroAttachments() var payload = new MultiTestRunFinalizationCompletePayload() { - FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, false, null), + FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, null), Attachments = new AttachmentSet[0] }; @@ -1919,7 +1919,7 @@ public async Task FinalizeTestsShouldCompleteWithZeroAttachments() mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationStart, It.IsAny())); mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsAborted && !a.IsCanceled && a.Error == null), It.Is>(a => a.Count == 0)), Times.Once, "Finalization Complete must be called"); + mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsCanceled && a.Error == null), It.Is>(a => a.Count == 0)), Times.Once, "Finalization Complete must be called"); mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); } @@ -1932,7 +1932,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachment() var payload = new MultiTestRunFinalizationCompletePayload() { - FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(true, true, new Exception("msg")), + FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(true, new Exception("msg")), Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } }; var finalizationComplete = new Message() @@ -1946,7 +1946,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachment() mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationStart, It.IsAny())); mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationCancel), Times.Never); - mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => a.IsAborted && a.IsCanceled && a.Error != null), It.Is>(a => a.Count == 1)), Times.Once, "Finalization Complete must be called"); + mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => a.IsCanceled && a.Error != null), It.Is>(a => a.Count == 1)), Times.Once, "Finalization Complete must be called"); mockHandler.Verify(mh => mh.HandleLogMessage(It.IsAny(), It.IsAny()), Times.Never, "TestMessage event must not be called"); } @@ -1959,7 +1959,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachmentAndTestMessage() var payload = new MultiTestRunFinalizationCompletePayload() { - FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, false, null), + FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, null), Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } }; @@ -1993,7 +1993,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachmentAndProgressMessage var completePayload = new MultiTestRunFinalizationCompletePayload() { - FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, false, null), + FinalizationCompleteEventArgs = new MultiTestRunFinalizationCompleteEventArgs(false, null), Attachments = new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") } }; @@ -2005,7 +2005,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachmentAndProgressMessage var progressPayload = new MultiTestRunFinalizationProgressPayload() { - FinalizationProgressEventArgs = new MultiTestRunFinalizationProgressEventArgs(1, "cc", 50, 2) + FinalizationProgressEventArgs = new MultiTestRunFinalizationProgressEventArgs(1, new System.Uri("http://www.bing.com/"), 50, 2) }; var finalizationProgress = new Message() @@ -2023,7 +2023,7 @@ public async Task FinalizeTestsShouldCompleteWithOneAttachmentAndProgressMessage mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationStart, It.IsAny())); mockCommunicationManager.Verify(c => c.SendMessage(MessageType.MultiTestRunFinalizationCancel), Times.Never); mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.IsAny(), It.Is>(a => a.Count == 1)), Times.Once, "Finalization Complete must be called"); - mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationProgress(It.Is(a => a.CurrentHandlerIndex == 1 && a.CurrentHandlerName == "cc" && a.CurrentHandlerProgress == 50 && a.HandlersCount == 2)), Times.Once, "Finalization Progress must be called"); + mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationProgress(It.Is(a => a.CurrentHandlerIndex == 1 && a.CurrentHandlerUri == new System.Uri("http://www.bing.com/") && a.CurrentHandlerProgress == 50 && a.HandlersCount == 2)), Times.Once, "Finalization Progress must be called"); mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Informational, "Hello"), Times.Never); } @@ -2102,7 +2102,7 @@ public async Task FinalizeTestsShouldAbortOnExceptionInSendMessage() await this.requestSender.FinalizeMultiTestRunAsync(new List { new AttachmentSet(new Uri("http://www.bing.com"), "out") }, false, mockHandler.Object, CancellationToken.None); - mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsCanceled && a.IsAborted && a.Error is IOException), null), Times.Once, "Finalization Complete must be called"); + mockHandler.Verify(mh => mh.HandleMultiTestRunFinalizationComplete(It.Is(a => !a.IsCanceled && a.Error is IOException), null), Times.Once, "Finalization Complete must be called"); mockHandler.Verify(mh => mh.HandleLogMessage(TestMessageLevel.Error, It.IsAny()), Times.Once, "TestMessage event must be called"); this.mockCommunicationManager.Verify(cm => cm.StopServer(), Times.Never); }