-
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.
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...esentation.Grpc.IntegrationTests/Services/AccountServices/ResendConfirmationEmailTests.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,59 @@ | ||
using MadWorldNL.Server.Infrastructure.Database.Users; | ||
using MadWorldNL.Server.Presentation.Grpc.IntegrationTests.TestBase; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Server.Presentation.Grpc.Account.V1; | ||
using Shouldly; | ||
|
||
namespace MadWorldNL.Server.Presentation.Grpc.IntegrationTests.Services.AccountServices; | ||
|
||
[Collection(Collections.Applcation)] | ||
public class ResendConfirmationEmailTests : IAsyncLifetime | ||
{ | ||
private readonly GrpcFactory _factory; | ||
|
||
public ResendConfirmationEmailTests(GrpcFactory factory) | ||
{ | ||
_factory = factory; | ||
} | ||
|
||
[Fact] | ||
public async Task ResendConfirmationEmail_GivenExistingEmail_ReturnsOK() | ||
{ | ||
// Arrange | ||
const string email = "test@test.nl"; | ||
|
||
using (var scope = _factory.CreateScope()) | ||
{ | ||
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<IdentityUserExtended>>(); | ||
|
||
var user = new IdentityUserExtended() | ||
{ | ||
UserName = email, | ||
Email = email | ||
}; | ||
|
||
await userManager.CreateAsync(user); | ||
} | ||
|
||
var request = new ResendConfirmationEmailRequest() | ||
{ | ||
Email = email | ||
}; | ||
|
||
var client = new Account.AccountClient(_factory.Channel); | ||
|
||
// Act | ||
var response = client.ResendConfirmationEmail(request); | ||
|
||
// Assert | ||
response.IsSuccess.ShouldBeTrue(); | ||
response.Message.ShouldNotBeNullOrEmpty(); | ||
} | ||
|
||
public Task InitializeAsync() => Task.CompletedTask; | ||
public Task DisposeAsync() | ||
{ | ||
return _factory.ResetDatabase(); | ||
} | ||
} |