-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR feedback, Adding tests for user input on uninstall command prompts
- Loading branch information
Showing
4 changed files
with
65 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/dotnet-core-uninstall.Tests/Shared/Commands/UninstallCommandExecTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo; | ||
using Microsoft.DotNet.Tools.Uninstall.Shared.Commands; | ||
using Xunit; | ||
using FluentAssertions; | ||
using Microsoft.DotNet.Tools.Uninstall.Shared.BundleInfo.Versioning; | ||
|
||
namespace Microsoft.DotNet.Tools.Uninstall.Tests.Shared.Commands | ||
{ | ||
public class UninstallCommandExecTests | ||
{ | ||
internal enum Results | ||
{ | ||
Success, | ||
Reject, | ||
Error | ||
} | ||
|
||
[Theory] | ||
[InlineData("Y", Results.Success)] | ||
[InlineData("YES", Results.Success)] | ||
[InlineData("yes", Results.Success)] | ||
[InlineData("n", Results.Reject)] | ||
[InlineData("", Results.Error)] | ||
[InlineData("foo", Results.Error)] | ||
internal void UserInputIsInterpretedCorrectly(string userResponse, Results expectedResult) | ||
{ | ||
var bundles = new Dictionary<Bundle, string>() { { new Bundle<SdkVersion>(new SdkVersion(), new BundleArch(), string.Empty, string.Empty), "Required" } }; | ||
try | ||
{ | ||
var res = UninstallCommandExec.AskWithWarningsForRequiredBundles(bundles, userResponse); | ||
res.Should().Be(expectedResult.Equals(Results.Success)); | ||
} | ||
catch | ||
{ | ||
expectedResult.Should().Be(Results.Error); | ||
} | ||
|
||
try | ||
{ | ||
var res = UninstallCommandExec.AskItAndReturnUserAnswer(bundles, userResponse); | ||
res.Should().Be(expectedResult.Equals(Results.Success)); | ||
} | ||
catch | ||
{ | ||
expectedResult.Should().Be(Results.Error); | ||
} | ||
} | ||
} | ||
} |