Beispiel #1
0
        public async Task filters_by_event_type_name()
        {
            using (var session = theStore.OpenSession())
            {
                for (int i = 0; i < 20; i++)
                {
                    var joined = new MembersJoined
                    {
                        Day = i,
                        Location = Guid.NewGuid().ToString(),
                        Members = new string[] { Guid.NewGuid().ToString() }
                    };

                    var departed = new MembersDeparted { Day = i, Location = Guid.NewGuid().ToString(), Members = new[] { Guid.NewGuid().ToString() } };

                    var reached = new ArrivedAtLocation { Day = i, Location = Guid.NewGuid().ToString() };

                    session.Events.Append(Guid.NewGuid(), joined, departed, reached);
                }

                await session.SaveChangesAsync().ConfigureAwait(false);
            }

            var settings = new DaemonSettings
            {
                LeadingEdgeBuffer = 0.Seconds()
            };

            using (var data = new Fetcher(theStore, settings, new AsyncOptions(), Substitute.For<IDaemonLogger>(), new StubErrorHandler(), new Type[] {typeof(MembersDeparted), typeof(ArrivedAtLocation)}))
            {
                var page = await data.FetchNextPage(0).ConfigureAwait(false);

                var all = page.Streams.SelectMany(x => x.Events).ToArray();

                all.OfType<Event<MembersJoined>>().Any().ShouldBeFalse();
                all.OfType<Event<MembersDeparted>>().Any().ShouldBeTrue();
                all.OfType<Event<ArrivedAtLocation>>().Any().ShouldBeTrue();
            }

        }
Beispiel #2
0
        public async Task correctly_correlates_by_stream()
        {
            var streams = new List<EventStream>();
            var logger = new RecordingLogger();

            using (var session = theStore.LightweightSession())
            {
                session.Logger = logger;

                for (int i = 0; i < 20; i++)
                {
                    var joined = new MembersJoined
                    {
                        Day = i,
                        Location = Guid.NewGuid().ToString(),
                        Members = new string[] { Guid.NewGuid().ToString() }
                    };

                    var departed = new MembersDeparted { Day = i, Location = Guid.NewGuid().ToString(), Members = new[] { Guid.NewGuid().ToString() } };

                    var reached = new ArrivedAtLocation { Day = i, Location = Guid.NewGuid().ToString() };

                    session.Events.Append(Guid.NewGuid(), joined, departed, reached);
                }

                await session.SaveChangesAsync().ConfigureAwait(false);

                streams.AddRange(logger.LastCommit.GetStreams());
            }

            var types = new Type[]
            {
                typeof(MembersJoined), typeof(MembersDeparted), typeof(ArrivedAtLocation)
            };

            var settings = new DaemonSettings
            {
                LeadingEdgeBuffer = 0.Seconds()
            };
            using (var data = new Fetcher(theStore, settings, new AsyncOptions(), Substitute.For<IDaemonLogger>(), new StubErrorHandler(), types))
            {
                var page = await data.FetchNextPage(0).ConfigureAwait(false);

                foreach (var stream in page.Streams)
                {
                    var existing = streams.Single(x => x.Id == stream.Id);

                    existing.Events.Select(x => x.Id)
                        .ShouldHaveTheSameElementsAs(stream.Events.Select(x => x.Id));
                }
            }

        }
Beispiel #3
0
 public void Apply(MembersDeparted departed)
 {
     _members.RemoveAll(x => departed.Members.Contains(x));
 }
Beispiel #4
0
 public void Apply(MembersDeparted departed)
 {
     _members.RemoveAll(x => departed.Members.Contains(x));
 }