public void CreateOrUpdateDupExTest()
        {
            TransitReferrerHost host = new TransitReferrerHost();

            host.LastSource   = string.Format("http://{0}", Guid.NewGuid().ToString());
            host.LastUrl      = string.Format("http://{0}", Guid.NewGuid().ToString());
            host.Name         = Guid.NewGuid().ToString();
            host.RequestCount = 1;
            host.Id           = Blog.CreateOrUpdateReferrerHost(Ticket, host);

            string rollupname = Guid.NewGuid().ToString();

            TransitReferrerHostRollup rollup = new TransitReferrerHostRollup();

            rollup.Name   = string.Format("%.{0}", rollupname);
            rollup.Rollup = host.Name;
            rollup.Id     = Blog.CreateOrUpdateReferrerHostRollup(Ticket, rollup);

            TransitReferrerHost host2 = new TransitReferrerHost();

            host2.LastSource   = host2.LastUrl = string.Format("http://{0}", Guid.NewGuid().ToString());
            host2.Name         = string.Format("www.{0}", rollupname);
            host2.RequestCount = 1;
            host2.Id           = Blog.CreateOrUpdateReferrerHost(Ticket, host2);

            Assert.AreEqual(host.Id, host2.Id, "Rollup did not translate a LIKE host.");

            Blog.DeleteReferrerHost(Ticket, host.Id);
            Blog.DeleteReferrerHostRollup(Ticket, rollup.Id);
        }
Example #2
0
        public void ExistingReferrerHostRollupTest()
        {
            int count = 10;
            // create hosts
            TransitReferrerHost host = new TransitReferrerHost();

            host.LastSource   = host.LastUrl = "http://localhost";
            host.RequestCount = 1;

            string root = Guid.NewGuid().ToString();

            for (int i = 0; i < count; i++)
            {
                host.Name = string.Format("www.{0}.{1}", root, i);
                Blog.CreateOrUpdateReferrerHost(Ticket, host);
                Console.WriteLine("Created {0}", host.Name);
            }

            // create a rollup, should merge hosts
            TransitReferrerHostRollup rollup = new TransitReferrerHostRollup();

            rollup.Name   = string.Format("www.{0}.%", root);
            rollup.Rollup = string.Format("www.{0}.target", root);
            rollup.Id     = Blog.CreateOrUpdateReferrerHostRollup(Ticket, rollup);

            // additional host will auto-rollup
            for (int i = 0; i < count; i++)
            {
                host.Name = string.Format("www.{0}.{1}", root, i);
                Blog.CreateOrUpdateReferrerHost(Ticket, host);
                Console.WriteLine("Created {0}", host.Name);
            }

            // get the rollup host
            TransitReferrerHost[] hosts = Blog.GetReferrerHosts(Ticket, null);

            bool found = false;

            foreach (TransitReferrerHost rh in hosts)
            {
                if (rh.Name == rollup.Rollup)
                {
                    Console.WriteLine("Found {0} with {1} hits", rh.Name, rh.RequestCount);
                    Assert.AreEqual(rh.RequestCount, count * 2);
                    found = true;
                    Blog.DeleteReferrerHost(Ticket, rh.Id);
                }
            }

            Assert.IsTrue(found);
            Blog.DeleteReferrerHostRollup(Ticket, rollup.Id);
        }
Example #3
0
 public BlogReferrerHostRollupTest()
 {
     mReferrerHostRollup        = new TransitReferrerHostRollup();
     mReferrerHostRollup.Name   = Guid.NewGuid().ToString();
     mReferrerHostRollup.Rollup = Guid.NewGuid().ToString();
 }