コード例 #1
0
ファイル: ZoneScenarioTests.cs プロジェクト: QITIE/ADLSTool
        public void ListZones()
        {
            using (
                MockContext context = MockContext.Start(this.GetType().FullName)
                )
            {
                var resourcesHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = HttpStatusCode.OK
                };
                var dnsHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = HttpStatusCode.OK
                };
                DnsManagementClient dnsClient =
                    ResourceGroupHelper.GetDnsClient(context, dnsHandler);

                var zoneNames = new[]
                {
                    TestUtilities.GenerateName("hydratest.dnszone.com"),
                    TestUtilities.GenerateName("hydratest.dnszone.com")
                };
                var resourceManagementClient =
                    ResourceGroupHelper.GetResourcesClient(
                        context,
                        resourcesHandler);
                ResourceGroup resourceGroup =
                    ResourceGroupHelper.CreateResourceGroup(
                        resourceManagementClient);
                ZoneScenarioTests.CreateZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames,
                    resourceManagementClient);

                var listresponse =
                    dnsClient.Zones.ListInResourceGroup(resourceGroup.Name);

                Assert.NotNull(listresponse);
                Assert.Equal(2, listresponse.Count());
                Assert.True(
                    listresponse.Any(
                        zoneReturned =>
                        string.Equals(zoneNames[0], zoneReturned.Name))
                    &&
                    listresponse.Any(
                        zoneReturned =>
                        string.Equals(zoneNames[1], zoneReturned.Name)),
                    "The response of the List request does not meet expectations.");

                ZoneScenarioTests.DeleteZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames);
            }
        }
コード例 #2
0
        public void ListZonesWithListNext()
        {
            using (
                MockContext context = MockContext.Start(this.GetType().FullName)
                )
            {
                var resourcesHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = System.Net.HttpStatusCode.OK
                };
                var dnsHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = System.Net.HttpStatusCode.OK
                };
                DnsManagementClient dnsClient =
                    ResourceGroupHelper.GetDnsClient(context, dnsHandler);

                var zoneNames = new[]
                {
                    TestUtilities.GenerateName("hydratest.dnszone.com"),
                    TestUtilities.GenerateName("hydratest.dnszone.com")
                };
                var resourceManagementClient =
                    ResourceGroupHelper.GetResourcesClient(
                        context,
                        resourcesHandler);
                ResourceGroup resourceGroup =
                    ResourceGroupHelper.CreateResourceGroup(
                        resourceManagementClient);
                ZoneScenarioTests.CreateZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames,
                    resourceManagementClient);

                var listresponse =
                    dnsClient.Zones.ListByResourceGroup(resourceGroup.Name, 1);

                Assert.NotNull(listresponse.NextPageLink);

                listresponse =
                    dnsClient.Zones.ListByResourceGroupNext(
                        (listresponse.NextPageLink));

                Assert.Single(listresponse);

                ZoneScenarioTests.DeleteZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames);
            }
        }
コード例 #3
0
ファイル: ZoneScenarioTests.cs プロジェクト: QITIE/ADLSTool
        public void ListZonesWithTopParameter()
        {
            using (
                MockContext context = MockContext.Start(this.GetType().FullName)
                )
            {
                var resourcesHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = HttpStatusCode.OK
                };
                var dnsHandler = new RecordedDelegatingHandler
                {
                    StatusCodeToReturn = HttpStatusCode.OK
                };
                DnsManagementClient dnsClient =
                    ResourceGroupHelper.GetDnsClient(context, dnsHandler);

                var zoneNames = new[]
                {
                    TestUtilities.GenerateName("hydratest.dnszone") + ".com",
                    TestUtilities.GenerateName("hydratest.dnszone") + ".com"
                };
                var resourceManagementClient =
                    ResourceGroupHelper.GetResourcesClient(
                        context,
                        resourcesHandler);
                ResourceGroup resourceGroup =
                    ResourceGroupHelper.CreateResourceGroup(
                        resourceManagementClient);
                ZoneScenarioTests.CreateZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames,
                    resourceManagementClient);

                var listresponse =
                    dnsClient.Zones.ListInResourceGroup(resourceGroup.Name, "1");

                Assert.NotNull(listresponse);
                Assert.Equal(1, listresponse.Count());
                Assert.True(
                    zoneNames.Any(
                        zoneName => zoneName == listresponse.ElementAt(0).Name));

                ZoneScenarioTests.DeleteZones(
                    dnsClient,
                    resourceGroup,
                    zoneNames);
            }
        }
