Example #1
0
        private static WhoisEnhancedRecord WhoisEnhanced(string ipAddress, string filters, string referrer)
        {
            if (filters != null)
            {
                filters = filters.Scrub();
                Assert.ValidInput(filters, "filters");
            }
            if (referrer != null)
            {
                referrer = referrer.Scrub();
                Assert.ValidInput(referrer, "referrer");
            }

            var hash = BuildHashKey(ipAddress, filters);

            if (ServiceCache.IsInCache <WhoisEnhancedRecord>(hash))
            {
                var cachedRecord = (WhoisEnhancedRecord)ServiceCache.GetFromCache <WhoisEnhancedRecord>(hash);
                if (cachedRecord != null)
                {
                    return(cachedRecord);
                }
            }

            var whoisEnhancedRecord = new WhoisEnhancedRecord(Whois(ipAddress), filters, referrer);

            return(whoisEnhancedRecord.AddToCache(hash));
        }
        public void ShouldVerifyReferrerByReferrer()
        {
            var response = new WhoisEnhancedRecord();

            response.ProcessReferrer("Twitter");

            Assert.IsTrue(response.IsReferrerMatch);
            Assert.Contains("twitter", response.ReferrerMatches);
        }
        public void ShouldVerifyFriendlyByOrganization()
        {
            var response = new WhoisEnhancedRecord {Organization = "Google Inc."};

            response.ProcessFriendly();
            
            Assert.IsTrue(response.IsFriendly);
            Assert.Contains("google",response.FriendlyMatches);
        }
        public void ShouldVerifyFiltersByCountryAndReferrer()
        {
            var response = new WhoisEnhancedRecord {Country = "CANADA"};

            response.ProcessFilters("Canada,github", "github");

            Assert.IsTrue(response.IsFilterMatch);
            Assert.Contains("Country", response.FilterMatches);
            Assert.Contains("Referrer", response.FilterMatches);
        }
        private static WhoisEnhancedRecord WhoisEnhanced(string ipAddress, string filters, string referrer)
        {
            if (filters != null)
            {
                filters = filters.Scrub();
                Assert.ValidInput(filters, "filters");
            }
            if (referrer != null)
            {
                referrer = referrer.Scrub();
                Assert.ValidInput(referrer, "referrer");
            }

            var hash = BuildHashKey(ipAddress, filters);

            if (ServiceCache.IsInCache<WhoisEnhancedRecord>(hash))
            {
                var cachedRecord = (WhoisEnhancedRecord)ServiceCache.GetFromCache<WhoisEnhancedRecord>(hash);
                if (cachedRecord != null)
                {
                    return cachedRecord;
                }
            }

            var whoisEnhancedRecord = new WhoisEnhancedRecord(Whois(ipAddress), filters, referrer);

            return whoisEnhancedRecord.AddToCache(hash);
        }