public async Task updateonly_event_for_custom_view_projection_should_not_create_new_document()
        {
            StoreOptions(_ =>
            {
                _.AutoCreateSchemaObjects = AutoCreate.All;
                _.Events.TenancyStyle     = Marten.Storage.TenancyStyle.Conjoined;
                _.Events.InlineProjections.Add <NewsletterSubscriptionProjection>();
            });

            var subscriptionId = Guid.NewGuid();
            var newsletterId   = Guid.NewGuid();
            var readerId       = Guid.NewGuid();

            var readerSubscribed = new ReaderSubscribed(subscriptionId, newsletterId, readerId, "John Doe");

            theSession.Events.StartStream <NewsletterSubscription>(streamId, readerSubscribed);
            await theSession.SaveChangesAsync();

            var subscription = await theSession.LoadAsync <NewsletterSubscription>(subscriptionId);

            subscription.ShouldNotBeNull();

            var newsletterOpened = new NewsletterOpened(subscriptionId, DateTime.Now);

            theSession.Events.Append(subscriptionId, newsletterOpened);
            await theSession.SaveChangesAsync();

            subscription = await theSession.LoadAsync <NewsletterSubscription>(subscriptionId);

            subscription.ShouldNotBeNull();

            var readerUnsubscribed = new ReaderUnsubscribed(subscriptionId);

            theSession.Events.Append(subscriptionId, readerUnsubscribed);
            await theSession.SaveChangesAsync();

            subscription = await theSession.LoadAsync <NewsletterSubscription>(subscriptionId);

            subscription.ShouldBeNull();

            var newsletterOpenedAfterUnsubscribe = new NewsletterOpened(subscriptionId, DateTime.Now);

            theSession.Events.Append(subscriptionId, newsletterOpenedAfterUnsubscribe);
            await theSession.SaveChangesAsync();

            subscription = await theSession.LoadAsync <NewsletterSubscription>(subscriptionId);

            subscription.ShouldBeNull();
        }
 private void Persist(NewsletterSubscription view, NewsletterOpened @event)
 {
     view.OpensCount++;
 }
Exemple #3
0
 public void Apply(NewsletterSubscription view, NewsletterOpened @event)
 {
     view.OpensCount++;
 }