fix concurrent starts of NuGet.exe'
[teamcity/dotNetPackagesSupport.git] / nuget-extensions / nuget-tests / src / NuGetRunnerTest.cs
index 050408357826896841794b441c87c6b9aa40501f..555dc04b11693dffded2569acaa2660fceeed62d 100644 (file)
@@ -1,6 +1,8 @@
 ´╗┐using System;\r
 using System.IO;\r
+using System.Threading;\r
 using NUnit.Framework;\r
+using System.Linq;\r
 \r
 namespace JetBrains.TeamCity.NuGet.Tests\r
 {\r
@@ -70,5 +72,46 @@ namespace JetBrains.TeamCity.NuGet.Tests
         .AssertNoErrorOutput()\r
         .AssertOutputContains("TeamCity NuGet Extension is available.");\r
     }\r
+\r
+    [Test]\r
+    public void TestCommands_RunConcurrently()\r
+    {\r
+      bool failed = false;\r
+      new[] {1, 2, 3, 4, 5, 6, 7}\r
+        .Select(\r
+          x => new Thread(() =>\r
+                            {\r
+                              for (int i = 0; i < 3; i++)\r
+                              {\r
+                                var proc = ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, Files.NuGetExe, "TeamCity.Ping", "-Sleep");\r
+                                if (proc.ExitCode != 0 || !string.IsNullOrWhiteSpace(proc.Error))\r
+                                {\r
+                                  proc.Dump();\r
+                                  failed = true;\r
+                                }\r
+                                proc.AssertNoErrorOutput().AssertExitedSuccessfully();\r
+                              }\r
+                            })\r
+                 {\r
+                   Name = "Checker " + x,\r
+                 })\r
+        .ToList()\r
+        .Select(\r
+          x =>\r
+            {\r
+              x.Start();\r
+              return x;\r
+            })\r
+        .ToList()\r
+        .Select(x =>\r
+                  {\r
+                    x.Join();\r
+                    return 0;\r
+                  })\r
+        .ToList();\r
+\r
+      Assert.IsFalse(failed);\r
+    }\r
+\r
   }\r
 }\r