Skip to content

Commit

Permalink
Fix test to reset working directory (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilpaf authored Aug 28, 2024
1 parent 3145629 commit 4ee767d
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Sitefinity CLI.Tests/UpgradeCommandTests/UpgradeCommand_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Extensions.DependencyInjection;
using SitefinityCLI.Tests.UpgradeCommandTests.Mocks;
using System.Net.Http;
using System;

namespace SitefinityCLI.Tests.UpgradeCommandTests
{
Expand Down Expand Up @@ -77,18 +78,27 @@ public async Task SolutionPathIsSetCorrect_When_SolutionPathCommandIsPassedRelat
{
var upgradeCommand = new UpgradeCommandSut(promptService, sitefinityPackageManager, csProjectFileEditor, logger, projectConfigFileEditor, upgradeConfigGenerator, visualStudioWorker, httpClientFactory, packageSourceBuilder);
string workingDirectory = Directory.GetCurrentDirectory();
string newWorkingDirectory = Path.Combine(workingDirectory, "UpgradeCommandTests");
string solutionPath = Path.Combine("Mocks", "fake.sln");

upgradeCommand.SolutionPath = solutionPath;
upgradeCommand.Version = "15.1.8325";
upgradeCommand.SkipPrompts = true;
Directory.SetCurrentDirectory(newWorkingDirectory);
await upgradeCommand.Execute();
try
{
string newWorkingDirectory = Path.Combine(workingDirectory, "UpgradeCommandTests");
string solutionPath = Path.Combine("Mocks", "fake.sln");

upgradeCommand.SolutionPath = solutionPath;
upgradeCommand.Version = "15.1.8325";
upgradeCommand.SkipPrompts = true;
Directory.SetCurrentDirectory(newWorkingDirectory);
await upgradeCommand.Execute();

Assert.AreEqual(Path.Combine(newWorkingDirectory, solutionPath), upgradeCommand.SolutionPath);
}
finally
{
Directory.SetCurrentDirectory(workingDirectory);
}

Assert.AreEqual(Path.Combine(newWorkingDirectory, solutionPath), upgradeCommand.SolutionPath);
}

[TestMethod]
public async Task SolutionPathIsSetCorrect_When_SolutionPathCommandIsPassedFull()
{
Expand Down

0 comments on commit 4ee767d

Please sign in to comment.