コード例 #1
0
        public void Dispose()
        {
            _commandProcessor.Dispose();

            //_should_throw_an_exception
            _exception.Should().BeOfType <InvalidOperationException>();
        }
        //TODO: Because we use a global logger with Serilog, this won't run in parallel
        //[Fact]
        public async Task When_A_Request_Logger_Is_In_The_Pipeline_Async()
        {
            Log.Logger = new LoggerConfiguration().MinimumLevel.Information().WriteTo.TestCorrelator().CreateLogger();
            using (var context = TestCorrelator.CreateContext())
            {
                var myCommand = new MyCommand();

                var registry = new SubscriberRegistry();
                registry.RegisterAsync <MyCommand, MyLoggedHandlerAsync>();

                var container = new ServiceCollection();
                container.AddTransient <MyLoggedHandlerAsync, MyLoggedHandlerAsync>();
                container.AddTransient(typeof(RequestLoggingHandlerAsync <>), typeof(RequestLoggingHandlerAsync <>));

                var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider());

                var commandProcessor = new CommandProcessor(registry, handlerFactory, handlerFactory,
                                                            new InMemoryRequestContextFactory(), new PolicyRegistry());


                await commandProcessor.SendAsync(myCommand);

                //_should_log_the_request_handler_call
                //_should_log_the_type_of_handler_in_the_call
                TestCorrelator.GetLogEventsFromContextGuid(context.Guid)
                .Should().Contain(x => x.MessageTemplate.Text.StartsWith("Logging handler pipeline call"))
                .Which.Properties["1"].ToString().Should().Be($"\"{typeof(MyCommand)}\"");

                commandProcessor?.Dispose();
            }
        }
コード例 #3
0
        public void Cleanup()
        {
            _commandProcessor.Dispose();

            // _should_throw_an_exception
            Assert.IsInstanceOf <InvalidOperationException>(_exception);
        }
コード例 #4
0
        public void when_disposing_processor_then_disposes_receiver_if_disposable()
        {
            var receiver   = new Mock <IMessageReceiver>();
            var disposable = receiver.As <IDisposable>();

            var processor = new CommandProcessor(receiver.Object, Mock.Of <ISerializer>());

            processor.Dispose();

            disposable.Verify(x => x.Dispose());
        }
コード例 #5
0
 public void Dispose()
 {
     _commandProcessor?.Dispose();
     GC.SuppressFinalize(this);
 }
コード例 #6
0
 public void Dispose()
 {
     _commandProcessor?.Dispose();
 }
コード例 #7
0
 public void Dispose()
 {
     MyFeatureSwitchedConfigHandler.CommandReceived = false;
     _commandProcessor?.Dispose();
     GC.SuppressFinalize(this);
 }
コード例 #8
0
 public void Cleanup()
 {
     _commandProcessor.Dispose();
 }
コード例 #9
0
        public void when_disposing_processor_then_no_op_if_receiver_not_disposable()
        {
            var processor = new CommandProcessor(Mock.Of <IMessageReceiver>(), Mock.Of <ISerializer>());

            processor.Dispose();
        }