forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorCommand.cs
More file actions
130 lines (119 loc) · 5.03 KB
/
Copy pathErrorCommand.cs
File metadata and controls
130 lines (119 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// -----------------------------------------------------------------------------
// <copyright file="ErrorCommand.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------
namespace AppInstallerCLIE2ETests
{
using AppInstallerCLIE2ETests.Helpers;
using NUnit.Framework;
/// <summary>
/// Test error command.
/// </summary>
public class ErrorCommand
{
/// <summary>
/// Tests 0.
/// </summary>
[Test]
public void Success()
{
var result = TestCommon.RunAICLICommand("error", "0");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x00000000"));
}
/// <summary>
/// Tests 0x8a15c001.
/// </summary>
[Test]
public void HexError()
{
var result = TestCommon.RunAICLICommand("error", "0x8a15c001");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a15c001"));
Assert.True(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"));
}
/// <summary>
/// Tests a number larger than an HRESULT.
/// </summary>
[Test]
public void HexErrorTooBig()
{
var result = TestCommon.RunAICLICommand("error", "0x8a15c0014");
Assert.AreEqual(Constants.ErrorCode.E_INVALIDARG, result.ExitCode);
Assert.True(result.StdOut.Contains("The given number is too large to be an HRESULT."));
}
/// <summary>
/// Tests 2316681217.
/// </summary>
[Test]
public void DecimalError()
{
var result = TestCommon.RunAICLICommand("error", "2316681217");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a15c001"));
Assert.True(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"));
}
/// <summary>
/// Tests -1978335191.
/// </summary>
[Test]
public void NegativeDecimalError()
{
var result = TestCommon.RunAICLICommand("error", "-- -1978335191");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a150029"));
Assert.True(result.StdOut.Contains("APPINSTALLER_CLI_ERROR_MANIFEST_VALIDATION_FAILURE"));
}
/// <summary>
/// Tests 0x8a15c000.
/// </summary>
[Test]
public void HexErrorNotFound()
{
var result = TestCommon.RunAICLICommand("error", "0x8a15c000");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a15c000"));
Assert.True(result.StdOut.Contains("Unknown error code"));
}
/// <summary>
/// Tests 0xA150202.
/// </summary>
[Test]
public void NonError()
{
var result = TestCommon.RunAICLICommand("error", "0xA150202");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x0a150202"));
Assert.True(result.StdOut.Contains("WINGET_INSTALLED_STATUS_INSTALL_LOCATION_NOT_APPLICABLE"));
}
/// <summary>
/// Tests WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE.
/// </summary>
[Test]
public void Symbol()
{
var result = TestCommon.RunAICLICommand("error", "WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a15c001"));
Assert.True(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"));
Assert.AreEqual(2, result.StdOut.Split('\n', System.StringSplitOptions.RemoveEmptyEntries).Length);
}
/// <summary>
/// Tests config.
/// </summary>
[Test]
public void String()
{
var result = TestCommon.RunAICLICommand("error", "config");
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("0x8a15c001"));
Assert.True(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"));
Assert.True(result.StdOut.Contains("0x8a15c110"));
Assert.True(result.StdOut.Contains("WINGET_CONFIG_ERROR_UNIT_SETTING_CONFIG_ROOT"));
// This contains config in it's message.
Assert.True(result.StdOut.Contains("0x8a150038"));
Assert.True(result.StdOut.Contains("APPINSTALLER_CLI_ERROR_UNSUPPORTED_RESTSOURCE"));
}
}
}