コード例 #4
0
        public void ListZonesWithFilterParameter()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient();

                var zoneNames = new[] { TestUtilities.GenerateName("hydratestdnszone"), TestUtilities.GenerateName("hydratestdnszone") };
                ResourceGroupExtended resourceGroup = ResourceGroupHelper.CreateResourceGroup();
                ZoneScenarioTests.CreateZones(dnsClient, resourceGroup, zoneNames);

                ZoneListResponse listresponse = dnsClient.Zones.List(resourceGroup.Name, new ZoneListParameters {
                    Filter = string.Format("endswith(Name,'{0}')", zoneNames[0])
                });

                Assert.NotNull(listresponse);
                Assert.Equal(1, listresponse.Zones.Count);

                ZoneScenarioTests.DeleteZones(dnsClient, resourceGroup, zoneNames);
            }
        }
コード例 #5
0
        public void ListZonesWithTopParameter()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient();

                var zoneNames = new[] { TestUtilities.GenerateName("hydratestdnszone") + ".com", TestUtilities.GenerateName("hydratestdnszone") + ".con" };
                ResourceGroupExtended resourceGroup = ResourceGroupHelper.CreateResourceGroup();
                ZoneScenarioTests.CreateZones(dnsClient, resourceGroup, zoneNames);

                ZoneListResponse listresponse = dnsClient.Zones.List(resourceGroup.Name, new ZoneListParameters {
                    Top = "1"
                });

                Assert.NotNull(listresponse);
                Assert.Equal(1, listresponse.Zones.Count);
                Assert.True(listresponse.Zones.Any(zoneReturned => string.Equals(zoneNames[0], zoneReturned.Name)),
                            "The response of the List request does not meet expectations.");

                ZoneScenarioTests.DeleteZones(dnsClient, resourceGroup, zoneNames);
            }
        }
コード例 #6
0
        public void ListZonesWithTopParameter()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient();

                var zoneNames = new[] { TestUtilities.GenerateName("hydratestdnszone") + ".com", TestUtilities.GenerateName("hydratestdnszone") + ".com" };
                ResourceGroupExtended resourceGroup = ResourceGroupHelper.CreateResourceGroup();
                ZoneScenarioTests.CreateZones(dnsClient, resourceGroup, zoneNames);

                ZoneListResponse listresponse = dnsClient.Zones.ListZonesInResourceGroup(resourceGroup.Name, new ZoneListParameters {
                    Top = "1"
                });

                Assert.NotNull(listresponse);
                Assert.Equal(1, listresponse.Zones.Count);
                Assert.True(zoneNames.Any(zoneName => zoneName == listresponse.Zones[0].Name), string.Format(" did not find zone name {0} in list ", listresponse.Zones[0].Name));
                Assert.True(listresponse.Zones[0].Properties.ParentResourceGroupName == resourceGroup.Name, string.Format(" expected resource group name {0} is different from actual {1}", resourceGroup.Name, listresponse.Zones[0].Properties.ParentResourceGroupName));

                ZoneScenarioTests.DeleteZones(dnsClient, resourceGroup, zoneNames);
            }
        }
コード例 #7
0
        public void ListZonesWithListNext()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                DnsManagementClient dnsClient = ResourceGroupHelper.GetDnsClient();

                var zoneNames = new[] { TestUtilities.GenerateName("hydratestdnszone.com"), TestUtilities.GenerateName("hydratestdnszone.com") };
                ResourceGroupExtended resourceGroup = ResourceGroupHelper.CreateResourceGroup();
                ZoneScenarioTests.CreateZones(dnsClient, resourceGroup, zoneNames);

                ZoneListResponse listresponse = dnsClient.Zones.ListZonesInResourceGroup(resourceGroup.Name, new ZoneListParameters {
                    Top = "1"
                });

                Assert.NotNull(listresponse.NextLink);

                listresponse = dnsClient.Zones.ListNext(listresponse.NextLink);

                Assert.Equal(1, listresponse.Zones.Count);

                ZoneScenarioTests.DeleteZones(dnsClient, resourceGroup, zoneNames);
            }
        }