示例#1
0
        public void capture_immutable_events_with_for_update_lock(DocumentTracking sessionType, TenancyStyle tenancyStyle, string[] tenants)
        {
            var store = InitStore(tenancyStyle, useAppendEventForUpdateLock: true);

            var id = Guid.NewGuid();

            When.CalledForEach(tenants, (tenantId, index) =>
            {
                var immutableEvent = new ImmutableEvent(id, "some-name");

                using (var session = store.OpenSession(tenantId, sessionType))
                {
                    session.Events.Append(id, immutableEvent);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession(tenantId, sessionType))
                {
                    var streamEvents = session.Events.FetchStream(id);

                    streamEvents.Count.ShouldBe(1);
                    var @event = streamEvents.ElementAt(0).Data.ShouldBeOfType <ImmutableEvent>();

                    @event.Id.ShouldBe(id);
                    @event.Name.ShouldBe("some-name");
                }
            }).ShouldThrowIf(
                (tenancyStyle == TenancyStyle.Single && tenants.Length > 1) || (tenancyStyle == TenancyStyle.Conjoined && tenants.SequenceEqual(SameTenants))
                );
        }
        public void capture_immutable_events(DocumentTracking sessionType)
        {
            var store = InitStore();

            var id             = Guid.NewGuid();
            var immutableEvent = new ImmutableEvent(id, "some-name");

            using (var session = store.OpenSession(sessionType))
            {
                session.Events.Append(id, immutableEvent);
                session.SaveChanges();
            }

            using (var session = store.OpenSession(sessionType))
            {
                var streamEvents = session.Events.FetchStream(id);

                streamEvents.Count.ShouldBe(1);
                var @event = streamEvents.ElementAt(0).Data.ShouldBeOfType <ImmutableEvent>();

                @event.Id.ShouldBe(id);
                @event.Name.ShouldBe("some-name");
            }
        }
        public void capture_immutable_events(DocumentTracking sessionType)
        {
            var store = InitStore();

            var id = Guid.NewGuid();
            var immutableEvent = new ImmutableEvent(id, "some-name");

            using (var session = store.OpenSession(sessionType))
            {
                session.Events.Append(id, immutableEvent);
                session.SaveChanges();
            }

            using (var session = store.OpenSession(sessionType))
            {
                var streamEvents = session.Events.FetchStream(id);

                streamEvents.Count.ShouldBe(1);
                var @event = streamEvents.ElementAt(0).Data.ShouldBeOfType<ImmutableEvent>();

                @event.Id.ShouldBe(id);
                @event.Name.ShouldBe("some-name");
            }
        }