public async Task CloudQueueCreate_IfNotExist_CreatesQueue() { // Arrange CloudStorageAccount sdkAccount = CreateSdkAccount(); string queueName = GetQueueName("create-queue"); CloudQueue sdkQueue = CreateSdkQueue(sdkAccount, queueName); try { IStorageAccount product = CreateProductUnderTest(sdkAccount); IStorageQueueClient client = product.CreateQueueClient(); Assert.NotNull(client); // Guard IStorageQueue queue = client.GetQueueReference(queueName); Assert.NotNull(queue); // Guard // Act await queue.CreateIfNotExistsAsync(CancellationToken.None); // Assert Assert.True(await sdkQueue.ExistsAsync()); } finally { if (await sdkQueue.ExistsAsync()) { await sdkQueue.DeleteAsync(); } } }
private async Task <IStorageQueue> BuildClientFromQueueAttributeAsync(QueueAttribute attrResolved) { IStorageQueue queue = GetQueue(attrResolved); await queue.CreateIfNotExistsAsync(CancellationToken.None); return(queue); }
public static async Task AddMessageAndCreateIfNotExistsAsync(this IStorageQueue queue, IStorageQueueMessage message, CancellationToken cancellationToken) { if (queue == null) { throw new ArgumentNullException("queue"); } bool isQueueNotFoundException = false; try { await queue.AddMessageAsync(message, cancellationToken); return; } catch (StorageException exception) { if (!exception.IsNotFoundQueueNotFound()) { throw; } isQueueNotFoundException = true; } Debug.Assert(isQueueNotFoundException); await queue.CreateIfNotExistsAsync(cancellationToken); await queue.AddMessageAsync(message, cancellationToken); }
public static void CreateIfNotExists(this IStorageQueue queue) { if (queue == null) { throw new ArgumentNullException("queue"); } queue.CreateIfNotExistsAsync(CancellationToken.None).GetAwaiter().GetResult(); }
protected override async Task CopyMessageToPoisonQueueAsync(CloudQueueMessage message, CloudQueue poisonQueue, CancellationToken cancellationToken) { FakeStorageQueueMessage fakeMessage = new FakeStorageQueueMessage(message); await _poisonQueue.CreateIfNotExistsAsync(cancellationToken); await _poisonQueue.AddMessageAsync(fakeMessage, cancellationToken); OnMessageAddedToPoisonQueue(new PoisonMessageEventArgs(message, poisonQueue)); }