Inheritance: IPluginQueueFactory
        public void ShouldProcessUiMessageWhenItArrives()
        {
            var pluginQueueFactory = new PluginQueueFactoryMock();
            var transport          = CreateTransport(pluginQueueFactory);

            var messages = new List <Message> {
                new Message {
                    Body = "Message1"
                }, new Message("Message2")
            };
            var uiMessages = new List <Message>();

            pluginQueueFactory.SetMessagesForQueue(transport.InputQueue, messages);
            pluginQueueFactory.SetMessagesForQueue(transport.UICommandInputQueue, uiMessages);

            transport.Start();
            transport.Process();
            uiMessages.Add(new Message {
                Body = "UiMessage1"
            });
            transport.Process();
            transport.Process();

            pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(
                Be.EquivalentTo(new[] { "Message1", "UiMessage1", "Message2" }));
        }
        public void ShouldProcessUiMessagesFirst()
        {
            var pluginQueueFactory = new PluginQueueFactoryMock();
            var transport          = CreateTransport(pluginQueueFactory);

            var messages = new List <Message> {
                new Message {
                    Body = "Message1"
                }, new Message("Message2")
            };
            var uiMessages = new List <Message> {
                new Message {
                    Body = "UiMessage1"
                }, new Message("UiMessage2")
            };

            pluginQueueFactory.SetMessagesForQueue(transport.InputQueue, messages);
            pluginQueueFactory.SetMessagesForQueue(transport.UICommandInputQueue, uiMessages);

            transport.Start();
            var totalMessageCount = messages.Count + uiMessages.Count;

            for (var i = 0; i < totalMessageCount; i++)
            {
                transport.Process();
            }

            pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(
                Be.EquivalentTo(new[] { "UiMessage1", "UiMessage2", "Message1", "Message2" }));
        }
		private static MsmqUiPriorityTransport CreateTransport(PluginQueueFactoryMock pluginQueueFactory)
		{
			var transport = new MsmqUiPriorityTransport
			                	{
			                		IsTransactional = false,
			                		InputQueue = "InputQueue",
			                		SkipDeserialization = true,
			                		DoNotCreateQueues = true,
			                		NumberOfWorkerThreads = 0,
			                		PluginQueueFactory = pluginQueueFactory
			                	};
			return transport;
		}
        private static MsmqUiPriorityTransport CreateTransport(PluginQueueFactoryMock pluginQueueFactory)
        {
            var transport = new MsmqUiPriorityTransport
            {
                IsTransactional       = false,
                InputQueue            = "InputQueue",
                SkipDeserialization   = true,
                DoNotCreateQueues     = true,
                NumberOfWorkerThreads = 0,
                PluginQueueFactory    = pluginQueueFactory
            };

            return(transport);
        }
		public void ShouldProcessUiMessageWhenItArrives()
		{
			var pluginQueueFactory = new PluginQueueFactoryMock();
			var transport = CreateTransport(pluginQueueFactory);

			var messages = new List<Message> {new Message {Body = "Message1"}, new Message("Message2")};
			var uiMessages = new List<Message>();

			pluginQueueFactory.SetMessagesForQueue(transport.InputQueue, messages);
			pluginQueueFactory.SetMessagesForQueue(transport.UICommandInputQueue, uiMessages);

			transport.Start();
			transport.Process();
			uiMessages.Add(new Message {Body = "UiMessage1"});
			transport.Process();
			transport.Process();

			pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(
				Be.EquivalentTo(new[] {"Message1", "UiMessage1", "Message2"}), "pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(Be.EquivalentTo(new[] {\"Message1\", \"UiMessage1\", \"Message2\"}))");
		}
		public void ShouldProcessUiMessagesFirst()
		{
			var pluginQueueFactory = new PluginQueueFactoryMock();
			var transport = CreateTransport(pluginQueueFactory);

			var messages = new List<Message> {new Message {Body = "Message1"}, new Message("Message2")};
			var uiMessages = new List<Message> {new Message {Body = "UiMessage1"}, new Message("UiMessage2")};

			pluginQueueFactory.SetMessagesForQueue(transport.InputQueue, messages);
			pluginQueueFactory.SetMessagesForQueue(transport.UICommandInputQueue, uiMessages);

			transport.Start();
			var totalMessageCount = messages.Count + uiMessages.Count;
			for (var i = 0; i < totalMessageCount; i++)
			{
				transport.Process();
			}

			pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(
				Be.EquivalentTo(new[] {"UiMessage1", "UiMessage2", "Message1", "Message2"}), "pluginQueueFactory.ProcessedMessages.Select(x => x.Body as string).ToArray().Should(Be.EquivalentTo(new[] {\"UiMessage1\", \"UiMessage2\", \"Message1\", \"Message2\"}))");
		}