Пример #1
0
        public async Task GetAllEventsByAggregateId_AsExpected()
        {
            try
            {
                DeleteAll();
                new Bootstrapper()
                .UseEFCoreAsEventStore(
                    new EFEventStoreOptions(c =>
                                            c.UseSqlite("Filename=Events_Test_Base.db")))
                .Bootstrapp();
                var agg = new SampleAgg();
                agg.SimulateWork();
                await agg.PublishDomainEventsAsync();

                using (var ctx = GetContext())
                {
                    ctx.Set <Event>().Should().HaveCount(2);
                }

                var collection = await new EFEventStore(GetOptions()).GetAllEventsByAggregateId <SampleAgg, Guid>(agg.Id).ToListAsync();
                collection.Should().HaveCount(2);

                collection.Any(e => e.GetType() == typeof(AggCreated)).Should().BeTrue();
                collection.Any(e => e.GetType() == typeof(AggDeleted)).Should().BeTrue();
                collection.All(e => e.AggregateId is Guid guidId && guidId == agg.Id).Should().BeTrue();
                collection[0].Should().BeOfType <AggCreated>();
                collection.Skip(1).First().Should().BeOfType <AggDeleted>();
            }
            finally
            {
                EventStoreManager.Deactivate();
                DeleteAll();
            }
        }
Пример #2
0
 public EFEventStoreTests()
 {
     _snapshotProviderMock = new Mock <ISnapshotBehaviorProvider>();
     if (!s_Init)
     {
         using (var ctx = GetContext())
         {
             ctx.Database.EnsureDeleted();
             ctx.Database.EnsureCreated();
         }
         using (var aCtx = GetArchiveContext())
         {
             aCtx.Database.EnsureDeleted();
             aCtx.Database.EnsureCreated();
         }
         s_Init = true;
     }
     DeleteAll();
     EventStoreManager.Deactivate();
 }