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); }
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); }
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); }
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); }
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); }
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(); } }
public void CanConstruct() { var cookie = Guid.NewGuid(); var visitor = new Visitor(cookie); Assert.AreEqual(cookie, visitor.VisitorIdentifier); }