示例#1
0
 public void AddVisitor(string webIdentifier)
 {
     var theVisitor = new Visitor(webIdentifier);
     _visits.Add(new Visit(DateTime.Now,theVisitor));
     if (_visitors.Contains(theVisitor)) return;
     _visitors.Add(theVisitor);
     DomainEvents.Raise(new VisitorForFirstTimeInDay(webIdentifier,DateTime.Now));
 }
示例#2
0
        public void only_one_visitor_per_day_per_identifier_is_added()
        {
            var eventRaisedCount = 0;
            DomainEvents.Register<VisitorForFirstTimeInDay>(e => eventRaisedCount++);
            var visitor = new Visitor("SomeId");
            var today = DateTime.Today;
            var atNoon = today.AddHours(12);
            var atDinnerTime = today.AddHours(17);
            visitor.Visit(today);
            visitor.Visit(atNoon);
            visitor.Visit(atDinnerTime);

            Assert.AreEqual(1,eventRaisedCount);
        }
示例#3
0
 public bool Equals(Visitor other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.WebIdentifier, WebIdentifier);
 }
示例#4
0
 public void Arrange()
 {
     _visitor = new Visitor("SomeSessionId");
     _repository = new VisitorsByDateRepository();
     _reporter = new ReportWriter(_repository);
 }
示例#5
0
 public Visit(DateTime when,Visitor visitor)
 {
     When = when;
     Visitor = visitor;
 }