Beispiel #1
0
        /// <summary>
        /// Creates or Updates a CustomLocation Resource
        /// </summary>
        /// <returns>The CustomLocation Resource that was created or updated.</returns>
        public CustomLocation CreateCustomLocations()
        {
            Console.WriteLine("Creating a Custom Location...");
            Microsoft.Azure.Management.ExtendedLocation.Models.CustomLocation parameters;
            parameters = new Microsoft.Azure.Management.ExtendedLocation.Models.CustomLocation(location: CustomLocationTestData.Location);
            parameters.HostResourceId = CustomLocationTestData.HostResourceIdTest;
            List <string> clusterextids = new List <string>(new string[] { CustomLocationTestData.CassandraTest });

            parameters.ClusterExtensionIds = clusterextids;
            parameters.HostType            = "Kubernetes";
            parameters.NamespaceProperty   = CustomLocationTestData.NamespaceTest;
            parameters.DisplayName         = CustomLocationTestData.ResourceName;
            parameters.Authentication      = null;
            // this ICustomLocationsOperations operations, string resourceGroupName, string resourceName, CustomLocation parameters
            return(CustomLocationsClient.CustomLocations.CreateOrUpdate(resourceGroupName: CustomLocationTestData.ResourceGroup, resourceName: CustomLocationTestData.ResourceName, parameters: parameters));
        }
        public void TestOperationsCustomLocation()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (var customLocationTestBase = new CustomLocationsOperationsTestBase(context))
                {
                    // CREATE CL
                    Microsoft.Azure.Management.ExtendedLocation.Models.CustomLocation customLocation = customLocationTestBase.CreateCustomLocations();
                    Assert.True(customLocation.DisplayName == CustomLocationTestData.ResourceName);
                    Assert.True(customLocation.ProvisioningState == "Succeeded");
                    Assert.False(String.IsNullOrEmpty(customLocation.Identity.PrincipalId));
                    Assert.True(customLocation.Identity.Type == "SystemAssigned");

                    // GET ON CREATED CL
                    Console.WriteLine("\n");
                    customLocation = customLocationTestBase.GetCustomLocation();
                    Assert.True(customLocation.DisplayName == CustomLocationTestData.ResourceName);

                    // PATCH CL
                    Console.WriteLine("\n");
                    customLocation = customLocationTestBase.PatchCustomLocation();
                    Assert.True(customLocation.ProvisioningState == "Patching");

                    // GET ON UPDATED CL
                    Console.WriteLine("\n");
                    customLocation = customLocationTestBase.GetCustomLocation();
                    List <string> clusterextids = new List <string>(new string[] { CustomLocationTestData.CassandraTest, CustomLocationTestData.AnsibleTest });
                    Assert.True(customLocation.DisplayName == CustomLocationTestData.ResourceName);
                    if (customLocation.ClusterExtensionIds[0] == CustomLocationTestData.CassandraTest)
                    {
                        Assert.True(customLocation.ClusterExtensionIds[1] == CustomLocationTestData.AnsibleTest);
                    }
                    else
                    {
                        Assert.True(customLocation.ClusterExtensionIds[0] == CustomLocationTestData.AnsibleTest);
                    }

                    // LIST BY SUBSCRIPTION
                    Console.WriteLine("\n");
                    Microsoft.Azure.Management.ExtendedLocation.Models.Page <CustomLocation> page = (Microsoft.Azure.Management.ExtendedLocation.Models.Page <CustomLocation>)customLocationTestBase.ListCustomLocationsBySubscription();
                    bool foundCL;
                    foundCL = Paging.PageListResult(page, customLocationTestBase.ListCustomLocationsBySubscriptionNext);
                    Assert.True(foundCL);

                    // LIST BY RESOURCE GROUP
                    Console.WriteLine("\n");
                    page    = (Microsoft.Azure.Management.ExtendedLocation.Models.Page <CustomLocation>)customLocationTestBase.ListCustomLocationsByResourceGroup();
                    foundCL = Paging.PageListResult(page, customLocationTestBase.ListCustomLocationsByResourceGroupNext);
                    Assert.True(foundCL);

                    // DELETE CREATED CL
                    Console.WriteLine("\n");
                    customLocationTestBase.DeleteCustomLocation();
                    Console.WriteLine("\n");

                    // LIST OPERATION SHOULD NOT FIND CL
                    page    = (Microsoft.Azure.Management.ExtendedLocation.Models.Page <CustomLocation>)customLocationTestBase.ListCustomLocationsByResourceGroup();
                    foundCL = Paging.PageListResult(page, customLocationTestBase.ListCustomLocationsByResourceGroupNext);
                    Assert.False(foundCL);
                }
            }
        }