-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs…
… -> FAIL
- Loading branch information
Showing
6 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...Tests.Unit/Services/Foundations/Assemblies/AssemblyServiceTests.Exceptions.GetAssembly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<string>(actualAssemblyPath => | ||
actualAssemblyPath == someAssemblyPath))) | ||
.Throws(externalException); | ||
|
||
// when | ||
Func<Assembly> getAssemblyFunction = () => | ||
this.assemblyService.GetAssembly(someAssemblyPath); | ||
|
||
AssemblyDependencyException actualAssemblyDependencyException = | ||
Assert.Throws<AssemblyDependencyException>( | ||
getAssemblyFunction); | ||
|
||
//then | ||
actualAssemblyDependencyException.Should().BeEquivalentTo( | ||
expectedAssemblyDependencyException); | ||
|
||
this.assemblyBroker | ||
.Verify(broker => | ||
broker.GetAssembly(It.IsAny<string>()), | ||
Times.Once); | ||
|
||
this.assemblyBroker.VerifyNoOtherCalls(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...PAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyDependencyException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
{ } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
STX.SPAL.Core/Models/Services/Foundations/Assemblies/Exceptions/AssemblyLoadException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
{ } | ||
} | ||
} |