public override void Cleanup()
        {
            var totalCommandsToIssue    = Scenario.CommandPlans.Count();
            var journalConnectionString = new AutoTestNodeDbConfiguration().JournalConnectionString;
            var dbContextOptions        = new DbContextOptionsBuilder().UseSqlServer(journalConnectionString)
                                          .Options;

            var rawJournalRepository = new RawJournalRepository(dbContextOptions);
            var count = rawJournalRepository.TotalCount();

            if (count != totalCommandsToIssue)
            {
                _output.WriteLine($"!!! Journal contains only {count} of {totalCommandsToIssue} !!!");
                Task.Delay(2000)
                .Wait();
                count = rawJournalRepository.TotalCount();
                _output.WriteLine($"After 2 sec Journal contains {count} of {totalCommandsToIssue}");
            }

            using (var context = new BalloonContext(DbContextOptions))
            {
                var projectedCount = context.BalloonCatalog.Select(x => x)
                                     .Count();
                _output.WriteLine($"Found {projectedCount} projected rows");
            }
        }
Пример #2
0
        public async Task When_Executing_command_events_should_be_projected()
        {
            var autoTestDb = ConnectionStrings.AutoTestDb;

            var dbOptions = new DbContextOptionsBuilder <BalloonContext>().UseSqlServer(autoTestDb).Options;

            //warm up EF
            using (var context = new BalloonContext(dbOptions))
            {
                context.BalloonCatalog.Add(new BalloonCatalogItem()
                {
                    BalloonId = Guid.NewGuid().ToString(), LastChanged = DateTime.UtcNow, Title = "WarmUp"
                });
                await context.SaveChangesAsync();
            }

            await TestDbTools.Truncate(autoTestDb, "BalloonCatalog");

            var cmd = new InflateNewBallonCommand(123, Guid.NewGuid().ToString());
            await Node.Prepare(cmd)
            .Expect <BalloonCreatedNotification>()
            .Execute(TimeSpan.FromSeconds(30));

            using (var context = new BalloonContext(dbOptions))
            {
                var catalogItem = await context.BalloonCatalog.FindAsync(cmd.AggregateId);

                Assert.Equal(cmd.Title.ToString(), catalogItem.Title);
            }
        }
Пример #3
0
 internal override void OnSetup()
 {
     using (var ctx = new BalloonContext(DbContextOptions))
     {
         ctx.Database.EnsureDeleted();
         ctx.Database.EnsureCreated();
     }
     base.OnSetup();
 }
        public override void Setup(BenchmarkContext context)
        {
            base.Setup(context);
            //warm up EF
            using (var ctx = new BalloonContext(DbContextOptions))
            {
                ctx.BalloonCatalog.Add(new BalloonCatalogItem()
                {
                    BalloonId = Guid.NewGuid().ToString(), LastChanged = DateTime.UtcNow, Title = "WarmUp"
                });
                ctx.SaveChanges();
            }

            TestDbTools.Truncate(ReadDbReadModelConnectionString, "BalloonCatalog")
            .Wait();
        }
        internal override void OnSetup()
        {
            var readDb = new AutoTestLocalDbConfiguration();

            DbContextOptions = new DbContextOptionsBuilder <BalloonContext>().UseSqlServer(readDb.ReadModelConnectionString)
                               .Options;
            using (var ctx = new BalloonContext(DbContextOptions))
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
                ctx.BalloonCatalog.Add(new BalloonCatalogItem()
                {
                    BalloonId = Guid.NewGuid()
                                .ToString(),
                    LastChanged = DateTime.UtcNow,
                    Title       = "WarmUp"
                });
                ctx.SaveChanges();
            }

            base.OnSetup();
        }