Ejemplo n.º 1
0
        public async Task use_type_filters()
        {
            NumberOfStreams = 10;
            await PublishSingleThreaded();

            using var fetcher1 = new EventFetcher(theStore, theStore.Tenancy.Default.Database, new ISqlFragment[0]);

            var shardName = new ShardName("name");
            var range1    = new EventRange(shardName, 0, NumberOfEvents);
            await fetcher1.Load(range1, CancellationToken.None);

            var uniqueTypeCount = range1.Events.Select(x => x.EventType).Distinct()
                                  .Count();

            uniqueTypeCount.ShouldBe(5);

            var filter = new EventTypeFilter(theStore.Events, new Type[] { typeof(Travel), typeof(Arrival) });

            using var fetcher2 = new EventFetcher(theStore, theStore.Tenancy.Default.Database, new ISqlFragment[] { filter });

            var range2 = new EventRange(shardName, 0, NumberOfEvents);
            await fetcher2.Load(range2, CancellationToken.None);

            range2.Events
            .Select(x => x.EventType)
            .OrderBy(x => x.Name).Distinct()
            .ShouldHaveTheSameElementsAs(typeof(Arrival), typeof(Travel));
        }
Ejemplo n.º 2
0
        internal async Task executeAfterLoadingEvents(Action <IEventStore> loadEvents)
        {
            loadEvents(theSession.Events);
            await theSession.SaveChangesAsync();

            var fetcher = new EventFetcher(theStore, theStore.Tenancy.Default.Database, theFilters.ToArray());
            await fetcher.Load(theRange, default);
        }
        public async Task event_fetcher_simple_case()
        {
            using var fetcher = new EventFetcher(theStore, new ISqlFragment[0]);

            NumberOfStreams = 10;
            await PublishSingleThreaded();

            var range1 = new EventRange(new ShardName("name"), 0, 10);
            await fetcher.Load(range1, CancellationToken.None);

            var range2 = new EventRange(new ShardName("name"), 10, 20);
            await fetcher.Load(range2, CancellationToken.None);

            var range3 = new EventRange(new ShardName("name"), 20, 38);
            await fetcher.Load(range3, CancellationToken.None);

            range1.Events.Count.ShouldBe(10);
            range2.Events.Count.ShouldBe(10);
            range3.Events.Count.ShouldBe(18);
        }