<commit_before>using System;
using System.Threading;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace MassTransit.ServiceBus.Tests
{
    [TestFixture]
    public class When_Publishing_A_Message :
        ServiceBusSetupFixture
    {
        [Test]
        public void The_Message_Should_Be_Delivered_To_All_Subscribers()
        {
			bool _updated = false;
        	ManualResetEvent _updateEvent = new ManualResetEvent(false);

			_serviceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
			{
				_updated = true;
				_updateEvent.Set();
			};

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

        [Test]
        public void The_Message_Should_Be_Handled_By_A_Remote_Service()
        {
			bool _updated = false;
			ManualResetEvent _updateEvent = new ManualResetEvent(false);

			_remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
			{
				_updated = true;
				_updateEvent.Set();
			};

        	Thread.Sleep(TimeSpan.FromSeconds(5));

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

        [Test]
        public void The_Message_Should_Be_Handled_By_A_Remote_Service_And_Replyable()
        {
            bool _updated = false;
            bool _replied = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            EventHandler<MessageReceivedEventArgs<UpdateMessage>> handler = delegate(object sender, MessageReceivedEventArgs<UpdateMessage> args)
            {
                _updated = true;
                _updateEvent.Set();
                _remoteServiceBus.Send(args.Envelope.ReturnTo, new UpdateMessage());
            };

            _remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += handler;
            _serviceBus.Subscribe<UpdateMessage>().MessageReceived += delegate { _replied = true; };

            Thread.Sleep(TimeSpan.FromSeconds(5));

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
            Assert.That(_replied, Is.True, "Reply Failed");
        }

		[Test]
		public void Multiple_Local_Services_Should_Be_Available()
		{
			bool _updated = false;
			ManualResetEvent _updateEvent = new ManualResetEvent(false);

			_serviceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
			{
				_updated = true;
				_updateEvent.Set();
			};

			bool _deleted = false;
			ManualResetEvent _deleteEvent = new ManualResetEvent(false);

			_serviceBus.Subscribe<DeleteMessage>().MessageReceived += delegate
			{
				_deleted = true;
				_deleteEvent.Set();
			};

			Thread.Sleep(TimeSpan.FromSeconds(5));

			DeleteMessage dm = new DeleteMessage();

			_serviceBus.Publish(dm);

			Assert.That(_deleteEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
						"Timeout expired waiting for message");

			Assert.That(_deleted, Is.True);

			UpdateMessage um = new UpdateMessage();

			_serviceBus.Publish(um);

			Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
						"Timeout expired waiting for message");

			Assert.That(_updated, Is.True);
		}

        [Test]
        public void Multiple_Remote_Services_Should_Be_Available()
        {
			bool _updated = false;
			ManualResetEvent _updateEvent = new ManualResetEvent(false);

			_remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
			{
				_updated = true;
				_updateEvent.Set();
			};

			bool _deleted = false;
			ManualResetEvent _deleteEvent = new ManualResetEvent(false);

			_remoteServiceBus.Subscribe<DeleteMessage>().MessageReceived += delegate
			{
				_deleted = true;
				_deleteEvent.Set();
			};

            Thread.Sleep(TimeSpan.FromSeconds(3));

            DeleteMessage dm = new DeleteMessage();

            _serviceBus.Publish(dm);

            Assert.That(_deleteEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_deleted, Is.True);

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

    }

    [Serializable]
    public class UpdateMessage : IMessage
    {
    }

    [Serializable]
    public class DeleteMessage : IMessage
    {
    }
}<commit_msg>Fixed long-method reply test to pass<commit_after>using System;
using System.Threading;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace MassTransit.ServiceBus.Tests
{
    [TestFixture]
    public class When_Publishing_A_Message :
        ServiceBusSetupFixture
    {
        [Test]
        public void The_Message_Should_Be_Delivered_To_All_Subscribers()
        {
            bool _updated = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            _serviceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
                                                                          {
                                                                              _updated = true;
                                                                              _updateEvent.Set();
                                                                          };

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

        [Test]
        public void The_Message_Should_Be_Handled_By_A_Remote_Service()
        {
            bool _updated = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            _remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
                                                                                {
                                                                                    _updated = true;
                                                                                    _updateEvent.Set();
                                                                                };

            Thread.Sleep(TimeSpan.FromSeconds(5));

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

        [Test]
        public void The_Message_Should_Be_Handled_By_A_Remote_Service_And_Replyable()
        {
            bool _updated = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            EventHandler<MessageReceivedEventArgs<UpdateMessage>> handler =
                delegate(object sender, MessageReceivedEventArgs<UpdateMessage> args)
                    {
                        _updated = true;
                        _updateEvent.Set();

                        _remoteServiceBus.Send(args.Envelope.ReturnTo, new UpdateAcceptedMessage());
                    };

            bool _replied = false;
            ManualResetEvent _repliedEvent = new ManualResetEvent(false);

            _remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += handler;

            _serviceBus.Subscribe<UpdateAcceptedMessage>().MessageReceived +=
                delegate
                    {
                        _replied = true;
                        _repliedEvent.Set();
                    };

            Thread.Sleep(TimeSpan.FromSeconds(5));

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);

            Assert.That(_repliedEvent.WaitOne(TimeSpan.FromSeconds(3), true), Is.True, "NO response message received");

            Assert.That(_replied, Is.True, "Reply Failed");
        }

        [Test]
        public void Multiple_Local_Services_Should_Be_Available()
        {
            bool _updated = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            _serviceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
                                                                          {
                                                                              _updated = true;
                                                                              _updateEvent.Set();
                                                                          };

            bool _deleted = false;
            ManualResetEvent _deleteEvent = new ManualResetEvent(false);

            _serviceBus.Subscribe<DeleteMessage>().MessageReceived += delegate
                                                                          {
                                                                              _deleted = true;
                                                                              _deleteEvent.Set();
                                                                          };

            Thread.Sleep(TimeSpan.FromSeconds(5));

            DeleteMessage dm = new DeleteMessage();

            _serviceBus.Publish(dm);

            Assert.That(_deleteEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_deleted, Is.True);

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }

        [Test]
        public void Multiple_Remote_Services_Should_Be_Available()
        {
            bool _updated = false;
            ManualResetEvent _updateEvent = new ManualResetEvent(false);

            _remoteServiceBus.Subscribe<UpdateMessage>().MessageReceived += delegate
                                                                                {
                                                                                    _updated = true;
                                                                                    _updateEvent.Set();
                                                                                };

            bool _deleted = false;
            ManualResetEvent _deleteEvent = new ManualResetEvent(false);

            _remoteServiceBus.Subscribe<DeleteMessage>().MessageReceived += delegate
                                                                                {
                                                                                    _deleted = true;
                                                                                    _deleteEvent.Set();
                                                                                };

            Thread.Sleep(TimeSpan.FromSeconds(3));

            DeleteMessage dm = new DeleteMessage();

            _serviceBus.Publish(dm);

            Assert.That(_deleteEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_deleted, Is.True);

            UpdateMessage um = new UpdateMessage();

            _serviceBus.Publish(um);

            Assert.That(_updateEvent.WaitOne(TimeSpan.FromSeconds(12), true), Is.True,
                        "Timeout expired waiting for message");

            Assert.That(_updated, Is.True);
        }
    }

    [Serializable]
    public class UpdateMessage : IMessage
    {
    }

    [Serializable]
    public class UpdateAcceptedMessage : IMessage
    {
    }

    [Serializable]
    public class DeleteMessage : IMessage
    {
    }
}
{'fraction_non_alphanumeric': 0.08097545724558387, 'fraction_numerical': 0.002423010786306081, 'mean_word_length': 1.4863972017100662, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 72, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '824655', 'n_tokens_mistral': 3123, 'n_tokens_neox': 2816, 'n_words': 538}