浏览代码

Including also the variables inside the lock.

BDisp 2 年之前
父节点
当前提交
e821435bac
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      UnitTests/ClipboardTests.cs

+ 9 - 8
UnitTests/ClipboardTests.cs

@@ -79,11 +79,12 @@ namespace Terminal.Gui.Core {
 		[AutoInitShutdown]
 		public void Contents_Gets_From_OS_Clipboard ()
 		{
-			var clipText = "This is a clipboard unit test to get clipboard from OS.";
-			var exit = false;
-			var getClipText = "";
-
 			lock (Clipboard.Contents) {
+
+				var clipText = "This is a clipboard unit test to get clipboard from OS.";
+				var exit = false;
+				var getClipText = "";
+
 				Application.Iteration += () => {
 					if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
 						// using (Process clipExe = new Process {
@@ -188,12 +189,12 @@ namespace Terminal.Gui.Core {
 
 					Application.RequestStop ();
 				};
-			}
 
-			Application.Run ();
+				Application.Run ();
 
-			if (!exit) {
-				Assert.Equal (clipText, getClipText);
+				if (!exit) {
+					Assert.Equal (clipText, getClipText);
+				}
 			}
 		}