public void the_order() { var container = new Container(); using (var runtime = FubuTransport.For <Defaults>().StructureMap(container).Bootstrap()) { var handlers = container.GetInstance <IHandlerPipeline>().ShouldBeOfType <HandlerPipeline>().Handlers; container.Dispose(); handlers[0].ShouldBeOfType <DelayedEnvelopeHandler>(); handlers[1].ShouldBeOfType <ResponseEnvelopeHandler>(); handlers[2].ShouldBeOfType <ChainExecutionEnvelopeHandler>(); handlers[3].ShouldBeOfType <NoSubscriberHandler>(); } }
public void SetUp() { theTransportRegistry = FubuTransportRegistry.Empty(); theTransportRegistry.Handlers.DisableDefaultHandlerSource(); theTransportRegistry.EnableInMemoryTransport(); TestMessageRecorder.Clear(); _invoker = new Lazy <IChainInvoker>(() => { var container = new Container(); theRuntime = FubuTransport.For(theTransportRegistry).StructureMap(container).Bootstrap(); return(container.GetInstance <IChainInvoker>()); }); theCallback = MockRepository.GenerateMock <IMessageCallback>(); theContextIs(); }
public void successfully_retries_now() { MessageThatBombsHandler.Throws = 2; MessageThatBombsHandler.Attempts = 0; MessageThatBombsHandler.Successful = null; using (var runtime = FubuTransport.For <RetryNoOnDbConcurrencyRegistry>() .StructureMap(new Container()) .Bootstrap()) { var pipeline = runtime.Factory.Get <IHandlerPipeline>(); pipeline.Invoke(new Envelope { Message = new MessageThatBombs(), Callback = MockRepository.GenerateMock <IMessageCallback>() }); } MessageThatBombsHandler.Successful.ShouldNotBeNull(); MessageThatBombsHandler.Attempts.ShouldBeGreaterThan(1); }
public FubuTransportSystem(ApplicationSettings settings) : base(settings) { FubuTransport.SetupForTesting(); // Uses FubuMode.SetUpTestingMode(); AddContextualProvider <MessageContextualInfoProvider>(); OnStartup <IMessagingSession>(x => Bottles.Services.Messaging.EventAggregator.Messaging.AddListener(x)); // Clean up all the existing queue state to prevent test pollution OnContextCreation <TransportCleanup>(cleanup => { cleanup.ClearAll(); RemoteSubSystems.Each(x => x.Runner.SendRemotely(new ClearAllTransports())); }); OnContextCreation <IMessagingSession>( x => RemoteSubSystems.Each(sys => sys.Runner.Messaging.AddListener(x))); OnContextCreation(TestNodes.Reset); }
public void SetUp() { InMemoryQueueManager.ClearAll(); FubuTransport.Reset(); theSettings = new ConfiguredSettings { Upstream = "memory://foo".ToUri(), Outbound = "memory://bar".ToUri() }; theContainer = new Container(x => { x.For <ConfiguredSettings>().Use(theSettings); }); theRuntime = FubuTransport.For <ConfiguredFubuRegistry>().StructureMap(theContainer) .Bootstrap(); theGraph = theContainer.GetInstance <ChannelGraph>(); }
public void successfully_does_composite_continuations() { MessageThatThrowsHandler.ThrowsUntilAttemptNumber = 3; MessageThatThrowsHandler.Attempts = 0; MessageThatThrowsHandler.Successful = null; CounterContinuation.Counter = 0; using (var runtime = FubuTransport.For <CountAndRetryOnExceptionRegistry>() .StructureMap(new Container()) .Bootstrap()) { var pipeline = runtime.Factory.Get <IHandlerPipeline>(); pipeline.Invoke(new Envelope { Message = new MessageThatThrows(), Callback = MockRepository.GenerateMock <IMessageCallback>() }); } CounterContinuation.Counter.ShouldEqual(2); MessageThatThrowsHandler.Attempts.ShouldEqual(3); MessageThatThrowsHandler.Successful.ShouldNotBeNull(); }
public void ordered_the_way_we_expect_it_to_be() { AsyncWatcher.Clear(); using (var runtime = FubuTransport.For <AsyncRegistry>().StructureMap().Bootstrap()) { var invoker = runtime.Factory.Get <IChainInvoker>(); var message = new Foo { Name = "Buck Rogers" }; invoker.InvokeNow(message); Wait.Until(() => AsyncWatcher.Messages.Count() == 4); AsyncWatcher.Messages.ElementAt(0).ShouldEqual("wrapper:start"); AsyncWatcher.Messages.ElementAt(1).ShouldEndWith("Buck Rogers"); AsyncWatcher.Messages.ElementAt(2).ShouldEndWith("Buck Rogers"); AsyncWatcher.Messages.ElementAt(3).ShouldEndWith("wrapper:finish"); } }
public void send_now_is_handled_right_now() { using (var container = new Container()) { using (var runtime = FubuTransport.For(x => { x.EnableInMemoryTransport(); x.Handlers.DisableDefaultHandlerSource(); x.Handlers.Include <SimpleHandler <OneMessage> >(); }).StructureMap(container).Bootstrap()) { var serviceBus = container.GetInstance <IServiceBus>(); TestMessageRecorder.Clear(); var message = new OneMessage(); serviceBus.Consume(message); TestMessageRecorder.ProcessedFor <OneMessage>().Single().Message .ShouldBeTheSameAs(message); } } }
public FubuApplication BuildApplication() { return(FubuTransport.For <ServiceRegistry>().StructureMap()); }
public void TearDown() { _runtime.Dispose(); FubuTransport.Reset(); }
public void TearDown() { FubuTransport.Reset(); }
public FubuApplication BuildApplication() { return(FubuTransport.For <GettingStartedTransportRegistry>() .StructureMap(new Container())); }
public SampleSystem() { OnContextCreation <SystemUnderTest.MessageRecorder>(x => x.Messages.Clear()); FubuTransport.SetupForInMemoryTesting <TestSettings>(); }
internal void Execute(IScenarioWriter writer) { TraceListener[] listeners = new TraceListener[Debug.Listeners.Count]; Debug.Listeners.CopyTo(listeners, 0); Debug.Listeners.Clear(); FubuTransport.SetupForInMemoryTesting(); InMemoryQueueManager.ClearAll(); TestMessageRecorder.Clear(); MessageHistory.ClearAll(); _configurations.Each(x => x.SpinUp()); writer.WriteTitle(Title); using (writer.Indent()) { writeArrangement(writer); writer.WriteLine("Actions"); using (writer.Indent()) { _steps.Each(x => { x.PreviewAct(writer); try { x.Act(writer); } catch (Exception e) { writer.Exception(e); } }); } var success = Wait.Until(() => { return(!MessageHistory.Outstanding().Any()); }, timeoutInMilliseconds: 60000); Debug.Listeners.AddRange(listeners); if (success) { writer.WriteLine("Messages are all accounted for"); } else { writer.WriteLine("Messages are outstanding:"); MessageHistory.Outstanding().Each(x => Debug.WriteLine(x)); } writer.BlankLine(); _configurations.Each(x => x.SafeDispose()); writer.WriteLine("Assertions"); using (writer.Indent()) { _steps.Each(x => { x.PreviewAssert(writer); x.Assert(writer); }); } writer.BlankLine(); if (TestMessageRecorder.AllProcessed.Any()) { writer.WriteLine("Messages Received"); TestMessageRecorder.AllProcessed.Each(x => { writer.Bullet("{0} received by {1}", x.Message.GetType().Name, x.Message.Source); }); } else { writer.WriteLine("No messages were received!"); } var unexpectedMessages = TestMessageRecorder.AllProcessed.Where(x => !_steps.Any(step => step.MatchesSentMessage(x.Message))) .ToArray(); if (unexpectedMessages.Any()) { writer.BlankLine(); writer.WriteLine("Found unexpected messages"); unexpectedMessages.Each(x => writer.Failure(x.ToString())); } } }
public void TearDown() { InMemoryQueueManager.ClearAll(); FubuTransport.Reset(); theRuntime.Dispose(); }