Exemple #1
0
        private void ListRecordsInZoneWithSuffixCrossType(
            bool isCrossType,
            [System.Runtime.CompilerServices.CallerMemberName] string methodName
            = "testframework_failed")
        {
            using (
                MockContext context = MockContext.Start(
                    this.GetType(),
                    methodName))
            {
                var testContexts = SetupSingleRecordSetTestContexts(context);
                foreach (var testContext in testContexts)
                {
                    string subzoneName = "contoso";

                    var recordSetNames = new[]
                    {
                        TestUtilities.GenerateName("hydratestrec"),
                        TestUtilities.GenerateName("hydratestrec"),
                        TestUtilities.GenerateName("hydratestrec")
                    }.Select(x => x + "." + subzoneName).ToArray();

                    RecordSetScenarioTests.CreateRecordSets(
                        testContext,
                        recordSetNames);

                    if (isCrossType)
                    {
                        var listresponse = testContext.DnsClient.RecordSets
                                           .ListByDnsZone(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName,
                            recordsetnamesuffix: subzoneName);

                        Assert.NotNull(listresponse);
                        Assert.Equal(listresponse.Count(), recordSetNames.Length);
                        Assert.True(
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[0],
                                    recordSetReturned.Name))
                            &&
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[1],
                                    recordSetReturned.Name))
                            &&
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[2],
                                    recordSetReturned.Name)),
                            "The returned records do not meet expectations");
                    }
                    else
                    {
                        var listresponse = testContext.DnsClient.RecordSets
                                           .ListByType(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName,
                            RecordType.TXT,
                            recordsetnamesuffix: subzoneName);

                        Assert.NotNull(listresponse);
                        Assert.Equal(2, listresponse.Count());
                        Assert.True(
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[0],
                                    recordSetReturned.Name))
                            &&
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[1],
                                    recordSetReturned.Name)),
                            "The returned records do not meet expectations");
                    }

                    RecordSetScenarioTests.DeleteRecordSetsAndZone(
                        testContext,
                        recordSetNames);
                }
            }
        }
Exemple #2
0
        private void ListRecordsInZoneWithTop(
            bool isCrossType,
            [System.Runtime.CompilerServices.CallerMemberName] string methodName
            = "testframework_failed")
        {
            using (
                MockContext context = MockContext.Start(
                    this.GetType(),
                    methodName))
            {
                var testContexts = SetupSingleRecordSetTestContexts(context);
                foreach (var testContext in testContexts)
                {
                    var recordSetNames = new[]
                    {
                        TestUtilities.GenerateName("hydratestrec") + ".com",
                        TestUtilities.GenerateName("hydratestrec") + ".com",
                        TestUtilities.GenerateName("hydratestrec") + ".com"
                    };

                    RecordSetScenarioTests.CreateRecordSets(
                        testContext,
                        recordSetNames);

                    IPage <RecordSet> listResponse;

                    if (isCrossType)
                    {
                        // Using top = 3, it will pick up SOA, NS and the first TXT
                        listResponse = testContext.DnsClient.RecordSets
                                       .ListByDnsZone(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName,
                            3);
                        // verify if TXT is in the list
                        Assert.True(
                            listResponse.Where(rs => rs.Type == "TXT")
                            .All(
                                listedRecordSet =>
                                recordSetNames.Any(
                                    createdName =>
                                    createdName == listedRecordSet.Name)),
                            "The returned records do not meet expectations");
                    }
                    else
                    {
                        // Using top = 3, it will pick up SOA, NS and the first TXT, process it and return just the TXT
                        listResponse = testContext.DnsClient.RecordSets.ListByType(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName,
                            RecordType.TXT,
                            3);
                        Assert.True(
                            listResponse.All(
                                listedRecordSet =>
                                recordSetNames.Any(
                                    createdName =>
                                    createdName == listedRecordSet.Name)),
                            "The returned records do not meet expectations");
                    }

                    RecordSetScenarioTests.DeleteRecordSetsAndZone(
                        testContext,
                        recordSetNames);
                }
            }
        }
Exemple #3
0
        private void ListRecordsInZone(
            bool isCrossType,
            [System.Runtime.CompilerServices.CallerMemberName] string methodName
            = "testframework_failed")
        {
            using (
                MockContext context = MockContext.Start(
                    this.GetType(),
                    methodName))
            {
                var testContexts = SetupSingleRecordSetTestContexts(context);
                foreach (var testContext in testContexts)
                {
                    var recordSetNames = new[]
                    {
                        TestUtilities.GenerateName("hydratestrec"),
                        TestUtilities.GenerateName("hydratestrec"),
                        TestUtilities.GenerateName("hydratestrec")
                    };

                    RecordSetScenarioTests.CreateRecordSets(
                        testContext,
                        recordSetNames);

                    if (isCrossType)
                    {
                        var listresponse1 = testContext.DnsClient.RecordSets
                                            .ListByDnsZone(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName);

                        var listresponse2 = testContext.DnsClient.RecordSets
                                            .ListAllByDnsZone(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName);

                        foreach (var listresponse in new[] { listresponse1, listresponse2 })
                        {
                            // not checking for the record count as this will return standard SOA and auth NS records as well
                            Assert.NotNull(listresponse);
                            Assert.True(
                                listresponse.Any(
                                    recordSetReturned =>
                                    string.Equals(
                                        recordSetNames[0],
                                        recordSetReturned.Name))
                                &&
                                listresponse.Any(
                                    recordSetReturned =>
                                    string.Equals(
                                        recordSetNames[1],
                                        recordSetReturned.Name))
                                &&
                                listresponse.Any(
                                    recordSetReturned =>
                                    string.Equals(
                                        recordSetNames[2],
                                        recordSetReturned.Name)),
                                "The returned records do not meet expectations");
                        }
                    }
                    else
                    {
                        var listresponse = testContext.DnsClient.RecordSets
                                           .ListByType(
                            testContext.ResourceGroup.Name,
                            testContext.ZoneName,
                            RecordType.TXT);

                        Assert.NotNull(listresponse);
                        Assert.Equal(2, listresponse.Count());
                        Assert.True(
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[0],
                                    recordSetReturned.Name))
                            &&
                            listresponse.Any(
                                recordSetReturned =>
                                string.Equals(
                                    recordSetNames[1],
                                    recordSetReturned.Name)),
                            "The returned records do not meet expectations");
                    }

                    RecordSetScenarioTests.DeleteRecordSetsAndZone(
                        testContext,
                        recordSetNames);
                }
            }
        }