Beispiel #1
0
        public void CustomProvider_CRUD()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (var testFixture = new CustomProvidersTestBase(context))
                {
                    var rpRouteDef = new CustomRPActionRouteDefinition(ActionRouteName, URLEndpoint);
                    var rpManifest = new CustomRPManifest();
                    rpManifest.Location = Location;
                    rpManifest.Actions  = new List <CustomRPActionRouteDefinition>();
                    rpManifest.Actions.Add(rpRouteDef);

                    //1. Create an custom provider with Action
                    var createOperationResponse = testFixture.customprovidersClient.CustomResourceProvider.CreateOrUpdate(ResourceGroupName, ResourceProviderName, rpManifest);
                    Assert.NotNull(createOperationResponse);
                    Assert.Equal(ProvisioningState.Succeeded, createOperationResponse.ProvisioningState);
                    Assert.True(createOperationResponse.Actions.Count() == 1);

                    //2. Get custom provider
                    var getOperationResponse = testFixture.customprovidersClient.CustomResourceProvider.Get(ResourceGroupName, ResourceProviderName);
                    Assert.NotNull(getOperationResponse);
                    Assert.Equal(ProvisioningState.Succeeded, getOperationResponse.ProvisioningState);
                    Assert.True(getOperationResponse.Actions.Count() == 1);

                    //3. List custom provider by subscription
                    var subListOperationResponse = testFixture.customprovidersClient.CustomResourceProvider.ListBySubscription();
                    Assert.NotNull(subListOperationResponse);
                    Assert.True(subListOperationResponse.Count() == 1);

                    //4. List custom provider by resource group
                    var rgListOperationResponse = testFixture.customprovidersClient.CustomResourceProvider.ListByResourceGroup(ResourceGroupName);
                    Assert.NotNull(rgListOperationResponse);
                    Assert.True(rgListOperationResponse.Count() == 1);

                    //5. Delele custom provider
                    testFixture.customprovidersClient.CustomResourceProvider.Delete(ResourceGroupName, ResourceProviderName);

                    //6. Verify delete
                    rgListOperationResponse = testFixture.customprovidersClient.CustomResourceProvider.ListByResourceGroup(ResourceGroupName);
                    Assert.NotNull(rgListOperationResponse);
                    Assert.True(rgListOperationResponse.Count() == 0);
                }
            }
        }
 /// <summary>
 /// Creates or updates the custom resource provider.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='resourceProviderName'>
 /// The name of the resource provider.
 /// </param>
 /// <param name='resourceProvider'>
 /// The parameters required to create or update a custom resource provider
 /// definition.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <CustomRPManifest> CreateOrUpdateAsync(this ICustomResourceProviderOperations operations, string resourceGroupName, string resourceProviderName, CustomRPManifest resourceProvider, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, resourceProviderName, resourceProvider, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates or updates the custom resource provider.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='resourceProviderName'>
 /// The name of the resource provider.
 /// </param>
 /// <param name='resourceProvider'>
 /// The parameters required to create or update a custom resource provider
 /// definition.
 /// </param>
 public static CustomRPManifest CreateOrUpdate(this ICustomResourceProviderOperations operations, string resourceGroupName, string resourceProviderName, CustomRPManifest resourceProvider)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, resourceProviderName, resourceProvider).GetAwaiter().GetResult());
 }