protected override void Given() { base.Given(); this.eventStore = new Mock <Domain.Model.IEventStore>(); this.sut = new NotificationApplicationService(this.eventStore.Object); this.events = this.GetEvents(); this.eventStore .Setup(e => e.GetLog(It.IsAny <NotificationLogId>(), It.IsAny <CancellationToken>())) .Returns <string, NotificationLogId, CancellationToken>( (s, n, ct) => EventStore.CreateNotificationLog( n, this.CountOfEventsToAdd, this.events.Where( e => e.SequenceId >= n.Low && e.SequenceId <= n.High ).ToArray() ) ); this.eventStore .Setup(e => e.GetLog(It.IsAny <CancellationToken>())) .Returns <string, CancellationToken>( (s, ct) => { var n = EventStore.CalculateCurrentNotificationLogId(this.CountOfEventsToAdd); if (this.CountOfEventsToAdd > 0) { return(EventStore.CreateNotificationLog( n.NotificationLogId, this.CountOfEventsToAdd, this.events.Where( e => e.SequenceId >= n.NotificationLogId.Low && e.SequenceId <= n.NotificationLogId.High ).ToArray() )); } else { return(EventStore.CreateNotificationLog( n, this.CountOfEventsToAdd, this.events.Where( e => e.SequenceId >= n.NotificationLogId.Low && e.SequenceId <= n.NotificationLogId.High ).ToArray() )); } } ); }