public async Task CloudQueueSetGetMetadataAsync_NullArgs() { CloudQueueClient client = GenerateCloudQueueClient(); CloudQueue queue = client.GetQueueReference(GenerateNewQueueName()); await queue.CreateAsync(); CloudQueue queueToRetrieve = client.GetQueueReference(queue.Name); await queueToRetrieve.FetchAttributesAsync(); Assert.AreEqual <int>(0, queueToRetrieve.Metadata.Count); queue.Metadata.Add("key1", "value1"); await queue.SetMetadataAsync(); await queueToRetrieve.FetchAttributesAsync(); Assert.AreEqual(1, queueToRetrieve.Metadata.Count); Assert.AreEqual("value1", queueToRetrieve.Metadata["key1"]); // Metadata keys should be case-insensitive Assert.AreEqual("value1", queueToRetrieve.Metadata["KEY1"]); CloudQueue listedQueue = (await client.ListQueuesSegmentedAsync(queue.Name, QueueListingDetails.All, null, null, null, null)).Results.First(); Assert.AreEqual(1, listedQueue.Metadata.Count); Assert.AreEqual("value1", listedQueue.Metadata["key1"]); Assert.AreEqual("value1", listedQueue.Metadata["KEY1"]); await queue.SetMetadataAsync(null, null); Assert.AreEqual(1, queue.Metadata.Count); await queueToRetrieve.FetchAttributesAsync(); Assert.AreEqual(1, queueToRetrieve.Metadata.Count); queue.Metadata.Clear(); await queue.SetMetadataAsync(); Assert.AreEqual(0, queue.Metadata.Count); await queueToRetrieve.FetchAttributesAsync(); Assert.AreEqual(0, queueToRetrieve.Metadata.Count); await queue.DeleteAsync(); }
public async Task CloudQueueGetSetPermissionsAsync() { CloudQueueClient client = GenerateCloudQueueClient(); CloudQueue queue = client.GetQueueReference(GenerateNewQueueName()); await queue.CreateAsync(); QueuePermissions emptyPermission = await queue.GetPermissionsAsync(); Assert.AreEqual(emptyPermission.SharedAccessPolicies.Count, 0); string id = Guid.NewGuid().ToString(); DateTime start = DateTime.UtcNow; DateTime expiry = start.AddMinutes(30); QueuePermissions permissions = new QueuePermissions(); SharedAccessQueuePermissions queuePerm = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update; permissions.SharedAccessPolicies.Add(id, new SharedAccessQueuePolicy() { SharedAccessStartTime = start, SharedAccessExpiryTime = expiry, Permissions = queuePerm }); await queue.SetPermissionsAsync(permissions); await Task.Delay(30 * 1000); await queue.FetchAttributesAsync(); CloudQueue queueToRetrieve = client.GetQueueReference(queue.Name); QueuePermissions permissionsToRetrieve = await queueToRetrieve.GetPermissionsAsync(); Assert.AreEqual(permissions.SharedAccessPolicies.Count, permissionsToRetrieve.SharedAccessPolicies.Count); //Assert.AreEqual(start, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessStartTime.Value.UtcDateTime); //Assert.AreEqual(expiry, permissionsToRetrieve.SharedAccessPolicies[id].SharedAccessExpiryTime.Value.UtcDateTime); Assert.AreEqual(permissions.SharedAccessPolicies[id].Permissions, permissionsToRetrieve.SharedAccessPolicies[id].Permissions); await queue.DeleteAsync(); }