1010using FineCodeCoverage . Engine . MsTestPlatform . CodeCoverage ;
1111using FineCodeCoverage . Impl ;
1212using FineCodeCoverage . Options ;
13+ using Microsoft . Build . Evaluation ;
1314using Microsoft . VisualStudio . TestWindow . Extensibility ;
1415using Moq ;
1516using NUnit . Framework ;
17+ using static System . Windows . Forms . VisualStyles . VisualStyleElement ;
1618
1719namespace 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}
0 commit comments