Ejemplo n.º 1
0
        public void Disposed_ThenIsClosed()
        {
            var client = new Mock <IQueueClient>();
            AzureCommandQueue queue = new AzureCommandQueue(client.Object);

            queue.Dispose();

            client.Verify(c => c.Close(), Times.Once());
        }
Ejemplo n.º 2
0
        public async Task SendAsync()
        {
            var command = new FakeCommand("test");
            var client  = new Mock <IQueueClient>();

            using (AzureCommandQueue queue = new AzureCommandQueue(client.Object))
            {
                await queue.SendAsync(command, CancellationToken.None);

                client.Verify(c => c.SendAsync(It.IsAny <BrokeredMessage>()), Times.Once());
            }
        }
Ejemplo n.º 3
0
        public void IsCompleted(bool closed)
        {
            var client = new Mock <IQueueClient>();

            client
            .Setup(c => c.IsClosed)
            .Returns(closed);
            AzureCommandQueue queue = new AzureCommandQueue(client.Object);

            queue.Complete();

            Assert.Equal(closed, queue.IsCompleted);
        }
Ejemplo n.º 4
0
        public async Task ReceiveAsync()
        {
            JsonSerializerSettings serializationSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Objects
            };
            var command = new FakeCommand("test");
            var client  = new Mock <IQueueClient>();

            client
            .Setup(c => c.ReceiveAsync())
            .Returns(Task.FromResult(new BrokeredMessage(JsonConvert.SerializeObject(command, serializationSettings))));

            using (AzureCommandQueue queue = new AzureCommandQueue(client.Object))
            {
                ICommand result = await queue.ReceiveAsync(CancellationToken.None);

                Assert.NotNull(result);
                AssertLikeness.Like(command, result);
            }
        }
Ejemplo n.º 5
0
        public static void EnableAzureMessageQueuing(this ProcessorConfiguration configuration, string connectionString, int runnerCount)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            AzureCommandQueue azureQueue = null;

            try
            {
                azureQueue = new AzureCommandQueue(connectionString);
                configuration.EnableMessageQueuing(runnerCount, azureQueue, azureQueue);
                azureQueue = null;
            }
            finally
            {
                if (azureQueue != null)
                {
                    azureQueue.Dispose();
                }
            }
        }