more tests
[teamcity/dotNetPackagesSupport.git] / nuget-extensions / nuget-tests / src / TempFilesHolder.cs
1 using System;\r
2 using System.IO;\r
3 \r
4 namespace JetBrains.TeamCity.NuGet.Tests\r
5 {\r
6   public static class TempFilesHolder\r
7   {\r
8     public static void WithTempFile(Action<string> action)\r
9     {\r
10       string tmp = Path.GetTempFileName();\r
11       try\r
12       {\r
13         action(tmp);\r
14       } finally\r
15       {\r
16         File.Delete(tmp);\r
17       }\r
18     }\r
19 \r
20     public static void WithTempDirectory(Action<string> action)\r
21     {\r
22       string tmp = Path.GetTempFileName();\r
23       File.Delete(tmp);\r
24       Directory.CreateDirectory(tmp);\r
25       try\r
26       {\r
27         action(tmp);\r
28       }\r
29       finally\r
30       {\r
31         Directory.Delete(tmp,true);\r
32       }\r
33     }\r
34   }\r
35 }