Skip to content

Commit

Permalink
Housekeeping: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyRaga committed Jun 17, 2023
1 parent dd69952 commit 5f33634
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.Extensions.Logging;
using Npgsql;

namespace KafkaFlow.ProcessManagers.IntegrationTests;
namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture;

public class KafkaFlowFixture : IDisposable, IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using KafkaFlow.ProcessManagers.InMemory;

namespace KafkaFlow.ProcessManagers.IntegrationTests;
namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture;

public sealed class LoggingProcessStateStore : IProcessStateStore
{
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace KafkaFlow.ProcessManagers.IntegrationTests;

using Microsoft.Extensions.DependencyInjection;

namespace KafkaFlow.ProcessManagers.IntegrationTests.Fixture;

public static class ServiceCollectionExtensions
{
/// <summary>
Expand Down
37 changes: 0 additions & 37 deletions tests/KafkaFlow.ProcessManagers.IntegrationTests/Playground.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
using System.Collections.Immutable;
using Microsoft.Extensions.Logging;

namespace KafkaFlow.ProcessManagers.IntegrationTests;
namespace KafkaFlow.ProcessManagers.IntegrationTests.UserLifeCycle;

public sealed record TestState(DateTimeOffset StartedAt, ImmutableList<string> 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<TestState>,
public class UserLifeCycleProcess : ProcessManager<TestState>,
IProcessMessage<UserRegistered>,
IProcessMessage<UserAccessGranted>,
IProcessMessage<UserApproved>
{
private readonly ILogger _logger;
private readonly IMessageProducer<ITestMessageProducer> _producer;

public TestProcessManager(ILogger<TestProcessManager> logger, IMessageProducer<ITestMessageProducer> producer)
public UserLifeCycleProcess(ILogger<UserLifeCycleProcess> logger, IMessageProducer<ITestMessageProducer> producer)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_producer = producer ?? throw new ArgumentNullException(nameof(producer));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<KafkaFlowFixture>
public sealed class UserLifecycleProcessManagerTests : IAssemblyFixture<KafkaFlowFixture>
{
private readonly KafkaFlowFixture _fixture;

public ProcessManagerTests(KafkaFlowFixture fixture)
public UserLifecycleProcessManagerTests(KafkaFlowFixture fixture)
{
_fixture = fixture ?? throw new ArgumentNullException(nameof(fixture));
_fixture.ProcessStateStore.ClearChanges();
}

[Fact]
Expand All @@ -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());
});
}
Expand Down
3 changes: 2 additions & 1 deletion tests/KafkaFlow.ProcessManagers.IntegrationTests/Usings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
global using Xunit;
global using Xunit;
global using KafkaFlow.ProcessManagers.IntegrationTests.Utils;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Xunit.Sdk;

namespace KafkaFlow.ProcessManagers.IntegrationTests;
namespace KafkaFlow.ProcessManagers.IntegrationTests.Utils;

public static class TestUtils
{
Expand Down

0 comments on commit 5f33634

Please sign in to comment.