예제 #1
0
            public void CreatesNewVisit()
            {
                var visitor = new Visitor(Guid.NewGuid());
                var requestInfo = CreateRequestInfo();

                var visit = visitor.FindOrCreateVisit(requestInfo);

                Assert.IsNotNull(visit);
                Assert.AreEqual(requestInfo.SessionId, visit.SessionId);
            }
예제 #2
0
            public void FindsCurrentVisit()
            {
                var visitor = new Visitor(Guid.NewGuid());
                var requestInfo = CreateRequestInfo();

                var visit = visitor.FindOrCreateVisit(requestInfo);

                var foundVisit = visitor.FindOrCreateVisit(requestInfo);

                Assert.IsNotNull(foundVisit);
                Assert.AreSame(visit, foundVisit);
            }
예제 #3
0
            public void CanConstruct()
            {
                var requestInfo = CreateRequestInfo();

                var visitor = new Visitor(requestInfo.VisitorIdentifier);
                var visit = new Visit(visitor, requestInfo);
                var item = CreateItem();
                var action = new VisitAction(visit, VisitActionType.ContentView, item);

                Assert.AreEqual(VisitActionType.ContentView, action.VisitActionType);
                Assert.AreSame(item, action.BehaviorMonitoredItem);
                Assert.AreSame(visit, action.Visit);
            }
예제 #4
0
            public void CanConstruct()
            {
                var requestInfo = CreateRequestInfo();

                var visitor = new Visitor(requestInfo.VisitorIdentifier);

                var visit = new Visit(visitor, requestInfo);

                Assert.AreSame(visitor, visit.Visitor);
                Assert.AreEqual(requestInfo.IPAddress, visit.IPAddress);
                Assert.AreEqual(requestInfo.SessionId, visit.SessionId);
                Assert.AreEqual(requestInfo.UrlReferrer.ToString(), visit.UrlReferrer);
                Assert.AreEqual(requestInfo.UserAgent, visit.UserAgent);
            }
예제 #5
0
            public void FindsLatestVisitWhenMultipleVisitRecordsForTheSameSessionIdExist()
            {
                var visitor = new Visitor(Guid.NewGuid());
                var requestInfo = CreateRequestInfo();

                var firstVisit = visitor.FindOrCreateVisit(requestInfo);
                firstVisit.Id = 1;

                //simulate glitch that might cause additional visit records for the same session
                var secondVisit = new Visit(visitor, requestInfo) { Id = 2};
                visitor.Visits.Add(secondVisit);

                var foundVisit = visitor.FindOrCreateVisit(requestInfo);

                Assert.AreSame(secondVisit, foundVisit);
            }
예제 #6
0
 public Visit(Visitor visitor, RequestInfo requestInfo)
     : this()
 {
     if (visitor == null)
     {
         throw new ArgumentNullException("visitor");
     }
     if (requestInfo == null)
     {
         throw new ArgumentNullException("requestInfo");
     }
     Visitor = visitor;
     SessionId = requestInfo.SessionId;
     IPAddress = requestInfo.IPAddress ?? string.Empty;
     UserAgent = requestInfo.UserAgent ?? string.Empty;
     if (requestInfo.UrlReferrer != null)
     {
         UrlReferrer = requestInfo.UrlReferrer.ToString();
     }
 }
예제 #7
0
 public void CanConstruct()
 {
     var cookie = Guid.NewGuid();
     var visitor = new Visitor(cookie);
     Assert.AreEqual(cookie, visitor.VisitorIdentifier);
 }