private void ListRecordsInZoneWithNext(bool isCrossType) { using (UndoContext context = UndoContext.Current) { context.Start(currentMethodStackDepth: 4); SingleRecordSetTestContext testContext = RecordSetScenarioTests.SetupSingleRecordSetTest(); const string suffix = ".com"; var recordSetNames = new[] { TestUtilities.GenerateName("hydratestrec") + suffix, TestUtilities.GenerateName("hydratestrec") + ".con", TestUtilities.GenerateName("hydratestrec") + ".con" }; RecordSetScenarioTests.CreateRecordSets(testContext, recordSetNames); RecordSetListResponse listResponse; if (isCrossType) { listResponse = testContext.DnsClient.RecordSets.ListAll( testContext.ResourceGroup.Name, testContext.ZoneName, new RecordSetListParameters { Top = "3" }); } else { listResponse = testContext.DnsClient.RecordSets.List( testContext.ResourceGroup.Name, testContext.ZoneName, RecordType.TXT, new RecordSetListParameters { Top = "3" }); } listResponse = testContext.DnsClient.RecordSets.ListNext(listResponse.NextLink); Assert.NotNull(listResponse); Assert.True( listResponse.RecordSets.Any(recordReturned => string.Equals(recordSetNames[1], recordReturned.Name)), "The returned records do not meet expectations"); RecordSetScenarioTests.DeleteRecordSetsAndZone(testContext, recordSetNames); } }
private void ListRecordsInZoneWithTop(bool isCrossType) { using (UndoContext context = UndoContext.Current) { context.Start(currentMethodStackDepth: 4); SingleRecordSetTestContext testContext = RecordSetScenarioTests.SetupSingleRecordSetTest(); var recordSetNames = new[] { TestUtilities.GenerateName("hydratestrec") + ".com", TestUtilities.GenerateName("hydratestrec") + ".con", TestUtilities.GenerateName("hydratestrec") + ".con" }; RecordSetScenarioTests.CreateRecordSets(testContext, recordSetNames); RecordSetListResponse listResponse; if (isCrossType) { // Using top = 3, it will pick up SOA, NS and the first TXT listResponse = testContext.DnsClient.RecordSets.ListAll( testContext.ResourceGroup.Name, testContext.ZoneName, new RecordSetListParameters { Top = "3" }); } 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.List( testContext.ResourceGroup.Name, testContext.ZoneName, RecordType.TXT, new RecordSetListParameters { Top = "3" }); } Assert.NotNull(listResponse); Assert.True( listResponse.RecordSets.Any(recordReturned => string.Equals(recordSetNames[0], recordReturned.Name)), "The returned records do not meet expectations"); RecordSetScenarioTests.DeleteRecordSetsAndZone(testContext, recordSetNames); } }
private void ListRecordsInZoneWithFilter(bool isCrossType) { using (UndoContext context = UndoContext.Current) { context.Start(currentMethodStackDepth: 4); SingleRecordSetTestContext testContext = RecordSetScenarioTests.SetupSingleRecordSetTest(); var recordSetNames = new[] { TestUtilities.GenerateName("hydratestrec"), TestUtilities.GenerateName("hydratestrec"), TestUtilities.GenerateName("hydratestrec") }; RecordSetScenarioTests.CreateRecordSets(testContext, recordSetNames); RecordSetListResponse listResponse; if (isCrossType) { listResponse = testContext.DnsClient.RecordSets.ListAll( testContext.ResourceGroup.Name, testContext.ZoneName, new RecordSetListParameters { Filter = string.Format("endswith(Name,'{0}')", recordSetNames[0]) }); } else { listResponse = testContext.DnsClient.RecordSets.List( testContext.ResourceGroup.Name, testContext.ZoneName, RecordType.TXT, new RecordSetListParameters { Filter = string.Format("endswith(Name,'{0}')", recordSetNames[0]) }); } // not checking for the record count as this will return standard SOA and auth NS records as well Assert.NotNull(listResponse); Assert.Equal(1, listResponse.RecordSets.Count); Assert.NotNull(listResponse.RecordSets.FirstOrDefault()); Assert.Equal(recordSetNames[0], listResponse.RecordSets.FirstOrDefault().Name); RecordSetScenarioTests.DeleteRecordSetsAndZone(testContext, recordSetNames); } }
private void ListRecordsInZoneWithTop( bool isCrossType, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "testframework_failed") { using ( MockContext context = MockContext.Start( this.GetType().FullName, methodName)) { SingleRecordSetTestContext testContext = RecordSetScenarioTests.SetupSingleRecordSetTest(context); 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 .ListAllInResourceGroup( 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); } }