-
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.
- Loading branch information
John Miller
committed
Aug 23, 2024
1 parent
265f4e9
commit 5ed8edf
Showing
8 changed files
with
35 additions
and
28 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Ignore Spelling: Mediatr | ||
|
||
using FluentValidation; | ||
using MediatR; | ||
using Microservice.Customer.Api.Data.Repository.Interfaces; | ||
|
@@ -14,10 +16,10 @@ namespace Microservice.Customer.Api.Test.Unit; | |
[TestFixture] | ||
public class UpdateCustomerMediatrTests | ||
{ | ||
private Mock<ICustomerRepository> customerRepositoryMock = new(); | ||
private Mock<ICustomerHttpAccessor> customerHttpAccessorMock = new(); | ||
private Mock<ILogger<UpdateCustomerCommandHandler>> loggerMock = new(); | ||
private ServiceCollection services = new(); | ||
private readonly Mock<ICustomerRepository> customerRepositoryMock = new(); | ||
private readonly Mock<ICustomerHttpAccessor> customerHttpAccessorMock = new(); | ||
private readonly Mock<ILogger<UpdateCustomerCommandHandler>> loggerMock = new(); | ||
private readonly ServiceCollection services = new(); | ||
private ServiceProvider serviceProvider; | ||
private IMediator mediator; | ||
private Guid customerId; | ||
|
@@ -59,25 +61,28 @@ public async Task Customer_updated_return_success_message() | |
{ | ||
var customerId = Guid.NewGuid(); | ||
|
||
var customer = new Domain.Customer() { Id = customerId, Email = "[email protected]", Surname = "TestSurname", FirstName = "TestFirstName" }; | ||
Domain.Customer? customer = new Domain.Customer() { Id = customerId, Email = "[email protected]", Surname = "TestSurname", FirstName = "TestFirstName" }; | ||
|
||
customerHttpAccessorMock.Setup(x => x.CustomerId) | ||
.Returns(customerId); | ||
|
||
customerRepositoryMock | ||
.Setup(x => x.ByIdAsync(customerId)) | ||
.Returns(Task.FromResult(customer)); | ||
.Returns(Task.FromResult(customer ?? null)); | ||
|
||
customerRepositoryMock | ||
.Setup(x => x.ExistsAsync(customerId)) | ||
.Returns(Task.FromResult(true)); | ||
|
||
customer.Surname = "Changed Surname"; | ||
customer.FirstName = "Changed FirstName"; | ||
customer.Email = "Changed Email"; | ||
if (customer is not null) | ||
{ | ||
customer.Surname = "Changed Surname"; | ||
customer.FirstName = "Changed FirstName"; | ||
customer.Email = "Changed Email"; | ||
|
||
customerRepositoryMock | ||
.Setup(x => x.UpdateAsync(customer)); | ||
customerRepositoryMock | ||
.Setup(x => x.UpdateAsync(customer)); | ||
} | ||
|
||
var updateCustomerRequest = new UpdateCustomerRequest(customerId, "[email protected]", "TestSurname", "TestFirstName"); | ||
|
||
|
@@ -142,7 +147,7 @@ public void Customer_not_updated_invalid_email_return_exception_fail_message() | |
} | ||
|
||
[Test] | ||
public void Customer_not_updated_invalid_surname_firstname_return_exception_fail_message() | ||
public void Customer_not_updated_invalid_surname_first_name_return_exception_fail_message() | ||
{ | ||
customerRepositoryMock | ||
.Setup(x => x.ExistsAsync("[email protected]")) | ||
|
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
namespace Microservice.Customer.Api.Helpers; | ||
// Ignore Spelling: Jwt | ||
|
||
namespace Microservice.Customer.Api.Helpers; | ||
|
||
public class EnvironmentVariables | ||
{ | ||
public static string JwtIssuer = Environment.GetEnvironmentVariable(Constants.JwtIssuer); | ||
public static string JwtAudience = Environment.GetEnvironmentVariable(Constants.JwtAudience); | ||
public static string JwtSymmetricSecurityKey = Environment.GetEnvironmentVariable(Constants.JwtSymmetricSecurityKey); | ||
public static string JwtIssuer = Environment.GetEnvironmentVariable(Constants.JwtIssuer) ?? "Environment Variable JwtIssuer not found."; | ||
public static string JwtAudience = Environment.GetEnvironmentVariable(Constants.JwtAudience) ?? "Environment Variable JwtAudience not found."; | ||
public static string JwtSymmetricSecurityKey = Environment.GetEnvironmentVariable(Constants.JwtSymmetricSecurityKey) ?? "Environment Variable JwtSymmetricSecurityKey not found."; | ||
} |
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