From 625ed7d03d66a101e173d445974a757cbf26f43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Wed, 22 May 2024 22:26:01 +0200 Subject: [PATCH 01/19] ShouldGetApplicationPathAssemblies -> FAIL --- .../STX.SPAL.Core.Tests.Unit.csproj | 10 +++- ...sts.Logic.GetApplicationPathsAssemblies.cs | 43 +++++++++++++++++ .../Assemblies/AssemblyServiceTests.cs | 46 +++++++++++++++++++ .../Brokers/Assemblies/IAssemblyBroker.cs | 1 + STX.SPAL.Core/STX.SPAL.Core.csproj | 24 ++++++---- .../Foundations/Assemblies/AssemblyService.cs | 24 ++++++++++ .../Assemblies/IAssemblyService.cs | 11 +++++ 7 files changed, 148 insertions(+), 11 deletions(-) create mode 100644 STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs create mode 100644 STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs create mode 100644 STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs create mode 100644 STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs diff --git a/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj b/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj index 9897380..28a1244 100644 --- a/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj +++ b/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -9,7 +9,9 @@ - + + + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -25,4 +27,8 @@ + + + + diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs new file mode 100644 index 0000000..b312953 --- /dev/null +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs @@ -0,0 +1,43 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System.Threading.Tasks; +using Moq; + +namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies +{ + public partial class AssemblyServiceTests + { + [Fact] + private async Task ShouldGetApplicationPathAssemblies() + { + // given + string[] randomApplicationPathsAssemblies = + CreateRandomPathArray(); + + string[] expectedApplicationPathsAssemblies = + randomApplicationPathsAssemblies; + + string[] returnedApplicationPathsAssemblies = + randomApplicationPathsAssemblies; + + this.assemblyBroker + .Setup(broker => + broker.GetApplicationPathsAssemblies()) + .Returns(returnedApplicationPathsAssemblies); + + // when + string[] actuaApplicationPathsAssemblies = + this.assemblyService.GetApplicationPathsAssemblies(); + + //then + this.assemblyBroker.Verify( + broker => + broker.GetApplicationPathsAssemblies(), + Times.Once); + + this.assemblyBroker.VerifyNoOtherCalls(); + } + } +} diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs new file mode 100644 index 0000000..6fe951f --- /dev/null +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System.IO; +using System.Linq; +using Moq; +using STX.SPAL.Core.Brokers.Assemblies; +using STX.SPAL.Core.Services.Foundations.Assemblies; +using Tynamix.ObjectFiller; + +namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies +{ + public partial class AssemblyServiceTests + { + private readonly Mock assemblyBroker; + private readonly IAssemblyService assemblyService; + + public AssemblyServiceTests() + { + this.assemblyBroker = new Mock(); + + this.assemblyService = + new AssemblyService(assemblyBroker.Object); + } + + private static string GetRandomString() => + new MnemonicString().GetValue(); + + private static int GetRandomNumber() => + new IntRange(min: 2, max: 10).GetValue(); + + private static string[] CreateRandomPathArray() + { + return Enumerable.Range(0, GetRandomNumber()) + .Select(i => + { + string randomPathName = GetRandomString(); + string randomFileName = GetRandomString(); + + return $"{Path.Combine(randomPathName, randomFileName)}.dll"; + }) + .ToArray(); + } + } +} diff --git a/STX.SPAL.Core/Brokers/Assemblies/IAssemblyBroker.cs b/STX.SPAL.Core/Brokers/Assemblies/IAssemblyBroker.cs index d36bfa2..6c88634 100644 --- a/STX.SPAL.Core/Brokers/Assemblies/IAssemblyBroker.cs +++ b/STX.SPAL.Core/Brokers/Assemblies/IAssemblyBroker.cs @@ -8,6 +8,7 @@ namespace STX.SPAL.Core.Brokers.Assemblies { internal partial interface IAssemblyBroker { + string[] GetApplicationPathsAssemblies(); Assembly GetAssembly(string fullPath); } } diff --git a/STX.SPAL.Core/STX.SPAL.Core.csproj b/STX.SPAL.Core/STX.SPAL.Core.csproj index 48b846e..1a6cb3d 100644 --- a/STX.SPAL.Core/STX.SPAL.Core.csproj +++ b/STX.SPAL.Core/STX.SPAL.Core.csproj @@ -1,13 +1,19 @@  - - net8.0 - disable - disable - - - - - + + net8.0 + disable + disable + + + + + + + + + + + diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs new file mode 100644 index 0000000..b8b9244 --- /dev/null +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -0,0 +1,24 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using STX.SPAL.Core.Brokers.Assemblies; + +namespace STX.SPAL.Core.Services.Foundations.Assemblies +{ + internal partial class AssemblyService : IAssemblyService + { + private readonly IAssemblyBroker assemblyBroker; + + public AssemblyService(IAssemblyBroker assemblyBroker) + { + this.assemblyBroker = assemblyBroker; + } + + public string[] GetApplicationPathsAssemblies() + { + throw new NotImplementedException(); + } + } +} diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs new file mode 100644 index 0000000..e71c140 --- /dev/null +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs @@ -0,0 +1,11 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +namespace STX.SPAL.Core.Services.Foundations.Assemblies +{ + internal interface IAssemblyService + { + string[] GetApplicationPathsAssemblies(); + } +} From 420e32b8613727265bfbcd506f76489a7520d3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Wed, 22 May 2024 22:28:48 +0200 Subject: [PATCH 02/19] ShouldGetApplicationPathAssemblies -> PASS --- .../Services/Foundations/Assemblies/AssemblyService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs index b8b9244..7ba69a1 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -16,9 +16,7 @@ public AssemblyService(IAssemblyBroker assemblyBroker) this.assemblyBroker = assemblyBroker; } - public string[] GetApplicationPathsAssemblies() - { - throw new NotImplementedException(); - } + public string[] GetApplicationPathsAssemblies() => + this.assemblyBroker.GetApplicationPathsAssemblies(); } } From 2726cad2345567e4012f51895c84426d0d07e340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 08:09:32 +0200 Subject: [PATCH 03/19] MINOR FIX: Add fluent assertion package --- STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj | 1 + ...emblyServiceTests.Logic.GetApplicationPathsAssemblies.cs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj b/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj index 28a1244..9823055 100644 --- a/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj +++ b/STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj @@ -10,6 +10,7 @@ + diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs index b312953..edb2920 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs @@ -3,6 +3,7 @@ // ---------------------------------------------------------------------------------- using System.Threading.Tasks; +using FluentAssertions; using Moq; namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies @@ -28,10 +29,13 @@ private async Task ShouldGetApplicationPathAssemblies() .Returns(returnedApplicationPathsAssemblies); // when - string[] actuaApplicationPathsAssemblies = + string[] actualApplicationPathsAssemblies = this.assemblyService.GetApplicationPathsAssemblies(); //then + actualApplicationPathsAssemblies.Should() + .BeEquivalentTo(expectedApplicationPathsAssemblies); + this.assemblyBroker.Verify( broker => broker.GetApplicationPathsAssemblies(), From 438aee8fbab65f345923f2acb3a49f70d0eb2db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 19:45:07 +0200 Subject: [PATCH 04/19] ShouldGetAssembly -> FAIL --- .../AssemblyServiceTests.Logic.GetAssembly.cs | 51 +++++++++++++++++++ .../Assemblies/AssemblyServiceTests.cs | 32 +++++++++--- .../Foundations/Assemblies/AssemblyService.cs | 4 ++ .../Assemblies/IAssemblyService.cs | 3 ++ 4 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs new file mode 100644 index 0000000..ae59470 --- /dev/null +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs @@ -0,0 +1,51 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using FluentAssertions; +using Moq; + +namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies +{ + public partial class AssemblyServiceTests + { + [Fact] + private async Task ShouldGetAssembly() + { + // given + Assembly randomAssembly = CreateRandomAssembly(); + Assembly expectedAssembly = randomAssembly; + Assembly returnedAssembly = randomAssembly; + string randomPathAssembly = GetRandomPathAssembly(); + string inputPathAssembly = randomPathAssembly; + + this.assemblyBroker + .Setup(broker => + broker.GetAssembly( + It.Is(actualPathAssembly => + actualPathAssembly == inputPathAssembly))) + .Returns(returnedAssembly); + + // when + Assembly actualAssembly = + this.assemblyService.GetAssembly(inputPathAssembly); + + //then + actualAssembly.Should().BeSameAs(expectedAssembly); + + this.assemblyBroker.Verify( + broker => + broker.GetAssembly( + It.Is(actualPathAssembly => + actualPathAssembly == inputPathAssembly)), + Times.Once); + + this.assemblyBroker.VerifyNoOtherCalls(); + } + } +} diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs index 6fe951f..5db4a5a 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -4,6 +4,8 @@ using System.IO; using System.Linq; +using System.Reflection; +using System.Reflection.Emit; using Moq; using STX.SPAL.Core.Brokers.Assemblies; using STX.SPAL.Core.Services.Foundations.Assemblies; @@ -30,17 +32,33 @@ private static string GetRandomString() => private static int GetRandomNumber() => new IntRange(min: 2, max: 10).GetValue(); + private static string GetRandomPathAssembly() + { + string randomPathName = GetRandomString(); + string randomFileName = GetRandomString(); + + return $"{Path.Combine(randomPathName, randomFileName)}.dll"; + } + private static string[] CreateRandomPathArray() { return Enumerable.Range(0, GetRandomNumber()) - .Select(i => - { - string randomPathName = GetRandomString(); - string randomFileName = GetRandomString(); - - return $"{Path.Combine(randomPathName, randomFileName)}.dll"; - }) + .Select(i => GetRandomPathAssembly()) .ToArray(); } + + private static Assembly CreateRandomAssembly() + { + string randomAssemblyName = GetRandomString(); + var assemblyName = + new AssemblyName("randomAssemblyName"); + + AssemblyBuilder assemblyBuilder = + AssemblyBuilder.DefineDynamicAssembly( + assemblyName, + AssemblyBuilderAccess.Run); + + return assemblyBuilder; + } } } diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs index 7ba69a1..210804b 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -3,6 +3,7 @@ // ---------------------------------------------------------------------------------- using System; +using System.Reflection; using STX.SPAL.Core.Brokers.Assemblies; namespace STX.SPAL.Core.Services.Foundations.Assemblies @@ -18,5 +19,8 @@ public AssemblyService(IAssemblyBroker assemblyBroker) public string[] GetApplicationPathsAssemblies() => this.assemblyBroker.GetApplicationPathsAssemblies(); + + public Assembly GetAssembly(string fullPath) => + throw new NotImplementedException(); } } diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs index e71c140..b68a93c 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/IAssemblyService.cs @@ -2,10 +2,13 @@ // Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- +using System.Reflection; + namespace STX.SPAL.Core.Services.Foundations.Assemblies { internal interface IAssemblyService { string[] GetApplicationPathsAssemblies(); + Assembly GetAssembly(string fullPath); } } From 21dd7b8455f6c0cadcb73b80ec9cb53944d365ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 19:45:43 +0200 Subject: [PATCH 05/19] CODE RUB: Remove unused usings --- .../Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs index ae59470..fedf8fd 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs @@ -2,10 +2,7 @@ // Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- -using System; using System.Reflection; -using System.Reflection.Emit; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using FluentAssertions; using Moq; From abb34d2e13543b3da3971a0139cf093d58f223a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 19:49:45 +0200 Subject: [PATCH 06/19] ShouldGetAssembly -> PASS --- .../Services/Foundations/Assemblies/AssemblyService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs index 210804b..21a8450 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -2,7 +2,6 @@ // Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- -using System; using System.Reflection; using STX.SPAL.Core.Brokers.Assemblies; @@ -21,6 +20,6 @@ public string[] GetApplicationPathsAssemblies() => this.assemblyBroker.GetApplicationPathsAssemblies(); public Assembly GetAssembly(string fullPath) => - throw new NotImplementedException(); + this.assemblyBroker.GetAssembly(fullPath); } } From 313ab5c0942d76585bac63c2fa88875bf4f02277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 20:09:04 +0200 Subject: [PATCH 07/19] ShouldThrowExceptionIfInvalidAssemblyPath -> FAIL --- ...blyServiceTests.Validations.GetAssembly.cs | 43 +++++++++++++++++++ .../InvalidAssemblyPathException.cs | 14 ++++++ STX.SPAL.Core/STX.SPAL.Core.csproj | 4 ++ 3 files changed, 61 insertions(+) create mode 100644 STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/InvalidAssemblyPathException.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs new file mode 100644 index 0000000..3b1e0fc --- /dev/null +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs @@ -0,0 +1,43 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using Moq; +using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; + +namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies +{ + public partial class AssemblyServiceTests + { + [Theory] + [InlineData(null)] + [InlineData("")] + [InlineData(" ")] + public void ShouldThrowExceptionIfInvalidAssemblyPath(string inputPathAssembly) + { + // given + Assembly randomAssembly = CreateRandomAssembly(); + Assembly expectedAssembly = randomAssembly; + Assembly returnedAssembly = randomAssembly; + string randomPathAssembly = GetRandomPathAssembly(); + + this.assemblyBroker + .Setup(broker => + broker.GetAssembly( + It.Is(actualPathAssembly => + actualPathAssembly == inputPathAssembly))); + + // when + Func getAssemblyFunction = () => + this.assemblyService.GetAssembly(inputPathAssembly); + + Assert.Throws( + getAssemblyFunction); + + //then + this.assemblyBroker.VerifyNoOtherCalls(); + } + } +} diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/InvalidAssemblyPathException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/InvalidAssemblyPathException.cs new file mode 100644 index 0000000..ae311eb --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/InvalidAssemblyPathException.cs @@ -0,0 +1,14 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class InvalidAssemblyPathException : Xeption + { + public InvalidAssemblyPathException(string message) : base(message) + { } + } +} diff --git a/STX.SPAL.Core/STX.SPAL.Core.csproj b/STX.SPAL.Core/STX.SPAL.Core.csproj index 1a6cb3d..849e8b3 100644 --- a/STX.SPAL.Core/STX.SPAL.Core.csproj +++ b/STX.SPAL.Core/STX.SPAL.Core.csproj @@ -16,4 +16,8 @@ + + + + From 2a9c54b1e501b2310f3413f4b88ac6955a5f14ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 20:45:11 +0200 Subject: [PATCH 08/19] ShouldThrowValidationExceptionIfInvalidAssemblyPath -> PASS --- ...blyServiceTests.Validations.GetAssembly.cs | 41 ++++++++++++--- .../Exceptions/AssemblyValidationException.cs | 15 ++++++ .../Assemblies/AssemblyService.Exceptions.cs | 38 ++++++++++++++ .../Assemblies/AssemblyService.Validations.cs | 52 +++++++++++++++++++ .../Foundations/Assemblies/AssemblyService.cs | 9 +++- 5 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationException.cs create mode 100644 STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs create mode 100644 STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Validations.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs index 3b1e0fc..cb48799 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs @@ -4,6 +4,7 @@ using System; using System.Reflection; +using FluentAssertions; using Moq; using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; @@ -12,10 +13,13 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies public partial class AssemblyServiceTests { [Theory] - [InlineData(null)] - [InlineData("")] - [InlineData(" ")] - public void ShouldThrowExceptionIfInvalidAssemblyPath(string inputPathAssembly) + [InlineData(null, "Value is required")] + [InlineData("", "Value is required")] + [InlineData(" ", "Value is required")] + [InlineData("file", "Value is not a valid assembly path")] + public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( + string inputPathAssembly, + string exceptionMessage) { // given Assembly randomAssembly = CreateRandomAssembly(); @@ -23,20 +27,43 @@ public void ShouldThrowExceptionIfInvalidAssemblyPath(string inputPathAssembly) Assembly returnedAssembly = randomAssembly; string randomPathAssembly = GetRandomPathAssembly(); + var invalidAssemblyPathException = + new InvalidAssemblyPathException( + message: "Invalid assembly path error occurred, fix errors and try again."); + + invalidAssemblyPathException.AddData( + key: "assemblyPath", + values: exceptionMessage + ); + + var expectedAssemblyValidationException = + new AssemblyValidationException( + message: "Assembly validation error occurred, fix errors and try again.", + innerException: invalidAssemblyPathException); + this.assemblyBroker .Setup(broker => broker.GetAssembly( It.Is(actualPathAssembly => - actualPathAssembly == inputPathAssembly))); + actualPathAssembly == inputPathAssembly))); // when Func getAssemblyFunction = () => this.assemblyService.GetAssembly(inputPathAssembly); - Assert.Throws( - getAssemblyFunction); + AssemblyValidationException actualAssemblyValidationException = + Assert.Throws( + getAssemblyFunction); //then + actualAssemblyValidationException.Should().BeEquivalentTo( + expectedAssemblyValidationException); + + this.assemblyBroker + .Verify(broker => + broker.GetAssembly(It.IsAny()), + Times.Never); + this.assemblyBroker.VerifyNoOtherCalls(); } } diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationException.cs new file mode 100644 index 0000000..139b935 --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationException.cs @@ -0,0 +1,15 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + public class AssemblyValidationException : Xeption + { + public AssemblyValidationException(string message, Xeption innerException) + : base(message, innerException) + { } + } +} \ No newline at end of file diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs new file mode 100644 index 0000000..3774315 --- /dev/null +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -0,0 +1,38 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System.Reflection; +using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; +using Xeptions; + +namespace STX.SPAL.Core.Services.Foundations.Assemblies +{ + internal partial class AssemblyService + { + private delegate Assembly ReturningAssemblyFunction(); + + private static Assembly TryCatch( + ReturningAssemblyFunction returningAssemblyFunction) + { + try + { + return returningAssemblyFunction(); + } + + catch (InvalidAssemblyPathException invalidAssemblyPathException) + { + throw CreateAssemblyValidationException( + invalidAssemblyPathException); + } + } + + private static AssemblyValidationException CreateAssemblyValidationException( + Xeption exception) + { + return new AssemblyValidationException( + message: "Assembly validation error occurred, fix errors and try again.", + innerException: exception); + } + } +} diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Validations.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Validations.cs new file mode 100644 index 0000000..a5cbfa1 --- /dev/null +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Validations.cs @@ -0,0 +1,52 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; + +namespace STX.SPAL.Core.Services.Foundations.Assemblies +{ + internal partial class AssemblyService + { + private static dynamic IsInvalid(string text) => new + { + Condition = string.IsNullOrWhiteSpace(text), + Message = "Value is required" + }; + + private static dynamic IsInvalidAssemblyPath(string assemblyPath) => + new + { + Condition = !assemblyPath.EndsWith(".dll"), + Message = "Value is not a valid assembly path" + }; + + private static void Validate(params (dynamic Rule, string Parameter)[] validations) + { + var invalidAssemblyPathException = + new InvalidAssemblyPathException( + message: "Invalid assembly path error occurred, fix errors and try again."); + + foreach ((dynamic rule, string parameter) in validations) + { + if (rule.Condition) + { + invalidAssemblyPathException.UpsertDataList( + key: parameter, + value: rule.Message); + } + } + + invalidAssemblyPathException.ThrowIfContainsErrors(); + } + + private static void ValidateAssemblyPath(string assemblyPath) + { + Validate( + (Rule: IsInvalid(assemblyPath), Parameter: nameof(assemblyPath))); + + Validate( + (Rule: IsInvalidAssemblyPath(assemblyPath), Parameter: nameof(assemblyPath))); + } + } +} diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs index 21a8450..532aad1 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -19,7 +19,12 @@ public AssemblyService(IAssemblyBroker assemblyBroker) public string[] GetApplicationPathsAssemblies() => this.assemblyBroker.GetApplicationPathsAssemblies(); - public Assembly GetAssembly(string fullPath) => - this.assemblyBroker.GetAssembly(fullPath); + public Assembly GetAssembly(string assemblyPath) => + TryCatch(() => + { + ValidateAssemblyPath(assemblyPath); + + return this.assemblyBroker.GetAssembly(assemblyPath); + }); } } From 6009806cdbcd3e5f1045eb05ffd2aab9741af3df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Thu, 23 May 2024 22:22:47 +0200 Subject: [PATCH 09/19] CODE RUB: Fix naming variables --- .../AssemblyServiceTests.Validations.GetAssembly.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs index cb48799..885e35c 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs @@ -18,7 +18,7 @@ public partial class AssemblyServiceTests [InlineData(" ", "Value is required")] [InlineData("file", "Value is not a valid assembly path")] public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( - string inputPathAssembly, + string assemblyPath, string exceptionMessage) { // given @@ -26,13 +26,14 @@ public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( Assembly expectedAssembly = randomAssembly; Assembly returnedAssembly = randomAssembly; string randomPathAssembly = GetRandomPathAssembly(); + string inputAssemblyPath = assemblyPath; var invalidAssemblyPathException = new InvalidAssemblyPathException( message: "Invalid assembly path error occurred, fix errors and try again."); invalidAssemblyPathException.AddData( - key: "assemblyPath", + key: nameof(assemblyPath), values: exceptionMessage ); @@ -44,12 +45,12 @@ public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( this.assemblyBroker .Setup(broker => broker.GetAssembly( - It.Is(actualPathAssembly => - actualPathAssembly == inputPathAssembly))); + It.Is(actualAssemblyPath => + actualAssemblyPath == inputAssemblyPath))); // when Func getAssemblyFunction = () => - this.assemblyService.GetAssembly(inputPathAssembly); + this.assemblyService.GetAssembly(inputAssemblyPath); AssemblyValidationException actualAssemblyValidationException = Assert.Throws( From 7c5db2d819f26eb175cf35882fb03fc75e5c2b9f Mon Sep 17 00:00:00 2001 From: Christo du Toit Date: Thu, 23 May 2024 22:02:35 +0100 Subject: [PATCH 10/19] CODE RUB: Code cleanup --- ...blyServiceTests.Logic.GetApplicationPathsAssemblies.cs | 3 +-- .../Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs | 4 ++-- .../Foundations/Assemblies/AssemblyService.Exceptions.cs | 6 ++---- .../Services/Foundations/Assemblies/AssemblyService.cs | 8 ++++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs index edb2920..b4c1374 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs @@ -24,8 +24,7 @@ private async Task ShouldGetApplicationPathAssemblies() randomApplicationPathsAssemblies; this.assemblyBroker - .Setup(broker => - broker.GetApplicationPathsAssemblies()) + .Setup(broker => broker.GetApplicationPathsAssemblies()) .Returns(returnedApplicationPathsAssemblies); // when diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs index fedf8fd..0abdea0 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs @@ -25,7 +25,7 @@ private async Task ShouldGetAssembly() .Setup(broker => broker.GetAssembly( It.Is(actualPathAssembly => - actualPathAssembly == inputPathAssembly))) + actualPathAssembly == inputPathAssembly))) .Returns(returnedAssembly); // when @@ -40,7 +40,7 @@ private async Task ShouldGetAssembly() broker.GetAssembly( It.Is(actualPathAssembly => actualPathAssembly == inputPathAssembly)), - Times.Once); + Times.Once); this.assemblyBroker.VerifyNoOtherCalls(); } diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs index 3774315..adc5f51 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -12,8 +12,7 @@ internal partial class AssemblyService { private delegate Assembly ReturningAssemblyFunction(); - private static Assembly TryCatch( - ReturningAssemblyFunction returningAssemblyFunction) + private static Assembly TryCatch(ReturningAssemblyFunction returningAssemblyFunction) { try { @@ -27,8 +26,7 @@ private static Assembly TryCatch( } } - private static AssemblyValidationException CreateAssemblyValidationException( - Xeption exception) + private static AssemblyValidationException CreateAssemblyValidationException(Xeption exception) { return new AssemblyValidationException( message: "Assembly validation error occurred, fix errors and try again.", diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs index 532aad1..27e9895 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.cs @@ -21,10 +21,10 @@ public string[] GetApplicationPathsAssemblies() => public Assembly GetAssembly(string assemblyPath) => TryCatch(() => - { - ValidateAssemblyPath(assemblyPath); + { + ValidateAssemblyPath(assemblyPath); - return this.assemblyBroker.GetAssembly(assemblyPath); - }); + return this.assemblyBroker.GetAssembly(assemblyPath); + }); } } From ec0d6aff306f42fb37072712d6a3c03dedaabad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 11:04:39 +0200 Subject: [PATCH 11/19] ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs -> FAIL --- ...mblyServiceTests.Exceptions.GetAssembly.cs | 60 +++++++++++++++++++ .../AssemblyServiceTests.Logic.GetAssembly.cs | 2 +- ...blyServiceTests.Validations.GetAssembly.cs | 2 +- .../Assemblies/AssemblyServiceTests.cs | 21 ++++++- .../Exceptions/AssemblyDependencyException.cs | 15 +++++ .../Exceptions/AssemblyLoadException.cs | 16 +++++ 6 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyDependencyException.cs create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyLoadException.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs new file mode 100644 index 0000000..80f2c4c --- /dev/null +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs @@ -0,0 +1,60 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using FluentAssertions; +using Moq; +using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; + +namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies +{ + public partial class AssemblyServiceTests + { + [Theory] + [MemberData(nameof(AssemblyLoadExceptions))] + public void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( + Exception externalException) + { + // given + string someAssemblyPath = CreateRandomPathAssembly(); + + var assemblyLoadException = + new AssemblyLoadException( + message: "Assembly load error occurred, contact support.", + innerException: externalException); + + var expectedAssemblyDependencyException = + new AssemblyDependencyException( + message: "Assembly dependency error occurred, contact support.", + innerException: assemblyLoadException); + + this.assemblyBroker + .Setup(broker => + broker.GetAssembly( + It.Is(actualAssemblyPath => + actualAssemblyPath == someAssemblyPath))) + .Throws(externalException); + + // when + Func getAssemblyFunction = () => + this.assemblyService.GetAssembly(someAssemblyPath); + + AssemblyDependencyException actualAssemblyDependencyException = + Assert.Throws( + getAssemblyFunction); + + //then + actualAssemblyDependencyException.Should().BeEquivalentTo( + expectedAssemblyDependencyException); + + this.assemblyBroker + .Verify(broker => + broker.GetAssembly(It.IsAny()), + Times.Once); + + this.assemblyBroker.VerifyNoOtherCalls(); + } + } +} diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs index 0abdea0..9e631fa 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs @@ -18,7 +18,7 @@ private async Task ShouldGetAssembly() Assembly randomAssembly = CreateRandomAssembly(); Assembly expectedAssembly = randomAssembly; Assembly returnedAssembly = randomAssembly; - string randomPathAssembly = GetRandomPathAssembly(); + string randomPathAssembly = CreateRandomPathAssembly(); string inputPathAssembly = randomPathAssembly; this.assemblyBroker diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs index 885e35c..2179478 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs @@ -25,7 +25,7 @@ public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( Assembly randomAssembly = CreateRandomAssembly(); Assembly expectedAssembly = randomAssembly; Assembly returnedAssembly = randomAssembly; - string randomPathAssembly = GetRandomPathAssembly(); + string randomPathAssembly = CreateRandomPathAssembly(); string inputAssemblyPath = assemblyPath; var invalidAssemblyPathException = diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs index 5db4a5a..b850b1f 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -2,10 +2,12 @@ // Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- +using System; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; +using System.Security; using Moq; using STX.SPAL.Core.Brokers.Assemblies; using STX.SPAL.Core.Services.Foundations.Assemblies; @@ -32,7 +34,7 @@ private static string GetRandomString() => private static int GetRandomNumber() => new IntRange(min: 2, max: 10).GetValue(); - private static string GetRandomPathAssembly() + private static string CreateRandomPathAssembly() { string randomPathName = GetRandomString(); string randomFileName = GetRandomString(); @@ -43,7 +45,7 @@ private static string GetRandomPathAssembly() private static string[] CreateRandomPathArray() { return Enumerable.Range(0, GetRandomNumber()) - .Select(i => GetRandomPathAssembly()) + .Select(i => CreateRandomPathAssembly()) .ToArray(); } @@ -60,5 +62,20 @@ private static Assembly CreateRandomAssembly() return assemblyBuilder; } + + public static TheoryData AssemblyLoadExceptions() + { + return new TheoryData + { + new SecurityException(), + new FileLoadException(), + new FileNotFoundException(), + new BadImageFormatException(), + new InvalidOperationException(), + new NotSupportedException(), + new IOException(), + new UnauthorizedAccessException() + }; + } } } diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyDependencyException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyDependencyException.cs new file mode 100644 index 0000000..c142ad6 --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyDependencyException.cs @@ -0,0 +1,15 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class AssemblyDependencyException : Xeption + { + public AssemblyDependencyException(string message, Xeption innerException) + : base(message, innerException) + { } + } +} diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyLoadException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyLoadException.cs new file mode 100644 index 0000000..29800ad --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyLoadException.cs @@ -0,0 +1,16 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class AssemblyLoadException : Xeption + { + public AssemblyLoadException(string message, Exception innerException) + : base(message: message, innerException) + { } + } +} From 0d909c19c971b6139270e924208356ce6aab6476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:38:07 +0200 Subject: [PATCH 12/19] ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs -> FAIL --- ...mblyServiceTests.Exceptions.GetAssembly.cs | 47 ++++++++++++++++++- .../Assemblies/AssemblyServiceTests.cs | 12 ++++- .../AssemblyValidationDependencyException.cs | 15 ++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationDependencyException.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs index 80f2c4c..28a47c0 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs @@ -13,7 +13,7 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies public partial class AssemblyServiceTests { [Theory] - [MemberData(nameof(AssemblyLoadExceptions))] + [MemberData(nameof(AssemblyLoadDependencyExceptions))] public void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( Exception externalException) { @@ -56,5 +56,50 @@ public void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccur this.assemblyBroker.VerifyNoOtherCalls(); } + + [Theory] + [MemberData(nameof(AssemblyLoadValidationDependencyExceptions))] + public void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( + Exception externalException) + { + // given + string someAssemblyPath = CreateRandomPathAssembly(); + + var assemblyLoadException = + new AssemblyLoadException( + message: "Assembly load error occurred, contact support.", + innerException: externalException); + + var expectedAssemblyValidationDependencyException = + new AssemblyValidationDependencyException( + message: "Assembly dependency error occurred, contact support.", + innerException: assemblyLoadException); + + this.assemblyBroker + .Setup(broker => + broker.GetAssembly( + It.Is(actualAssemblyPath => + actualAssemblyPath == someAssemblyPath))) + .Throws(externalException); + + // when + Func getAssemblyFunction = () => + this.assemblyService.GetAssembly(someAssemblyPath); + + AssemblyValidationDependencyException actualAssemblyValidationDependencyException = + Assert.Throws( + getAssemblyFunction); + + //then + actualAssemblyValidationDependencyException.Should().BeEquivalentTo( + expectedAssemblyValidationDependencyException); + + this.assemblyBroker + .Verify(broker => + broker.GetAssembly(It.IsAny()), + Times.Once); + + this.assemblyBroker.VerifyNoOtherCalls(); + } } } diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs index b850b1f..6af69a5 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -63,7 +63,7 @@ private static Assembly CreateRandomAssembly() return assemblyBuilder; } - public static TheoryData AssemblyLoadExceptions() + public static TheoryData AssemblyLoadDependencyExceptions() { return new TheoryData { @@ -77,5 +77,15 @@ public static TheoryData AssemblyLoadExceptions() new UnauthorizedAccessException() }; } + + public static TheoryData AssemblyLoadValidationDependencyExceptions() + { + return new TheoryData + { + new ArgumentException(), + new ArgumentNullException(), + new PathTooLongException(), + }; + } } } diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationDependencyException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationDependencyException.cs new file mode 100644 index 0000000..a58ab43 --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyValidationDependencyException.cs @@ -0,0 +1,15 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class AssemblyValidationDependencyException : Xeption + { + public AssemblyValidationDependencyException(string message, Xeption innerException) + : base(message, innerException) + { } + } +} From 3d64b9707319c628665fd79e0494c5a3e7bf0c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:40:55 +0200 Subject: [PATCH 13/19] ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs -> FAIL --- .../Assemblies/AssemblyServiceTests.cs | 4 +- .../Assemblies/AssemblyService.Exceptions.cs | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs index 6af69a5..1c135c1 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -82,9 +82,7 @@ public static TheoryData AssemblyLoadValidationDependencyExceptions() { return new TheoryData { - new ArgumentException(), - new ArgumentNullException(), - new PathTooLongException(), + new ArgumentException() }; } } diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs index adc5f51..a1cb38e 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -2,9 +2,13 @@ // Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers // ---------------------------------------------------------------------------------- +using System.IO; +using System; using System.Reflection; +using System.Security; using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions; using Xeptions; +using System.Runtime.InteropServices; namespace STX.SPAL.Core.Services.Foundations.Assemblies { @@ -24,6 +28,59 @@ private static Assembly TryCatch(ReturningAssemblyFunction returningAssemblyFunc throw CreateAssemblyValidationException( invalidAssemblyPathException); } + + catch (SecurityException securityException) + { + throw CreateAssemblyDependencyException( + securityException); + } + + catch (FileLoadException fileLoadException) + { + throw CreateAssemblyDependencyException( + fileLoadException); + } + + catch (FileNotFoundException fileNotFoundException) + { + throw CreateAssemblyDependencyException( + fileNotFoundException); + } + + catch (BadImageFormatException badImageFormatException) + { + throw CreateAssemblyDependencyException( + badImageFormatException); + } + + catch (InvalidOperationException invalidOperationException) + { + throw CreateAssemblyDependencyException( + invalidOperationException); + } + + catch (NotSupportedException notSupportedException) + { + throw CreateAssemblyDependencyException( + notSupportedException); + } + + catch (IOException iOException) + { + throw CreateAssemblyDependencyException(iOException); + } + + catch (UnauthorizedAccessException unauthorizedAccessException) + { + throw CreateAssemblyDependencyException( + unauthorizedAccessException); + } + + catch (ArgumentException argumentException) + { + throw CreateAssemblyDependencyException( + argumentException); + } } private static AssemblyValidationException CreateAssemblyValidationException(Xeption exception) @@ -32,5 +89,29 @@ private static AssemblyValidationException CreateAssemblyValidationException(Xep message: "Assembly validation error occurred, fix errors and try again.", innerException: exception); } + + private static AssemblyDependencyException CreateAssemblyDependencyException(Exception exception) + { + var assemblyLoadException = + new AssemblyLoadException( + message: "Assembly load error occurred, contact support.", + innerException: exception); + + return new AssemblyDependencyException( + message: "Assembly dependency error occurred, contact support.", + innerException: assemblyLoadException); + } + + private static AssemblyValidationDependencyException CreateAssemblyValidationDependencyException(Exception exception) + { + var assemblyLoadException = + new AssemblyLoadException( + message: "Assembly load error occurred, contact support.", + innerException: exception); + + return new AssemblyValidationDependencyException( + message: "Assembly validation dependency error occurred, contact support.", + innerException: assemblyLoadException); + } } } From 6721c4968fc17c2facabf0eec6be5faa3dc32734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:41:52 +0200 Subject: [PATCH 14/19] ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs -> FAIL --- .../Assemblies/AssemblyService.Exceptions.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs index a1cb38e..bff70f7 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -75,12 +75,6 @@ private static Assembly TryCatch(ReturningAssemblyFunction returningAssemblyFunc throw CreateAssemblyDependencyException( unauthorizedAccessException); } - - catch (ArgumentException argumentException) - { - throw CreateAssemblyDependencyException( - argumentException); - } } private static AssemblyValidationException CreateAssemblyValidationException(Xeption exception) @@ -101,17 +95,5 @@ private static AssemblyDependencyException CreateAssemblyDependencyException(Exc message: "Assembly dependency error occurred, contact support.", innerException: assemblyLoadException); } - - private static AssemblyValidationDependencyException CreateAssemblyValidationDependencyException(Exception exception) - { - var assemblyLoadException = - new AssemblyLoadException( - message: "Assembly load error occurred, contact support.", - innerException: exception); - - return new AssemblyValidationDependencyException( - message: "Assembly validation dependency error occurred, contact support.", - innerException: assemblyLoadException); - } } } From b75ecc4ca6866d7cedd0acb7812afaa5967da417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:43:26 +0200 Subject: [PATCH 15/19] ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs -> PASS --- ...emblyServiceTests.Exceptions.GetAssembly.cs | 2 +- .../Assemblies/AssemblyService.Exceptions.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs index 28a47c0..3f27c1c 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs @@ -72,7 +72,7 @@ public void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExce var expectedAssemblyValidationDependencyException = new AssemblyValidationDependencyException( - message: "Assembly dependency error occurred, contact support.", + message: "Assembly validation dependency error occurred, contact support.", innerException: assemblyLoadException); this.assemblyBroker diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs index bff70f7..f87d487 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -75,6 +75,12 @@ private static Assembly TryCatch(ReturningAssemblyFunction returningAssemblyFunc throw CreateAssemblyDependencyException( unauthorizedAccessException); } + + catch (ArgumentException argumentException) + { + throw CreateAssemblyValidationDependencyException( + argumentException); + } } private static AssemblyValidationException CreateAssemblyValidationException(Xeption exception) @@ -95,5 +101,17 @@ private static AssemblyDependencyException CreateAssemblyDependencyException(Exc message: "Assembly dependency error occurred, contact support.", innerException: assemblyLoadException); } + + private static AssemblyValidationDependencyException CreateAssemblyValidationDependencyException(Exception exception) + { + var assemblyLoadException = + new AssemblyLoadException( + message: "Assembly load error occurred, contact support.", + innerException: exception); + + return new AssemblyValidationDependencyException( + message: "Assembly validation dependency error occurred, contact support.", + innerException: assemblyLoadException); + } } } From 5953b8a44b774b0036c09322268247e9f70fb10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:50:28 +0200 Subject: [PATCH 16/19] ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs -> FAIL --- ...mblyServiceTests.Exceptions.GetAssembly.cs | 45 +++++++++++++++++++ .../Assemblies/AssemblyServiceTests.cs | 8 ++++ .../Exceptions/AssemblyServiceException.cs | 15 +++++++ .../FailedAssemblyServiceException.cs | 16 +++++++ 4 files changed, 84 insertions(+) create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyServiceException.cs create mode 100644 STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/FailedAssemblyServiceException.cs diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs index 3f27c1c..c787565 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs @@ -101,5 +101,50 @@ public void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExce this.assemblyBroker.VerifyNoOtherCalls(); } + + [Theory] + [MemberData(nameof(AssemblyLoadServiceExceptions))] + public void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs( + Exception externalException) + { + // given + string someAssemblyPath = CreateRandomPathAssembly(); + + var assemblyLoadException = + new FailedAssemblyServiceException( + message: "Failed service error occurred, contact support.", + innerException: externalException); + + var expectedAssemblyServiceException = + new AssemblyServiceException( + message: "Assembly service error occurred, contact support.", + innerException: assemblyLoadException); + + this.assemblyBroker + .Setup(broker => + broker.GetAssembly( + It.Is(actualAssemblyPath => + actualAssemblyPath == someAssemblyPath))) + .Throws(externalException); + + // when + Func getAssemblyFunction = () => + this.assemblyService.GetAssembly(someAssemblyPath); + + AssemblyServiceException actualAssemblyServiceException = + Assert.Throws( + getAssemblyFunction); + + //then + actualAssemblyServiceException.Should().BeEquivalentTo( + expectedAssemblyServiceException); + + this.assemblyBroker + .Verify(broker => + broker.GetAssembly(It.IsAny()), + Times.Once); + + this.assemblyBroker.VerifyNoOtherCalls(); + } } } diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs index 1c135c1..858aa30 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.cs @@ -85,5 +85,13 @@ public static TheoryData AssemblyLoadValidationDependencyExceptions() new ArgumentException() }; } + + public static TheoryData AssemblyLoadServiceExceptions() + { + return new TheoryData + { + new Exception() + }; + } } } diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyServiceException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyServiceException.cs new file mode 100644 index 0000000..df0d174 --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyServiceException.cs @@ -0,0 +1,15 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class AssemblyServiceException : Xeption + { + public AssemblyServiceException(string message, Xeption innerException) + : base(message, innerException) + { } + } +} diff --git a/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/FailedAssemblyServiceException.cs b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/FailedAssemblyServiceException.cs new file mode 100644 index 0000000..557b9dc --- /dev/null +++ b/STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/FailedAssemblyServiceException.cs @@ -0,0 +1,16 @@ +// ---------------------------------------------------------------------------------- +// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers +// ---------------------------------------------------------------------------------- + +using System; +using Xeptions; + +namespace STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions +{ + internal class FailedAssemblyServiceException : Xeption + { + public FailedAssemblyServiceException(string message, Exception innerException) + : base(message, innerException) + { } + } +} From b452d36140bc6fa6818ac23a2dae70b484ee3554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sat, 25 May 2024 19:55:10 +0200 Subject: [PATCH 17/19] ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs -> PASS --- .../Assemblies/AssemblyService.Exceptions.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs index f87d487..c43e5fa 100644 --- a/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs +++ b/STX.SPAL.Core/Services/Foundations/Assemblies/AssemblyService.Exceptions.cs @@ -81,6 +81,12 @@ private static Assembly TryCatch(ReturningAssemblyFunction returningAssemblyFunc throw CreateAssemblyValidationDependencyException( argumentException); } + + catch (Exception exception) + { + throw CreateAssemblyServiceException( + exception); + } } private static AssemblyValidationException CreateAssemblyValidationException(Xeption exception) @@ -113,5 +119,17 @@ private static AssemblyValidationDependencyException CreateAssemblyValidationDep message: "Assembly validation dependency error occurred, contact support.", innerException: assemblyLoadException); } + + private static AssemblyServiceException CreateAssemblyServiceException(Exception exception) + { + var failedAssemblyServiceException = + new FailedAssemblyServiceException( + message: "Failed service error occurred, contact support.", + innerException: exception); + + return new AssemblyServiceException( + message: "Assembly service error occurred, contact support.", + innerException: failedAssemblyServiceException); + } } } From 0ec015d9088a4a4c48ddcae9b9ee3f294566de80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Sun, 26 May 2024 11:57:28 +0200 Subject: [PATCH 18/19] CODE RUB: Fix returning void instead Task --- .../AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs | 2 +- .../Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs index b4c1374..4ed031b 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetApplicationPathsAssemblies.cs @@ -11,7 +11,7 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies public partial class AssemblyServiceTests { [Fact] - private async Task ShouldGetApplicationPathAssemblies() + private void ShouldGetApplicationPathAssemblies() { // given string[] randomApplicationPathsAssemblies = diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs index 9e631fa..f564a14 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Logic.GetAssembly.cs @@ -12,7 +12,7 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies public partial class AssemblyServiceTests { [Fact] - private async Task ShouldGetAssembly() + private void ShouldGetAssembly() { // given Assembly randomAssembly = CreateRandomAssembly(); From 7e2da0778ba02bf5822443ba955d912d2987c8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20LB?= Date: Mon, 27 May 2024 08:29:16 +0200 Subject: [PATCH 19/19] CODE RUB: Change all tests methods to private --- .../AssemblyServiceTests.Exceptions.GetAssembly.cs | 6 +++--- .../AssemblyServiceTests.Validations.GetAssembly.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs index c787565..95e8edc 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs @@ -14,7 +14,7 @@ public partial class AssemblyServiceTests { [Theory] [MemberData(nameof(AssemblyLoadDependencyExceptions))] - public void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( + private void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( Exception externalException) { // given @@ -59,7 +59,7 @@ public void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccur [Theory] [MemberData(nameof(AssemblyLoadValidationDependencyExceptions))] - public void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( + private void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs( Exception externalException) { // given @@ -104,7 +104,7 @@ public void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExce [Theory] [MemberData(nameof(AssemblyLoadServiceExceptions))] - public void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs( + private void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs( Exception externalException) { // given diff --git a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs index 2179478..d410865 100644 --- a/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs +++ b/STX.SPAL.Core.Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Validations.GetAssembly.cs @@ -17,7 +17,7 @@ public partial class AssemblyServiceTests [InlineData("", "Value is required")] [InlineData(" ", "Value is required")] [InlineData("file", "Value is not a valid assembly path")] - public void ShouldThrowValidationExceptionIfInvalidAssemblyPath( + private void ShouldThrowValidationExceptionIfInvalidAssemblyPath( string assemblyPath, string exceptionMessage) {