PlanTempusApp/PlanTempus.X.BDD/FeatureFixtures/OrganizationSetupSpecs.cs

69 lines
2 KiB
C#
Raw Normal View History

using Autofac;
2025-03-03 00:42:20 +01:00
using LightBDD.Framework;
using LightBDD.Framework.Scenarios;
using PlanTempus.Components.Accounts.Create;
using PlanTempus.Components.Organizations.Create;
using PlanTempus.Core.CommandQueries;
2025-03-03 00:42:20 +01:00
using Shouldly;
namespace PlanTempus.X.BDD.FeatureFixtures;
2025-03-03 00:42:20 +01:00
[TestClass]
[FeatureDescription(@"As a registered user
2025-03-03 00:42:20 +01:00
I want to set up my organization
So I can start using the system with my team")]
public partial class OrganizationSetupSpecs : BddTestFixture
2025-03-03 00:42:20 +01:00
{
protected CommandResponse _accountResponse;
protected CreateOrganizationResult _organizationResult;
protected Guid _accountId;
2025-03-03 00:42:20 +01:00
protected Exception _setupError;
public async Task Given_a_registered_account()
2025-03-03 00:42:20 +01:00
{
// Create an account first
var command = new CreateAccountCommand
2025-03-03 00:42:20 +01:00
{
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();
2025-03-03 00:42:20 +01:00
}
public async Task When_I_create_an_organization_with_connection_string(string connectionString)
2025-03-03 00:42:20 +01:00
{
try
{
var handler = Container.Resolve<CreateOrganizationHandler>();
var command = new CreateOrganizationCommand
{
ConnectionString = connectionString,
AccountId = _accountId
};
_organizationResult = await handler.Handle(command);
2025-03-03 00:42:20 +01:00
}
catch (Exception ex)
{
_setupError = ex;
}
}
public async Task Then_the_organization_should_be_created_successfully()
2025-03-03 00:42:20 +01:00
{
_setupError.ShouldBeNull();
_organizationResult.ShouldNotBeNull();
_organizationResult.Id.ShouldBeGreaterThan(0);
2025-03-03 00:42:20 +01:00
await Task.CompletedTask;
}
}