@@ -395,6 +395,102 @@ public async Task MXRecordOperationTest()
395395 Assert . IsFalse ( flag ) ;
396396 }
397397
398+ [ RecordedTest ]
399+ public async Task NAPTRRecordOperationTest ( )
400+ {
401+ var collection = _dnsZone . GetDnsNaptrRecords ( ) ;
402+ string naptrRecordName = Recording . GenerateAssetName ( "naptr" ) ;
403+ int orderValue1 = 10 ;
404+ int orderValue2 = 20 ;
405+ int preferenceValue1 = 100 ;
406+ int preferenceValue2 = 200 ;
407+ string flagsValue1 = "s" ;
408+ string flagsValue2 = "a" ;
409+ string servicesValue1 = "eau" ;
410+ string servicesValue2 = "eau+sip" ;
411+ string regexpValue1 = "" ;
412+ string regexpValue2 = "!^(\\ +441632960083)$!sip:\\ [email protected] !" ; 413+ string replacementValue1 = "sip.contoso.com" ;
414+ string replacementValue2 = "." ;
415+ // CreateOrUpdate
416+ var data = new DnsNaptrRecordData ( )
417+ {
418+ TtlInSeconds = 3600 ,
419+ DnsNaptrRecords =
420+ {
421+ new DnsNaptrRecordInfo ( )
422+ {
423+ Order = orderValue1 ,
424+ Preference = preferenceValue1 ,
425+ Flags = flagsValue1 ,
426+ Services = servicesValue1 ,
427+ Regexp = regexpValue1 ,
428+ Replacement = replacementValue1
429+ } ,
430+ new DnsNaptrRecordInfo ( )
431+ {
432+ Order = orderValue2 ,
433+ Preference = preferenceValue2 ,
434+ Flags = flagsValue2 ,
435+ Services = servicesValue2 ,
436+ Regexp = regexpValue2 ,
437+ Replacement = replacementValue2
438+ } ,
439+ }
440+ } ;
441+
442+ var naptrRecord = await collection . CreateOrUpdateAsync ( WaitUntil . Completed , naptrRecordName , data ) ;
443+ ValidateRecordBaseInfo ( naptrRecord . Value . Data , naptrRecordName ) ;
444+ Assert . AreEqual ( "dnszones/NAPTR" , naptrRecord . Value . Data . ResourceType . Type . ToString ( ) ) ;
445+ Assert . AreEqual ( 3600 , naptrRecord . Value . Data . TtlInSeconds ) ;
446+ Assert . AreEqual ( orderValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Order ) ;
447+ Assert . AreEqual ( preferenceValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Preference ) ;
448+ Assert . AreEqual ( flagsValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Flags ) ;
449+ Assert . AreEqual ( servicesValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Services ) ;
450+ Assert . AreEqual ( regexpValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Regexp ) ;
451+ Assert . AreEqual ( replacementValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Replacement ) ;
452+ Assert . AreEqual ( orderValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Order ) ;
453+ Assert . AreEqual ( preferenceValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Preference ) ;
454+ Assert . AreEqual ( flagsValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Flags ) ;
455+ Assert . AreEqual ( servicesValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Services ) ;
456+ Assert . AreEqual ( regexpValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Regexp ) ;
457+ Assert . AreEqual ( replacementValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Replacement ) ;
458+
459+ // Exist
460+ bool flag = await collection . ExistsAsync ( naptrRecordName ) ;
461+ Assert . IsTrue ( flag ) ;
462+
463+ // Update
464+ var updateResponse = await naptrRecord . Value . UpdateAsync ( new DnsNaptrRecordData ( ) { TtlInSeconds = 7200 } ) ;
465+ Assert . AreEqual ( 7200 , updateResponse . Value . Data . TtlInSeconds ) ;
466+
467+ // Get
468+ var getResponse = await collection . GetAsync ( naptrRecordName ) ;
469+ ValidateRecordBaseInfo ( getResponse . Value . Data , naptrRecordName ) ;
470+ Assert . AreEqual ( orderValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Order ) ;
471+ Assert . AreEqual ( preferenceValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Preference ) ;
472+ Assert . AreEqual ( flagsValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Flags ) ;
473+ Assert . AreEqual ( servicesValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Services ) ;
474+ Assert . AreEqual ( regexpValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Regexp ) ;
475+ Assert . AreEqual ( replacementValue1 , naptrRecord . Value . Data . DnsNaptrRecords [ 0 ] . Replacement ) ;
476+ Assert . AreEqual ( orderValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Order ) ;
477+ Assert . AreEqual ( preferenceValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Preference ) ;
478+ Assert . AreEqual ( flagsValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Flags ) ;
479+ Assert . AreEqual ( servicesValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Services ) ;
480+ Assert . AreEqual ( regexpValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Regexp ) ;
481+ Assert . AreEqual ( replacementValue2 , naptrRecord . Value . Data . DnsNaptrRecords [ 1 ] . Replacement ) ;
482+
483+ // GetAll
484+ var list = await collection . GetAllAsync ( ) . ToEnumerableAsync ( ) ;
485+ Assert . IsNotEmpty ( list ) ;
486+ ValidateRecordBaseInfo ( list . First ( item => item . Data . Name == naptrRecordName ) . Data , naptrRecordName ) ;
487+
488+ // Delete
489+ await naptrRecord . Value . DeleteAsync ( WaitUntil . Completed ) ;
490+ flag = await collection . ExistsAsync ( naptrRecordName ) ;
491+ Assert . IsFalse ( flag ) ;
492+ }
493+
398494 [ RecordedTest ]
399495 public async Task NSRecordOperationTest ( )
400496 {
0 commit comments