Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public void ClearDB()
        {
            DatabaseContext.RefreshDatabaseContext();
            DatabaseUtils.ClearDB(DatabaseContext);

            foreach (var service in Services)
            {
                Assert.AreEqual(0, service.Count(), service.GetType().Name);
            }
        }
Exemplo n.º 3
0
 public IActionResult Clean()
 {
     DatabaseUtils.ClearDB(m_Context);
     return(RedirectToAction("Index"));
 }