Пример #1
0
        public void WhenIGetTheQueryWithTheContextIdAndTo(IEventStore eventStore, IEventPlayer eventPlayer,
                                                          IUndoEventProcessingService undoEventProcessingService)
        {
            TestView expectedView = null;
            var      fixture      = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization());
            var      day          = 0;

            fixture.Register(() =>
            {
                day++;
                return(new DateTime().AddDays(day));
            });
            var events          = fixture.CreateMany <IEvent>(10).OrderBy(t => t.CreatedDateTime);
            var eventsToProcess = Substitute.For <IList <IEvent> >();
            var contextId       = Guid.NewGuid();
            var target          = new EventQuery <TestView>(eventStore, eventPlayer, undoEventProcessingService);

            eventStore.Get(contextId).Returns(events);
            undoEventProcessingService.Execute(Arg.Is <IEnumerable <IEvent> >(t => t.Count() == 5)).Returns(eventsToProcess);

            var result = target.Get(contextId, events.ElementAt(4).CreatedDateTime);

            eventPlayer.Received().Play(eventsToProcess, Arg.Is <TestView>(a => GetView(a, out expectedView)));
            Assert.Same(expectedView, result);
        }
Пример #2
0
        public void WhenIGetTheQueryWithOnlyTheContextId(IEventStore eventStore, IEventPlayer eventPlayer,
                                                         IUndoEventProcessingService undoEventProcessingService)
        {
            TestView expectedView    = null;
            var      events          = Substitute.For <IList <IEvent> >();
            var      eventsToProcess = Substitute.For <IList <IEvent> >();
            var      contextId       = Guid.NewGuid();
            var      target          = new EventQuery <TestView>(eventStore, eventPlayer, undoEventProcessingService);

            eventStore.Get(contextId).Returns(events);
            undoEventProcessingService.Execute(events).Returns(eventsToProcess);

            var result = target.Get(contextId);

            eventPlayer.Received().Play(eventsToProcess, Arg.Is <TestView>(a => GetView(a, out expectedView)));
            Assert.Same(expectedView, result);
        }