more tests
authorEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 15 Jul 2011 13:48:36 +0000 (17:48 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Fri, 15 Jul 2011 13:48:36 +0000 (17:48 +0400)
nuget-extensions/nuget-tests/src/NuGetRunnerTest.cs
nuget-extensions/nuget-tests/src/TempFilesHolder.cs

index 46902750b6ca2aedc673bcc2e08cc530bd5dab71..050408357826896841794b441c87c6b9aa40501f 100644 (file)
@@ -1,4 +1,5 @@
 ´╗┐using System;\r
+using System.IO;\r
 using NUnit.Framework;\r
 \r
 namespace JetBrains.TeamCity.NuGet.Tests\r
@@ -15,6 +16,42 @@ namespace JetBrains.TeamCity.NuGet.Tests
       Assert.IsTrue(r.ExitCode == 0);\r
     }\r
 \r
+    [Test]\r
+    public void TestExcuteNuGet_NuGetFromTemp()\r
+    {\r
+      TempFilesHolder.WithTempDirectory(\r
+        home =>\r
+          {\r
+            var destNuGet = Path.Combine(home, "NuGet.exe");\r
+            File.Copy(Files.NuGetExe, destNuGet);\r
+\r
+            ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, destNuGet, "TeamCity.Ping")\r
+              .Dump()\r
+              .AssertExitedSuccessfully();\r
+          });\r
+    }\r
+\r
+    [Test]\r
+    public void TestExcuteNuGet_BothInTemp()\r
+    {\r
+      TempFilesHolder.WithTempDirectory(\r
+        home =>\r
+          {\r
+            var destNuGet = Path.Combine(home, "NuGet.exe");\r
+            var destRunner = Path.Combine(home, "TeamCity.NuGetRunner.exe");\r
+            \r
+            File.Copy(Files.NuGetExe, destNuGet);            \r
+            File.Copy(Files.NuGetRunnerExe, destRunner);\r
+            const string ext = "JetBrains.TeamCity.NuGet.ExtendedCommands.dll";\r
+            File.Copy(Path.Combine(Files.NuGetRunnerExe, "../" + ext), Path.Combine(home, ext));\r
+\r
+            ProcessExecutor.ExecuteProcess(destRunner, destNuGet, "TeamCity.Ping")\r
+              .Dump()\r
+              .AssertExitedSuccessfully();\r
+          });\r
+    }\r
+\r
+\r
     [Test]\r
     public void TestDumpExtensionsPath()\r
     {\r
index 67445c7f7a0a10daf8c3c071c959202a9d7825e1..b560c8aa35a95616e55efb7b0de84faa62149768 100644 (file)
@@ -16,5 +16,20 @@ namespace JetBrains.TeamCity.NuGet.Tests
         File.Delete(tmp);\r
       }\r
     }\r
+\r
+    public static void WithTempDirectory(Action<string> action)\r
+    {\r
+      string tmp = Path.GetTempFileName();\r
+      File.Delete(tmp);\r
+      Directory.CreateDirectory(tmp);\r
+      try\r
+      {\r
+        action(tmp);\r
+      }\r
+      finally\r
+      {\r
+        Directory.Delete(tmp,true);\r
+      }\r
+    }\r
   }\r
 }
\ No newline at end of file