-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from tonyhallett/consistent-tool-window-opening
Move initialization into package. Record opened tool window when ope…
- Loading branch information
Showing
30 changed files
with
559 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using AutoMoq; | ||
using FineCodeCoverage.Core.Initialization; | ||
using FineCodeCoverage.Core.Utilities; | ||
using Moq; | ||
using NUnit.Framework; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace FineCodeCoverageTests | ||
{ | ||
internal class FirstTimeToolWindowOpener_Tests | ||
{ | ||
private AutoMoqer mocker; | ||
private FirstTimeToolWindowOpener firstTimeToolWindowOpener; | ||
|
||
[SetUp] | ||
public void SetUp() { | ||
mocker = new AutoMoqer(); | ||
firstTimeToolWindowOpener = mocker.Create<FirstTimeToolWindowOpener>(); | ||
} | ||
|
||
[TestCase(true,false,true)] | ||
[TestCase(true, true, false)] | ||
[TestCase(false, false, false)] | ||
[TestCase(false, true, false)] | ||
public async Task It_Should_Open_If_Have_Never_Shown_The_ToolWindow_And_InitializedFromTestContainerDiscoverer( | ||
bool initializedFromTestContainerDiscoverer, | ||
bool hasShownToolWindow, | ||
bool expectedShown | ||
) | ||
{ | ||
mocker.GetMock<IInitializedFromTestContainerDiscoverer>().Setup(x => x.InitializedFromTestContainerDiscoverer).Returns(initializedFromTestContainerDiscoverer); | ||
mocker.GetMock<IShownToolWindowHistory>().Setup(x => x.HasShownToolWindow).Returns(hasShownToolWindow); | ||
|
||
await firstTimeToolWindowOpener.OpenIfFirstTimeAsync(CancellationToken.None); | ||
|
||
var expectedTimes = expectedShown ? Times.Once() : Times.Never(); | ||
mocker.Verify<IToolWindowOpener>(toolWindowOpener => toolWindowOpener.OpenToolWindowAsync(), expectedTimes); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using AutoMoq; | ||
using FineCodeCoverage.Core.Initialization; | ||
using NUnit.Framework; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace FineCodeCoverageTests | ||
{ | ||
internal class PackageLoader_Tests | ||
{ | ||
private AutoMoqer mocker; | ||
private PackageLoader packageLoader; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
mocker = new AutoMoqer(); | ||
packageLoader = mocker.Create<PackageLoader>(); | ||
} | ||
|
||
|
||
|
||
[Test] | ||
public void Should_Not_Be_InitializedFromTestContainerDiscoverer_If_LoadPackageAsync() | ||
{ | ||
Assert.That(packageLoader.InitializedFromTestContainerDiscoverer, Is.False); | ||
} | ||
|
||
[Test] | ||
public async Task Should_Be_InitializedFromTestContainerDiscoverer_If_LoadPackageAsync() | ||
{ | ||
await packageLoader.LoadPackageAsync(CancellationToken.None); | ||
Assert.That(packageLoader.InitializedFromTestContainerDiscoverer, Is.True); | ||
} | ||
|
||
[Test] | ||
public async Task It_Should_Load_The_Package_If_LoadPackageAsync() | ||
{ | ||
await packageLoader.LoadPackageAsync(CancellationToken.None); | ||
|
||
mocker.Verify<IShellPackageLoader>(x => x.LoadPackageAsync()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using AutoMoq; | ||
using FineCodeCoverage.Core.Utilities; | ||
using FineCodeCoverage.Engine; | ||
using Moq; | ||
using NUnit.Framework; | ||
using StructureMap.AutoMocking; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FineCodeCoverageTests | ||
{ | ||
internal class ShownToolWindowHistory_Tests | ||
{ | ||
private AutoMoqer mocker; | ||
private ShownToolWindowHistory shownToolWindowHistory; | ||
private string markerFilePath; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
mocker = new AutoMoqer(); | ||
shownToolWindowHistory = mocker.Create<ShownToolWindowHistory>(); | ||
mocker.GetMock<IFCCEngine>().Setup(fccEngine => fccEngine.AppDataFolderPath).Returns("AppDataFolderPath"); | ||
markerFilePath = Path.Combine("AppDataFolderPath", "outputWindowInitialized"); | ||
} | ||
|
||
[Test] | ||
public void It_Should_Write_Marker_File_When_ShowedToolWindow_First_Time() | ||
{ | ||
shownToolWindowHistory.ShowedToolWindow(); | ||
mocker.Verify<IFileUtil>(f => f.WriteAllText(markerFilePath, string.Empty)); | ||
shownToolWindowHistory.ShowedToolWindow(); | ||
mocker.Verify<IFileUtil>(f => f.WriteAllText(markerFilePath, string.Empty),Times.Once()); | ||
} | ||
|
||
[Test] | ||
public void It_Should_HasShownToolWindow_Without_Searching_For_Marker_File_When_ShowedToolWindow_Is_Invoked() | ||
{ | ||
shownToolWindowHistory.ShowedToolWindow(); | ||
mocker.Verify<IFileUtil>(f => f.Exists(It.IsAny<string>()), Times.Never()); | ||
Assert.That(shownToolWindowHistory.HasShownToolWindow, Is.True); | ||
} | ||
|
||
[TestCase(true)] | ||
[TestCase(false)] | ||
public void When_ShowedToolWindow_Has_Not_Been_Invoked_Should_Search_For_Marker_File_Once_When_HasShownToolWindow(bool fileExists) | ||
{ | ||
mocker.GetMock<IFileUtil>().Setup(f => f.Exists(markerFilePath)).Returns(fileExists); | ||
|
||
void HasShownToolWindow() | ||
{ | ||
var hasShownToolWindow = shownToolWindowHistory.HasShownToolWindow; | ||
Assert.That(hasShownToolWindow, Is.EqualTo(fileExists)); | ||
} | ||
HasShownToolWindow(); | ||
HasShownToolWindow(); | ||
|
||
mocker.Verify<IFileUtil>(f => f.Exists(markerFilePath), Times.Once()); | ||
} | ||
} | ||
} |
Oops, something went wrong.