public void CreateWebHostBuilderAndDatabase() { Startup.UseInMemoryDatabase = UseInMemoryDB; Startup.UseTestDatabase = true; m_Host = CreateWebHostBuilder(); RefreshServicesAndClearCache(); try { if (!UseInMemoryDB) { DatabaseUtils.MigrateDB(DatabaseContext); DatabaseUtils.ClearDB(DatabaseContext); } DatabaseUtils.PopulateWithTestData(DatabaseContext); } catch { DatabaseUtils.DeleteDB(DatabaseContext); if (!UseInMemoryDB) { DatabaseUtils.MigrateDB(DatabaseContext); DatabaseUtils.ClearDB(DatabaseContext); } DatabaseUtils.PopulateWithTestData(DatabaseContext); } }
public void ClearDB() { DatabaseContext.RefreshDatabaseContext(); DatabaseUtils.ClearDB(DatabaseContext); foreach (var service in Services) { Assert.AreEqual(0, service.Count(), service.GetType().Name); } }
public IActionResult Clean() { DatabaseUtils.ClearDB(m_Context); return(RedirectToAction("Index")); }