コード例 #1
0
        public void CrudProfileWithCustomSubnets()
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                TrafficManagerManagementClient trafficManagerClient = this.GetTrafficManagerManagementClient(context);

                string        resourceGroupName = TrafficManagerHelper.GenerateName();
                string        profileName       = TrafficManagerHelper.GenerateName();
                ResourceGroup resourceGroup     = this.CreateResourceGroup(context, resourceGroupName);

                // Create the profile
                var expectedProfile = TrafficManagerHelper.CreateOrUpdateProfileWithSubnets(
                    trafficManagerClient,
                    resourceGroupName,
                    profileName);

                // Get the profile
                var actualProfile = trafficManagerClient.Profiles.Get(
                    resourceGroup.Name,
                    profileName);

                for (var i = 0; i < expectedProfile.Endpoints.Count; ++i)
                {
                    Assert.Equal(2, expectedProfile.Endpoints[i].Subnets.Count);
                    Assert.Equal($"1.2.{i}.0", expectedProfile.Endpoints[i].Subnets[0].First);
                    Assert.Equal($"1.2.{i}.250", expectedProfile.Endpoints[i].Subnets[0].Last);
                    Assert.Equal($"3.4.{i}.0", expectedProfile.Endpoints[i].Subnets[1].First);
                    Assert.Equal(24, expectedProfile.Endpoints[i].Subnets[1].Scope);
                }

                // Delete the profile
                trafficManagerClient.Profiles.Delete(resourceGroup.Name, profileName);

                this.DeleteResourceGroup(context, resourceGroupName);
            }
        }