/// <summary> /// Constructor. /// </summary> /// <exception cref="InvalidOperationException">Thrown if another test manager instance is active.</exception> public KubeTestManager() { lock (syncLock) { if (Current != null) { throw new InvalidOperationException("Another test manager is active."); } try { tempFolder = new TempFolder(); Current = this; KubeHelper.SetTestMode(tempFolder.Path); Environment.SetEnvironmentVariable(KubeConst.TestModeFolderVar, tempFolder.Path); } catch { Environment.SetEnvironmentVariable(KubeConst.TestModeFolderVar, null); Current = null; throw; } } }
/// <inheritdoc/> public void Dispose() { if (tempFolder != null) { KubeHelper.ResetTestMode(); tempFolder.Dispose(); tempFolder = null; Current = null; } }