diff --git a/RepoM.sln b/RepoM.sln index 3652c36e..6adf8a62 100644 --- a/RepoM.sln +++ b/RepoM.sln @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.Clipboard", "s EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.Clipboard.Tests", "tests\RepoM.Plugin.Clipboard.Tests\RepoM.Plugin.Clipboard.Tests.csproj", "{A26EF3E9-C267-499C-B5AB-E4FB3C7AB6E1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RepoM.Plugin.EverythingFileSearch.Tests", "tests\RepoM.Plugin.EverythingFileSearch.Tests\RepoM.Plugin.EverythingFileSearch.Tests.csproj", "{89D96078-2951-44C2-B5B1-1DA0D5E94C0C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -459,6 +461,26 @@ Global {A26EF3E9-C267-499C-B5AB-E4FB3C7AB6E1}.Release|x64.Build.0 = Release|Any CPU {A26EF3E9-C267-499C-B5AB-E4FB3C7AB6E1}.Release|x86.ActiveCfg = Release|Any CPU {A26EF3E9-C267-499C-B5AB-E4FB3C7AB6E1}.Release|x86.Build.0 = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|ARM.Build.0 = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|ARM64.Build.0 = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|x64.ActiveCfg = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|x64.Build.0 = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|x86.ActiveCfg = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Debug|x86.Build.0 = Debug|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|Any CPU.Build.0 = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|ARM.ActiveCfg = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|ARM.Build.0 = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|ARM64.ActiveCfg = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|ARM64.Build.0 = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|x64.ActiveCfg = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|x64.Build.0 = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|x86.ActiveCfg = Release|Any CPU + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -478,6 +500,7 @@ Global {1F18CE9A-8E4A-43AB-8E17-34F7564E2198} = {D6E372DC-10D3-4997-9DFC-568B4666635A} {8F87B73D-8A5D-4335-96E9-97EE0495B671} = {D6E372DC-10D3-4997-9DFC-568B4666635A} {A26EF3E9-C267-499C-B5AB-E4FB3C7AB6E1} = {D6E372DC-10D3-4997-9DFC-568B4666635A} + {89D96078-2951-44C2-B5B1-1DA0D5E94C0C} = {D6E372DC-10D3-4997-9DFC-568B4666635A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1765ABAA-0652-4DA5-ABBF-05396F2957D7} diff --git a/src/RepoM.Api/IO/GitRepositoryFinderFactory.cs b/src/RepoM.Api/IO/GitRepositoryFinderFactory.cs index f662896e..9ca39ad0 100644 --- a/src/RepoM.Api/IO/GitRepositoryFinderFactory.cs +++ b/src/RepoM.Api/IO/GitRepositoryFinderFactory.cs @@ -4,6 +4,7 @@ namespace RepoM.Api.IO; using System.Collections.Generic; using System.Linq; using RepoM.Api.Common; +using RepoM.Core.Plugin.RepositoryFinder; public class GitRepositoryFinderFactory : IGitRepositoryFinderFactory { diff --git a/src/RepoM.Api/IO/GravellGitRepositoryFinder.cs b/src/RepoM.Api/IO/GravellGitRepositoryFinder.cs index d1bc93f6..76a742b2 100644 --- a/src/RepoM.Api/IO/GravellGitRepositoryFinder.cs +++ b/src/RepoM.Api/IO/GravellGitRepositoryFinder.cs @@ -4,6 +4,7 @@ namespace RepoM.Api.IO; using System.Collections.Generic; using System.IO.Abstractions; using System.Linq; +using RepoM.Core.Plugin.RepositoryFinder; // http://stackoverflow.com/questions/2106877/is-there-a-faster-way-than-this-to-find-all-the-files-in-a-directory-and-all-sub internal class GravellGitRepositoryFinder : IGitRepositoryFinder diff --git a/src/RepoM.Api/IO/GravellGitRepositoryFinderFactory.cs b/src/RepoM.Api/IO/GravellGitRepositoryFinderFactory.cs index 22b7846d..477acc4e 100644 --- a/src/RepoM.Api/IO/GravellGitRepositoryFinderFactory.cs +++ b/src/RepoM.Api/IO/GravellGitRepositoryFinderFactory.cs @@ -2,6 +2,7 @@ namespace RepoM.Api.IO; using System; using System.IO.Abstractions; +using RepoM.Core.Plugin.RepositoryFinder; public class GravellGitRepositoryFinderFactory : ISingleGitRepositoryFinderFactory { diff --git a/src/RepoM.Api/IO/IGitRepositoryFinderFactory.cs b/src/RepoM.Api/IO/IGitRepositoryFinderFactory.cs index 35ab92d1..a16a3316 100644 --- a/src/RepoM.Api/IO/IGitRepositoryFinderFactory.cs +++ b/src/RepoM.Api/IO/IGitRepositoryFinderFactory.cs @@ -1,5 +1,7 @@ namespace RepoM.Api.IO; +using RepoM.Core.Plugin.RepositoryFinder; + public interface IGitRepositoryFinderFactory { IGitRepositoryFinder Create(); diff --git a/src/RepoM.Api/IO/WindowsPathSkipper.cs b/src/RepoM.Api/IO/WindowsPathSkipper.cs index a0fa01a6..60cd094a 100644 --- a/src/RepoM.Api/IO/WindowsPathSkipper.cs +++ b/src/RepoM.Api/IO/WindowsPathSkipper.cs @@ -3,6 +3,7 @@ namespace RepoM.Api.IO; using System; using System.Collections.Generic; using System.Linq; +using RepoM.Core.Plugin.RepositoryFinder; public class WindowsPathSkipper : IPathSkipper { diff --git a/src/RepoM.App/App.xaml.cs b/src/RepoM.App/App.xaml.cs index 85eb8ce2..b3b22069 100644 --- a/src/RepoM.App/App.xaml.cs +++ b/src/RepoM.App/App.xaml.cs @@ -51,6 +51,7 @@ namespace RepoM.App; using RepoM.App.RepositoryOrdering; using RepoM.Core.Plugin.Common; using RepoM.Core.Plugin.Expressions; +using RepoM.Core.Plugin.RepositoryFinder; /// /// Interaction logic for App.xaml diff --git a/src/RepoM.Api/IO/IGitRepositoryFinder.cs b/src/RepoM.Core.Plugin/RepositoryFinder/IGitRepositoryFinder.cs similarity index 77% rename from src/RepoM.Api/IO/IGitRepositoryFinder.cs rename to src/RepoM.Core.Plugin/RepositoryFinder/IGitRepositoryFinder.cs index 4cd101f8..36d9ecfd 100644 --- a/src/RepoM.Api/IO/IGitRepositoryFinder.cs +++ b/src/RepoM.Core.Plugin/RepositoryFinder/IGitRepositoryFinder.cs @@ -1,4 +1,4 @@ -namespace RepoM.Api.IO; +namespace RepoM.Core.Plugin.RepositoryFinder; using System; using System.Collections.Generic; diff --git a/src/RepoM.Api/IO/IPathSkipper.cs b/src/RepoM.Core.Plugin/RepositoryFinder/IPathSkipper.cs similarity index 59% rename from src/RepoM.Api/IO/IPathSkipper.cs rename to src/RepoM.Core.Plugin/RepositoryFinder/IPathSkipper.cs index 81597594..22b655b4 100644 --- a/src/RepoM.Api/IO/IPathSkipper.cs +++ b/src/RepoM.Core.Plugin/RepositoryFinder/IPathSkipper.cs @@ -1,4 +1,4 @@ -namespace RepoM.Api.IO; +namespace RepoM.Core.Plugin.RepositoryFinder; public interface IPathSkipper { diff --git a/src/RepoM.Api/IO/ISingleGitRepositoryFinderFactory.cs b/src/RepoM.Core.Plugin/RepositoryFinder/ISingleGitRepositoryFinderFactory.cs similarity index 75% rename from src/RepoM.Api/IO/ISingleGitRepositoryFinderFactory.cs rename to src/RepoM.Core.Plugin/RepositoryFinder/ISingleGitRepositoryFinderFactory.cs index 366d8c5f..6213a5a9 100644 --- a/src/RepoM.Api/IO/ISingleGitRepositoryFinderFactory.cs +++ b/src/RepoM.Core.Plugin/RepositoryFinder/ISingleGitRepositoryFinderFactory.cs @@ -1,4 +1,4 @@ -namespace RepoM.Api.IO; +namespace RepoM.Core.Plugin.RepositoryFinder; public interface ISingleGitRepositoryFinderFactory { diff --git a/src/RepoM.Plugin.EverythingFileSearch/EverythingGitRepositoryFinderFactory.cs b/src/RepoM.Plugin.EverythingFileSearch/EverythingGitRepositoryFinderFactory.cs index 1b446c00..a625b20f 100644 --- a/src/RepoM.Plugin.EverythingFileSearch/EverythingGitRepositoryFinderFactory.cs +++ b/src/RepoM.Plugin.EverythingFileSearch/EverythingGitRepositoryFinderFactory.cs @@ -2,7 +2,7 @@ namespace RepoM.Plugin.EverythingFileSearch; using System; using JetBrains.Annotations; -using RepoM.Api.IO; +using RepoM.Core.Plugin.RepositoryFinder; using RepoM.Plugin.EverythingFileSearch.Internal; [UsedImplicitly] diff --git a/src/RepoM.Plugin.EverythingFileSearch/EverythingModule.cs b/src/RepoM.Plugin.EverythingFileSearch/EverythingPackage.cs similarity index 80% rename from src/RepoM.Plugin.EverythingFileSearch/EverythingModule.cs rename to src/RepoM.Plugin.EverythingFileSearch/EverythingPackage.cs index f3c1c6cb..2802ea4d 100644 --- a/src/RepoM.Plugin.EverythingFileSearch/EverythingModule.cs +++ b/src/RepoM.Plugin.EverythingFileSearch/EverythingPackage.cs @@ -1,12 +1,12 @@ namespace RepoM.Plugin.EverythingFileSearch; using JetBrains.Annotations; -using RepoM.Api.IO; +using RepoM.Core.Plugin.RepositoryFinder; using SimpleInjector; using SimpleInjector.Packaging; [UsedImplicitly] -public class EverythingModule : IPackage +public class EverythingPackage : IPackage { public void RegisterServices(Container container) { diff --git a/src/RepoM.Plugin.EverythingFileSearch/Internal/EverythingGitRepositoryFinder.cs b/src/RepoM.Plugin.EverythingFileSearch/Internal/EverythingGitRepositoryFinder.cs index 8144de07..018fb4b4 100644 --- a/src/RepoM.Plugin.EverythingFileSearch/Internal/EverythingGitRepositoryFinder.cs +++ b/src/RepoM.Plugin.EverythingFileSearch/Internal/EverythingGitRepositoryFinder.cs @@ -3,7 +3,7 @@ namespace RepoM.Plugin.EverythingFileSearch.Internal; using System; using System.Collections.Generic; using System.Linq; -using RepoM.Api.IO; +using RepoM.Core.Plugin.RepositoryFinder; internal class EverythingGitRepositoryFinder : IGitRepositoryFinder { diff --git a/src/RepoM.Plugin.EverythingFileSearch/RepoM.Plugin.EverythingFileSearch.csproj b/src/RepoM.Plugin.EverythingFileSearch/RepoM.Plugin.EverythingFileSearch.csproj index 65148b3d..49020ef3 100644 --- a/src/RepoM.Plugin.EverythingFileSearch/RepoM.Plugin.EverythingFileSearch.csproj +++ b/src/RepoM.Plugin.EverythingFileSearch/RepoM.Plugin.EverythingFileSearch.csproj @@ -8,14 +8,14 @@ - - - - Always + + + + diff --git a/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingGitRepositoryFinderFactoryTests.cs b/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingGitRepositoryFinderFactoryTests.cs new file mode 100644 index 00000000..451b54bc --- /dev/null +++ b/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingGitRepositoryFinderFactoryTests.cs @@ -0,0 +1,69 @@ +namespace RepoM.Plugin.EverythingFileSearch.Tests; + +using System; +using FakeItEasy; +using FluentAssertions; +using RepoM.Core.Plugin.RepositoryFinder; +using RepoM.Plugin.EverythingFileSearch.Internal; +using Xunit; + +public class EverythingGitRepositoryFinderFactoryTests +{ + private readonly IPathSkipper _pathSkipper; + + public EverythingGitRepositoryFinderFactoryTests() + { + _pathSkipper = A.Fake(); + } + + [Fact] + public void Ctor_ShouldThrow_WhenArgumentIsNull() + { + // arrange + + // act + Action act = () => _ = new EverythingGitRepositoryFinderFactory(null!); + + // assert + act.Should().ThrowExactly(); + } + + [Fact] + public void Name_ShouldBeEverything() + { + // arrange + var sut = new EverythingGitRepositoryFinderFactory(_pathSkipper); + + // act + var result = sut.Name; + + // assert + result.Should().Be("Everything"); + } + + [Fact] + public void IsActive_ShouldReturnSameValueAsEverythingApi() + { + // arrange + var sut = new EverythingGitRepositoryFinderFactory(_pathSkipper); + + // act + var result = sut.IsActive; + + // assert + result.Should().Be(Everything64Api.IsInstalled()); + } + + [Fact] + public void Create_ShouldReturnSameValueAsEverythingApi() + { + // arrange + var sut = new EverythingGitRepositoryFinderFactory(_pathSkipper); + + // act + IGitRepositoryFinder result = sut.Create(); + + // assert + result.Should().NotBeNull().And.BeOfType(); + } +} \ No newline at end of file diff --git a/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingPackageTests.cs b/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingPackageTests.cs new file mode 100644 index 00000000..15140a2e --- /dev/null +++ b/tests/RepoM.Plugin.EverythingFileSearch.Tests/EverythingPackageTests.cs @@ -0,0 +1,46 @@ +namespace RepoM.Plugin.EverythingFileSearch.Tests; + +using System; +using FakeItEasy; +using RepoM.Core.Plugin.RepositoryFinder; +using RepoM.Plugin.EverythingFileSearch; +using SimpleInjector; +using Xunit; + +public class EverythingPackageTests +{ + [Fact] + public void RegisterServices_ShouldBeSuccessful_WhenExternalDependenciesAreRegistered() + { + // arrange + var container = new Container(); + RegisterExternals(container); + var sut = new EverythingPackage(); + + // act + sut.RegisterServices(container); + + // assert + // implicit, Verify throws when container is not valid. + container.Verify(VerificationOption.VerifyAndDiagnose); + } + + [Fact] + public void RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegistered() + { + // arrange + var container = new Container(); + var sut = new EverythingPackage(); + + // act + sut.RegisterServices(container); + + // assert + Assert.Throws(() => container.Verify(VerificationOption.VerifyAndDiagnose)); + } + + private static void RegisterExternals(Container container) + { + container.RegisterSingleton(A.Dummy); + } +} \ No newline at end of file diff --git a/tests/RepoM.Plugin.EverythingFileSearch.Tests/Internal/EverythingGitRepositoryFinderTests.cs b/tests/RepoM.Plugin.EverythingFileSearch.Tests/Internal/EverythingGitRepositoryFinderTests.cs new file mode 100644 index 00000000..e0491ba4 --- /dev/null +++ b/tests/RepoM.Plugin.EverythingFileSearch.Tests/Internal/EverythingGitRepositoryFinderTests.cs @@ -0,0 +1,35 @@ +namespace RepoM.Plugin.EverythingFileSearch.Tests.Internal; + +using System; +using FakeItEasy; +using FluentAssertions; +using RepoM.Core.Plugin.RepositoryFinder; +using RepoM.Plugin.EverythingFileSearch.Internal; +using Xunit; + +public class EverythingGitRepositoryFinderTests +{ + [Fact] + public void Ctor_ShouldThrow_WhenArgumentIsNull() + { + // arrange + + // act + Action act = () => _ = new EverythingGitRepositoryFinder(null!); + + // assert + act.Should().ThrowExactly(); + } + + [Fact] + public void Ctor_ShouldNotThrown_WhenArgumentIsNotNull() + { + // arrange + + // act + Action act = () => _ = new EverythingGitRepositoryFinder(A.Dummy()); + + // assert + act.Should().NotThrow(); + } +} \ No newline at end of file diff --git a/tests/RepoM.Plugin.EverythingFileSearch.Tests/RepoM.Plugin.EverythingFileSearch.Tests.csproj b/tests/RepoM.Plugin.EverythingFileSearch.Tests/RepoM.Plugin.EverythingFileSearch.Tests.csproj new file mode 100644 index 00000000..4fd38c74 --- /dev/null +++ b/tests/RepoM.Plugin.EverythingFileSearch.Tests/RepoM.Plugin.EverythingFileSearch.Tests.csproj @@ -0,0 +1,34 @@ + + + + net6.0 + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + diff --git a/tests/Specs/DefaultRepositoryMonitorTests.cs b/tests/Specs/DefaultRepositoryMonitorTests.cs index f77a2e36..0a36fa57 100644 --- a/tests/Specs/DefaultRepositoryMonitorTests.cs +++ b/tests/Specs/DefaultRepositoryMonitorTests.cs @@ -25,6 +25,7 @@ namespace Specs; using RepoM.Api.IO; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.VariableProviders; +using RepoM.Core.Plugin.RepositoryFinder; using Specs.IO; using Specs.Mocks; diff --git a/tests/Specs/Mocks/NeverSkippingPathSkipper.cs b/tests/Specs/Mocks/NeverSkippingPathSkipper.cs index a0ad2ae7..20f0306a 100644 --- a/tests/Specs/Mocks/NeverSkippingPathSkipper.cs +++ b/tests/Specs/Mocks/NeverSkippingPathSkipper.cs @@ -1,6 +1,7 @@ namespace Specs.Mocks; using RepoM.Api.IO; +using RepoM.Core.Plugin.RepositoryFinder; internal class NeverSkippingPathSkipper : IPathSkipper {