/// <summary>
        /// this routine populates the cache with items and confirms that they are in there
        /// </summary>
        public void PopulateBasicCache()
        {
            m_drrc = new DnsResponseCache(Guid.NewGuid().ToString("D"));

            DumpSuccess("");

            // populate the entires
            PopulateMockDnsARecordResponseEntries();

            // force static TTL
            ForceTtlTime(m_basettl);

            foreach (DnsResponse dr in m_responses)
            {
                m_drrc.Put(dr);
            }

            DumpSuccess("Checking for {0} items stored in cache", m_responses.Count());

            // make sure that the cache count reflects 10 entries
            Assert.Equal(m_responses.Count(), m_drrc.CacheCount);

            DumpSuccess("Checking all entries in cache to make sure they exist as expected");

            // check the entries to make sure that all are found in the cache
            foreach (DnsResponse dr in m_responses)
            {
                DnsResponse res = m_drrc.Get(dr.Question);

                // make sure that the expect entry was found
                Assert.NotNull(res);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <b>DnsClientWithCacheFacts</b> class.
 /// </summary>
 public DnsClientWithCacheFacts()
     : base(DumpIsEnabled)
 {
     m_cache = new DnsResponseCache(Guid.NewGuid().ToString("D"));
     m_client = new DnsClientWithCache(PublicDns) { Timeout = TimeSpan.FromSeconds(5), Cache = m_cache};
     m_client.MaxRetries = 1;
     m_clientNoCache = new DnsClient(PublicDns) { Timeout = TimeSpan.FromSeconds(5) };
     m_clientNoCache.MaxRetries = 1;
 }
 /// <summary>
 /// Initializes a new instance of the <b>DnsClientWithCacheFacts</b> class.
 /// </summary>
 public DnsClientWithCacheFacts()
     : base(DumpIsEnabled)
 {
     m_cache  = new DnsResponseCache(Guid.NewGuid().ToString("D"));
     m_client = new DnsClientWithCache(PublicDns)
     {
         Timeout = TimeSpan.FromSeconds(5), Cache = m_cache
     };
     m_client.MaxRetries = 1;
     m_clientNoCache     = new DnsClient(PublicDns)
     {
         Timeout = TimeSpan.FromSeconds(5)
     };
     m_clientNoCache.MaxRetries = 1;
 }
Esempio n. 4
0
        /// <summary>
        /// this routine populates the cache with items and confirms that they are in there
        /// </summary>
        public void PopulateBasicCache()
        {
            m_drrc = new DnsResponseCache(Guid.NewGuid().ToString("D"));

            DumpSuccess("");

            // populate the entires
            PopulateMockDnsARecordResponseEntries();
            
            // force static TTL
            ForceTtlTime(m_basettl);

            foreach (DnsResponse dr in m_responses)
            {
                m_drrc.Put(dr);
            }

            DumpSuccess("Checking for {0} items stored in cache", m_responses.Count());

            // make sure that the cache count reflects 10 entries
            Assert.Equal(m_responses.Count(), m_drrc.CacheCount);

            DumpSuccess("Checking all entries in cache to make sure they exist as expected");

            // check the entries to make sure that all are found in the cache
            foreach (DnsResponse dr in m_responses)
            {
                DnsResponse res = m_drrc.Get(dr.Question);

                // make sure that the expect entry was found
                Assert.NotNull(res);
            }
        }