Esempio n. 1
0
        /// <summary>
        /// this method populates the DnsRecords table with viable DnsRecords stored in metadata
        /// </summary>
        /// <remarks>
        /// Related domains are pulled from the DnsRecodDomainNames per each possible DnsRecordType.
        /// These can be generated using the common.tests.DnsResponseToBinExample.cs test class, however
        /// they must be copied to the metadata\dns responses folder in this project and marked as copy to output
        /// directory, if newer
        /// </remarks>
        protected void InitDnsRecords()
        {
            List <string> domains = DnsRecordDomainNames.ToList <string>();
            List <DnsStandard.RecordType> recTypes = DnsRecordTypes.ToList <DnsStandard.RecordType>();

            DnsRecordManager mgr = new DnsRecordManager(new ConfigStore(ConnectionString));

            mgr.RemoveAll();

            //----------------------------------------------------------------------------------------------------
            //---go through all domains and load up the corresponding record types
            foreach (string domainName in domains)
            {
                mgr.Add(new DnsRecord(domainName
                                      , (int)DnsStandard.RecordType.MX
                                      , LoadAndVerifyDnsRecordFromBin <MXRecord>(Path.Combine(DnsRecordsPath
                                                                                              , string.Format("mx.{0}.bin", domainName)))
                                      , string.Format("some test notes for mx domain{0}", domainName)));

                mgr.Add(new DnsRecord(domainName
                                      , (int)DnsStandard.RecordType.SOA
                                      , LoadAndVerifyDnsRecordFromBin <SOARecord>(Path.Combine(DnsRecordsPath
                                                                                               , string.Format("soa.{0}.bin", domainName)))
                                      , string.Format("some test notes for soa domain{0}", domainName)));

                mgr.Add(new DnsRecord(domainName
                                      , (int)DnsStandard.RecordType.ANAME
                                      , LoadAndVerifyDnsRecordFromBin <AddressRecord>(Path.Combine(DnsRecordsPath
                                                                                                   , string.Format("aname.{0}.bin", domainName)))
                                      , string.Format("some test notes for aname domain{0}", domainName)));
            }
        }
Esempio n. 2
0
        public void StoreTest()
        {
            DnsRecordManager mgr    = CreateManager();
            ConfigStore      actual = mgr.Store;

            Assert.Equal(mgr.Store, actual);
        }
Esempio n. 3
0
        public void GetTest10()
        {
            InitDnsRecords();

            DnsRecordManager mgr = CreateManager();

            DnsRecord[] recs = mgr.Get("microsoft.com");
            Assert.Equal(3, recs.Length);
            recs = mgr.Get("microsoft11.com");
            Assert.Equal(0, recs.Length);

            recs = mgr.Get("microsoft.com", Common.DnsResolver.DnsStandard.RecordType.AAAA);
            Assert.Equal(0, recs.Length);
            recs = mgr.Get("microsoft.com", Common.DnsResolver.DnsStandard.RecordType.SOA);
            Assert.Equal(1, recs.Length);
            recs = mgr.Get("microsoft.com", Common.DnsResolver.DnsStandard.RecordType.MX);
            Assert.Equal(1, recs.Length);
            recs = mgr.Get("microsoft.com", Common.DnsResolver.DnsStandard.RecordType.ANAME);
            Assert.Equal(1, recs.Length);
        }