10
10
using FineCodeCoverage . Engine . MsTestPlatform . CodeCoverage ;
11
11
using FineCodeCoverage . Impl ;
12
12
using FineCodeCoverage . Options ;
13
+ using Microsoft . Build . Evaluation ;
13
14
using Microsoft . VisualStudio . TestWindow . Extensibility ;
14
15
using Moq ;
15
16
using NUnit . Framework ;
17
+ using static System . Windows . Forms . VisualStyles . VisualStyleElement ;
16
18
17
19
namespace Test
18
20
{
@@ -260,10 +262,12 @@ public void Should_Collect_Ms_Code_Coverage_When_TestExecutionFinished_And_Ms_Co
260
262
mockTestOperationFactory . Setup ( testOperationFactory => testOperationFactory . Create ( operation ) ) . Returns ( testOperation ) ;
261
263
262
264
RaiseTestExecutionFinished ( operation ) ;
265
+ #pragma warning disable VSTHRD110 // Observe result of async calls
263
266
mocker . Verify < IMsCodeCoverageRunSettingsService > (
264
267
msCodeCoverageRunSettingsService =>
265
268
msCodeCoverageRunSettingsService . CollectAsync ( operation , testOperation )
266
269
) ;
270
+ #pragma warning restore VSTHRD110 // Observe result of async calls
267
271
}
268
272
269
273
[ Test ]
@@ -401,5 +405,29 @@ public void Should_Send_TestExecutionStartingMessage_When_TestExecutionStarting(
401
405
RaiseTestExecutionStarting ( operation ) ;
402
406
mocker . Verify < IEventAggregator > ( eventAggregator => eventAggregator . SendMessage ( It . IsAny < TestExecutionStartingMessage > ( ) , null ) ) ;
403
407
}
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
+ }
404
432
}
405
433
}
0 commit comments