<commit_before>using System;
using System.IO;
using System.Net;
using System.Transactions;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using Rhino.Mocks;
using Rhino.Queues;
using Rhino.Queues.Model;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
using Rhino.ServiceBus.MessageModules;
using Rhino.ServiceBus.Messages;
using Xunit;

namespace Rhino.ServiceBus.Tests.RhinoQueues
{
    public class MessageLoggingTests : WithDebugging, IDisposable
    {
        private readonly IWindsorContainer container;
        private readonly ITransport transport;
        private readonly IMessageSerializer messageSerializer;
        private readonly QueueManager queue;
        private readonly Uri logEndpoint = new Uri("rhino.queues://localhost:2202/log_endpoint");

        public MessageLoggingTests()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log_endpoint.esent");
            if (Directory.Exists(path))
                Directory.Delete(path, true);

            container = new WindsorContainer(new XmlInterpreter("RhinoQueues/RhinoQueues.config"));
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container.Register(Component.For<MessageLoggingModule>());

            messageSerializer = container.Resolve<IMessageSerializer>();
            queue = new QueueManager(new IPEndPoint(IPAddress.Any, 2202), path);
            queue.CreateQueues("log_endpoint");
            

            var innerTransport = container.Resolve<ITransport>();
            innerTransport.Start();
            transport = MockRepository.GenerateStub<ITransport>();
            transport.Stub(t => t.Send(null, null)).IgnoreArguments()
                .Do((Delegates.Action<Endpoint, object[]>)(innerTransport.Send));
        }

        [Fact]
        public void Will_send_message_about_serialization_failure()
        {
            var module = container.Resolve<MessageLoggingModule>(new { logQueue = logEndpoint });
            module.Init(transport, null);

            transport.Raise(x => x.MessageSerializationException += null,
                new CurrentMessageInformation { MessageId = Guid.NewGuid() },
                new InvalidOperationException("Operation is not valid due to the current state of the object."));
<commit_msg>Updated message logging tests for new container setup.<commit_after>using System;
using System.IO;
using System.Net;
using System.Transactions;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Rhino.Mocks;
using Rhino.Queues;
using Rhino.Queues.Model;
using Rhino.ServiceBus.Impl;
using Rhino.ServiceBus.Internal;
using Rhino.ServiceBus.MessageModules;
using Rhino.ServiceBus.Messages;
using Xunit;

namespace Rhino.ServiceBus.Tests.RhinoQueues
{
    public class MessageLoggingTests : WithDebugging, IDisposable
    {
        private readonly IWindsorContainer container;
        private readonly ITransport transport;
        private readonly IMessageSerializer messageSerializer;
        private readonly QueueManager queue;
        private readonly Uri logEndpoint = new Uri("rhino.queues://localhost:2202/log_endpoint");

        public MessageLoggingTests()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log_endpoint.esent");
            if (Directory.Exists(path))
                Directory.Delete(path, true);

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
                .UseCastleWindsor(container)
                .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
                .Configure();
            container.Register(Component.For<MessageLoggingModule>());

            messageSerializer = container.Resolve<IMessageSerializer>();
            queue = new QueueManager(new IPEndPoint(IPAddress.Any, 2202), path);
            queue.CreateQueues("log_endpoint");
            

            var innerTransport = container.Resolve<ITransport>();
            innerTransport.Start();
            transport = MockRepository.GenerateStub<ITransport>();
            transport.Stub(t => t.Send(null, null)).IgnoreArguments()
                .Do((Delegates.Action<Endpoint, object[]>)(innerTransport.Send));
        }

        [Fact]
        public void Will_send_message_about_serialization_failure()
        {
            var module = container.Resolve<MessageLoggingModule>(new { logQueue = logEndpoint });
            module.Init(transport, null);

            transport.Raise(x => x.MessageSerializationException += null,
                new CurrentMessageInformation { MessageId = Guid.NewGuid() },
                new InvalidOperationException("Operation is not valid due to the current state of the object."));

{'fraction_non_alphanumeric': 0.09256198347107437, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 3.057837384744342, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5933208', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1208, 'n_words': 262}