From 5e2e3560fd238ab97d04f503fbe737d1de46d335 Mon Sep 17 00:00:00 2001 From: Coen van den Munckhof Date: Tue, 15 Aug 2023 21:42:02 +0200 Subject: [PATCH] cleanup --- .../RepositorySpecificConfigurationTest.cs | 63 ++++++------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/RepositorySpecificConfigurationTest.cs b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/RepositorySpecificConfigurationTest.cs index 2c0a1732..a6f6085c 100644 --- a/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/RepositorySpecificConfigurationTest.cs +++ b/tests/RepoM.Api.Tests/IO/ModuleBasedRepositoryActionProvider/RepositorySpecificConfigurationTest.cs @@ -86,11 +86,11 @@ public RepositorySpecificConfigurationTest() new DateTimeTimeVariableProvider(dateTimeTimeVariableProviderOptions), new DateTimeDateVariableProvider(dateTimeDateVariableProviderOptions), new EmptyVariableProvider(), - new VariableProviderAdapter(new [] + new VariableProviderAdapter(new Core.Plugin.VariableProviders.IVariableProvider[] { - (RepoM.Core.Plugin.VariableProviders.IVariableProvider)new CustomEnvironmentVariableVariableProvider(), - (RepoM.Core.Plugin.VariableProviders.IVariableProvider)new RepoMVariableProvider(), - (RepoM.Core.Plugin.VariableProviders.IVariableProvider)new RepositoryVariableProvider(), + new CustomEnvironmentVariableVariableProvider(), + new RepoMVariableProvider(), + new RepositoryVariableProvider(), }), new SlashVariableProvider(), new BackslashVariableProvider(), @@ -142,17 +142,7 @@ public async Task Create_ShouldRespectMultiSelectRepos() _testFileSettings.UseFileName("RepositoryActionsMultiSelect"); var content = await EasyTestFile.LoadAsText(_testFileSettings); _fileSystem.AddFile(Path.Combine(_tempPath, RepositoryConfigurationReader.FILENAME), new MockFileData(content, Encoding.UTF8)); - var sut = new RepositorySpecificConfiguration( - _fileSystem, - _repositoryExpressionEvaluator, - _actionMapperComposition, - _translationService, - new RepositoryConfigurationReader( - _appDataPathProvider, - _fileSystem, - _yamlAppSettingsDeserializer, - _repositoryExpressionEvaluator, - NullLogger.Instance)); + RepositorySpecificConfiguration sut = CreateSut(); // act IEnumerable result = sut.CreateActions(new Repository("path1"), new Repository("path2")); @@ -168,17 +158,7 @@ public async Task Create_ShouldNotCareAboutMultiSelectRepos_WhenSingleRepo() _testFileSettings.UseFileName("RepositoryActionsMultiSelect"); var content = await EasyTestFile.LoadAsText(_testFileSettings); _fileSystem.AddFile(Path.Combine(_tempPath, RepositoryConfigurationReader.FILENAME), new MockFileData(content, Encoding.UTF8)); - var sut = new RepositorySpecificConfiguration( - _fileSystem, - _repositoryExpressionEvaluator, - _actionMapperComposition, - _translationService, - new RepositoryConfigurationReader( - _appDataPathProvider, - _fileSystem, - _yamlAppSettingsDeserializer, - _repositoryExpressionEvaluator, - NullLogger.Instance)); + RepositorySpecificConfiguration sut = CreateSut(); // act IEnumerable result = sut.CreateActions(new Repository("path1")); @@ -194,17 +174,7 @@ public async Task Create_ShouldOnlyProcessActiveItems() _testFileSettings.UseFileName("RepositoryActions1"); var content = await EasyTestFile.LoadAsText(_testFileSettings); _fileSystem.AddFile(Path.Combine(_tempPath, RepositoryConfigurationReader.FILENAME), new MockFileData(content, Encoding.UTF8)); - var sut = new RepositorySpecificConfiguration( - _fileSystem, - _repositoryExpressionEvaluator, - _actionMapperComposition, - _translationService, - new RepositoryConfigurationReader( - _appDataPathProvider, - _fileSystem, - _yamlAppSettingsDeserializer, - _repositoryExpressionEvaluator, - NullLogger.Instance)); + RepositorySpecificConfiguration sut = CreateSut(); // act IEnumerable result = sut.CreateActions(new Repository("path1")); @@ -220,7 +190,18 @@ public async Task Create_ShouldProcessSeparator1() _testFileSettings.UseFileName("RepositoryActionsWithSeparator1"); var content = await EasyTestFile.LoadAsText(_testFileSettings); _fileSystem.AddFile(Path.Combine(_tempPath, RepositoryConfigurationReader.FILENAME), new MockFileData(content, Encoding.UTF8)); - var sut = new RepositorySpecificConfiguration( + RepositorySpecificConfiguration sut = CreateSut(); + + // act + IEnumerable result = sut.CreateActions(new Repository("path1")); + + // assert + await Verifier.Verify(result, _verifySettings); + } + + private RepositorySpecificConfiguration CreateSut() + { + return new RepositorySpecificConfiguration( _fileSystem, _repositoryExpressionEvaluator, _actionMapperComposition, @@ -231,11 +212,5 @@ public async Task Create_ShouldProcessSeparator1() _yamlAppSettingsDeserializer, _repositoryExpressionEvaluator, NullLogger.Instance)); - - // act - IEnumerable result = sut.CreateActions(new Repository("path1")); - - // assert - await Verifier.Verify(result, _verifySettings); } } \ No newline at end of file