Ejemplo n.º 1
0
 void IDisposable.Dispose()
 {
     using (var context = new TestBudgetContext(_databaseUniqueId))
     {
         Console.WriteLine($"Deleting database {_databaseUniqueId}");
         context.Database.EnsureDeleted();
     }
 }
Ejemplo n.º 2
0
        public TestBase()
        {
            _databaseUniqueId = Guid.NewGuid();
            using (var context = new TestBudgetContext(_databaseUniqueId))
            {
                Console.WriteLine($"EnsureCreated database {_databaseUniqueId}");
                context.Database.EnsureCreated();
            }

            _testServer = new Lazy <TestServer>(() => new TestServer(new WebHostBuilder()
                                                                     .UseStartup <Startup>()
                                                                     .ConfigureServices(collection =>
            {
                collection.AddScoped <BudgetContext>(_ => new TestBudgetContext(_databaseUniqueId));
            })));
        }