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 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 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); }