From 82d3f5b0ccc36f2524fccf5ffc2c504b201e6caa Mon Sep 17 00:00:00 2001 From: osoykan Date: Tue, 30 Jan 2018 01:30:17 +0300 Subject: [PATCH 1/2] Added StoveCommandContextAccessor to StoveComponentBase --- .../Commands/IStoveCommandContextAccessor.cs | 4 + src/Stove/StoveComponentBase.cs | 312 +----------------- test/Stove.TestBase/ApplicationTestBase.cs | 3 + .../Domain/SomeDomainService.cs | 21 +- .../SampleApplicationTestBase.cs | 1 - .../StoveComponentBase_Tests.cs | 16 +- 6 files changed, 56 insertions(+), 301 deletions(-) diff --git a/src/Stove/Commands/IStoveCommandContextAccessor.cs b/src/Stove/Commands/IStoveCommandContextAccessor.cs index cf661d7..6e5e275 100644 --- a/src/Stove/Commands/IStoveCommandContextAccessor.cs +++ b/src/Stove/Commands/IStoveCommandContextAccessor.cs @@ -23,6 +23,10 @@ public interface IStoveCommandContextAccessor /// IDisposable Use(Action contextCallback); + /// + /// Changes the current + /// + /// void Manipulate(Action contextCallback); } } diff --git a/src/Stove/StoveComponentBase.cs b/src/Stove/StoveComponentBase.cs index c39d1ec..84558ea 100644 --- a/src/Stove/StoveComponentBase.cs +++ b/src/Stove/StoveComponentBase.cs @@ -2,8 +2,8 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using System.Transactions; +using Stove.Commands; using Stove.Domain.Uow; using Stove.Log; using Stove.MQ; @@ -67,140 +67,32 @@ public IUnitOfWorkManager UnitOfWorkManager /// public IMessageBus MessageBus { get; set; } - protected void UseUow(Action act) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin()) - { - act(); - - uow.Complete(); - } - } - - protected Task UseUow(Func func, CancellationToken cancellationToken = default) - { - Task task; - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin()) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - - return task; - } - - protected void UseUow(Action act, IsolationLevel isolation) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions { IsolationLevel = isolation })) - { - act(); - - uow.Complete(); - } - } - - protected Task UseUow(Func func, IsolationLevel isolation, CancellationToken cancellationToken = default) - { - Task task; - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions { IsolationLevel = isolation })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - - return task; - } - - protected void UseUow(Action act, bool isTransactional) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions { IsTransactional = isTransactional })) - { - act(); - - uow.Complete(); - } - } - - protected Task UseUow(Func func, bool isTransactional, CancellationToken cancellationToken = default) - { - Task task; - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions { IsTransactional = isTransactional })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - - return task; - } - - protected void UseUow(Action act, TransactionScopeOption scope) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - Scope = scope - })) - { - act(); - - uow.Complete(); - } - } - - protected Task UseUow(Func func, TransactionScopeOption scope, CancellationToken cancellationToken = default) - { - Task task; - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - Scope = scope - })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - - return task; - } + /// + /// The accessor + /// + public IStoveCommandContextAccessor CommandContextAccessor { get; set; } - protected void UseUow(Action act, IsolationLevel isolation, TransactionScopeOption scope) + protected void CorrelatingBy(Action act, string correlationId) { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsolationLevel = isolation, - Scope = scope - })) + using (CommandContextAccessor.Use(correlationId)) { act(); - - uow.Complete(); } } - protected Task UseUow(Func func, IsolationLevel isolation, TransactionScopeOption scope, CancellationToken cancellationToken = default) + protected Task CorrelatingBy(Func func, string correlationId) { - Task task; - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions + using (CommandContextAccessor.Use(correlationId)) { - IsolationLevel = isolation, - Scope = scope - })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); + return func(); } - - return task; } - protected void UseUow(Action act, Action optsAction) + protected void UseUow(Action act, Action optsCallback = null) { var options = new UnitOfWorkOptions(); - optsAction(options); + optsCallback?.Invoke(options); using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) { @@ -210,11 +102,11 @@ protected void UseUow(Action act, Action optsAction) } } - protected Task UseUow(Func func, Action optsAction, CancellationToken cancellationToken = default) + protected Task UseUow(Func func, Action optsAction = null, CancellationToken cancellationToken = default) { var options = new UnitOfWorkOptions(); - optsAction(options); + optsAction?.Invoke(options); Task task; using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) @@ -227,178 +119,10 @@ protected Task UseUow(Func func, Action optsAction, Can return task; } - protected void UseUowIfNot(Action act) - { - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin()) - { - act(); - - uow.Complete(); - } - } - else - { - act(); - } - } - - protected Task UseUowIfNot(Func func, CancellationToken cancellationToken = default) - { - Task task; - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin()) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - } - else - { - task = func(); - } - - return task; - } - - protected void UseUowIfNot(Action act, bool isTransactional) - { - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsTransactional = isTransactional - })) - { - act(); - - uow.Complete(); - } - } - else - { - act(); - } - } - - protected Task UseUowIfNot(Func func, bool isTransactional, CancellationToken cancellationToken = default) - { - Task task; - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsTransactional = isTransactional - })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - } - else - { - task = func(); - } - - return task; - } - - protected void UseUowIfNot(Action act, IsolationLevel isolation) - { - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsolationLevel = isolation - })) - { - act(); - - uow.Complete(); - } - } - else - { - act(); - } - } - - protected Task UseUowIfNot(Func func, IsolationLevel isolation, CancellationToken cancellationToken = default) - { - Task task; - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsolationLevel = isolation - })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - } - else - { - task = func(); - } - - return task; - } - - protected void UseUowIfNot(Action act, IsolationLevel isolation, TransactionScopeOption scope) - { - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsolationLevel = isolation, - Scope = scope - })) - { - act(); - - uow.Complete(); - } - } - else - { - act(); - } - } - - protected Task UseUowIfNot(Func func, IsolationLevel isolation, TransactionScopeOption scope, CancellationToken cancellationToken = default) - { - Task task; - if (UnitOfWorkManager.Current == null) - { - using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(new UnitOfWorkOptions - { - IsolationLevel = isolation, - Scope = scope - })) - { - task = func(); - - uow.CompleteAsync(cancellationToken); - } - } - else - { - task = func(); - } - - return task; - } - - protected void UseUowIfNot(Action act, Action optsAction) + protected void UseUowIfNot(Action act, Action optsAction = null) { var options = new UnitOfWorkOptions(); - optsAction(options); + optsAction?.Invoke(options); if (UnitOfWorkManager.Current == null) { @@ -415,10 +139,10 @@ protected void UseUowIfNot(Action act, Action optsAction) } } - protected Task UseUowIfNot(Func func, Action optsAction, CancellationToken cancellationToken = default) + protected Task UseUowIfNot(Func func, Action optsAction = null, CancellationToken cancellationToken = default) { var options = new UnitOfWorkOptions(); - optsAction(options); + optsAction?.Invoke(options); Task task; if (UnitOfWorkManager.Current == null) diff --git a/test/Stove.TestBase/ApplicationTestBase.cs b/test/Stove.TestBase/ApplicationTestBase.cs index 169b64c..4228f2a 100644 --- a/test/Stove.TestBase/ApplicationTestBase.cs +++ b/test/Stove.TestBase/ApplicationTestBase.cs @@ -1,6 +1,7 @@ using Autofac.Extras.IocManager; using Stove.Bootstrapping; +using Stove.Commands; using Stove.Reflection.Extensions; using Stove.Runtime.Session; @@ -23,6 +24,8 @@ protected ApplicationTestBase(bool autoUnitOfWorkInterceptionEnabled = false) protected TestStoveSession StoveSession => The(); + protected IStoveCommandContextAccessor CommandContextAccessor => The(); + protected override void PreBuild() { } diff --git a/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs b/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs index 2facd57..b8aee9e 100644 --- a/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs +++ b/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs @@ -36,7 +36,7 @@ public async Task GetUserByName_async(string name) await UseUow(async () => { user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }, CancellationToken.None); + }, options => { }, CancellationToken.None); return user; } @@ -48,7 +48,7 @@ public async Task GetUserByName_async_With_IsolationLevel(string name) await UseUow(async () => { user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }, IsolationLevel.ReadCommitted); + }, options => { options.IsolationLevel = IsolationLevel.ReadCommitted; }); return user; } @@ -60,7 +60,7 @@ public User GetUserByName_with_isolationlevel(string name) UseUow(() => { user = _repository.FirstOrDefault(x => x.Name == name); - }, IsolationLevel.Chaos); + }, options => { options.IsolationLevel = IsolationLevel.Chaos; }); return user; } @@ -72,7 +72,7 @@ public User GetUserByName_isTransactional(string name) UseUow(() => { user = _repository.FirstOrDefault(x => x.Name == name); - }, true); + }); return user; } @@ -84,7 +84,7 @@ public async Task GetUserByName_async_isTransactional(string name) await UseUow(async () => { user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }, true); + }); return user; } @@ -99,5 +99,16 @@ await UseUowIfNot(async () => return msg; } + + public Task CreateUserByCorrelating(string name, string surname, string email, string correlationId) + { + return CorrelatingBy(() => + { + return UseUow(() => + { + return _repository.InsertAsync(User.Create(name, surname, email)); + }); + }, correlationId); + } } } diff --git a/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs b/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs index 326be80..69d08ac 100644 --- a/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs +++ b/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs @@ -10,7 +10,6 @@ using Stove.EntityFramework; using Stove.Mapster; -using Stove.Runtime.Session; using Stove.TestBase; using Stove.Tests.SampleApplication.Domain; using Stove.Tests.SampleApplication.Domain.Entities; diff --git a/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs b/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs index f4e193b..f160a28 100644 --- a/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs +++ b/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs @@ -1,7 +1,9 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Shouldly; +using Stove.Events.Bus; using Stove.Tests.SampleApplication; using Stove.Tests.SampleApplication.Domain; using Stove.Tests.SampleApplication.Domain.Entities; @@ -69,5 +71,17 @@ public async Task UseUow_and_auditing() message.CreatorUserId.ShouldBe(266); } } + + [Fact] + public async Task UseUow_and_correlatingBy_should_work() + { + string correlationId = Guid.NewGuid().ToString(); + The().Register((@event, headers) => + { + headers[StoveConsts.Events.CorrelationId].ShouldBe(correlationId); + }); + + await The().CreateUserByCorrelating("oguzhan", "soykan", "oguzhansoykan@gmail.com", correlationId); + } } } From 31de56bc4094ceff06a309fc1b1e65ebbf020f48 Mon Sep 17 00:00:00 2001 From: Oguzhan Soykan Date: Tue, 30 Jan 2018 10:52:00 +0300 Subject: [PATCH 2/2] Some of UseUow and CorrelatingBy added to StoveComponentBase --- common.props | 2 +- src/Stove/StoveComponentBase.cs | 114 ++++++++++++++++-- .../Threading/Extensions/TaskExtensions.cs | 27 +++++ .../Domain/SomeDomainService.cs | 51 ++------ .../StoveComponentBase_Tests.cs | 2 +- 5 files changed, 141 insertions(+), 55 deletions(-) create mode 100644 src/Stove/Threading/Extensions/TaskExtensions.cs diff --git a/common.props b/common.props index a7029c6..5d06b6b 100644 --- a/common.props +++ b/common.props @@ -1,6 +1,6 @@ - 2.3.1 + 2.3.2 $(NoWarn);CS1591 https://raw.githubusercontent.com/osoykan/Stove/master/stove.png https://github.com/osoykan/Stove diff --git a/src/Stove/StoveComponentBase.cs b/src/Stove/StoveComponentBase.cs index 84558ea..e091bee 100644 --- a/src/Stove/StoveComponentBase.cs +++ b/src/Stove/StoveComponentBase.cs @@ -8,6 +8,7 @@ using Stove.Log; using Stove.MQ; using Stove.ObjectMapping; +using Stove.Threading.Extensions; namespace Stove { @@ -68,7 +69,7 @@ public IUnitOfWorkManager UnitOfWorkManager public IMessageBus MessageBus { get; set; } /// - /// The accessor + /// The accessor /// public IStoveCommandContextAccessor CommandContextAccessor { get; set; } @@ -80,6 +81,14 @@ protected void CorrelatingBy(Action act, string correlationId) } } + protected TResponse CorrelatingBy(Func func, string correlationId) + { + using (CommandContextAccessor.Use(correlationId)) + { + return func(); + } + } + protected Task CorrelatingBy(Func func, string correlationId) { using (CommandContextAccessor.Use(correlationId)) @@ -88,6 +97,14 @@ protected Task CorrelatingBy(Func func, string correlationId) } } + protected Task CorrelatingBy(Func> func, string correlationId) + { + using (CommandContextAccessor.Use(correlationId)) + { + return func(); + } + } + protected void UseUow(Action act, Action optsCallback = null) { var options = new UnitOfWorkOptions(); @@ -102,21 +119,51 @@ protected void UseUow(Action act, Action optsCallback = null) } } - protected Task UseUow(Func func, Action optsAction = null, CancellationToken cancellationToken = default) + protected TResponse UseUow(Func func, Action optsCallback = null) + { + var options = new UnitOfWorkOptions(); + + optsCallback?.Invoke(options); + + TResponse response; + using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) + { + response = func(); + + uow.Complete(); + } + + return response; + } + + protected async Task UseUow(Func func, Action optsAction = null, CancellationToken cancellationToken = default) { var options = new UnitOfWorkOptions(); optsAction?.Invoke(options); - Task task; using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) { - task = func(); + await func().NotOnCapturedContext(); - uow.CompleteAsync(cancellationToken); + await uow.CompleteAsync(cancellationToken).NotOnCapturedContext(); } + } + + protected async Task UseUow(Func> func, Action optsAction = null, CancellationToken cancellationToken = default) + { + var options = new UnitOfWorkOptions(); + optsAction?.Invoke(options); - return task; + TResponse response; + using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) + { + response = await func().NotOnCapturedContext(); + + await uow.CompleteAsync(cancellationToken).NotOnCapturedContext(); + } + + return response; } protected void UseUowIfNot(Action act, Action optsAction = null) @@ -139,27 +186,70 @@ protected void UseUowIfNot(Action act, Action optsAction = nu } } - protected Task UseUowIfNot(Func func, Action optsAction = null, CancellationToken cancellationToken = default) + protected TResponse UseUowIfNot(Func func, Action optsAction = null) + { + var options = new UnitOfWorkOptions(); + optsAction?.Invoke(options); + + TResponse response; + if (UnitOfWorkManager.Current == null) + { + using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) + { + response = func(); + + uow.Complete(); + } + } + else + { + response = func(); + } + + return response; + } + + protected async Task UseUowIfNot(Func func, Action optsAction = null, CancellationToken cancellationToken = default) + { + var options = new UnitOfWorkOptions(); + optsAction?.Invoke(options); + + if (UnitOfWorkManager.Current == null) + { + using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) + { + await func().NotOnCapturedContext(); + + await uow.CompleteAsync(cancellationToken).NotOnCapturedContext(); + } + } + else + { + await func().NotOnCapturedContext(); + } + } + + protected async Task UseUowIfNot(Func> func, Action optsAction = null, CancellationToken cancellationToken = default) { var options = new UnitOfWorkOptions(); optsAction?.Invoke(options); - Task task; + TResponse response; if (UnitOfWorkManager.Current == null) { using (IUnitOfWorkCompleteHandle uow = UnitOfWorkManager.Begin(options)) { - task = func(); + response = await func().NotOnCapturedContext(); - uow.CompleteAsync(cancellationToken); + await uow.CompleteAsync(cancellationToken).NotOnCapturedContext(); } } else { - task = func(); + response = await func().NotOnCapturedContext(); } - return task; + return response; } protected void OnUowCompleted(Action action) diff --git a/src/Stove/Threading/Extensions/TaskExtensions.cs b/src/Stove/Threading/Extensions/TaskExtensions.cs new file mode 100644 index 0000000..dacd7fc --- /dev/null +++ b/src/Stove/Threading/Extensions/TaskExtensions.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Stove.Threading.Extensions +{ + /// + /// Represents extensions on Tasks. + /// + public static class TaskExtensions + { + /// + /// ConfigureAwait(false) + /// + public static ConfiguredTaskAwaitable NotOnCapturedContext(this Task task) + { + return task.ConfigureAwait(false); + } + + /// + /// ConfigureAwait(false) + /// + public static ConfiguredTaskAwaitable NotOnCapturedContext(this Task task) + { + return task.ConfigureAwait(false); + } + } +} diff --git a/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs b/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs index b8aee9e..99ecccf 100644 --- a/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs +++ b/test/Stove.Tests.SampleApplication/Domain/SomeDomainService.cs @@ -22,10 +22,7 @@ public SomeDomainService(IRepository repository, IRepository mess public User GetUserByName(string name) { User user = null; - UseUow(() => - { - user = _repository.FirstOrDefault(x => x.Name == name); - }); + UseUow(() => { user = _repository.FirstOrDefault(x => x.Name == name); }); return user; } @@ -33,10 +30,7 @@ public User GetUserByName(string name) public async Task GetUserByName_async(string name) { User user = null; - await UseUow(async () => - { - user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }, options => { }, CancellationToken.None); + await UseUow(async () => { user = await _repository.FirstOrDefaultAsync(x => x.Name == name); }, options => { }, CancellationToken.None); return user; } @@ -45,10 +39,7 @@ public async Task GetUserByName_async_With_IsolationLevel(string name) { User user = null; - await UseUow(async () => - { - user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }, options => { options.IsolationLevel = IsolationLevel.ReadCommitted; }); + await UseUow(async () => { user = await _repository.FirstOrDefaultAsync(x => x.Name == name); }, options => { options.IsolationLevel = IsolationLevel.ReadCommitted; }); return user; } @@ -57,10 +48,7 @@ public User GetUserByName_with_isolationlevel(string name) { User user = null; - UseUow(() => - { - user = _repository.FirstOrDefault(x => x.Name == name); - }, options => { options.IsolationLevel = IsolationLevel.Chaos; }); + UseUow(() => { user = _repository.FirstOrDefault(x => x.Name == name); }, options => { options.IsolationLevel = IsolationLevel.Chaos; }); return user; } @@ -69,45 +57,26 @@ public User GetUserByName_isTransactional(string name) { User user = null; - UseUow(() => - { - user = _repository.FirstOrDefault(x => x.Name == name); - }); + UseUow(() => { user = _repository.FirstOrDefault(x => x.Name == name); }); return user; } - public async Task GetUserByName_async_isTransactional(string name) + public Task GetUserByName_async_isTransactional(string name) { - User user = null; - - await UseUow(async () => - { - user = await _repository.FirstOrDefaultAsync(x => x.Name == name); - }); - - return user; + return UseUow(() => { return _repository.FirstOrDefaultAsync(x => x.Name == name); }); } public async Task CreateMessageAndGet(string message) { - Message msg = null; - await UseUowIfNot(async () => - { - msg = await _messageRepository.InsertAsync(new Message(message)); - }); - - return msg; + return await UseUowIfNot(async () => await _messageRepository.InsertAsync(new Message(message))); } - public Task CreateUserByCorrelating(string name, string surname, string email, string correlationId) + public Task CreateUserByCorrelating(string name, string surname, string email, string correlationId) { return CorrelatingBy(() => { - return UseUow(() => - { - return _repository.InsertAsync(User.Create(name, surname, email)); - }); + return UseUow(() => _repository.InsertAsync(User.Create(name, surname, email))); }, correlationId); } } diff --git a/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs b/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs index f160a28..fee17f6 100644 --- a/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs +++ b/test/Stove.Tests.SampleApplication/StoveComponentBase_Tests.cs @@ -78,7 +78,7 @@ public async Task UseUow_and_correlatingBy_should_work() string correlationId = Guid.NewGuid().ToString(); The().Register((@event, headers) => { - headers[StoveConsts.Events.CorrelationId].ShouldBe(correlationId); + headers[StoveConsts.Events.CausationId].ShouldBe(correlationId); }); await The().CreateUserByCorrelating("oguzhan", "soykan", "oguzhansoykan@gmail.com", correlationId);