diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/KafkaFlowFixture.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/KafkaFlowFixture.cs similarity index 98% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/KafkaFlowFixture.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/KafkaFlowFixture.cs index 760ca84..b3f7cdc 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/KafkaFlowFixture.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/KafkaFlowFixture.cs @@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging; using Npgsql; -namespace KafkaFlow.ProcessManagers.IntegrationTests; +namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture; public class KafkaFlowFixture : IDisposable, IAsyncDisposable { diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/LoggingProcessStateStore.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/LoggingProcessStateStore.cs similarity index 91% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/LoggingProcessStateStore.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/LoggingProcessStateStore.cs index 8617b6a..4e823e7 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/LoggingProcessStateStore.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/LoggingProcessStateStore.cs @@ -1,6 +1,4 @@ -using KafkaFlow.ProcessManagers.InMemory; - -namespace KafkaFlow.ProcessManagers.IntegrationTests; +namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture; public sealed class LoggingProcessStateStore : IProcessStateStore { @@ -18,6 +16,8 @@ public LoggingProcessStateStore(IProcessStateStore innerStore) public IReadOnlyList<(ActionType, Type, Guid, VersionedState?)> Changes => _log.AsReadOnly(); + public void ClearChanges() => _log.Clear(); + public ValueTask Persist(Type processType, Guid processId, VersionedState state) { _log.Add((ActionType.Persisted, processType, processId, state)); diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ServiceCollectionExtensions.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/ServiceCollectionExtensions.cs similarity index 98% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/ServiceCollectionExtensions.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/ServiceCollectionExtensions.cs index cfb204d..ad0bcc8 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ServiceCollectionExtensions.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Fixture/ServiceCollectionExtensions.cs @@ -1,7 +1,7 @@ -namespace KafkaFlow.ProcessManagers.IntegrationTests; - using Microsoft.Extensions.DependencyInjection; +namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture; + public static class ServiceCollectionExtensions { /// diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/Types.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/ITestMessageProducer.cs similarity index 100% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/Types.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/ITestMessageProducer.cs diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/Playground.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Playground.cs deleted file mode 100644 index 424f028..0000000 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/Playground.cs +++ /dev/null @@ -1,37 +0,0 @@ -using FluentAssertions; - -namespace KafkaFlow.ProcessManagers.IntegrationTests; - -public sealed class A -{ - public A(string value) - { - Value = value; - } - public string Value { get; set; } -} - -public sealed class C : IEquatable -{ - public C(string value) - { - Value = value; - } - public string Value { get; set; } - - public bool Equals(C? other) => Value == other?.Value; -} - -public sealed record B(string Value); - -public sealed class Playground -{ - [Fact] - public void ShouldEqual() - { - EqualityComparer.Default.Equals(new A("a"), new A("a")).Should().BeFalse(); - EqualityComparer.Default.Equals(new C("a"), new C("a")).Should().BeTrue(); - - EqualityComparer.Default.Equals(new B("a"), new B("a")).Should().BeTrue(); - } -} diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/PostgresProcessManagerStoreTests.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/PostgresProcessManagerStoreTests.cs index b92efb7..6d1972e 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/PostgresProcessManagerStoreTests.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/PostgresProcessManagerStoreTests.cs @@ -1,7 +1,6 @@ using FluentAssertions; using KafkaFlow.Contrib.ProcessManagers.Postgres; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; using Npgsql; namespace KafkaFlow.ProcessManagers.IntegrationTests; diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ProducerMarkers.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/ProducerMarkers.cs deleted file mode 100644 index 62ab28e..0000000 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ProducerMarkers.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace KafkaFlow.ProcessManagers.IntegrationTests; - -public interface IEventsProducer -{ -} - -public interface ICommandsProducer -{ -} \ No newline at end of file diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/TestProcessManager.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifeCycleProcess.cs similarity index 75% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/TestProcessManager.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifeCycleProcess.cs index 1220831..2788ec1 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/TestProcessManager.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifeCycleProcess.cs @@ -1,33 +1,17 @@ using System.Collections.Immutable; using Microsoft.Extensions.Logging; -namespace KafkaFlow.ProcessManagers.IntegrationTests; +namespace KafkaFlow.ProcessManagers.IntegrationTests.UserLifeCycle; public sealed record TestState(DateTimeOffset StartedAt, ImmutableList Log); -public sealed class UserRegistered -{ - public UserRegistered(Guid UserId, string Email) - { - this.UserId = UserId; - this.Email = Email; - } - - public Guid UserId { get; init; } - public string Email { get; init; } - - public void Deconstruct(out Guid UserId, out string Email) - { - UserId = this.UserId; - Email = this.Email; - } -} +public sealed record UserRegistered(Guid UserId, string Email); public sealed record UserApproved(Guid UserId); public sealed record UserAccessGranted(Guid UserId); -public class TestProcessManager : ProcessManager, +public class UserLifeCycleProcess : ProcessManager, IProcessMessage, IProcessMessage, IProcessMessage @@ -35,7 +19,7 @@ public class TestProcessManager : ProcessManager, private readonly ILogger _logger; private readonly IMessageProducer _producer; - public TestProcessManager(ILogger logger, IMessageProducer producer) + public UserLifeCycleProcess(ILogger logger, IMessageProducer producer) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _producer = producer ?? throw new ArgumentNullException(nameof(producer)); diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ProcessManagerTests.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifecycleProcessManagerTests.cs similarity index 68% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/ProcessManagerTests.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifecycleProcessManagerTests.cs index bc60da7..da39fc7 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/ProcessManagerTests.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/UserLifeCycle/UserLifecycleProcessManagerTests.cs @@ -1,14 +1,16 @@ using FluentAssertions; +using KafkaFlow.ProcessManagers.IntegrationTests.Fixture; -namespace KafkaFlow.ProcessManagers.IntegrationTests; +namespace KafkaFlow.ProcessManagers.IntegrationTests.UserLifeCycle; -public sealed class ProcessManagerTests : IAssemblyFixture +public sealed class UserLifecycleProcessManagerTests : IAssemblyFixture { private readonly KafkaFlowFixture _fixture; - public ProcessManagerTests(KafkaFlowFixture fixture) + public UserLifecycleProcessManagerTests(KafkaFlowFixture fixture) { _fixture = fixture ?? throw new ArgumentNullException(nameof(fixture)); + _fixture.ProcessStateStore.ClearChanges(); } [Fact] @@ -26,7 +28,7 @@ public async Task Should_start_fixture() { LoggingProcessStateStore.ActionType.Persisted, LoggingProcessStateStore.ActionType.Persisted, - LoggingProcessStateStore.ActionType.Deleted, + LoggingProcessStateStore.ActionType.Deleted }, x => x.WithStrictOrdering()); }); } diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/Usings.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Usings.cs index 8c927eb..10cea68 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/Usings.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Usings.cs @@ -1 +1,2 @@ -global using Xunit; \ No newline at end of file +global using Xunit; +global using KafkaFlow.ProcessManagers.IntegrationTests.Utils; diff --git a/tests/KafkaFlow.ProcessManagers.IntegrationTests/TestUtils.cs b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Utils/TestUtils.cs similarity index 92% rename from tests/KafkaFlow.ProcessManagers.IntegrationTests/TestUtils.cs rename to tests/KafkaFlow.ProcessManagers.IntegrationTests/Utils/TestUtils.cs index bd02dd6..6ca026c 100644 --- a/tests/KafkaFlow.ProcessManagers.IntegrationTests/TestUtils.cs +++ b/tests/KafkaFlow.ProcessManagers.IntegrationTests/Utils/TestUtils.cs @@ -1,6 +1,6 @@ using Xunit.Sdk; -namespace KafkaFlow.ProcessManagers.IntegrationTests; +namespace KafkaFlow.ProcessManagers.IntegrationTests.Utils; public static class TestUtils {