Skip to content

Commit 860a295

Browse files
authored
Merge pull request #443 from tonyhallett/fix-runsettings-projectfile-cleanup
Fix runsettings projectfile cleanup
2 parents aab53e4 + fab9b74 commit 860a295

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

FineCodeCoverageTests/TestContainerDiscovery_Tests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
using FineCodeCoverage.Engine.MsTestPlatform.CodeCoverage;
1111
using FineCodeCoverage.Impl;
1212
using FineCodeCoverage.Options;
13+
using Microsoft.Build.Evaluation;
1314
using Microsoft.VisualStudio.TestWindow.Extensibility;
1415
using Moq;
1516
using NUnit.Framework;
17+
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
1618

1719
namespace Test
1820
{
@@ -260,10 +262,12 @@ public void Should_Collect_Ms_Code_Coverage_When_TestExecutionFinished_And_Ms_Co
260262
mockTestOperationFactory.Setup(testOperationFactory => testOperationFactory.Create(operation)).Returns(testOperation);
261263

262264
RaiseTestExecutionFinished(operation);
265+
#pragma warning disable VSTHRD110 // Observe result of async calls
263266
mocker.Verify<IMsCodeCoverageRunSettingsService>(
264267
msCodeCoverageRunSettingsService =>
265268
msCodeCoverageRunSettingsService.CollectAsync(operation,testOperation)
266269
);
270+
#pragma warning restore VSTHRD110 // Observe result of async calls
267271
}
268272

269273
[Test]
@@ -401,5 +405,29 @@ public void Should_Send_TestExecutionStartingMessage_When_TestExecutionStarting(
401405
RaiseTestExecutionStarting(operation);
402406
mocker.Verify<IEventAggregator>(eventAggregator => eventAggregator.SendMessage(It.IsAny<TestExecutionStartingMessage>(),null));
403407
}
408+
409+
[Test]
410+
public void Should_MsCodeCoverageRunSettingsService_TestExecutionNotFinishedAsync_When_IsCollecting_TestExecutionFinishedAsync_And_CollectAsync_Not_Called()
411+
{
412+
var mockMsCodeCoverageRunSettingsService = mocker.GetMock<IMsCodeCoverageRunSettingsService>();
413+
mockMsCodeCoverageRunSettingsService.Setup(
414+
msCodeCoverageRunSettingsService =>
415+
msCodeCoverageRunSettingsService.IsCollectingAsync(It.IsAny<ITestOperation>())
416+
).ReturnsAsync(MsCodeCoverageCollectionStatus.Collecting);
417+
418+
SetUpOptions(mockOptions =>
419+
{
420+
mockOptions.Setup(options => options.Enabled).Returns(true);
421+
mockOptions.Setup(options => options.RunWhenTestsFail).Returns(false);
422+
});
423+
var mockTestOperation = new Mock<ITestOperation>();
424+
mockTestOperation.SetupGet(testOperation => testOperation.FailedTests).Returns(1);
425+
mocker.GetMock<ITestOperationFactory>().Setup(f => f.Create(It.IsAny<IOperation>())).Returns(mockTestOperation.Object);
426+
RaiseTestExecutionStarting();
427+
RaiseTestExecutionFinished();
428+
429+
mockMsCodeCoverageRunSettingsService.Verify(msCodeCoverageRunSettingsService => msCodeCoverageRunSettingsService.TestExecutionNotFinishedAsync(mockTestOperation.Object));
430+
431+
}
404432
}
405433
}

SharedProject/Impl/TestContainerDiscovery/TestContainerDiscoverer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ private async Task TestExecutionFinishedAsync(IOperation operation)
141141
{
142142
await TestExecutionFinishedCollectionAsync(operation, testOperation);
143143
}
144+
else
145+
{
146+
if (msCodeCoverageCollectionStatus == MsCodeCoverageCollectionStatus.Collecting)
147+
{
148+
await msCodeCoverageRunSettingsService.TestExecutionNotFinishedAsync(testOperation);
149+
}
150+
}
144151
}
145152

146153
private (bool should, ITestOperation testOperation) ShouldConditionallyCollectWhenTestExecutionFinished(IOperation operation)

0 commit comments

Comments
 (0)