public void Disposed_ThenIsClosed() { var client = new Mock <IQueueClient>(); AzureCommandQueue queue = new AzureCommandQueue(client.Object); queue.Dispose(); client.Verify(c => c.Close(), Times.Once()); }
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()); } }
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); }
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); } }
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(); } } }