-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from IowaComputerGurus/feature/async
Adjusted project to use Async Properly Fixes #28
- Loading branch information
Showing
8 changed files
with
222 additions
and
264 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -37,61 +37,14 @@ jobs: | |
- name: Build | ||
run: dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }} | ||
- name: Test | ||
run: dotnet test "${{ env.solution-path }}" --no-build --configuration Release | ||
|
||
|
||
code-quality: | ||
if: github.actor != 'dependabot[bot]' | ||
runs-on: windows-latest | ||
name: Analyze Code Quality | ||
env: | ||
solution-path: './src/NetCore.Utilities.Email.SendGrid.sln' | ||
steps: | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: zulu | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Cache SonarCloud packages | ||
uses: actions/[email protected] | ||
with: | ||
path: ~\sonar\cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache SonarCloud scanner | ||
id: cache-sonar-scanner | ||
uses: actions/[email protected] | ||
with: | ||
path: .\.sonar\scanner | ||
key: ${{ runner.os }}-sonar-scanner | ||
restore-keys: ${{ runner.os }}-sonar-scanner | ||
- name: Install SonarCloud scanner | ||
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | ||
shell: powershell | ||
run: | | ||
New-Item -Path .\.sonar\scanner -ItemType Directory | ||
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | ||
- name: Install GitVersion | ||
run: dotnet tool install --global GitVersion.Tool | ||
|
||
- name: Determine Version | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
useConfigFile: true | ||
run: dotnet test "${{ env.solution-path }}" --no-build --configuration Release --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --logger "trx;LogFileName=unittests.trx" | ||
|
||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
shell: powershell | ||
run: | | ||
.\.sonar\scanner\dotnet-sonarscanner begin /k:"IowaComputerGurus_netcore.utilities.email.sendgrid" /o:"iowacomputergurus-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" | ||
dotnet restore "${{ env.solution-path }}" | ||
dotnet build "${{ env.solution-path }}" --no-restore --configuration Release -p:version=${{ steps.gitversion.outputs.majorMinorPatch }} | ||
dotnet test "${{ env.solution-path }}" --no-build --configuration Release --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover --logger "trx;LogFileName=unittests.trx" | ||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | ||
- name: Push Coverage to Codacy | ||
shell: bash | ||
env: | ||
CODACY_ORGANIZATION_PROVIDER: ${{ secrets.CODACY_ORGANIZATION_PROVIDER }} | ||
CODACY_USERNAME: ${{ secrets.CODACY_USERNAME }} | ||
CODACY_PROJECT_NAME: ${{ secrets.CODACY_PROJECT_NAME }} | ||
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }} | ||
run: | | ||
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $(find . -name '*.opencover.xml' -printf '-r %p ') |
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
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 |
---|---|---|
|
@@ -84,48 +84,48 @@ public void AdminName_ShouldReturnNullWhenNoConfiguration() | |
} | ||
|
||
[Fact] | ||
public void SendToAdministrator_ShouldSend_DefaultingFromAndToAddress() | ||
public void SendToAdministratorAsync_ShouldSend_DefaultingFromAndToAddress() | ||
{ | ||
//Arrange | ||
var subject = "Test"; | ||
var message = "Message"; | ||
|
||
//Act | ||
_service.SendMessageToAdministrator(subject, message); | ||
_service.SendMessageToAdministratorAsync(subject, message); | ||
|
||
//Verify | ||
} | ||
|
||
[Fact] | ||
public void SendToAdministrator_ShouldSend_DefaultingFromAndToAddress_WithCCRecipients() | ||
public void SendToAdministratorAsync_ShouldSend_DefaultingFromAndToAddress_WithCCRecipients() | ||
{ | ||
//Arrange | ||
var subject = "Test"; | ||
var message = "Message"; | ||
var cc = new List<string> {"[email protected]"}; | ||
|
||
//Act | ||
_service.SendMessageToAdministrator(cc, subject, message); | ||
_service.SendMessageToAdministratorAsync(cc, subject, message); | ||
|
||
//Verify | ||
} | ||
|
||
[Fact] | ||
public void SendMessage_WithoutCCRecipients_ShouldSend_DefaultingFromAddress() | ||
public void SendMessageAsync_WithoutCCRecipients_ShouldSend_DefaultingFromAddress() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
var subject = "test"; | ||
var message = "message"; | ||
|
||
//Act | ||
_service.SendMessage(to, subject, message); | ||
_service.SendMessageAsync(to, subject, message); | ||
|
||
//Verify | ||
} | ||
|
||
[Fact] | ||
public void SendMessage_WithCCRecipients_ShouldSend_DefaultingFromAddress() | ||
public void SendMessageAsync_WithCCRecipients_ShouldSend_DefaultingFromAddress() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
|
@@ -134,13 +134,13 @@ public void SendMessage_WithCCRecipients_ShouldSend_DefaultingFromAddress() | |
var message = "message"; | ||
|
||
//Act | ||
_service.SendMessage(to, cc, subject, message); | ||
_service.SendMessageAsync(to, cc, subject, message); | ||
|
||
//Verify | ||
} | ||
|
||
[Fact] | ||
public void SendMessageWithAttachment_ShouldSend_DefaultingFromAddress() | ||
public void SendMessageWithAttachmentAsync_ShouldSend_DefaultingFromAddress() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
|
@@ -151,13 +151,13 @@ public void SendMessageWithAttachment_ShouldSend_DefaultingFromAddress() | |
var message = "message"; | ||
|
||
//Act | ||
_service.SendMessageWithAttachment(to, cc, subject, fileContent, fileName, message, null); | ||
_service.SendMessageWithAttachmentAsync(to, cc, subject, fileContent, fileName, message, null); | ||
|
||
//Assets | ||
} | ||
|
||
[Fact] | ||
public void SendMessage_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
public void SendMessageAsync_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
|
@@ -167,13 +167,13 @@ public void SendMessage_ShouldPassOptionalTemplateName_ToMessageMethods() | |
var requestedTemplate = "Test"; | ||
|
||
//Act | ||
_service.SendMessage(to, cc, subject, message, null, requestedTemplate); | ||
_service.SendMessageAsync(to, cc, subject, message, null, requestedTemplate); | ||
|
||
//Assets | ||
} | ||
|
||
[Fact] | ||
public void SendMessageWithAttachment_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
public void SendMessageWithAttachmentAsync_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
|
@@ -185,25 +185,25 @@ public void SendMessageWithAttachment_ShouldPassOptionalTemplateName_ToMessageMe | |
var requestedTemplate = "Test"; | ||
|
||
//Act | ||
_service.SendMessageWithAttachment(to, cc, subject, fileContent, fileName, message, null, requestedTemplate); | ||
_service.SendMessageWithAttachmentAsync(to, cc, subject, fileContent, fileName, message, null, requestedTemplate); | ||
|
||
//Assets | ||
} | ||
|
||
[Fact] | ||
public void SendWithReplyTo_ShouldThrowArgumentException_WhenReplyToMissing() | ||
public async void SendWithReplyToAsync_ShouldThrowArgumentException_WhenReplyToMissing() | ||
{ | ||
//Arrange | ||
var to = "[email protected]"; | ||
var subject = "test"; | ||
var message = "message"; | ||
|
||
//Act/Assert | ||
Assert.Throws<ArgumentNullException>(() => _service.SendWithReplyTo("", "", to, subject, message)); | ||
var result = await Assert.ThrowsAsync<ArgumentNullException>(() => _service.SendWithReplyToAsync("", "", to, subject, message)); | ||
} | ||
|
||
[Fact] | ||
public void SendWithReplyTo_WithoutCCRecipients_ShouldSend_DefaultingFromAddress() | ||
public void SendWithReplyToAsync_WithoutCCRecipients_ShouldSend_DefaultingFromAddress() | ||
{ | ||
//Arrange | ||
var replyTo = "[email protected]"; | ||
|
@@ -216,13 +216,13 @@ public void SendWithReplyTo_WithoutCCRecipients_ShouldSend_DefaultingFromAddress | |
"")).Returns(returnMessage).Verifiable(); | ||
|
||
//Act | ||
_service.SendWithReplyTo(replyTo, "", to, subject, message); | ||
_service.SendWithReplyToAsync(replyTo, "", to, subject, message); | ||
|
||
//Verify | ||
} | ||
|
||
[Fact] | ||
public void SendWithReplyTo_WithCCRecipients_ShouldSend_DefaultingFromAddress() | ||
public void SendWithReplyToAsync_WithCCRecipients_ShouldSend_DefaultingFromAddress() | ||
{ | ||
//Arrange | ||
var replyTo = "[email protected]"; | ||
|
@@ -235,14 +235,14 @@ public void SendWithReplyTo_WithCCRecipients_ShouldSend_DefaultingFromAddress() | |
.Setup(s => s.CreateMessage(_options.AdminEmail, _options.AdminName, to, cc, subject, message, "")).Returns(returnMessage).Verifiable(); | ||
|
||
//Act | ||
_service.SendWithReplyTo(replyTo, "", to, cc, subject, message); | ||
_service.SendWithReplyToAsync(replyTo, "", to, cc, subject, message); | ||
|
||
//Verify | ||
_sendGridMessageBuilderMock.Verify(); | ||
} | ||
|
||
[Fact] | ||
public void SendWithReplyTo_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
public void SendWithReplyToAsync_ShouldPassOptionalTemplateName_ToMessageMethods() | ||
{ | ||
//Arrange | ||
var replyTo = "[email protected]"; | ||
|
@@ -257,7 +257,7 @@ public void SendWithReplyTo_ShouldPassOptionalTemplateName_ToMessageMethods() | |
requestedTemplate)).Returns(returnMessage).Verifiable(); | ||
|
||
//Act | ||
_service.SendWithReplyTo(replyTo, "", to, cc, subject, message, null, requestedTemplate); | ||
_service.SendWithReplyToAsync(replyTo, "", to, cc, subject, message, null, requestedTemplate); | ||
|
||
//Assets | ||
_sendGridMessageBuilderMock.Verify(); | ||
|
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
Oops, something went wrong.