-
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented EventStoreDB Application Logic tests
- Loading branch information
1 parent
b1adfe9
commit 333defa
Showing
36 changed files
with
554 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
Workshops/IntroductionToEventSourcing/09-ApplicationLogic.EventStoreDB.Tests/Settings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
using Oakton; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
[assembly: TestFramework("ApplicationLogic.EventStoreDB.Tests.AssemblyFixture", "ApplicationLogic.EventStoreDB.Tests")] | ||
[assembly: CollectionBehavior(DisableTestParallelization = true)] | ||
|
||
namespace ApplicationLogic.EventStoreDB.Tests; | ||
|
||
public sealed class AssemblyFixture : XunitTestFramework | ||
{ | ||
public AssemblyFixture(IMessageSink messageSink) | ||
:base(messageSink) | ||
{ | ||
OaktonEnvironment.AutoStartHost = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ventSourcing/09-ApplicationLogic.EventStoreDB/Core/EventStoreDB/EventStoreDBExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Text.Json; | ||
using ApplicationLogic.EventStoreDB.Core.Entities; | ||
using ApplicationLogic.EventStoreDB.Core.Exceptions; | ||
using EventStore.Client; | ||
|
||
namespace ApplicationLogic.EventStoreDB.Core.EventStoreDB; | ||
|
||
public static class EventStoreDBExtensions | ||
{ | ||
public static Task<T?> AggregateStream<T, TEvent>( | ||
this EventStoreClient eventStore, | ||
Func<T> getInitial, | ||
Guid id, | ||
CancellationToken ct = default | ||
) where T : Aggregate<TEvent> => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
|
||
public static Task<T?> AggregateStream<T, TEvent>( | ||
this EventStoreClient eventStore, | ||
Func<T, TEvent, T> evolve, | ||
Func<T> getInitial, | ||
Guid id, | ||
CancellationToken cancellationToken = default | ||
) where T : class => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
|
||
public static Task Add<T>(this EventStoreClient eventStore, Guid id, T aggregate, CancellationToken ct) | ||
where T : class, IAggregate => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
|
||
public static Task Add<T>(this EventStoreClient eventStore, Guid id, object[] events, CancellationToken ct) | ||
where T : class => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
|
||
public static Task GetAndUpdate<T, TEvent>( | ||
this EventStoreClient eventStore, | ||
Func<T> getInitial, | ||
Guid id, | ||
Action<T> handle, | ||
CancellationToken ct | ||
) | ||
where T : Aggregate<TEvent> | ||
where TEvent: notnull => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
|
||
public static Task GetAndUpdate<T, TEvent>( | ||
this EventStoreClient eventStore, | ||
Func<T, TEvent, T> evolve, | ||
Func<T> getInitial, | ||
Guid id, | ||
Func<T, TEvent[]> handle, | ||
CancellationToken ct | ||
) | ||
where T : class | ||
where TEvent: notnull => | ||
throw new NotImplementedException("EventStoreDB Extensions not implemented!"); | ||
} |
29 changes: 0 additions & 29 deletions
29
...ToEventSourcing/09-ApplicationLogic.EventStoreDB/Core/Marten/DocumentSessionExtensions.cs
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...IntroductionToEventSourcing/09-ApplicationLogic.EventStoreDB/Core/Marten/EventMappings.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 27 additions & 21 deletions
48
...tionToEventSourcing/09-ApplicationLogic.EventStoreDB/Immutable/ShoppingCarts/Configure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
using ApplicationLogic.EventStoreDB.Core.Marten; | ||
using ApplicationLogic.EventStoreDB.Immutable.Pricing; | ||
using Marten; | ||
using EventStore.Client; | ||
using ApplicationLogic.EventStoreDB.Core.EventStoreDB; | ||
|
||
namespace ApplicationLogic.EventStoreDB.Immutable.ShoppingCarts; | ||
using static ShoppingCartEvent; | ||
|
||
public static class Configure | ||
{ | ||
private const string ModulePrefix = "immutable"; | ||
public static IServiceCollection AddImmutableShoppingCarts(this IServiceCollection services) | ||
{ | ||
public static IServiceCollection AddImmutableShoppingCarts(this IServiceCollection services) => | ||
services.AddSingleton<IProductPriceCalculator>(FakeProductPriceCalculator.Returning(100)); | ||
public static Task GetAndUpdate( | ||
this EventStoreClient eventStore, | ||
Guid id, | ||
Func<ShoppingCart, ShoppingCartEvent[]> handle, | ||
CancellationToken ct | ||
) => | ||
eventStore.GetAndUpdate( | ||
ShoppingCart.Evolve, | ||
ShoppingCart.Initial, | ||
id, | ||
handle, | ||
ct | ||
); | ||
|
||
return services; | ||
} | ||
public static StoreOptions ConfigureImmutableShoppingCarts(this StoreOptions options) | ||
{ | ||
options.Projections.LiveStreamAggregation<ShoppingCart>(); | ||
|
||
// this is needed as we're sharing document store and have event types with the same name | ||
options.MapEventWithPrefix<ShoppingCartOpened>(ModulePrefix); | ||
options.MapEventWithPrefix<ProductItemAddedToShoppingCart>(ModulePrefix); | ||
options.MapEventWithPrefix<ProductItemRemovedFromShoppingCart>(ModulePrefix); | ||
options.MapEventWithPrefix<ShoppingCartConfirmed>(ModulePrefix); | ||
options.MapEventWithPrefix<ShoppingCartCanceled>(ModulePrefix); | ||
|
||
return options; | ||
} | ||
public static Task<ShoppingCart?> GetShoppingCart( | ||
this EventStoreClient eventStore, | ||
Guid id, | ||
CancellationToken ct | ||
) => | ||
eventStore.AggregateStream<ShoppingCart, ShoppingCartEvent>( | ||
ShoppingCart.Evolve, | ||
ShoppingCart.Initial, | ||
id, | ||
ct | ||
); | ||
} |
Oops, something went wrong.