public void should_stop_transport_and_unregister_from_directory() { var sequence = new SetupSequence(); _directoryMock.Setup(x => x.Unregister(_bus)); _bus.Start(); _bus.Stop(); sequence.Verify(); _transport.IsStopped.ShouldBeTrue(); }
public void should_stop_dispatcher_before_transport() { var transportMock = new Mock <ITransport>(); var bus = new Bus(transportMock.Object, _directoryMock.Object, _messageSerializer, _messageDispatcherMock.Object, new DefaultMessageSendingStrategy(), new DefaultStoppingStrategy(), _configuration.Object); var sequence = new SetupSequence(); _messageDispatcherMock.Setup(dispatch => dispatch.Stop()).InSequence(sequence); transportMock.Setup(transport => transport.Stop()).InSequence(sequence); bus.Configure(_self.Id, "test"); bus.Start(); bus.Stop(); sequence.Verify(); }
public void should_invoke_initializers_in_order(bool invertOrder) { var container = new Container(); var initializers = Enumerable.Range(0, 10).Select(CreateMockInitializer).Reverse().ToArray(); AddInitializersToContainer(container, initializers.Select(x => x.Object).ToArray()); var setupSequence = new SetupSequence(); (invertOrder ? initializers.Reverse() : initializers).ForEach(x => x.Setup(init => init.BeforeStart()).InSequence(setupSequence)); container.CallActionOnInitializers(init => init.BeforeStart(), invertOrder); setupSequence.Verify(); }
public void should_initialize_transport_and_register_on_directory() { AddInvoker <FakeCommand>(shouldBeSubscribedOnStartup: true); var sequence = new SetupSequence(); _messageDispatcherMock.Setup(x => x.LoadMessageHandlerInvokers()).InSequence(sequence); _transport.Started += sequence.GetCallback(); _directoryMock.Setup(x => x.Register(_bus, It.Is <Peer>(p => p.DeepCompare(_self)), It.IsAny <IEnumerable <Subscription> >())).InSequence(sequence); _transport.Registered += sequence.GetCallback(); _bus.Start(); sequence.Verify(); _transport.IsStarted.ShouldBeTrue(); _transport.IsRegistered.ShouldBeTrue(); }