diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs index c9e0d2a1..195d80ec 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1Mapper.cs @@ -4,7 +4,6 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System.Collections.Generic; using System.IO; using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; @@ -15,12 +14,10 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; public class ActionAssociateFileV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionAssociateFileV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionAssociateFileV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) @@ -50,8 +47,8 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); - + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); + Git.RepositoryAction? menuItem = CreateFileAssociationSubMenu( repository, name, diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs index 55b3ae4e..11b06d3a 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowseRepositoryV1Mapper.cs @@ -50,7 +50,7 @@ private IEnumerable Map(RepositoryActionBrowseRepositoryV1? ac } } - private RepositoryAction? CreateBrowseRemoteAction(Repository repository, RepositoryActionBrowseRepositoryV1 action) + private RepositoryAction? CreateBrowseRemoteAction(IRepository repository, RepositoryActionBrowseRepositoryV1 action) { if (repository.Remotes.Count == 0) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs index ebc22001..ba01900f 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionBrowserV1Mapper.cs @@ -2,8 +2,6 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; -using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; @@ -13,12 +11,10 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; public class ActionBrowserV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionBrowserV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionBrowserV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(Data.RepositoryAction action) @@ -48,7 +44,7 @@ private IEnumerable Map(RepositoryActionBrowserV1? action, Rep yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); var url = _expressionEvaluator.EvaluateStringExpression(action.Url, repository); yield return new RepositoryAction(name, repository) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs index d64ce081..03665603 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionCommandV1Mapper.cs @@ -2,23 +2,20 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; -using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; +using RepoM.Core.Plugin.Repository; using RepoM.Core.Plugin.RepositoryActions.Actions; using RepositoryAction = RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.RepositoryAction; public class ActionCommandV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionCommandV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionCommandV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) @@ -31,7 +28,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository return Map(action as RepositoryActionCommandV1, repository); } - private IEnumerable Map(RepositoryActionCommandV1? action, Repository repository) + private IEnumerable Map(RepositoryActionCommandV1? action, IRepository repository) { if (action == null) { @@ -43,9 +40,9 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); - var command = _expressionEvaluator.EvaluateStringExpression(action.Command ?? string.Empty, repository); - var arguments = _expressionEvaluator.EvaluateStringExpression(action.Arguments ?? string.Empty, repository); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); + var command = _expressionEvaluator.EvaluateNullStringExpression(action.Command, repository); + var arguments = _expressionEvaluator.EvaluateNullStringExpression(action.Arguments, repository); yield return new Git.RepositoryAction(name, repository) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs index bbce34b8..899f42fa 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionExecutableV1Mapper.cs @@ -3,24 +3,21 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; using System.IO.Abstractions; -using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; +using RepoM.Core.Plugin.Repository; using RepoM.Core.Plugin.RepositoryActions.Actions; using RepositoryAction = Data.RepositoryAction; public class ActionExecutableV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; private readonly IFileSystem _fileSystem; - public ActionExecutableV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService, IFileSystem fileSystem) + public ActionExecutableV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, IFileSystem fileSystem) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); } @@ -34,7 +31,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository return Map(action as RepositoryActionExecutableV1, repository); } - private IEnumerable Map(RepositoryActionExecutableV1? action, Repository repository) + private IEnumerable Map(RepositoryActionExecutableV1? action, IRepository repository) { if (action == null) { @@ -46,7 +43,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); var found = false; foreach (var executable in action.Executables) diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs index 2b0929ca..2bdbb561 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionFolderV1Mapper.cs @@ -3,7 +3,6 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; @@ -12,12 +11,10 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; public class ActionFolderV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionFolderV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionFolderV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) @@ -48,7 +45,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository deferred = _expressionEvaluator.EvaluateBooleanExpression(action.IsDeferred, repository); } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); if (deferred) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs index c62c226a..34cf2da1 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitCheckoutV1Mapper.cs @@ -45,11 +45,7 @@ private IEnumerable Map(RepositoryActionGitCheckoutV1? act yield break; } - var name = action.Name; - if (!string.IsNullOrEmpty(name)) - { - name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); - } + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); if (string.IsNullOrWhiteSpace(name)) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs index 040c78d2..dfa1cf3a 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionGitFetchV1Mapper.cs @@ -2,7 +2,6 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; -using System.Linq; using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs index 62e1aacc..7f973b91 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionJustTextV1Mapper.cs @@ -2,23 +2,20 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; -using System.Linq; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; +using RepoM.Core.Plugin.Repository; using RepoM.Core.Plugin.RepositoryActions.Actions; using RepositoryAction = RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.RepositoryAction; public class ActionJustTextV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionJustTextV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionJustTextV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) @@ -31,7 +28,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository return Map(action as RepositoryActionJustTextV1, repository); } - private IEnumerable Map(RepositoryActionJustTextV1? action, Repository repository) + private IEnumerable Map(RepositoryActionJustTextV1? action, IRepository repository) { if (action == null) { @@ -43,7 +40,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); yield return new Git.RepositoryAction(name, repository) { diff --git a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs index 3645009e..ab53aa56 100644 --- a/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs +++ b/src/RepoM.Api/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionPinRepositoryV1Mapper.cs @@ -2,26 +2,24 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System; using System.Collections.Generic; -using RepoM.Api.Common; +using JetBrains.Annotations; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.Actions; using RepoM.Core.Plugin.Expressions; using RepoM.Core.Plugin.RepositoryActions.Actions; using RepositoryAction = RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data.RepositoryAction; +[UsedImplicitly] public class ActionPinRepositoryV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; private readonly IRepositoryMonitor _repositoryMonitor; public ActionPinRepositoryV1Mapper( IRepositoryExpressionEvaluator expressionEvaluator, - ITranslationService translationService, IRepositoryMonitor repositoryMonitor) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); _repositoryMonitor = repositoryMonitor ?? throw new ArgumentNullException(nameof(repositoryMonitor)); } @@ -47,11 +45,7 @@ private IEnumerable Map(RepositoryActionPinRepositoryV1? a yield break; } - var name = action.Name ?? string.Empty; - if (!string.IsNullOrEmpty(name)) - { - name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); - } + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); var currentlyPinned = _repositoryMonitor.IsPinned(repository); @@ -69,14 +63,6 @@ private IEnumerable Map(RepositoryActionPinRepositoryV1? a }; } - Git.RepositoryAction CreateAction(string name, Repository repository, bool newPinnedValue) - { - return new Git.RepositoryAction(name, repository) - { - Action = new DelegateAction((_, _) => _repositoryMonitor.SetPinned(newPinnedValue, repository)), - }; - } - yield return action.Mode switch { RepositoryActionPinRepositoryV1.PinMode.Toggle => CreateAction(name, repository, !currentlyPinned), @@ -84,5 +70,13 @@ Git.RepositoryAction CreateAction(string name, Repository repository, bool newPi RepositoryActionPinRepositoryV1.PinMode.UnPin => CreateAction(name, repository, false), _ => throw new NotImplementedException(), }; + + Git.RepositoryAction CreateAction(string actionName, Repository repo, bool newPinnedValue) + { + return new Git.RepositoryAction(actionName, repo) + { + Action = new DelegateAction((_, _) => _repositoryMonitor.SetPinned(newPinnedValue, repo)), + }; + } } } \ No newline at end of file diff --git a/src/RepoM.Api/IO/NameHelper.cs b/src/RepoM.Api/IO/NameHelper.cs deleted file mode 100644 index eb1d53d7..00000000 --- a/src/RepoM.Api/IO/NameHelper.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace RepoM.Api.IO; - -using RepoM.Api.Common; -using RepoM.Api.Git; -using RepoM.Core.Plugin.Expressions; - -public static class NameHelper -{ - // todo - public static string EvaluateName(in string? input, in Repository repository, ITranslationService translationService, IRepositoryExpressionEvaluator repositoryExpressionEvaluator) - { - return repositoryExpressionEvaluator.EvaluateStringExpression( - ReplaceTranslatables( - translationService.Translate(input ?? string.Empty), - translationService), - repository); - } - - private static string ReplaceTranslatables(string? value, ITranslationService translationService) - { - if (value is null) - { - return string.Empty; - } - - value = ReplaceTranslatable(value, "Open", translationService); - value = ReplaceTranslatable(value, "OpenIn", translationService); - value = ReplaceTranslatable(value, "OpenWith", translationService); - - return value; - } - - private static string ReplaceTranslatable(string value, string translatable, ITranslationService translationService) - { - if (!value.StartsWith("{" + translatable + "}")) - { - return value; - } - - var rest = value.Replace("{" + translatable + "}", "").Trim(); - return translationService.Translate("(" + translatable + ")", rest); // XMl doesn't support {} - } -} \ No newline at end of file diff --git a/src/RepoM.Core.Plugin/Expressions/IRepositoryExpressionEvaluator.cs b/src/RepoM.Core.Plugin/Expressions/IRepositoryExpressionEvaluator.cs index 44ff0d83..3a239938 100644 --- a/src/RepoM.Core.Plugin/Expressions/IRepositoryExpressionEvaluator.cs +++ b/src/RepoM.Core.Plugin/Expressions/IRepositoryExpressionEvaluator.cs @@ -9,4 +9,17 @@ public interface IRepositoryExpressionEvaluator object? EvaluateValueExpression(string value, IRepository? repository); bool EvaluateBooleanExpression(string? value, IRepository? repository); +} + +public static class RepositoryExpressionEvaluatorExtensions +{ + public static string EvaluateNullStringExpression(this IRepositoryExpressionEvaluator evaluator, string? value, IRepository? repository) + { + if (string.IsNullOrEmpty(value)) + { + return string.Empty; + } + + return evaluator.EvaluateStringExpression(value, repository); + } } \ No newline at end of file diff --git a/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs b/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs index 76b1cb66..04ad9a19 100644 --- a/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs +++ b/src/RepoM.Plugin.Clipboard/ActionProvider/ActionClipboardCopyV1Mapper.cs @@ -2,11 +2,8 @@ namespace RepoM.Plugin.Clipboard.ActionProvider; using System; using System.Collections.Generic; -using System.Linq; using JetBrains.Annotations; -using RepoM.Api.Common; using RepoM.Api.Git; -using RepoM.Api.IO; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using RepoM.Core.Plugin.Expressions; @@ -17,14 +14,10 @@ namespace RepoM.Plugin.Clipboard.ActionProvider; internal class ActionClipboardCopyV1Mapper : IActionToRepositoryActionMapper { private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionClipboardCopyV1Mapper( - IRepositoryExpressionEvaluator expressionEvaluator, - ITranslationService translationService) + public ActionClipboardCopyV1Mapper(IRepositoryExpressionEvaluator expressionEvaluator) { _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } public bool CanMap(RepositoryAction action) @@ -49,12 +42,8 @@ private IEnumerable Map(RepositoryActionClipboardCopyV1? a yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); - var txt = string.Empty; - if (!string.IsNullOrWhiteSpace(action.Text)) - { - txt = _expressionEvaluator.EvaluateStringExpression(action.Text, repository); - } + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); + var txt = _expressionEvaluator.EvaluateNullStringExpression(action.Text, repository); yield return new Api.Git.RepositoryAction(name, repository) { diff --git a/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs b/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs index b1acff0d..91f2b44a 100644 --- a/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs +++ b/src/RepoM.Plugin.Heidi/ActionProvider/ActionHeidiDatabasesV1Mapper.cs @@ -5,9 +5,7 @@ namespace RepoM.Plugin.Heidi.ActionProvider; using System.Linq; using JetBrains.Annotations; using Microsoft.Extensions.Logging; -using RepoM.Api.Common; using RepoM.Api.Git; -using RepoM.Api.IO; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using RepoM.Core.Plugin.Expressions; @@ -22,20 +20,17 @@ internal class ActionHeidiDatabasesV1Mapper : IActionToRepositoryActionMapper { private readonly IHeidiConfigurationService _service; private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; private readonly IHeidiSettings _settings; private readonly ILogger _logger; public ActionHeidiDatabasesV1Mapper( IHeidiConfigurationService service, IRepositoryExpressionEvaluator expressionEvaluator, - ITranslationService translationService, IHeidiSettings settings, ILogger logger) { _service = service ?? throw new ArgumentNullException(nameof(service)); _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); _settings = settings ?? throw new ArgumentNullException(nameof(settings)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } @@ -50,7 +45,7 @@ public IEnumerable Map(RepositoryAction action, Repository return Map(action as RepositoryActionHeidiDatabasesV1, repository); } - private IEnumerable Map(RepositoryActionHeidiDatabasesV1? action, Repository repository) + private IEnumerable Map(RepositoryActionHeidiDatabasesV1? action, IRepository repository) { if (action == null) { @@ -71,12 +66,7 @@ private IEnumerable Map(RepositoryActionHeidiDatabasesV1? RepositoryHeidiConfiguration[] databases = GetHeidiDatabases(action, repository); - string? name = action.Name; - - if (!string.IsNullOrWhiteSpace(name)) - { - name = NameHelper.EvaluateName(name, repository, _translationService, _expressionEvaluator); - } + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); if (!string.IsNullOrWhiteSpace(name)) { diff --git a/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs b/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs index d65e4d63..67cb39d4 100644 --- a/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs +++ b/src/RepoM.Plugin.SonarCloud/ActionSonarCloudV1Mapper.cs @@ -2,11 +2,8 @@ namespace RepoM.Plugin.SonarCloud; using System; using System.Collections.Generic; -using System.Linq; using JetBrains.Annotations; -using RepoM.Api.Common; using RepoM.Api.Git; -using RepoM.Api.IO; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using RepoM.Core.Plugin.Expressions; @@ -18,13 +15,11 @@ internal class ActionSonarCloudV1Mapper : IActionToRepositoryActionMapper { private readonly ISonarCloudFavoriteService _service; private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - public ActionSonarCloudV1Mapper(ISonarCloudFavoriteService service, IRepositoryExpressionEvaluator expressionEvaluator, ITranslationService translationService) + public ActionSonarCloudV1Mapper(ISonarCloudFavoriteService service, IRepositoryExpressionEvaluator expressionEvaluator) { _service = service ?? throw new ArgumentNullException(nameof(service)); _expressionEvaluator = expressionEvaluator ?? throw new ArgumentNullException(nameof(expressionEvaluator)); - _translationService = translationService ?? throw new ArgumentNullException(nameof(translationService)); } bool IActionToRepositoryActionMapper.CanMap(RepositoryAction action) @@ -54,7 +49,7 @@ IEnumerable IActionToRepositoryActionMapper.Map(Repository yield break; } - var name = NameHelper.EvaluateName(action.Name, repository, _translationService, _expressionEvaluator); + var name = _expressionEvaluator.EvaluateNullStringExpression(action.Name, repository); var key = _expressionEvaluator.EvaluateStringExpression(action.Project!, repository); if (_service.IsInitialized) diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMapperCompositionFactory.cs b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMapperCompositionFactory.cs index 761f8338..cb172580 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMapperCompositionFactory.cs +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMapperCompositionFactory.cs @@ -19,10 +19,10 @@ public static ActionMapperComposition Create( var mappers = new IActionToRepositoryActionMapper[] { new ActionBrowseRepositoryV1Mapper(expressionEvaluator, translationService), - new ActionBrowserV1Mapper(expressionEvaluator, translationService), - new ActionCommandV1Mapper(expressionEvaluator, translationService), - new ActionExecutableV1Mapper(expressionEvaluator,translationService, fileSystem), - new ActionFolderV1Mapper(expressionEvaluator, translationService), + new ActionBrowserV1Mapper(expressionEvaluator), + new ActionCommandV1Mapper(expressionEvaluator), + new ActionExecutableV1Mapper(expressionEvaluator, fileSystem), + new ActionFolderV1Mapper(expressionEvaluator), new ActionForEachV1Mapper(expressionEvaluator), new ActionGitCheckoutV1Mapper(expressionEvaluator, translationService, repositoryWriter), new ActionGitFetchV1Mapper(expressionEvaluator, translationService, repositoryWriter), @@ -30,8 +30,8 @@ public static ActionMapperComposition Create( new ActionGitPushV1Mapper(expressionEvaluator, translationService, repositoryWriter), new ActionIgnoreRepositoriesV1Mapper(expressionEvaluator, translationService, repositoryMonitor), new ActionSeparatorV1Mapper(expressionEvaluator), - new ActionAssociateFileV1Mapper(expressionEvaluator, translationService), - new ActionJustTextV1Mapper(expressionEvaluator, translationService), + new ActionAssociateFileV1Mapper(expressionEvaluator), + new ActionJustTextV1Mapper(expressionEvaluator), }; return new ActionMapperComposition(mappers, expressionEvaluator); @@ -39,10 +39,6 @@ public static ActionMapperComposition Create( public static ActionMapperComposition CreateSmall(IRepositoryExpressionEvaluator expressionEvaluator, IActionToRepositoryActionMapper actionToRepositoryActionMapper) { - var list = new[] - { - actionToRepositoryActionMapper, - }; - return new ActionMapperComposition(list, expressionEvaluator); + return new ActionMapperComposition(new[] { actionToRepositoryActionMapper, }, expressionEvaluator); } } \ No newline at end of file diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs index a6716f7b..b103b483 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/ActionMappers/ActionAssociateFileV1MapperTests.cs @@ -4,7 +4,6 @@ namespace RepoM.Api.Tests.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using System.Linq; using FakeItEasy; using FluentAssertions; -using RepoM.Api.Common; using RepoM.Api.Git; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; @@ -15,18 +14,8 @@ namespace RepoM.Api.Tests.IO.ModuleBasedRepositoryActionProvider.ActionMappers; public class ActionAssociateFileV1MapperTests { - private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; - private Repository _repository; - - public ActionAssociateFileV1MapperTests() - { - _repository = new Repository(""); - _expressionEvaluator = A.Fake(); - _translationService = A.Fake(); - A.CallTo(() => _translationService.Translate(A._, A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "dummy"); - A.CallTo(() => _translationService.Translate(A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "dummy"); - } + private readonly IRepositoryExpressionEvaluator _expressionEvaluator = A.Fake(); + private readonly Repository _repository = new(""); [Fact] public void Ctor_ShouldThrown_WhenArgumentIsNull() @@ -34,19 +23,17 @@ public void Ctor_ShouldThrown_WhenArgumentIsNull() // arrange // act - Action act1 = () => _ = new ActionAssociateFileV1Mapper(_expressionEvaluator, null!); - Action act2 = () => _ = new ActionAssociateFileV1Mapper(null!, _translationService); + Action act = () => _ = new ActionAssociateFileV1Mapper(null!); // assert - act1.Should().ThrowExactly(); - act2.Should().ThrowExactly(); + act.Should().ThrowExactly(); } [Fact] public void CanMap_ShouldReturnFalse_WhenInputNull() { // arrange - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act var result = sut.CanMap(null!); @@ -60,7 +47,7 @@ public void CanMap_ShouldReturnFalse_WhenInputIsNotCorrectType() { // arrange - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act var result = sut.CanMap(new DummyRepositoryAction()); @@ -73,7 +60,7 @@ public void CanMap_ShouldReturnFalse_WhenInputIsNotCorrectType() public void CanMap_ShouldReturnTrue_WhenInputIsOfTypeRepositoryActionAssociateFileV1() { // arrange - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act var result = sut.CanMap(new RepositoryActionAssociateFileV1()); @@ -87,7 +74,7 @@ public void Map_ShouldReturnEmpty_WhenActionIsNotOfCorrectType() { // arrange var action = new DummyRepositoryAction(); - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act RepositoryActionBase[] result = sut.Map(action, _repository, ActionMapperCompositionFactory.CreateSmall(_expressionEvaluator, A.Dummy())).ToArray(); @@ -105,7 +92,7 @@ public void Map_ShouldReturnEmpty_WhenActionActiveIsEvaluatesToFalse() Active = "dummy active string", }; A.CallTo(() => _expressionEvaluator.EvaluateBooleanExpression(action.Active, _repository)).Returns(false); - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act RepositoryActionBase[] result = sut.Map(action, _repository, ActionMapperCompositionFactory.CreateSmall(_expressionEvaluator, A.Dummy())).ToArray(); @@ -123,7 +110,7 @@ public void Map_ShouldReturnEmpty_WhenActionExtensionIsNull() Extension = null, }; A.CallTo(() => _expressionEvaluator.EvaluateBooleanExpression(A._, _repository)).Returns(true); - var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator, _translationService) as IActionToRepositoryActionMapper; + var sut = new ActionAssociateFileV1Mapper(_expressionEvaluator) as IActionToRepositoryActionMapper; // act RepositoryActionBase[] result = sut.Map(action, _repository, ActionMapperCompositionFactory.CreateSmall(_expressionEvaluator, A.Dummy())).ToArray(); diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/Verified/RepositorySpecificConfigurationTest.Create_ShouldProcessSeparator1.verified.txt b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/Verified/RepositorySpecificConfigurationTest.Create_ShouldProcessSeparator1.verified.txt index ad4f6223..1fe689a1 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/Verified/RepositorySpecificConfigurationTest.Create_ShouldProcessSeparator1.verified.txt +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/Verified/RepositorySpecificConfigurationTest.Create_ShouldProcessSeparator1.verified.txt @@ -6,7 +6,7 @@ $type: DelegateAction, Action: { Type: Action, - Target: ActionBrowserV1Mapper.<>c__DisplayClass5_0, + Target: ActionBrowserV1Mapper.<>c__DisplayClass4_0, Method: Void Map(System.Object, System.Object) } }, @@ -28,7 +28,7 @@ $type: DelegateAction, Action: { Type: Action, - Target: ActionBrowserV1Mapper.<>c__DisplayClass5_0, + Target: ActionBrowserV1Mapper.<>c__DisplayClass4_0, Method: Void Map(System.Object, System.Object) } }, diff --git a/tests/RepoM.Plugin.AzureDevOps.Tests/AzureDevOpsPackageTests.cs b/tests/RepoM.Plugin.AzureDevOps.Tests/AzureDevOpsPackageTests.cs index 84e17e10..d043cfe6 100644 --- a/tests/RepoM.Plugin.AzureDevOps.Tests/AzureDevOpsPackageTests.cs +++ b/tests/RepoM.Plugin.AzureDevOps.Tests/AzureDevOpsPackageTests.cs @@ -107,7 +107,6 @@ private void RegisterExternals(Container container) { container.RegisterSingleton(A.Dummy); container.RegisterSingleton(A.Dummy); - container.RegisterSingleton(A.Dummy); container.RegisterInstance(_appSettingsService); container.RegisterSingleton(A.Dummy); } diff --git a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs index 10ca468f..9a0e9c36 100644 --- a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs +++ b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/ActionClipboardCopyV1MapperTests.cs @@ -6,7 +6,6 @@ namespace RepoM.Plugin.Clipboard.Tests.ActionProvider; using System.Threading.Tasks; using FakeItEasy; using FluentAssertions; -using RepoM.Api.Common; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using RepoM.Core.Plugin.Expressions; @@ -34,11 +33,8 @@ public ActionClipboardCopyV1MapperTests() _actionMapperComposition = new ActionMapperComposition(new List(), A.Dummy()); _repository = new Repository("dummy"); IRepositoryExpressionEvaluator expressionEvaluator = A.Fake(); - ITranslationService translationService = A.Fake(); - _sut = new ActionClipboardCopyV1Mapper( - expressionEvaluator, - translationService); + _sut = new ActionClipboardCopyV1Mapper(expressionEvaluator); _action = new RepositoryActionClipboardCopyV1 { @@ -58,22 +54,17 @@ public ActionClipboardCopyV1MapperTests() throw new Exception("Thrown by test, Not expected"); }); - A.CallTo(() => translationService.Translate(A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "unexpected by test."); - A.CallTo(() => translationService.Translate(A._, A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "unexpected by test."); } [Fact] public void Ctor_ShouldThrowArgumentNullException_WhenAnArgumentIsNull() { // arrange - IRepositoryExpressionEvaluator expressionEvaluator = A.Dummy(); - ITranslationService translationService = A.Dummy(); // act var actions = new List { - () => _ = new ActionClipboardCopyV1Mapper(expressionEvaluator, null!), - () => _ = new ActionClipboardCopyV1Mapper(null!, translationService), + () => _ = new ActionClipboardCopyV1Mapper(null!), }; // assert diff --git a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_empty.verified.txt b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_empty.verified.txt index e5ced40c..6f6f0135 100644 --- a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_empty.verified.txt +++ b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_empty.verified.txt @@ -1,7 +1,7 @@ [ { $type: RepositoryAction, - Name: ES_, + Name: , Action: { $type: CopyToClipboardAction, Text: ES_text123 diff --git a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_null.verified.txt b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_null.verified.txt index e5ced40c..6f6f0135 100644 --- a/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_null.verified.txt +++ b/tests/RepoM.Plugin.Clipboard.Tests/ActionProvider/Verified/ActionClipboardCopyV1MapperTests.Map_ShouldMap_WhenNameSet_null.verified.txt @@ -1,7 +1,7 @@ [ { $type: RepositoryAction, - Name: ES_, + Name: , Action: { $type: CopyToClipboardAction, Text: ES_text123 diff --git a/tests/RepoM.Plugin.Clipboard.Tests/ClipboardPackageTests.cs b/tests/RepoM.Plugin.Clipboard.Tests/ClipboardPackageTests.cs index 3e16dd17..1e3272c8 100644 --- a/tests/RepoM.Plugin.Clipboard.Tests/ClipboardPackageTests.cs +++ b/tests/RepoM.Plugin.Clipboard.Tests/ClipboardPackageTests.cs @@ -43,7 +43,6 @@ public void RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegistered private static void RegisterExternals(Container container) { container.RegisterSingleton(A.Dummy); - container.RegisterSingleton(A.Dummy); } } diff --git a/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs b/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs index 908f21dc..31758bae 100644 --- a/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs +++ b/tests/RepoM.Plugin.Heidi.Tests/ActionProvider/ActionHeidiDatabasesV1MapperTests.cs @@ -8,7 +8,6 @@ namespace RepoM.Plugin.Heidi.Tests.ActionProvider; using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using RepoM.Api.Common; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionMappers; using RepoM.Core.Plugin.Expressions; @@ -44,12 +43,10 @@ public ActionHeidiDatabasesV1MapperTests() _service = A.Fake(); _expressionEvaluator = A.Fake(); _settings = A.Fake(); - ITranslationService translationService = A.Fake(); _sut = new ActionHeidiDatabasesV1Mapper( _service, _expressionEvaluator, - translationService, _settings, NullLogger.Instance); @@ -74,8 +71,6 @@ public ActionHeidiDatabasesV1MapperTests() }); A.CallTo(() => _service.GetByKey(A._)).Returns(Array.Empty()); A.CallTo(() => _service.GetByRepository(_repository)).Returns(Array.Empty()); - A.CallTo(() => translationService.Translate(A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "unexpected by test."); - A.CallTo(() => translationService.Translate(A._, A._)).ReturnsLazily(call => call.Arguments[0] as string ?? "unexpected by test."); } [Fact] @@ -84,18 +79,16 @@ public void Ctor_ShouldThrowArgumentNullException_WhenAnArgumentIsNull() // arrange IHeidiConfigurationService service = A.Dummy(); IRepositoryExpressionEvaluator expressionEvaluator = A.Dummy(); - ITranslationService translationService = A.Dummy(); IHeidiSettings settings = A.Dummy(); ILogger logger = A.Dummy(); // act var actions = new List { - () => _ = new ActionHeidiDatabasesV1Mapper(service, expressionEvaluator, translationService, settings, null!), - () => _ = new ActionHeidiDatabasesV1Mapper(service, expressionEvaluator, translationService, null!, logger), - () => _ = new ActionHeidiDatabasesV1Mapper(service, expressionEvaluator, null!, settings, logger), - () => _ = new ActionHeidiDatabasesV1Mapper(service, null!, translationService, settings, logger), - () => _ = new ActionHeidiDatabasesV1Mapper(null!, expressionEvaluator, translationService, settings, logger), + () => _ = new ActionHeidiDatabasesV1Mapper(service, expressionEvaluator, settings, null!), + () => _ = new ActionHeidiDatabasesV1Mapper(service, expressionEvaluator, null!, logger), + () => _ = new ActionHeidiDatabasesV1Mapper(service, null!, settings, logger), + () => _ = new ActionHeidiDatabasesV1Mapper(null!, expressionEvaluator, settings, logger), }; // assert diff --git a/tests/RepoM.Plugin.Heidi.Tests/HeidiPackageTest.cs b/tests/RepoM.Plugin.Heidi.Tests/HeidiPackageTest.cs index 8fd2eba9..c55c06ae 100644 --- a/tests/RepoM.Plugin.Heidi.Tests/HeidiPackageTest.cs +++ b/tests/RepoM.Plugin.Heidi.Tests/HeidiPackageTest.cs @@ -5,7 +5,6 @@ namespace RepoM.Plugin.Heidi.Tests; using System.Threading.Tasks; using FakeItEasy; using Microsoft.Extensions.Logging; -using RepoM.Api.Common; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider; using RepoM.Core.Plugin; using RepoM.Core.Plugin.Expressions; @@ -107,6 +106,5 @@ private static void RegisterExternals(Container container) container.RegisterSingleton(A.Dummy); container.RegisterSingleton(A.Dummy); container.RegisterSingleton(A.Dummy); - container.RegisterSingleton(A.Dummy); } } \ No newline at end of file diff --git a/tests/RepoM.Plugin.Misc.Tests/DefaultAppSettingsTests/DocsAppSettingsTests.cs b/tests/RepoM.Plugin.Misc.Tests/DefaultAppSettingsTests/DocsAppSettingsTests.cs index d9b2d154..7d5c3ec4 100644 --- a/tests/RepoM.Plugin.Misc.Tests/DefaultAppSettingsTests/DocsAppSettingsTests.cs +++ b/tests/RepoM.Plugin.Misc.Tests/DefaultAppSettingsTests/DocsAppSettingsTests.cs @@ -1,6 +1,5 @@ namespace RepoM.Plugin.Misc.Tests.DefaultAppSettingsTests; -using System; using System.IO.Abstractions.TestingHelpers; using System.Text; using System.Threading.Tasks; @@ -57,7 +56,7 @@ public async Task AppSettingsDocumentationGeneration() }; AssemblyMembers members = DocReader.Read(typeof(AppSettings).Assembly, options); #else - var members = new DocumentMembers(System.Xml.Linq.XDocument.Parse(""), Array.Empty()); + var members = new DocumentMembers(System.Xml.Linq.XDocument.Parse(""), System.Array.Empty()); #endif var visitor = new AppSettingsMarkdownVisitor(); diff --git a/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs b/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs index 0f962656..ddc6e8c6 100644 --- a/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs +++ b/tests/RepoM.Plugin.SonarCloud.Tests/ActionSonarCloudV1MapperTests.cs @@ -3,7 +3,6 @@ namespace RepoM.Plugin.SonarCloud.Tests; using System; using FakeItEasy; using FluentAssertions; -using RepoM.Api.Common; using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data; using Xunit; using RepoM.Core.Plugin.Expressions; @@ -13,15 +12,13 @@ public class ActionSonarCloudV1MapperTests { private readonly ISonarCloudFavoriteService _service; private readonly IRepositoryExpressionEvaluator _expressionEvaluator; - private readonly ITranslationService _translationService; private readonly ActionSonarCloudV1Mapper _sut; public ActionSonarCloudV1MapperTests() { _service = A.Fake(); _expressionEvaluator = A.Fake(); - _translationService = A.Fake(); - _sut = new ActionSonarCloudV1Mapper(_service, _expressionEvaluator, _translationService); + _sut = new ActionSonarCloudV1Mapper(_service, _expressionEvaluator); } [Fact] @@ -30,17 +27,14 @@ public void Ctor_ShouldThrow_WhenArgumentNull() // arrange ISonarCloudFavoriteService service = A.Fake(); IRepositoryExpressionEvaluator expressionEvaluator = A.Fake(); - ITranslationService translationService = A.Fake(); // act - Func act1 = () => new ActionSonarCloudV1Mapper(service, expressionEvaluator, null!); - Func act2 = () => new ActionSonarCloudV1Mapper(service, null!, translationService); - Func act3 = () => new ActionSonarCloudV1Mapper(null!, expressionEvaluator, translationService); + Func act1 = () => new ActionSonarCloudV1Mapper(service, null!); + Func act2 = () => new ActionSonarCloudV1Mapper(null!, expressionEvaluator); // assert act1.Should().Throw(); act2.Should().Throw(); - act3.Should().Throw(); } [Fact] diff --git a/tests/RepoM.Plugin.SonarCloud.Tests/SonarCloudPackageTest.cs b/tests/RepoM.Plugin.SonarCloud.Tests/SonarCloudPackageTest.cs index 958dd28f..f12ea5aa 100644 --- a/tests/RepoM.Plugin.SonarCloud.Tests/SonarCloudPackageTest.cs +++ b/tests/RepoM.Plugin.SonarCloud.Tests/SonarCloudPackageTest.cs @@ -87,6 +87,5 @@ private void RegisterExternals(Container container) { container.RegisterInstance(_appSettingsService); container.RegisterSingleton(A.Dummy); - container.RegisterSingleton(A.Dummy); } } \ No newline at end of file