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)); }
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); }
public bool Equals(Visitor other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.WebIdentifier, WebIdentifier); }
public void Arrange() { _visitor = new Visitor("SomeSessionId"); _repository = new VisitorsByDateRepository(); _reporter = new ReportWriter(_repository); }
public Visit(DateTime when,Visitor visitor) { When = when; Visitor = visitor; }