Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FineCodeCoverage/FineCodeCoverage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<PackageReference Include="CliWrap">
<Version>3.2.2</Version>
</PackageReference>
<PackageReference Include="EventAggregator.Net">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="ExCSS">
<Version>4.1.1</Version>
</PackageReference>
Expand Down
3 changes: 3 additions & 0 deletions FineCodeCoverage2022/FineCodeCoverage2022.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<PackageReference Include="CliWrap">
<Version>3.2.2</Version>
</PackageReference>
<PackageReference Include="EventAggregator.Net">
<Version>1.2.0</Version>
</PackageReference>
<PackageReference Include="ExCSS">
<Version>4.1.1</Version>
</PackageReference>
Expand Down
565 changes: 565 additions & 0 deletions FineCodeCoverageTests/Events/EventAggregator.cs

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions FineCodeCoverageTests/FCCEngine_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public void SetUp()
updatedMarginTags = true;
};


fccEngine.UpdateOutputWindow += (UpdateOutputWindowEventArgs e) =>
{
htmlContent = e.HtmlContent;
};
}

[Test]
Expand Down Expand Up @@ -104,7 +99,6 @@ public class FCCEngine_ReloadCoverage_Tests
private FCCEngine fccEngine;
private List<UpdateMarginTagsEventArgs> updateMarginTagsEvents;
private List<List<CoverageLine>> updateMarginTagsCoverageLines;
private List<UpdateOutputWindowEventArgs> updateOutputWindowEvents;

[SetUp]
public void SetUp()
Expand All @@ -114,18 +108,12 @@ public void SetUp()

updateMarginTagsEvents = new List<UpdateMarginTagsEventArgs>();
updateMarginTagsCoverageLines = new List<List<CoverageLine>>();
updateOutputWindowEvents = new List<UpdateOutputWindowEventArgs>();

fccEngine.UpdateMarginTags += (UpdateMarginTagsEventArgs e) =>
{
updateMarginTagsEvents.Add(e);
updateMarginTagsCoverageLines.Add(fccEngine.CoverageLines);
};

fccEngine.UpdateOutputWindow += (UpdateOutputWindowEventArgs e) =>
{
updateOutputWindowEvents.Add(e);
};
}

[Test]
Expand Down Expand Up @@ -411,7 +399,6 @@ private void VerifyLogsReloadCoverageStatus(ReloadCoverageStatus reloadCoverageS
private void VerifyClearUIEvents(int eventNumber)
{
Assert.Null(updateMarginTagsCoverageLines[eventNumber]);
Assert.Null(updateOutputWindowEvents[eventNumber].HtmlContent);
}

private async Task<(string reportGeneratedHtmlContent, List<CoverageLine> updatedCoverageLines)> RunToCompletion(bool noCoverageProjects)
Expand Down
1 change: 1 addition & 0 deletions FineCodeCoverageTests/FineCodeCoverageTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="CoverageToolOutput_Tests\FccOutputExistenceCoverageToolOutputFolderSolutionProvider_Tests.cs" />
<Compile Include="CoverageToolOutput_Tests\SolutionFolderProvider_Tests.cs" />
<Compile Include="CoverageUtilManager_Tests.cs" />
<Compile Include="Events\EventAggregator.cs" />
<Compile Include="Test helpers\MefOrderAssertions.cs" />
<Compile Include="ToolFolder_Tests.cs" />
<Compile Include="ToolZipProvider_Tests.cs" />
Expand Down
11 changes: 6 additions & 5 deletions FineCodeCoverageTests/ScriptManager_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using FineCodeCoverage.Core.Utilities;
using FineCodeCoverage.Engine;
using FineCodeCoverage.Output;
using Moq;
Expand All @@ -11,13 +12,15 @@ public class ScriptManager_When_Called_Back_Window_External
private ScriptManager scriptManager;
private Mock<ISourceFileOpener> sourceFileOpener;
private Mock<IProcess> mockProcess;
private Mock<IEventAggregator> mockEventAggregator;

[SetUp]
public void SetUp()
{
sourceFileOpener = new Mock<ISourceFileOpener>();
mockProcess = new Mock<IProcess>();
scriptManager = new ScriptManager(sourceFileOpener.Object, mockProcess.Object);
mockEventAggregator = new Mock<IEventAggregator>();
scriptManager = new ScriptManager(sourceFileOpener.Object, mockProcess.Object, mockEventAggregator.Object);
}

[Test]
Expand All @@ -42,12 +45,10 @@ public void RateAndReview_Should_Open_Market_Place_Rate_And_Review()
}

[Test]
public void DocumentFocused_Should_Call_The_Focus_Callback()
public void DocumentFocused_Should_Send_Message()
{
var calledCallback = false;
scriptManager.FocusCallback = () => calledCallback = true;
scriptManager.DocumentFocused();
Assert.True(calledCallback);
mockEventAggregator.Verify(e => e.SendMessage(It.IsAny<ReportFocusedMessage>(), null));
}

