public void OpContextTestClientRequestIDOnQueue()
        {
            CloudQueueClient qClient = GenerateCloudQueueClient();
            CloudQueue       queue   = qClient.GetQueueReference("test");

            string uniqueID = Guid.NewGuid().ToString();

            Action act = () => queue.Exists(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            });

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, XStoreSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

            act = () => queue.EndExists(queue.BeginExists(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            }, null, null));

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, XStoreSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

#if TASK
            act = () => queue.ExistsAsync(null, new OperationContext()
            {
                ClientRequestID = uniqueID
            }).Wait();

            TestHelper.VerifyHeaderWasSent("x-ms-client-request-id", uniqueID, XStoreSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);
#endif
        }
        public void OpContextTestUserHeadersOnQueue()
        {
            CloudQueueClient qClient = GenerateCloudQueueClient();
            CloudQueue       queue   = qClient.GetQueueReference("test");

            string uniqueID = Guid.NewGuid().ToString();

            OperationContext ctx = new OperationContext();

            ctx.UserHeaders = new Dictionary <string, string>();
            ctx.UserHeaders.Add("foo", "bar");

            Action act = () => queue.Exists(null, ctx);

            TestHelper.VerifyHeaderWasSent(ctx.UserHeaders.Keys.First(), ctx.UserHeaders[ctx.UserHeaders.Keys.First()], XStoreSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);

            act = () => queue.EndExists(queue.BeginExists(null, ctx, null, null));

            TestHelper.VerifyHeaderWasSent(ctx.UserHeaders.Keys.First(), ctx.UserHeaders[ctx.UserHeaders.Keys.First()], XStoreSelectors.QueueTraffic().IfHostNameContains(qClient.Credentials.AccountName), act);
        }
        public void QueueGetACLCancellation()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue       queue  = client.GetQueueReference(GenerateNewQueueName());

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, XStoreSelectors.QueueTraffic().IfHostNameContains(client.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => queue.BeginGetPermissions((QueueRequestOptions)options, opContext, callback, state),
                                                        (res) => queue.EndGetPermissions(res));
        }
        public void QueueSetACLCancellation()
        {
            CloudQueueClient client = GenerateCloudQueueClient();
            CloudQueue       queue  = client.GetQueueReference(GenerateNewQueueName());

            QueuePermissions permissions = new QueuePermissions();

            permissions.SharedAccessPolicies.Add(Guid.NewGuid().ToString(), new SharedAccessQueuePolicy()
            {
                SharedAccessStartTime  = DateTimeOffset.Now - TimeSpan.FromHours(1),
                SharedAccessExpiryTime = DateTimeOffset.Now + TimeSpan.FromHours(1),
                Permissions            = SharedAccessQueuePermissions.Add | SharedAccessQueuePermissions.ProcessMessages | SharedAccessQueuePermissions.Read | SharedAccessQueuePermissions.Update
            });

            TestHelper.ExecuteAPMMethodWithCancellation(4000,
                                                        new[] { DelayBehaviors.DelayAllRequestsIf(4000 * 3, XStoreSelectors.QueueTraffic().IfHostNameContains(client.Credentials.AccountName)) },
                                                        (options, opContext, callback, state) => queue.BeginSetPermissions(permissions, (QueueRequestOptions)options, opContext, callback, state),
                                                        queue.EndSetPermissions);
        }