Exemplo n.º 1
0
        public async Task batch_get_next_for_read_model_all_events()
        {
            var entity = Guid.NewGuid();
            await _store.Append(Setup.UnversionedCommit(guid: entity));

            await _store.Append(Setup.UnversionedCommit(guid: entity));

            await _store.Append(Setup.UnversionedCommit("1"));

            var rm = new ReadModelGenerationConfig("test");

            var rez = _store.GetNextBatch(rm, 0);

            rez.IsEmpty.Should().BeFalse();
            var first = rez.GetNext().Value;

            first.EntityId.Should().Be(entity);
            first.TenantId.Should().Be("_");
            first.Version.Should().Be(1);

            var second = rez.GetNext().Value;

            second.EntityId.Should().Be(entity);
            second.TenantId.Should().Be("_");
            second.Version.Should().Be(2);

            var third = rez.GetNext().Value;

            third.EntityId.Should().NotBe(entity);
            third.TenantId.Should().Be("1");
            third.Version.Should().Be(1);

            rez.GetNext().IsEmpty.Should().BeTrue();
        }
Exemplo n.º 2
0
 public ReadModelGenFacadeTests(ITestOutputHelper h)
 {
     _h       = h;
     _storage = Substitute.For <ISpecificDbStorage>();
     _sut     = new StoreFacade(_storage, Setup.EventStoreSettings(h));
     _config  = new ReadModelGenerationConfig("test");
 }
Exemplo n.º 3
0
        public CommittedEvents GetNextBatch(ReadModelGenerationConfig config, ProcessedCommitsCount count)
        {
            IEnumerable <Commit> all = _commits;

            if (!config.TenantId.IsNullOrEmpty())
            {
                all = all.Where(d => d.TenantId == config.TenantId);
            }
            if (config.EntityId.HasValue)
            {
                all = all.Where(d => d.EntityId == config.EntityId.Value);
            }
            all = all.OrderBy(d => d.Timestamp);
            return(new CommittedEvents(all.ToArray()));
        }
Exemplo n.º 4
0
 public CommittedEvents GetNextBatch(ReadModelGenerationConfig config, ProcessedCommitsCount count)
 {
     using (var db = _db.Create())
     {
         var all = db.QueryAs(q => q
                              .FromAnonymous(new { Id = 1, TenantId = "", EntityId = Guid.Empty },
                                             new TableName(CommitsTable, Schema)).Where(d => true)
                              .AndIf(() => config.EntityId.HasValue, d => d.EntityId == config.EntityId.Value)
                              .AndIf(() => !config.TenantId.IsNullOrEmpty(), d => d.TenantId == config.TenantId)
                              .OrderBy(d => d.Id)
                              .Limit(config.BatchSize, count.Value)
                              .SelectAll(useAsterisk: true).MapTo <Commit>()
                              );
         return(new CommittedEvents(all.ToArray()));
     }
 }