Renames core domain entities and services from "User" to "Account" Refactors project-wide namespaces, classes, and database tables to use "Account" terminology Updates related components, services, and database schema to reflect new domain naming Standardizes naming conventions across authentication and organization setup features
74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using LightBDD.Framework;
|
|
using LightBDD.Framework.Scenarios;
|
|
using LightBDD.MsTest3;
|
|
using PlanTempus.X.Services;
|
|
using Shouldly;
|
|
|
|
namespace PlanTempus.X.BDD.FeatureFixtures;
|
|
|
|
[TestClass]
|
|
[FeatureDescription(@"As a registered user
|
|
I want to confirm my email
|
|
So I can activate my account")]
|
|
public partial class EmailConfirmationSpecs : FeatureFixture
|
|
{
|
|
IAccountService _accountService;
|
|
IEmailService _emailService;
|
|
IOrganizationService _organizationService;
|
|
|
|
protected Account _currentAccount;
|
|
protected string _currentEmail;
|
|
protected string _confirmationLink;
|
|
protected bool _redirectedToWelcome;
|
|
protected string _errorMessage;
|
|
|
|
public async Task Given_an_account_exists_with_unconfirmed_email(string email)
|
|
{
|
|
_currentAccount = await _accountService.CreateAccountAsync(email, "TestPassword123!");
|
|
_currentAccount.EmailConfirmed.ShouldBeFalse();
|
|
_currentEmail = email;
|
|
}
|
|
|
|
public async Task When_I_click_the_valid_confirmation_link_for(string email)
|
|
{
|
|
_confirmationLink = await _emailService.GetConfirmationLinkForEmail(email);
|
|
await _accountService.ConfirmEmailAsync(_confirmationLink);
|
|
_redirectedToWelcome = true; // Simulate redirect
|
|
}
|
|
|
|
public async Task Then_the_accounts_email_confirmed_should_be_true()
|
|
{
|
|
_currentAccount = _accountService.GetAccountByEmail(_currentEmail);
|
|
_currentAccount.EmailConfirmed.ShouldBeTrue();
|
|
}
|
|
|
|
public async Task And_I_should_be_redirected_to_the_welcome_page()
|
|
{
|
|
_redirectedToWelcome.ShouldBeTrue();
|
|
}
|
|
|
|
public async Task When_I_click_an_invalid_confirmation_link()
|
|
{
|
|
try
|
|
{
|
|
await _accountService.ConfirmEmailAsync("invalid-confirmation-token");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_errorMessage = ex.Message;
|
|
}
|
|
}
|
|
|
|
public async Task Then_I_should_see_an_error_message(string expectedErrorMessage)
|
|
{
|
|
_errorMessage.ShouldBe(expectedErrorMessage);
|
|
}
|
|
|
|
public async Task And_my_email_remains_unconfirmed()
|
|
{
|
|
if (_currentAccount != null)
|
|
{
|
|
_currentAccount.EmailConfirmed.ShouldBeFalse();
|
|
}
|
|
}
|
|
}
|