11using System ;
22using System . Collections . Generic ;
3- using System . IO ;
43using System . Linq ;
54using System . Threading ;
65using System . Threading . Tasks ;
76using AutoMoq ;
7+ using FineCodeCoverage . Core . Initialization ;
88using FineCodeCoverage . Core . Utilities ;
99using FineCodeCoverage . Engine ;
1010using FineCodeCoverage . Engine . Cobertura ;
1111using FineCodeCoverage . Engine . Model ;
1212using FineCodeCoverage . Engine . MsTestPlatform ;
1313using FineCodeCoverage . Engine . ReportGenerator ;
14- using FineCodeCoverage . Impl ;
1514using FineCodeCoverage . Options ;
1615using FineCodeCoverage . Output ;
1716using Moq ;
@@ -50,7 +49,7 @@ public void Should_Initialize_AppFolder_Then_Utils()
5049
5150 var openCoverMock = mocker . GetMock < ICoverageUtilManager > ( ) . Setup ( openCover => openCover . Initialize ( appDataFolderPath , disposalToken ) ) . Callback ( ( ) => callOrder . Add ( 4 ) ) ;
5251
53- fccEngine . Initialize ( null , disposalToken ) ;
52+ fccEngine . Initialize ( disposalToken ) ;
5453
5554 Assert . AreEqual ( 4 , callOrder . Count ) ;
5655 Assert . AreEqual ( 1 , callOrder [ 0 ] ) ;
@@ -63,7 +62,7 @@ public void Should_Set_AppDataFolderPath_From_Initialized_AppDataFolder_Director
6362 var appDataFolderPath = "some path" ;
6463 var mockAppDataFolder = mocker . GetMock < IAppDataFolder > ( ) ;
6564 mockAppDataFolder . Setup ( appDataFolder => appDataFolder . DirectoryPath ) . Returns ( appDataFolderPath ) ;
66- fccEngine . Initialize ( null , CancellationToken . None ) ;
65+ fccEngine . Initialize ( CancellationToken . None ) ;
6766 Assert . AreEqual ( "some path" , fccEngine . AppDataFolderPath ) ;
6867 }
6968
@@ -102,46 +101,6 @@ public async Task Should_Log_Starting_When_Initialized()
102101 VerifyLogsReloadCoverageStatus ( ReloadCoverageStatus . Start ) ;
103102 }
104103
105- [ Test ]
106- public async Task Should_Poll_For_Initialized ( )
107- {
108- var times = 5 ;
109- var initializeWait = 1000 ;
110- fccEngine . InitializeWait = initializeWait ;
111-
112- var mockInitializeStatusProvider = new Mock < IInitializeStatusProvider > ( ) ;
113- mockInitializeStatusProvider . SetupProperty ( i => i . InitializeStatus ) ;
114- var initializeStatusProvider = mockInitializeStatusProvider . Object ;
115-
116- fccEngine . Initialize ( initializeStatusProvider , CancellationToken . None ) ;
117-
118- fccEngine . ReloadCoverage ( ( ) => Task . FromResult ( new List < ICoverageProject > ( ) ) ) ;
119- await Task . Delay ( times * initializeWait ) . ContinueWith ( _ =>
120- {
121- initializeStatusProvider . InitializeStatus = InitializeStatus . Initialized ;
122- } ) ;
123- await fccEngine . reloadCoverageTask ;
124- mocker . Verify < ILogger > ( l => l . Log ( fccEngine . GetLogReloadCoverageStatusMessage ( ReloadCoverageStatus . Initializing ) ) , Times . AtLeast ( times ) ) ;
125- }
126-
127- [ Test ]
128- public async Task Should_Throw_With_initializationFailedMessagePrefix_When_Initialize_Has_Failed ( )
129- {
130- var mockInitializerStatusProvider = new Mock < IInitializeStatusProvider > ( ) ;
131- mockInitializerStatusProvider . Setup ( i => i . InitializeStatus ) . Returns ( InitializeStatus . Error ) ;
132- var initializeExceptionMessage = "An exception was thrown" ;
133- mockInitializerStatusProvider . Setup ( i => i . InitializeExceptionMessage ) . Returns ( initializeExceptionMessage ) ;
134-
135- fccEngine . Initialize ( mockInitializerStatusProvider . Object , CancellationToken . None ) ;
136-
137- fccEngine . ReloadCoverage ( ( ) => Task . FromResult ( new List < ICoverageProject > ( ) ) ) ;
138-
139- await fccEngine . reloadCoverageTask ;
140-
141- mocker . Verify < ILogger > ( l => l . Log ( fccEngine . GetLogReloadCoverageStatusMessage ( ReloadCoverageStatus . Error ) , It . Is < Exception > ( exc => ( FCCEngine . initializationFailedMessagePrefix + Environment . NewLine + initializeExceptionMessage ) == exc . Message ) ) ) ;
142-
143- }
144-
145104 [ Test ]
146105 public async Task Should_Prepare_For_Coverage_Suitable_CoverageProjects ( )
147106 {
@@ -302,14 +261,6 @@ public async Task Should_Process_ReportGenerator_Output_If_Success_Raising_Event
302261
303262 }
304263
305- [ Test ]
306- public async Task Should_Log_Single_Exception_From_Aggregate_Exception ( )
307- {
308- Exception exception = null ;
309- await ThrowException ( exc => exception = exc ) ;
310- mocker . Verify < ILogger > ( l => l . Log ( fccEngine . GetLogReloadCoverageStatusMessage ( ReloadCoverageStatus . Error ) , exception ) ) ;
311- }
312-
313264 [ Test ]
314265 public async Task Should_Cancel_Running_Coverage_Logging_Cancelled_When_StopCoverage ( )
315266 {
@@ -417,21 +368,6 @@ private async Task ThrowReadingReportHtml()
417368
418369 }
419370
420- private async Task ThrowException ( Action < Exception > exceptionCallback = null )
421- {
422- var exception = new Exception ( "an exception" ) ;
423- exceptionCallback ? . Invoke ( exception ) ;
424- Task < List < ICoverageProject > > thrower ( ) => Task . FromException < List < ICoverageProject > > ( exception ) ;
425-
426- var mockInitializeStatusProvider = new Mock < IInitializeStatusProvider > ( ) ;
427- mockInitializeStatusProvider . Setup ( i => i . InitializeStatus ) . Returns ( InitializeStatus . Initialized ) ;
428- fccEngine . Initialize ( mockInitializeStatusProvider . Object , CancellationToken . None ) ;
429-
430- fccEngine . ReloadCoverage ( thrower ) ;
431-
432- await fccEngine . reloadCoverageTask ;
433- }
434-
435371 private async Task StopCoverage ( )
436372 {
437373 var mockSuitableCoverageProject = new Mock < ICoverageProject > ( ) ;
@@ -461,9 +397,7 @@ private void SetUpSuccessfulRunReportGenerator()
461397 private async Task ReloadInitializedCoverage ( params ICoverageProject [ ] coverageProjects )
462398 {
463399 var projectsFromTask = Task . FromResult ( coverageProjects . ToList ( ) ) ;
464- var mockInitializeStatusProvider = new Mock < IInitializeStatusProvider > ( ) ;
465- mockInitializeStatusProvider . Setup ( i => i . InitializeStatus ) . Returns ( InitializeStatus . Initialized ) ;
466- fccEngine . Initialize ( mockInitializeStatusProvider . Object , CancellationToken . None ) ;
400+ fccEngine . Initialize ( CancellationToken . None ) ;
467401 fccEngine . ReloadCoverage ( ( ) => projectsFromTask ) ;
468402 await fccEngine . reloadCoverageTask ;
469403 }
0 commit comments