コード例 #1
0
 public void TearDown()
 {
     _testApp = null;
     ApplicationEventsResolver.Reset();
     SqlSyntaxProvidersResolver.Reset();
     Resolution.IsFrozen = false;
 }
コード例 #2
0
        public virtual void TearDown()
        {
            if (ApplicationContext != null)
            {
                if (DatabaseContext != null && DatabaseContext.Database != null)
                {
                    DatabaseContext.Database.Dispose();
                }
                //reset the app context
                ApplicationContext.ApplicationCache.ClearAllCache();
            }

            SqlSyntaxContext.SqlSyntaxProvider = null;

            //legacy API database connection close - because a unit test using PetaPoco db-layer can trigger the usage of SqlHelper we need to ensure that a possible connection is closed.
            SqlCeContextGuardian.CloseBackgroundConnection();

            ApplicationContext.Current = null;
            Resolution.IsFrozen        = false;
            RepositoryResolver.Reset();
            SqlSyntaxProvidersResolver.Reset();

            TestHelper.CleanContentDirectories();

            string path = TestHelper.CurrentAssemblyDirectory;

            AppDomain.CurrentDomain.SetData("DataDirectory", null);

            SettingsForTests.Reset();
            UmbracoSettings.ResetSetters();

            try
            {
                string filePath = string.Concat(path, "\\UmbracoPetaPocoTests.sdf");
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <BaseDatabaseFactoryTest>("Could not remove the old database file", ex);

                //We will swallow this exception! That's because a sub class might require further teardown logic.
            }
        }