Пример #1
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);
            }
Пример #2
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);
            }
Пример #3
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);
            }