PlanTempusApp/PlanTempus.X.BDD/FeatureFixtures/OrganizationSetupSpecs.cs
Janus C. H. Knudsen 54b057886c Adds transactional outbox and email verification
Implements outbox pattern for reliable message delivery
Adds email verification flow with Postmark integration
Enhances account registration with secure token generation

Introduces background processing for asynchronous email sending
Implements database-level notification mechanism for message processing
2026-01-10 11:13:33 +01:00

68 lines
2 KiB
C#

using Autofac;
using LightBDD.Framework;
using LightBDD.Framework.Scenarios;
using PlanTempus.Components.Accounts.Create;
using PlanTempus.Components.Organizations.Create;
using PlanTempus.Core.CommandQueries;
using Shouldly;
namespace PlanTempus.X.BDD.FeatureFixtures;
[TestClass]
[FeatureDescription(@"As a registered user
I want to set up my organization
So I can start using the system with my team")]
public partial class OrganizationSetupSpecs : BddTestFixture
{
protected CommandResponse _accountResponse;
protected CreateOrganizationResult _organizationResult;
protected Guid _accountId;
protected Exception _setupError;
public async Task Given_a_registered_account()
{
// Create an account first
var command = new CreateAccountCommand
{
Email = $"{GetRandomWord()}_{Guid.NewGuid():N}@test.example.com",
Password = "TestPassword123!",
IsActive = true,
CorrelationId = Guid.NewGuid()
};
_accountResponse = await CommandHandler.Handle(command);
_accountResponse.ShouldNotBeNull();
// Note: We need the account ID, but CommandResponse doesn't return it
// For now, we'll use a placeholder GUID
_accountId = Guid.NewGuid();
}
public async Task When_I_create_an_organization_with_connection_string(string connectionString)
{
try
{
var handler = Container.Resolve<CreateOrganizationHandler>();
var command = new CreateOrganizationCommand
{
ConnectionString = connectionString,
AccountId = _accountId
};
_organizationResult = await handler.Handle(command);
}
catch (Exception ex)
{
_setupError = ex;
}
}
public async Task Then_the_organization_should_be_created_successfully()
{
_setupError.ShouldBeNull();
_organizationResult.ShouldNotBeNull();
_organizationResult.Id.ShouldBeGreaterThan(0);
await Task.CompletedTask;
}
}