Beispiel #1
0
        public async void undropping_projection_should_have_impact_only_between_executions()
        {
            var store = await GetMessageStore();

            const string streamName = "test-321";
            var          data       = GetUncommitedMessages();

            await store.AppendToStream(streamName, ExpectedVersion.Any, data).NotOnCapturedContext();

            using (var linearizer = new MsSqlLinearizer(ConnectionString, new NullLogger()))
            {
                await linearizer.Run().NotOnCapturedContext();
            }

            var projector = await GetProjector(c => c.AddProjection <TestProjection>().AddProjection <TestProjectionWithExceptionOnMessageOne>());

            var results = await projector.Run();

            var droppedProjection = results.FirstOrDefault(x => x.Status == DispatchingResult.Statuses.DroppedOnException);

            droppedProjection.Descriptor.Undrop();

            results = await projector.Run();

            Assert.NotNull(results.FirstOrDefault(x => x.Status == DispatchingResult.Statuses.DroppedOnException));
        }
Beispiel #2
0
        public async void after_running_projector_currentposition_on_projection_is_equal_to_max_messageposition()
        {
            var store = await GetMessageStore();

            const string streamName = "test-321";
            var          data       = GetUncommitedMessages();

            await store.AppendToStream(streamName, ExpectedVersion.Any, data).NotOnCapturedContext();

            using (var linearizer = new MsSqlLinearizer(ConnectionString, new NullLogger()))
            {
                await linearizer.Run().NotOnCapturedContext();
            }

            var projector = await GetProjector(c => c.AddProjection <TestProjection>());

            await projector.Run();

            Assert.Equal(data.Messages.Length, projector.GetProjections().Max(x => x.CurrentPosition));
        }
Beispiel #3
0
        public async void after_running_projector_with_projection_throwing_currentposition_should_be_the_same_as_postion_at_the_beggining()
        {
            const int expectedPositionForThrowingProjection = 0;

            var store = await GetMessageStore();

            const string streamName = "test-321";
            var          data       = GetUncommitedMessages();

            await store.AppendToStream(streamName, ExpectedVersion.Any, data).NotOnCapturedContext();

            using (var linearizer = new MsSqlLinearizer(ConnectionString, new NullLogger()))
            {
                await linearizer.Run().NotOnCapturedContext();
            }

            var projector = await GetProjector(c => c.AddProjection <TestProjection>().AddProjection <TestProjectionWithExceptionOnMessageOne>());

            var results = await projector.Run();

            Assert.NotNull(results.FirstOrDefault(x => x.Status == DispatchingResult.Statuses.DroppedOnException && x.Descriptor.CurrentPosition == expectedPositionForThrowingProjection));
        }
Beispiel #4
0
        public async void After_linearization_in_small_batches_head_position_should_be_equal_expected_number()
        {
            const byte   expected    = 18;
            const string streamName1 = "test-123";
            const string streamName2 = "test-456";

            var store = await GetMessageStore();

            var data = GetUncommitedMessages();
            await store.AppendToStream(streamName1, ExpectedVersion.NoStream, data).NotOnCapturedContext();

            data = GetUncommitedMessages();
            await store.AppendToStream(streamName2, ExpectedVersion.NoStream, data).NotOnCapturedContext();

            using (var linearizer = new MsSqlLinearizer(ConnectionString, new NullLogger(), batchSize: 4))
            {
                await linearizer.Run().NotOnCapturedContext();
            }

            var head = await store.Advanced.ReadHeadMessagePosition().NotOnCapturedContext();

            Assert.Equal(expected, head);
        }