예제 #1
0
        public void CrudProfileWithCustomHeaders()
        {
            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.CreateOrUpdateProfileWithCustomHeadersAndStatusCodeRanges(
                    trafficManagerClient,
                    resourceGroupName,
                    profileName);

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

                Assert.Equal(expectedProfile.MonitorConfig.CustomHeaders.Count, actualProfile.MonitorConfig.CustomHeaders.Count);
                for (var i = 0; i < expectedProfile.MonitorConfig.CustomHeaders.Count; ++i)
                {
                    Assert.Equal(expectedProfile.MonitorConfig.CustomHeaders[i].Name, actualProfile.MonitorConfig.CustomHeaders[i].Name);
                    Assert.Equal(expectedProfile.MonitorConfig.CustomHeaders[i].Value, actualProfile.MonitorConfig.CustomHeaders[i].Value);
                }

                for (var i = 0; i < expectedProfile.MonitorConfig.ExpectedStatusCodeRanges.Count; ++i)
                {
                    Assert.Equal(expectedProfile.MonitorConfig.ExpectedStatusCodeRanges[i].Min, actualProfile.MonitorConfig.ExpectedStatusCodeRanges[i].Min);
                    Assert.Equal(expectedProfile.MonitorConfig.ExpectedStatusCodeRanges[i].Max, actualProfile.MonitorConfig.ExpectedStatusCodeRanges[i].Max);
                }

                for (var i = 0; i < expectedProfile.Endpoints.Count; ++i)
                {
                    for (var j = 0; j < expectedProfile.Endpoints[i].CustomHeaders.Count; ++j)
                    {
                        Assert.Equal(expectedProfile.Endpoints[i].CustomHeaders[j].Name, actualProfile.Endpoints[i].CustomHeaders[j].Name);
                        Assert.Equal(expectedProfile.Endpoints[i].CustomHeaders[j].Value, actualProfile.Endpoints[i].CustomHeaders[j].Value);
                    }
                }

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

                this.DeleteResourceGroup(context, resourceGroupName);
            }
        }