-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: David Boike <[email protected]>
- Loading branch information
1 parent
d374e8d
commit 7223e5f
Showing
2 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace NServiceBus.Testing.Tests.Sagas | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class SagaCompletion | ||
{ | ||
[Test] | ||
public async Task MarkStartedSagaAsComplete() | ||
{ | ||
var saga = new TestableSaga<TestSaga, TestSagaData>(); | ||
|
||
var result = await saga.Handle(new StartSagaMessage() { CorrelationId = Guid.NewGuid() }); | ||
|
||
Assert.IsTrue(result.Completed); | ||
} | ||
|
||
class TestSaga : NServiceBus.Saga<TestSagaData>, IAmStartedByMessages<StartSagaMessage> | ||
{ | ||
protected override void ConfigureHowToFindSaga(SagaPropertyMapper<TestSagaData> mapper) => mapper | ||
.MapSaga(d => d.CorrelationId) | ||
.ToMessage<StartSagaMessage>(m => m.CorrelationId); | ||
|
||
public Task Handle(StartSagaMessage message, IMessageHandlerContext context) | ||
{ | ||
MarkAsComplete(); | ||
return Task.FromResult(0); | ||
} | ||
} | ||
|
||
class TestSagaData : ContainSagaData | ||
{ | ||
public Guid CorrelationId { get; set; } | ||
} | ||
|
||
class StartSagaMessage : IMessage | ||
{ | ||
public Guid CorrelationId { get; set; } | ||
} | ||
} | ||
} |
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