Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to send implementing object as a message #139

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/FubuTransportation.Testing/Sagas/SagaBehaviorTester.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using FubuMVC.Core.Behaviors;
using FubuMVC.Core.Runtime;
using FubuTestingSupport;
Expand Down Expand Up @@ -99,6 +102,7 @@ public void updates_and_deletes_nothing()
public abstract class SagaBehaviorContext : InteractionContext<SagaBehavior<SagaState, Message1, ITestingSagaHandler>>
{
protected Message1 theMessage;
protected IList<Message1> theMessageList;
protected SagaState theInitialState;
protected ITestingSagaHandler theHandler;
protected IActionBehavior theInnerBehavior;
Expand All @@ -108,8 +112,11 @@ public abstract class SagaBehaviorContext : InteractionContext<SagaBehavior<Saga
protected override void beforeEach()
{
theMessage = new Message1();
MockFor<IFubuRequest>().Stub(x => x.Get<Message1>())
.Return(theMessage);
theMessageList = new List<Message1>{new Message1()};
MockFor<IFubuRequest>().Stub(x => x.Find<Message1>())
.Return(theMessageList);

theMessage = theMessageList.FirstOrDefault();

theInitialState = new SagaState();

Expand Down
22 changes: 13 additions & 9 deletions src/FubuTransportation.Testing/Sagas/SagaIntegrationTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class SagaIntegrationTester
public void SetUp()
{
FubuTransport.SetupForInMemoryTesting();

theLogger = new SagaLogger();
theContainer = new Container(x =>
{
Expand All @@ -50,9 +49,9 @@ public void TearDown()
{
FubuTransport.Reset();
theRuntime.Dispose();
theContainer.GetInstance<InMemoryTransport>().ClearAll();
}


[Test]
public void try_to_run_the_saga_from_beginning_to_end()
{
Expand Down Expand Up @@ -86,7 +85,7 @@ public void try_to_run_the_saga_from_beginning_to_end_with_implementing_class()
.Count().ShouldEqual(1); // should be the same correlation id all the way through

messages
.ShouldHaveTheSameElementsAs("Started Jeremy", "Updated Jeremy", "Finished with Updated Jeremy!");
.ShouldHaveTheSameElementsAs("Implemented Jeremy", "Started Jeremy", "Updated Implemented Jeremy", "Finished with Updated Implemented Jeremy!");
}
}

Expand Down Expand Up @@ -203,19 +202,24 @@ public bool IsCompleted()
return _isCompleted;
}

public void Handle(ImplementingClass message)
{

}

public TestSagaUpdate Handle(TestSagaStart start)
{
if(State == null)
State = new TestSagaState { Id = Guid.NewGuid(), Name = start.Name };
_logger.Trace(State.Id, "Started " + start.Name);

return new TestSagaUpdate { CorrelationId = State.Id };
}

public void Handle(ImplementingClass implement)
{
State = new TestSagaState{Id = Guid.NewGuid(), Name = implement.Name };

_logger.Trace(State.Id, "Implemented " + State.Name);

State.Name = "Implemented " + State.Name;
}

public TestSagaFinish Handle(TestSagaUpdate update)
{
_logger.Trace(State.Id, "Updated " + State.Name);
Expand All @@ -239,7 +243,7 @@ public class TestSagaStart

public class ImplementingClass : TestSagaStart
{

}

public class TestSagaUpdate
Expand Down