Skip to content

Commit a9b510e

Browse files
author
Yu Leng (from Dev Box)
committed
update
1 parent 77b0a93 commit a9b510e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/modules/cmdpal/Tests/Microsoft.CmdPal.UITests/CalculatorTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ public void EnterCalculatorExtension()
3131
private string ConvertResult(string originalResult, int originalBase, int convertToBase)
3232
{
3333
Assert.IsNotEmpty(originalResult, "Original result cannot be empty.");
34-
Assert.IsTrue(originalBase is 2 or 8 or 10 or 16, "Original base must be one of the following: 2, 8, 10, or 16.");
35-
Assert.IsTrue(convertToBase is 2 or 8 or 10 or 16, "Convert to base must be one of the following: 2, 8, 10, or 16.");
34+
Assert.IsTrue(originalBase is 2 or 10 or 16, "Original base must be one of the following: 2, 8, 10, or 16.");
35+
Assert.IsTrue(convertToBase is 2 or 10 or 16, "Convert to base must be one of the following: 2, 8, 10, or 16.");
3636

3737
var originalDecimal = Convert.ToInt32(originalResult, originalBase);
3838

3939
// support base two, decimal, hexadecimal, and octal
4040
return convertToBase switch
4141
{
42-
2 => Convert.ToString(originalDecimal, 2),
43-
8 => Convert.ToString(originalDecimal, 8),
42+
2 => $"0b{Convert.ToString(originalDecimal, 2)}",
4443
10 => Convert.ToString(originalDecimal, 10),
45-
16 => Convert.ToString(originalDecimal, 16).ToUpper(System.Globalization.CultureInfo.CurrentCulture),
44+
16 => $"0x{Convert.ToString(originalDecimal, 16).ToUpper(System.Globalization.CultureInfo.CurrentCulture)}",
4645
_ => throw new ArgumentOutOfRangeException(nameof(convertToBase), "Unsupported base conversion"),
4746
};
4847
}
@@ -163,6 +162,6 @@ public void CalculatorContextMenuBaseConvertTests(string expression, string expe
163162
binaryItem.Click();
164163

165164
var clipboardContent = System.Windows.Forms.Clipboard.GetText();
166-
Assert.IsTrue(clipboardContent.Equals(expectation, StringComparison.Ordinal), $"Clipboard content does not equal the expected result. clipboard: {clipboardContent}");
165+
Assert.IsTrue(clipboardContent.Equals(binaryResult, StringComparison.Ordinal), $"Clipboard content does not equal the expected result. clipboard: {clipboardContent}");
167166
}
168167
}

0 commit comments

Comments
 (0)