コード例 #1
0
        private void IntegrationTest(bool isolated, Action callback, Action <SystemFolder> callbackWithSandbox)
        {
            var platformName   = Platform.GetType().Name;
            var needToStartNew = isolated || _repositoryInstance == null || platformName != _lastPlatformName;

            if (needToStartNew)
            {
                Logger.Log("  (cleanup repository)");
                _repositoryInstance?.Dispose();
                _repositoryInstance = null;
                _lastPlatformName   = null;

                var builder = Platform.CreateRepositoryBuilder();

                Logger.Log("  start new repository");
                _repositoryInstance = Repository.Start(builder);
                _lastPlatformName   = platformName;

                //PrepareRepository();
            }

            SystemFolder sandbox = null;

            try
            {
                using (new SystemAccount())
                    if (callback != null)
                    {
                        callback();
                    }
                    else
                    {
                        callbackWithSandbox(sandbox = CreateSandbox());
                    }
            }
            finally
            {
                if (sandbox != null)
                {
                    using (new SystemAccount())
                        sandbox.ForceDelete();
                }

                if (isolated)
                {
                    Logger.Log("  cleanup repository");
                    _repositoryInstance?.Dispose();
                    _repositoryInstance = null;
                    _lastPlatformName   = null;
                }
            }
        }
コード例 #2
0
ファイル: AccessTokenTests.cs プロジェクト: y1027/sensenet
 public static void ShutDownRepository()
 {
     _repository?.Dispose();
 }