diff --git a/src/FubuTransportation.Testing/Sagas/SagaBehaviorTester.cs b/src/FubuTransportation.Testing/Sagas/SagaBehaviorTester.cs index e2b121c..2cf9a4a 100644 --- a/src/FubuTransportation.Testing/Sagas/SagaBehaviorTester.cs +++ b/src/FubuTransportation.Testing/Sagas/SagaBehaviorTester.cs @@ -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; @@ -99,6 +102,7 @@ public void updates_and_deletes_nothing() public abstract class SagaBehaviorContext : InteractionContext> { protected Message1 theMessage; + protected IList theMessageList; protected SagaState theInitialState; protected ITestingSagaHandler theHandler; protected IActionBehavior theInnerBehavior; @@ -108,8 +112,11 @@ public abstract class SagaBehaviorContext : InteractionContext().Stub(x => x.Get()) - .Return(theMessage); + theMessageList = new List{new Message1()}; + MockFor().Stub(x => x.Find()) + .Return(theMessageList); + + theMessage = theMessageList.FirstOrDefault(); theInitialState = new SagaState(); diff --git a/src/FubuTransportation.Testing/Sagas/SagaIntegrationTester.cs b/src/FubuTransportation.Testing/Sagas/SagaIntegrationTester.cs index 4bd8f13..b496ba4 100644 --- a/src/FubuTransportation.Testing/Sagas/SagaIntegrationTester.cs +++ b/src/FubuTransportation.Testing/Sagas/SagaIntegrationTester.cs @@ -31,7 +31,6 @@ public class SagaIntegrationTester public void SetUp() { FubuTransport.SetupForInMemoryTesting(); - theLogger = new SagaLogger(); theContainer = new Container(x => { @@ -50,9 +49,9 @@ public void TearDown() { FubuTransport.Reset(); theRuntime.Dispose(); + theContainer.GetInstance().ClearAll(); } - [Test] public void try_to_run_the_saga_from_beginning_to_end() { @@ -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!"); } } @@ -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); @@ -239,7 +243,7 @@ public class TestSagaStart public class ImplementingClass : TestSagaStart { - + } public class TestSagaUpdate