Skip to content

Commit 0cdba96

Browse files
CopilotmarcpopMSFT
andcommitted
Use CopyTestAsset("HelloWorld") for RunParserCanGetArgumentFromDoubleDash test
Co-authored-by: marcpopMSFT <[email protected]>
1 parent 47d4222 commit 0cdba96

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

test/dotnet.Tests/CommandTests/Run/RunParserTests.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@ public RunParserTests(ITestOutputHelper output)
1717
[Fact]
1818
public void RunParserCanGetArgumentFromDoubleDash()
1919
{
20-
// Create a temporary project file to ensure file validation passes
21-
var tempDir = Path.GetTempPath();
22-
var projectPath = Path.Combine(tempDir, "foo.csproj");
23-
File.WriteAllText(projectPath, "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net8.0</TargetFramework></PropertyGroup></Project>");
24-
20+
var tam = new TestAssetsManager(output);
21+
var oldWorkingDirectory = Directory.GetCurrentDirectory();
22+
var newWorkingDir = tam.CopyTestAsset("HelloWorld").Path;
23+
2524
try
2625
{
26+
Directory.SetCurrentDirectory(newWorkingDir);
27+
var projectPath = Path.Combine(newWorkingDir, "HelloWorld.csproj");
28+
2729
var runCommand = RunCommand.FromArgs(new[] { "--project", projectPath, "--", "foo" });
2830
runCommand.Args.Single().Should().Be("foo");
2931
}
3032
finally
3133
{
32-
if (File.Exists(projectPath))
33-
{
34-
File.Delete(projectPath);
35-
}
34+
Directory.SetCurrentDirectory(oldWorkingDirectory);
3635
}
3736
}
3837
}

0 commit comments

Comments
 (0)