示例#1
0
        public async Task HandleAsync_EventAlreadyApplied_PublishesAlreadyAppliedNotification()
        {
            var command = Fixtures.Pipelines.FakeCreateCommand();
            var @event  = Fixtures.Pipelines.FakeCreatedIntegrationEvent(command);

            // Ensure query model already exist.
            var queryModel = new FakeImmutableQueryModel
            {
                Id           = @event.SnapshotId.EntryId,
                Version      = @event.SnapshotId.EntryVersion,
                AppliedEvent = new AppliedEvent {
                    Id = @event.Id, Created = @event.Created
                }
            };

            await storage.CreateAsync(queryModel);

            // Fire event again.
            var notification = new IntegrationEventNotification <FakeCreatedIntegrationEvent>(@event);

            await handler.Handle(notification, CancellationToken.None);

            // Event already applied notification is fired.
            mediator.PublishedNotifications.Single().Should().BeOfType <EventAlreadyAppliedNotification>()
            .Which.QueryModelType.Should().Be(typeof(FakeImmutableQueryModel));
        }
示例#2
0
        public async Task Create_NoQueryModel_Creates()
        {
            var queryModel = new FakeImmutableQueryModel();

            var stored = await storage.CreateAsync(queryModel);

            stored.Should().BeEquivalentTo(queryModel, options => options.ForImmutableQueryModel());
        }
示例#3
0
        public async Task Create_QueryModelAlreadyExist_Throws()
        {
            var queryModel = new FakeImmutableQueryModel();

            await storage.CreateAsync(queryModel);

            storage.Awaiting(s => s.CreateAsync(queryModel)).Should().Throw <StorageException>()
            .Which.RequestInformation.ExtendedErrorInformation.ErrorCode.Should().Be(TableErrorCodeStrings.EntityAlreadyExists);
        }