public void ContainerRegistryWebhookTest()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                var resourceClient = ContainerRegistryTestUtilities.GetResourceManagementClient(context, handler);
                var registryClient = ContainerRegistryTestUtilities.GetContainerRegistryManagementClient(context, handler);

                // Create resource group
                var resourceGroup = ContainerRegistryTestUtilities.CreateResourceGroup(resourceClient);

                // Create container registry and webhook
                var registry = ContainerRegistryTestUtilities.CreateManagedContainerRegistry(registryClient, resourceGroup.Name, resourceGroup.Location);
                var webhook  = ContainerRegistryTestUtilities.CreatedContainerRegistryWebhook(registryClient, resourceGroup.Name, registry.Name, resourceGroup.Location);

                // Validate the created webhook
                ContainerRegistryTestUtilities.ValidateResourceDefaultTags(webhook);
                Assert.Equal(WebhookStatus.Enabled, webhook.Status);
                Assert.True(string.IsNullOrEmpty(webhook.Scope));
                Assert.Equal(1, webhook.Actions.Count);
                Assert.True(webhook.Actions.Contains(WebhookAction.Push));
                Assert.Equal(ProvisioningState.Succeeded, webhook.ProvisioningState);

                // List webhooks by container registry
                var webhooks = registryClient.Webhooks.List(resourceGroup.Name, registry.Name);
                webhook = webhooks.First(
                    w => StringComparer.OrdinalIgnoreCase.Equals(w.Name, webhook.Name));
                Assert.Single(webhooks);
                ContainerRegistryTestUtilities.ValidateResourceDefaultTags(webhook);

                // Get the webhook
                webhook = registryClient.Webhooks.Get(resourceGroup.Name, registry.Name, webhook.Name);
                ContainerRegistryTestUtilities.ValidateResourceDefaultTags(webhook);

                // Update the webhook
                webhook = registryClient.Webhooks.Update(resourceGroup.Name, registry.Name, webhook.Name, new WebhookUpdateParameters
                {
                    Tags    = ContainerRegistryTestUtilities.DefaultNewTags,
                    Status  = WebhookStatus.Disabled,
                    Scope   = ContainerRegistryTestUtilities.DefaultWebhookScope,
                    Actions = new List <string>
                    {
                        WebhookAction.Push, WebhookAction.Delete
                    },
                    CustomHeaders = new Dictionary <string, string>
                    {
                        { "key", "value" }
                    }
                });

                // Validate the updated webhook
                ContainerRegistryTestUtilities.ValidateResourceDefaultNewTags(webhook);
                Assert.Equal(WebhookStatus.Disabled, webhook.Status);
                Assert.Equal(ContainerRegistryTestUtilities.DefaultWebhookScope, webhook.Scope);
                Assert.Equal(2, webhook.Actions.Count);
                Assert.True(webhook.Actions.Contains(WebhookAction.Push));
                Assert.True(webhook.Actions.Contains(WebhookAction.Delete));
                Assert.Equal(ProvisioningState.Succeeded, webhook.ProvisioningState);

                // Get the webhook call back config
                var webhookConfig = registryClient.Webhooks.GetCallbackConfig(resourceGroup.Name, registry.Name, webhook.Name);
                Assert.NotNull(webhookConfig);
                Assert.Equal(ContainerRegistryTestUtilities.DefaultWebhookServiceUri, webhookConfig.ServiceUri);
                Assert.Equal(1, webhookConfig.CustomHeaders.Count);
                Assert.Equal("value", webhookConfig.CustomHeaders["key"]);

                // Ping the webhook
                var eventInfo = registryClient.Webhooks.Ping(resourceGroup.Name, registry.Name, webhook.Name);
                Assert.NotNull(eventInfo);
                Assert.NotNull(eventInfo.Id);

                var events = registryClient.Webhooks.ListEvents(resourceGroup.Name, registry.Name, webhook.Name);
                Assert.NotNull(events);

                // Delete the webhook
                registryClient.Webhooks.Delete(resourceGroup.Name, registry.Name, webhook.Name);

                // Delete the webhook again
                registryClient.Webhooks.Delete(resourceGroup.Name, registry.Name, webhook.Name);

                // Delete the container registry
                registryClient.Registries.Delete(resourceGroup.Name, registry.Name);
            }
        }