private void ListRecordsInZone(bool isCrossType) { using (UndoContext context = UndoContext.Current) { context.Start(currentMethodStackDepth: 4); SingleRecordSetTestContext testContext = SetupSingleRecordSetTest(); var recordSetNames = new[] { TestUtilities.GenerateName("hydratestrec"), TestUtilities.GenerateName("hydratestrec"), TestUtilities.GenerateName("hydratestrec") }; RecordSetScenarioTests.CreateRecordSets(testContext, recordSetNames); if (isCrossType) { RecordSetListResponse listresponse = testContext.DnsClient.RecordSets.ListAll( testContext.ResourceGroup.Name, testContext.ZoneName, new RecordSetListParameters()); // not checking for the record count as this will return standard SOA and auth NS records as well Assert.NotNull(listresponse); Assert.True( listresponse.RecordSets.Any(recordSetReturned => string.Equals(recordSetNames[0], recordSetReturned.Name)) && listresponse.RecordSets.Any(recordSetReturned => string.Equals(recordSetNames[1], recordSetReturned.Name)) && listresponse.RecordSets.Any(recordSetReturned => string.Equals(recordSetNames[2], recordSetReturned.Name)), "The returned records do not meet expectations"); } else { RecordSetListResponse listresponse = testContext.DnsClient.RecordSets.List( testContext.ResourceGroup.Name, testContext.ZoneName, RecordType.TXT, new RecordSetListParameters()); Assert.NotNull(listresponse); Assert.Equal(2, listresponse.RecordSets.Count); Assert.True( listresponse.RecordSets.Any(recordSetReturned => string.Equals(recordSetNames[0], recordSetReturned.Name)) && listresponse.RecordSets.Any(recordSetReturned => string.Equals(recordSetNames[1], recordSetReturned.Name)), "The returned records do not meet expectations"); } RecordSetScenarioTests.DeleteRecordSetsAndZone(testContext, recordSetNames); } }
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)) { 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); } } }
private void ListRecordsInZoneWithSuffixCrossType( bool isCrossType, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "testframework_failed") { using ( MockContext context = MockContext.Start( this.GetType().FullName, 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); } } }
private void ListRecordsInZone( bool isCrossType, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "testframework_failed") { using ( MockContext context = MockContext.Start( this.GetType().FullName, 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); } } }