예제 #1
0
        public void DatabaseFixture_AttemptToGetInMemoryLoggersBeforeInitialization_InvalidOperationException()
        {
            var databaseFixture = new DatabaseFixture <SampleDbContext>();

            Assert.Throws <InvalidOperationException>(() =>
            {
                _ = databaseFixture.GetInMemoryLoggers();
            });
        }
        public async Task DatabaseFixture_EFInMemoryLoggingEnabled_LogsPopulated()
        {
            var person = FakesFactory.Create <Person>();

            await _DatabaseFixture.PerformDatabaseOperation(async context =>
            {
                context.Persons.Add(person);
                await context.SaveChangesAsync();
            });

            var logger = _DatabaseFixture
                         .GetInMemoryLoggers()["Microsoft.EntityFrameworkCore.Database.Command"];

            Assert.NotEmpty(logger.Logs);
            Assert.NotEqual(0, logger.Logs.First().EventId);
        }