Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEDIUM CODE RUB: Upgrade to The Standard 2.10.3 #33

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions STX.SPAL.Core.Tests.Unit/STX.SPAL.Core.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Nullable>disable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<NoWarn>CS1998</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Reflection;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions;
Expand All @@ -14,7 +15,7 @@ public partial class AssemblyServiceTests
{
[Theory]
[MemberData(nameof(AssemblyLoadDependencyExceptions))]
private void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs(
private async Task ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccursAsync(
Exception externalException)
{
// given
Expand All @@ -32,17 +33,19 @@ private void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccu

this.assemblyBroker
.Setup(broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualAssemblyPath =>
actualAssemblyPath == someAssemblyPath)))
.Throws(externalException);
.ThrowsAsync(externalException);

// when
Func<Assembly> getAssemblyFunction = () =>
this.assemblyService.GetAssembly(someAssemblyPath);
Func<Task<Assembly>> getAssemblyFunction =
() =>
this.assemblyService.GetAssemblyAsync(someAssemblyPath)
.AsTask();

AssemblyDependencyException actualAssemblyDependencyException =
Assert.Throws<AssemblyDependencyException>(
await Assert.ThrowsAsync<AssemblyDependencyException>(
getAssemblyFunction);

// then
Expand All @@ -51,15 +54,15 @@ private void ShouldThrowDependencyExceptionOnLoadAssemblyIfExternalExceptionOccu

this.assemblyBroker
.Verify(broker =>
broker.GetAssembly(It.IsAny<string>()),
broker.GetAssemblyAsync(It.IsAny<string>()),
Times.Once);

this.assemblyBroker.VerifyNoOtherCalls();
}

[Theory]
[MemberData(nameof(AssemblyLoadValidationDependencyExceptions))]
private void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccurs(
private async Task ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExceptionOccursAsync(
Exception externalException)
{
// given
Expand All @@ -77,17 +80,18 @@ private void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExc

this.assemblyBroker
.Setup(broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualAssemblyPath =>
actualAssemblyPath == someAssemblyPath)))
.Throws(externalException);

// when
Func<Assembly> getAssemblyFunction = () =>
this.assemblyService.GetAssembly(someAssemblyPath);
Func<Task<Assembly>> getAssemblyFunction = () =>
this.assemblyService.GetAssemblyAsync(someAssemblyPath)
.AsTask();

AssemblyValidationDependencyException actualAssemblyValidationDependencyException =
Assert.Throws<AssemblyValidationDependencyException>(
await Assert.ThrowsAsync<AssemblyValidationDependencyException>(
getAssemblyFunction);

// then
Expand All @@ -96,15 +100,15 @@ private void ShouldThrowValidationDependencyExceptionOnLoadAssemblyIfExternalExc

this.assemblyBroker
.Verify(broker =>
broker.GetAssembly(It.IsAny<string>()),
broker.GetAssemblyAsync(It.IsAny<string>()),
Times.Once);

this.assemblyBroker.VerifyNoOtherCalls();
}

[Theory]
[MemberData(nameof(AssemblyLoadServiceExceptions))]
private void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs(
private async Task ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccursAsync(
Exception externalException)
{
// given
Expand All @@ -122,17 +126,19 @@ private void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs(

this.assemblyBroker
.Setup(broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualAssemblyPath =>
actualAssemblyPath == someAssemblyPath)))
.Throws(externalException);

// when
Func<Assembly> getAssemblyFunction = () =>
this.assemblyService.GetAssembly(someAssemblyPath);
Func<Task<Assembly>> getAssemblyFunction =
() =>
this.assemblyService.GetAssemblyAsync(someAssemblyPath)
.AsTask();

AssemblyServiceException actualAssemblyServiceException =
Assert.Throws<AssemblyServiceException>(
await Assert.ThrowsAsync<AssemblyServiceException>(
getAssemblyFunction);

// then
Expand All @@ -141,7 +147,7 @@ private void ShouldThrowServiceExceptionOnLoadAssemblyIfExceptionOccurs(

this.assemblyBroker
.Verify(broker =>
broker.GetAssembly(It.IsAny<string>()),
broker.GetAssemblyAsync(It.IsAny<string>()),
Times.Once);

this.assemblyBroker.VerifyNoOtherCalls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------

using System.Threading.Tasks;
using FluentAssertions;
using Moq;

Expand All @@ -10,7 +11,7 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies
public partial class AssemblyServiceTests
{
[Fact]
private void ShouldGetApplicationPathAssemblies()
private async Task ShouldGetApplicationPathAssembliesAsync()
{
// given
string[] randomApplicationPathsAssemblies =
Expand All @@ -23,20 +24,20 @@ private void ShouldGetApplicationPathAssemblies()
randomApplicationPathsAssemblies;

this.assemblyBroker
.Setup(broker => broker.GetApplicationPathsAssemblies())
.Returns(returnedApplicationPathsAssemblies);
.Setup(broker => broker.GetApplicationPathsAssembliesAsync())
.ReturnsAsync(returnedApplicationPathsAssemblies);

// when
string[] actualApplicationPathsAssemblies =
this.assemblyService.GetApplicationPathsAssemblies();
await this.assemblyService.GetApplicationPathsAssembliesAsync();

// then
actualApplicationPathsAssemblies.Should()
.BeEquivalentTo(expectedApplicationPathsAssemblies);

this.assemblyBroker.Verify(
broker =>
broker.GetApplicationPathsAssemblies(),
broker.GetApplicationPathsAssembliesAsync(),
Times.Once);

this.assemblyBroker.VerifyNoOtherCalls();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ----------------------------------------------------------------------------------

using System.Reflection;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;

Expand All @@ -11,7 +12,7 @@ namespace STX.SPAL.Core.Tests.Unit.Services.Foundations.Assemblies
public partial class AssemblyServiceTests
{
[Fact]
private void ShouldGetAssembly()
private async Task ShouldGetAssemblyAsync()
{
// given
Assembly randomAssembly = CreateRandomAssembly();
Expand All @@ -22,21 +23,21 @@ private void ShouldGetAssembly()

this.assemblyBroker
.Setup(broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualPathAssembly =>
actualPathAssembly == inputPathAssembly)))
.Returns(returnedAssembly);
.ReturnsAsync(returnedAssembly);

// when
Assembly actualAssembly =
this.assemblyService.GetAssembly(inputPathAssembly);
await this.assemblyService.GetAssemblyAsync(inputPathAssembly);

// then
actualAssembly.Should().BeSameAs(expectedAssembly);

this.assemblyBroker.Verify(
broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualPathAssembly =>
actualPathAssembly == inputPathAssembly)),
Times.Once);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Reflection;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using STX.SPAL.Core.Models.Services.Foundations.Assemblies.Exceptions;
Expand All @@ -17,7 +18,7 @@ public partial class AssemblyServiceTests
[InlineData("", "Value is required")]
[InlineData(" ", "Value is required")]
[InlineData("file", "Value is not a valid assembly path")]
private void ShouldThrowValidationExceptionIfInvalidAssemblyPath(
private async Task ShouldThrowValidationExceptionIfInvalidAssemblyPathAsync(
string assemblyPath,
string exceptionMessage)
{
Expand All @@ -44,16 +45,18 @@ private void ShouldThrowValidationExceptionIfInvalidAssemblyPath(

this.assemblyBroker
.Setup(broker =>
broker.GetAssembly(
broker.GetAssemblyAsync(
It.Is<string>(actualAssemblyPath =>
actualAssemblyPath == inputAssemblyPath)));

// when
Func<Assembly> getAssemblyFunction = () =>
this.assemblyService.GetAssembly(inputAssemblyPath);
Func<Task<Assembly>> getAssemblyFunction =
() =>
this.assemblyService.GetAssemblyAsync(inputAssemblyPath)
.AsTask();

AssemblyValidationException actualAssemblyValidationException =
Assert.Throws<AssemblyValidationException>(
await Assert.ThrowsAsync<AssemblyValidationException>(
getAssemblyFunction);

// then
Expand All @@ -62,7 +65,7 @@ private void ShouldThrowValidationExceptionIfInvalidAssemblyPath(

this.assemblyBroker
.Verify(broker =>
broker.GetAssembly(It.IsAny<string>()),
broker.GetAssemblyAsync(It.IsAny<string>()),
Times.Never);

this.assemblyBroker.VerifyNoOtherCalls();
Expand Down
Loading
Loading