public void BoundSolutionAnalyzer_HasRuleSetsInSonarQubeDirectory()
{
// Setup
string sonarQubeDirectory = Path.Combine(this.solutionRootFolder, BoundSolutionAnalyzer.SonarQubeFilesFolder);
GenerateBindingInformationFile(sonarQubeDirectory);
BoundSolutionAnalyzer testSubject = null;
try
{
// Case 1: Context is already active
this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);
// Act
testSubject = new BoundSolutionAnalyzer(this.serviceProvider);
// Verify
this.logger.AssertSingleEventWasWritten(TelemetryEvent.BoundSolutionDetected);
// Case 2: Context deactivated
this.logger.Reset();
// Act
this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, false);
// Verify
this.logger.AssertNoEventWasWritten();
// Case 3: Context activated
this.logger.Reset();
// Act
this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);
// Verify
this.logger.AssertSingleEventWasWritten(TelemetryEvent.BoundSolutionDetected);
// Case 4: reactivate when disposed
this.logger.Reset();
this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, false);
testSubject.Dispose();
testSubject = null;
// Act
this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionBuilding_guid, true);
// Verify
this.logger.AssertNoEventWasWritten();
}
finally
{
testSubject?.Dispose();
DeleteBindingInformationFile(sonarQubeDirectory);
}
}