make nuget integration test explicit
[teamcity/dotNetPackagesSupport.git] / nuget-extensions / nuget-tests / src / NuGetRunnerWithTrunk.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.IO;\r
4 using System.Net;\r
5 using NUnit.Framework;\r
6 \r
7 namespace JetBrains.TeamCity.NuGet.Tests\r
8 {\r
9   [Explicit]\r
10   [TestFixture("bt4")]\r
11   [TestFixture("bt22")]\r
12   [TestFixture("bt21")]  \r
13   public class NuGetRunnerWithTrunk\r
14   {\r
15     private readonly Lazy<string> home;\r
16     \r
17     private readonly Lazy<string> nuget;\r
18 \r
19     public NuGetRunnerWithTrunk(string bt)\r
20     {\r
21 \r
22       home = new Lazy<string>(() =>\r
23                                 {\r
24                                   var homePath = Path.GetTempFileName();\r
25                                   File.Delete(homePath);\r
26                                   Directory.CreateDirectory(homePath);\r
27                                   return homePath;\r
28                                 });\r
29       \r
30       nuget = new Lazy<string>(() =>\r
31                                  {\r
32                                    string url = "http://ci.nuget.org:8080/guestAuth/repository/download/" + bt +\r
33                                                 "/.lastSuccessful/Console/NuGet.exe";\r
34                                    var nugetPath = Path.Combine(home.Value, "NuGet.exe");\r
35                                    var cli = new WebClient();\r
36                                    cli.DownloadFile(url, nugetPath);\r
37                                    return nugetPath;\r
38                                  });\r
39       \r
40      \r
41     }\r
42 \r
43     [TestFixtureTearDown]\r
44     public void Cleanup()\r
45     {\r
46       if (home.IsValueCreated)\r
47       {\r
48         Directory.Delete(home.Value, true);\r
49       }\r
50     }\r
51 \r
52     [Test]\r
53     public void Test_Ping()\r
54     {\r
55       DoTest("TeamCity.Ping");\r
56     }\r
57 \r
58     [Test]\r
59     public void Test_List_NUnit_Remote()\r
60     {\r
61       DoTest("TeamCity.List", "-Id", "NUnit")\r
62         .AssertOutputContains("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
63     }\r
64 \r
65     [Test]\r
66     public void Test_List_NUnit_Local()\r
67     {\r
68       DoTest("TeamCity.List", "-Id", "Web", "-Source", Files.LocalFeed)\r
69         .AssertOutputContains("##teamcity[nuget-package Id='Web' Version='1.1.1']");\r
70     }\r
71     \r
72     private ProcessExecutor.Result DoTest(params string[] argz)\r
73     {\r
74       var az = new List<string>();\r
75       az.Add(nuget.Value);\r
76       az.AddRange(argz);\r
77 \r
78       return ProcessExecutor.ExecuteProcess(Files.NuGetRunnerExe, az.ToArray())\r
79         .Dump()\r
80         .AssertExitedSuccessfully();\r
81     }\r
82   }\r
83 }