[Test]
Expand Down
1 change: 1 addition & 0 deletions FineCodeCoverageTests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<package id="AutoMoq" version="2.0.0" targetFramework="net472" />
<package id="Castle.Core" version="4.4.1" targetFramework="net472" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net472" />
<package id="EventAggregator.Net" version="1.2" targetFramework="net472" />
<package id="Microsoft.VisualStudio.TestWindow.Interfaces" version="11.0.61030" targetFramework="net472" />
<package id="Moq" version="4.16.0" targetFramework="net472" />
<package id="NUnit" version="3.13.1" targetFramework="net472" />
Expand Down
6 changes: 0 additions & 6 deletions SharedProject/Core/CoverageUIEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@ namespace FineCodeCoverage.Engine
internal class UpdateMarginTagsEventArgs : EventArgs {
}

internal class UpdateOutputWindowEventArgs : EventArgs
{
public string HtmlContent { get; set; }
}

internal delegate void UpdateMarginTagsDelegate(UpdateMarginTagsEventArgs e);
internal delegate void UpdateOutputWindowDelegate(UpdateOutputWindowEventArgs e);
}
47 changes: 5 additions & 42 deletions SharedProject/Core/FCCEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading;
using System.Windows;
using FineCodeCoverage.Core.Utilities;
using FineCodeCoverage.Engine.Cobertura;
using FineCodeCoverage.Engine.Model;
Expand All @@ -25,33 +24,10 @@ internal class FCCEngine : IFCCEngine
private CancellationTokenSource cancellationTokenSource;

public event UpdateMarginTagsDelegate UpdateMarginTags;
public event UpdateOutputWindowDelegate UpdateOutputWindow;

public string AppDataFolderPath { get; private set; }
public List<CoverageLine> CoverageLines { get; internal set; }

private DpiScale dpiScale;
public DpiScale Dpi
{
get => dpiScale;
set
{
reportGeneratorUtil.DpiScale = value;
dpiScale = value;
UpdateReportWithDpiFontChanges();

}
}
private FontDetails environmentFontDetails;
public FontDetails EnvironmentFontDetails {
get => environmentFontDetails;
set {
environmentFontDetails = value;
reportGeneratorUtil.EnvironmentFontDetails = value;
UpdateReportWithDpiFontChanges();
}
}

private readonly ICoverageUtilManager coverageUtilManager;
private readonly ICoberturaUtil coberturaUtil;
private readonly IMsTestPlatformUtil msTestPlatformUtil;
Expand All @@ -64,7 +40,7 @@ public FontDetails EnvironmentFontDetails {
private readonly ICoverageToolOutputManager coverageOutputManager;
internal System.Threading.Tasks.Task reloadCoverageTask;
private ISolutionEvents solutionEvents; // keep alive
private bool hasGeneratedReport;
private readonly IEventAggregator eventAggregator;

[ImportingConstructor]
public FCCEngine(
Expand All @@ -77,10 +53,12 @@ public FCCEngine(
IAppDataFolder appDataFolder,
ICoverageToolOutputManager coverageOutputManager,
ISolutionEvents solutionEvents,
IAppOptionsProvider appOptionsProvider
IAppOptionsProvider appOptionsProvider,
IEventAggregator eventAggregator
)
{
this.solutionEvents = solutionEvents;
this.eventAggregator = eventAggregator;
solutionEvents.AfterClosing += (s,args) => ClearOutputWindow(false);
appOptionsProvider.OptionsChanged += (appOptions) =>
{
Expand Down Expand Up @@ -132,14 +110,6 @@ private void ClearOutputWindow(bool withHistory)
RaiseUpdateOutputWindow(reportGeneratorUtil.BlankReport(withHistory));
}

private void UpdateReportWithDpiFontChanges()
{
if (hasGeneratedReport)
{
reportGeneratorUtil.UpdateReportWithDpiFontChanges();
}
}

public void StopCoverage()
{
if (cancellationTokenSource != null)
Expand Down Expand Up @@ -209,9 +179,7 @@ await coverageProject.StepAsync("Run Coverage Tool", async (project) =>

private void RaiseUpdateOutputWindow(string reportHtml)
{
UpdateOutputWindowEventArgs updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { HtmlContent = reportHtml};
UpdateOutputWindow?.Invoke(updateOutputWindowEventArgs);
hasGeneratedReport = true;
eventAggregator.SendMessage(new NewReportMessage { Report = reportHtml });
}

private void UpdateUI(List<CoverageLine> coverageLines, string reportHtml)
Expand Down Expand Up @@ -362,11 +330,6 @@ public void ReloadCoverage(Func<System.Threading.Tasks.Task<List<ICoverageProjec
}, System.Threading.Tasks.TaskScheduler.Default);

}

public void ReadyForReport()
{
ClearOutputWindow(false);
}
}

}
8 changes: 0 additions & 8 deletions SharedProject/Core/IFCCEngine.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
using System;
using System.Collections.Generic;
using System.Windows;
using FineCodeCoverage.Engine.Model;
using FineCodeCoverage.Impl;
using FineCodeCoverage.Output;

namespace FineCodeCoverage.Engine
{
internal interface IFCCEngine
{
event UpdateMarginTagsDelegate UpdateMarginTags;
event UpdateOutputWindowDelegate UpdateOutputWindow;
string AppDataFolderPath { get; }
void Initialize(IInitializeStatusProvider initializeStatusProvider);
void StopCoverage();
void ReloadCoverage(Func<System.Threading.Tasks.Task<List<ICoverageProject>>> coverageRequestCallback);

DpiScale Dpi { get; set; }

void ClearUI();
List<CoverageLine> CoverageLines { get; }
FontDetails EnvironmentFontDetails { get; set; }

void ReadyForReport();
}

}
Loading