public async Task Can_dispatch_event()
        {
            List<object> projectedEvents = new List<object>();
            var handlerResolver = new ProjectionHandlerResolver(new TestProjectionModule(projectedEvents));
            const string streamId = "stream";
            var eventId = Guid.NewGuid();
            const int version = 2;
            var timeStamp = DateTimeOffset.UtcNow;
            var headers = new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());

            using(var dispatcher = new TestProjectionDispatcher(handlerResolver, new InMemoryCheckpointRepository()))
            {
                await dispatcher.Start();
                await dispatcher.DoDispatch(streamId, eventId, version, timeStamp, "checkpoint", headers, new TestEvent());
            }

            projectedEvents.Count.Should().Be(1);
            
            var projectionEvent = projectedEvents[0].As<ProjectionEvent<TestEvent>>();
            projectionEvent.StreamId.Should().Be(streamId);
            projectionEvent.EventId.Should().Be(eventId);
            projectionEvent.Version.Should().Be(version);
            projectionEvent.TimeStamp.Should().Be(timeStamp);
            projectionEvent.Headers.Should().NotBeNull();
        }
Beispiel #2
0
        public async Task Can_dispatch_event()
        {
            List <object> projectedEvents = new List <object>();
            var           handlerResolver = new ProjectionHandlerResolver(new TestProjectionModule(projectedEvents));
            const string  streamId        = "stream";
            var           eventId         = Guid.NewGuid();
            const int     version         = 2;
            var           timeStamp       = DateTimeOffset.UtcNow;
            var           headers         = new ReadOnlyDictionary <string, object>(new Dictionary <string, object>());

            using (var dispatcher = new TestProjectionDispatcher(handlerResolver, new InMemoryCheckpointRepository()))
            {
                await dispatcher.Start();

                await dispatcher.DoDispatch(streamId, eventId, version, timeStamp, "checkpoint", headers, new TestEvent());
            }

            projectedEvents.Count.Should().Be(1);

            var projectionEvent = projectedEvents[0].As <ProjectionEvent <TestEvent> >();

            projectionEvent.StreamId.Should().Be(streamId);
            projectionEvent.EventId.Should().Be(eventId);
            projectionEvent.Version.Should().Be(version);
            projectionEvent.TimeStamp.Should().Be(timeStamp);
            projectionEvent.Headers.Should().NotBeNull();
        }