diff --git a/doc/ReleaseNotes.md b/doc/ReleaseNotes.md
index 57c970aeb6..3ca859ab50 100644
--- a/doc/ReleaseNotes.md
+++ b/doc/ReleaseNotes.md
@@ -1,7 +1,7 @@
-## New in v1.29
+## New in v1.30
Nothing yet.
## Bug Fixes
-* None yet
+* Updated NUnit to v4
diff --git a/src/AppInstallerCLIE2ETests/AppShutdownTests.cs b/src/AppInstallerCLIE2ETests/AppShutdownTests.cs
index be143201be..f7c06af9b9 100644
--- a/src/AppInstallerCLIE2ETests/AppShutdownTests.cs
+++ b/src/AppInstallerCLIE2ETests/AppShutdownTests.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -98,7 +98,7 @@ public void RegisterApplicationTest()
// The ctrl-c command terminates the batch file before the exit code file gets created.
// Look for the output.
- Assert.True(testCmdTask.Result.StdOut.Contains("Succeeded waiting for app shutdown event"));
+ Assert.That(testCmdTask.Result.StdOut.Contains("Succeeded waiting for app shutdown event"), Is.True);
}
///
@@ -111,13 +111,13 @@ public void CanUnloadNowTest()
var lines = result.StdOut.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
- Assert.AreEqual(5, lines.Length);
- Assert.True(lines[0].Contains("Internal objects:"));
- Assert.False(lines[0].Contains("Internal objects: 0"));
- Assert.True(lines[1].Contains("External objects: 0"));
- Assert.True(lines[2].Contains("DllCanUnloadNow"));
- Assert.True(lines[3].Contains("Internal objects: 0"));
- Assert.True(lines[4].Contains("External objects: 0"));
+ Assert.That(lines.Length, Is.EqualTo(5));
+ Assert.That(lines[0].Contains("Internal objects:"), Is.True);
+ Assert.That(lines[0].Contains("Internal objects: 0"), Is.False);
+ Assert.That(lines[1].Contains("External objects: 0"), Is.True);
+ Assert.That(lines[2].Contains("DllCanUnloadNow"), Is.True);
+ Assert.That(lines[3].Contains("Internal objects: 0"), Is.True);
+ Assert.That(lines[4].Contains("External objects: 0"), Is.True);
}
///
@@ -127,7 +127,7 @@ public void CanUnloadNowTest()
public void TermSignalHandler()
{
var result = TestCommon.RunAICLICommand("test", "term-signal-handler --verbose");
- Assert.True(result.StdOut.Contains("Got a window handle"));
+ Assert.That(result.StdOut.Contains("Got a window handle"), Is.True);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/ConfigureCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureCommand.cs
index 521f4ace0b..d445ec939e 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -58,8 +58,8 @@ public void ConfigureFromGallery()
TestCommon.EnsureModuleState(Constants.GalleryTestModuleName, present: false);
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\PSGallery_NoModule_NoSettings.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED, result.ExitCode);
- Assert.True(result.StdOut.Contains("The configuration unit failed while attempting to test the current system state."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED));
+ Assert.That(result.StdOut.Contains("The configuration unit failed while attempting to test the current system state."), Is.True);
}
///
@@ -71,17 +71,17 @@ public void ConfigureFromTestRepo()
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
- Assert.True(Directory.Exists(
+ Assert.That(Directory.Exists(
Path.Combine(
TestCommon.GetExpectedModulePath(TestCommon.TestModuleLocation.Default),
- Constants.SimpleTestModuleName)));
+ Constants.SimpleTestModuleName)), Is.True);
}
///
@@ -105,8 +105,8 @@ public void ConfigureFromTestRepo_DefaultModuleRootSetting()
Directory.Delete(moduleTestDir, true);
}
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(moduleExists);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(moduleExists, Is.True);
}
///
@@ -141,11 +141,11 @@ public void ConfigureFromTestRepo_Location(TestCommon.TestModuleLocation locatio
}
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
- Assert.True(Directory.Exists(Path.Combine(
+ Assert.That(Directory.Exists(Path.Combine(
TestCommon.GetExpectedModulePath(location),
- Constants.SimpleTestModuleName)));
+ Constants.SimpleTestModuleName)), Is.True);
}
///
@@ -155,12 +155,12 @@ public void ConfigureFromTestRepo_Location(TestCommon.TestModuleLocation locatio
public void IndependentResourceWithSingleFailure()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\IndependentResources_OneFailure.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\IndependentResources_OneFailure.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
}
///
@@ -170,11 +170,11 @@ public void IndependentResourceWithSingleFailure()
public void DependentResourceWithFailure()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\DependentResources_Failure.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\DependentResources_Failure.txt");
- FileAssert.DoesNotExist(targetFilePath);
+ Assert.That(File.Exists(targetFilePath), Is.False);
}
///
@@ -184,11 +184,11 @@ public void DependentResourceWithFailure()
public void ConfigServerUnexpectedExit()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\ConfigServerUnexpectedExit.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_SET_APPLY_FAILED));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\ConfigServerUnexpectedExit.txt");
- FileAssert.DoesNotExist(targetFilePath);
+ Assert.That(File.Exists(targetFilePath), Is.False);
}
///
@@ -200,12 +200,12 @@ public void ResourceCaseInsensitive()
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\ResourceCaseInsensitive.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\ResourceCaseInsensitive.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
}
///
@@ -217,7 +217,7 @@ public void ConfigureFromHttpsConfigurationFile()
string args = $"{Constants.TestSourceUrl}/TestData/Configuration/Configure_TestRepo_Location.yml";
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, args);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
}
///
@@ -227,21 +227,21 @@ public void ConfigureFromHttpsConfigurationFile()
public void ConfigureFromHistory()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
File.WriteAllText(targetFilePath, "Changed contents!");
string guid = TestCommon.GetConfigurationInstanceIdentifierFor("Configure_TestRepo.yml");
result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, $"-h {guid}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
}
///
@@ -254,12 +254,12 @@ public void SpecifyModulePathToHighIntegrityServer()
string testDirectory = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, $"{configFile} --module-path \"{testDirectory}\"");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string testFile = Path.Join(TestCommon.GetTestDataFile("Configuration"), "PSModulePath.txt");
- Assert.True(File.Exists(testFile));
+ Assert.That(File.Exists(testFile), Is.True);
string testFileContents = File.ReadAllText(testFile);
- Assert.True(testFileContents.StartsWith(testDirectory));
+ Assert.That(testFileContents.StartsWith(testDirectory), Is.True);
}
///
@@ -269,21 +269,21 @@ public void SpecifyModulePathToHighIntegrityServer()
public void ConfigureThroughHistory_DSCv3()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\ShowDetails_DSCv3.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\ShowDetails_DSCv3.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("DSCv3 Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("DSCv3 Contents!"));
File.WriteAllText(targetFilePath, "Changed contents!");
string guid = TestCommon.GetConfigurationInstanceIdentifierFor("ShowDetails_DSCv3.yml");
result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, $"-h {guid}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("DSCv3 Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("DSCv3 Contents!"));
}
///
@@ -293,10 +293,10 @@ public void ConfigureThroughHistory_DSCv3()
public void TestFileResourceSchema()
{
var result = TestCommon.RunAICLICommand("dscv3 test-file", "--schema");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
var lines = result.StdOut.Split("\r\n", StringSplitOptions.RemoveEmptyEntries);
- Assert.AreEqual(1, lines.Length);
+ Assert.That(lines.Length, Is.EqualTo(1));
}
///
@@ -307,7 +307,7 @@ public void DSCv3_Export()
{
// Reset state
var result = TestCommon.RunAICLICommand("dscv3 test-json", "--delete");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// Configure properties
string propertyName1 = "prop1";
@@ -318,25 +318,25 @@ public void DSCv3_Export()
string propertySetFormatString = "{{ \"property\": \"{0}\", \"value\": \"{1}\" }}";
result = TestCommon.RunAICLICommand("dscv3 test-json", "--set", string.Format(propertySetFormatString, propertyName1, propertyValue1));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("dscv3 test-json", "--set", string.Format(propertySetFormatString, propertyName2, propertyValue2));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// Export
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
result = TestCommon.RunAICLICommand("test config-export-units", $"-o {exportFile} --resource Microsoft.WinGet.Dev/TestJSON --verbose");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
- Assert.True(File.Exists(exportFile));
+ Assert.That(File.Exists(exportFile), Is.True);
string exportText = File.ReadAllText(exportFile);
- Assert.True(exportText.Contains("Microsoft.WinGet.Dev/TestJSON"));
- Assert.True(exportText.Contains(propertyName1));
- Assert.True(exportText.Contains(propertyName2));
- Assert.True(exportText.Contains(propertyValue1));
- Assert.True(exportText.Contains(propertyValue2));
+ Assert.That(exportText.Contains("Microsoft.WinGet.Dev/TestJSON"), Is.True);
+ Assert.That(exportText.Contains(propertyName1), Is.True);
+ Assert.That(exportText.Contains(propertyName2), Is.True);
+ Assert.That(exportText.Contains(propertyValue1), Is.True);
+ Assert.That(exportText.Contains(propertyValue2), Is.True);
}
///
@@ -349,12 +349,12 @@ public void ConfigureFromTestRepo_DSCv3()
this.DeleteResourceArtifacts();
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_DSCv3.yml"), timeOut: 300000);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
}
///
@@ -365,29 +365,29 @@ public void ConfigureFindUnitProcessors()
{
// Find all unit processors.
var result = TestCommon.RunAICLICommand("test config-find-unit-processors", string.Empty, timeOut: 300000);
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains("Microsoft/OSInfo"));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains("Microsoft/OSInfo"), Is.True);
// Setup TestExeInstaller with dsc resources.
var installDir = TestCommon.GetRandomTestDir();
result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --override \"/InstallDir {installDir} /GenerateDscResourceFiles\"");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// Find unit processors filtering to install location.
result = TestCommon.RunAICLICommand("test config-find-unit-processors", $"-l {installDir}");
- Assert.AreEqual(0, result.ExitCode);
- Assert.False(result.StdOut.Contains("Microsoft/OSInfo"));
- Assert.True(result.StdOut.Contains("AppInstallerTest/TestResource"));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains("Microsoft/OSInfo"), Is.False);
+ Assert.That(result.StdOut.Contains("AppInstallerTest/TestResource"), Is.True);
// Find unit processors filtering to unknown location.
var unknownDir = TestCommon.GetRandomTestDir();
result = TestCommon.RunAICLICommand("test config-find-unit-processors", $"-l {unknownDir}");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains("No unit processors found."));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains("No unit processors found."), Is.True);
// Clean up
result = TestCommon.RunAICLICommand("uninstall", "AppInstallerTest.TestExeInstaller");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
}
///
@@ -405,13 +405,13 @@ public void RunCommandOnSetResourceTest()
File.WriteAllText(testConfigFile, content);
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, testConfigFile, timeOut: 300000);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// Verify test file created.
string targetFilePath = Path.Combine(testDir, "TestFile.txt");
- FileAssert.Exists(targetFilePath);
+ Assert.That(File.Exists(targetFilePath), Is.True);
string testContent = File.ReadAllText(targetFilePath);
- Assert.True(testContent.Contains("TestContent"));
+ Assert.That(testContent.Contains("TestContent"), Is.True);
}
private void DeleteResourceArtifacts()
diff --git a/src/AppInstallerCLIE2ETests/ConfigureExportCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureExportCommand.cs
index 99e84bf924..93e6e87c35 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureExportCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureExportCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -60,23 +60,23 @@ public void ExportTestPackage()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--package-id AppInstallerTest.TestPackageExport -o {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(File.Exists(exportFile));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(File.Exists(exportFile), Is.True);
// Check exported file is readable and validate content
var showResult = TestCommon.RunAICLICommand(ShowCommand, $"-f {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, showResult.ExitCode);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"));
- Assert.True(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"));
- Assert.True(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"));
-
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"));
+ Assert.That(showResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"), Is.True);
+
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"), Is.True);
}
///
@@ -88,27 +88,27 @@ public void ExportTestPackageWithPackageSettings()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--package-id AppInstallerTest.TestPackageExport --module AppInstallerTest --resource TestResource -o {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(File.Exists(exportFile));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(File.Exists(exportFile), Is.True);
// Check exported file is readable and validate content
var showResult = TestCommon.RunAICLICommand(ShowCommand, $"-f {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, showResult.ExitCode);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"));
- Assert.True(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"));
- Assert.True(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"));
-
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"));
-
- Assert.True(showResult.StdOut.Contains("AppInstallerTest/TestResource"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains("data: TestData"));
+ Assert.That(showResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"), Is.True);
+
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"), Is.True);
+
+ Assert.That(showResult.StdOut.Contains("AppInstallerTest/TestResource"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains("data: TestData"), Is.True);
}
///
@@ -120,24 +120,24 @@ public void ExportTestPackageWithVersion()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--package-id AppInstallerTest.TestPackageExport --include-versions -o {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(File.Exists(exportFile));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(File.Exists(exportFile), Is.True);
// Check exported file is readable and validate content
var showResult = TestCommon.RunAICLICommand(ShowCommand, $"-f {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, showResult.ExitCode);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"));
- Assert.True(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"));
- Assert.True(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"));
-
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"));
- Assert.True(showResult.StdOut.Contains("version: 1.0.0.0"));
+ Assert.That(showResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"), Is.True);
+
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"), Is.True);
+ Assert.That(showResult.StdOut.Contains("version: 1.0.0.0"), Is.True);
}
///
@@ -150,38 +150,38 @@ public void ExportAll()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--all --verbose -o {exportFile}", timeOut: 1200000);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(File.Exists(exportFile));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(File.Exists(exportFile), Is.True);
// Check exported file is readable and validate content
var showResult = TestCommon.RunAICLICommand(ShowCommand, $"-f {exportFile}", timeOut: 1200000);
- Assert.AreEqual(Constants.ErrorCode.S_OK, showResult.ExitCode);
+ Assert.That(showResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
- Assert.True(showResult.StdOut.Contains("Microsoft.PowerShell"));
+ Assert.That(showResult.StdOut.Contains("Microsoft.PowerShell"), Is.True);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/UserSettingsFile"));
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/AdminSettings"));
- Assert.True(showResult.StdOut.Contains("Microsoft.Windows.Settings/WindowsSettings"));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/UserSettingsFile"), Is.True);
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/AdminSettings"), Is.True);
+ Assert.That(showResult.StdOut.Contains("Microsoft.Windows.Settings/WindowsSettings"), Is.True);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"));
- Assert.True(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"));
- Assert.True(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Source"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_{Constants.TestSourceType}]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"type: {Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"argument: {Constants.TestSourceUrl}"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"name: {Constants.TestSourceName}"), Is.True);
- Assert.True(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"));
- Assert.True(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"));
- Assert.True(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"));
+ Assert.That(showResult.StdOut.Contains("Microsoft.WinGet.Dev/Package"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"[{Constants.TestSourceName}_AppInstallerTest.TestPackageExport]"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_{Constants.TestSourceType}"), Is.True);
+ Assert.That(showResult.StdOut.Contains("id: AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"source: {Constants.TestSourceName}"), Is.True);
- Assert.True(showResult.StdOut.Contains("AppInstallerTest/TestResource"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains("data: TestData"));
+ Assert.That(showResult.StdOut.Contains("AppInstallerTest/TestResource"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains("data: TestData"), Is.True);
- Assert.True(showResult.StdOut.Contains("AppInstallerTest/TestResource_SubDirectory"));
- Assert.True(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"));
- Assert.True(showResult.StdOut.Contains("data: TestData"));
+ Assert.That(showResult.StdOut.Contains("AppInstallerTest/TestResource_SubDirectory"), Is.True);
+ Assert.That(showResult.StdOut.Contains($"Dependencies: {Constants.TestSourceName}_AppInstallerTest.TestPackageExport"), Is.True);
+ Assert.That(showResult.StdOut.Contains("data: TestData"), Is.True);
}
///
@@ -193,7 +193,7 @@ public void ExportFailedWithNotFoundPackage()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--package-id NotFound.NotFound -o {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND));
}
///
@@ -205,7 +205,7 @@ public void ExportFailedWithAllAndSpecificPackage()
var exportDir = TestCommon.GetRandomTestDir();
var exportFile = Path.Combine(exportDir, "exported.yml");
var result = TestCommon.RunAICLICommand(Command, $"--all --package-id AppInstallerTest.TestPackageExport -o {exportFile}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS));
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/ConfigureListCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureListCommand.cs
index bd7128305e..95d36ea2ac 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureListCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureListCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -34,11 +34,11 @@ public void OneTimeTeardown()
public void ListAllConfigurations()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure list", "--verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(ConfigureTestRepoFile));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains(ConfigureTestRepoFile), Is.True);
}
///
@@ -48,13 +48,13 @@ public void ListAllConfigurations()
public void ListSpecificConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
result = TestCommon.RunAICLICommand("configure list", $"-h {guid}");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(guid));
- Assert.True(result.StdOut.Contains(ConfigureTestRepoFile));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains(guid), Is.True);
+ Assert.That(result.StdOut.Contains(ConfigureTestRepoFile), Is.True);
}
///
@@ -64,15 +64,15 @@ public void ListSpecificConfiguration()
public void RemoveConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
result = TestCommon.RunAICLICommand("configure list", $"-h {guid} --remove");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure list", "--verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.False(result.StdOut.Contains(guid));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains(guid), Is.False);
}
///
@@ -82,15 +82,15 @@ public void RemoveConfiguration()
public void OutputConfiguration()
{
var result = TestCommon.RunAICLICommand(ConfigureWithAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor(ConfigureTestRepoFile);
string tempFile = TestCommon.GetRandomTestFile(".yml");
result = TestCommon.RunAICLICommand("configure list", $"-h {guid} --output {tempFile}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
result = TestCommon.RunAICLICommand("configure validate", $"--verbose {tempFile}");
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
}
private void DeleteTxtFiles()
diff --git a/src/AppInstallerCLIE2ETests/ConfigureProcessorPathCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureProcessorPathCommand.cs
index f1d0a1d7a0..4fa1256240 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureProcessorPathCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureProcessorPathCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -74,12 +74,12 @@ public void ProcessorPath_AuditOutput_ShowsPathAndHash()
// Audit header must appear regardless of whether the configure succeeds or fails,
// because audit output happens during factory setup before DSC is invoked.
- Assert.True(result.StdOut.Contains("Custom processor path:"), $"Expected audit header in output. StdOut: {result.StdOut}");
- Assert.True(result.StdOut.Contains($" Path: {processorPath}"), $"Expected path in audit output. StdOut: {result.StdOut}");
- Assert.True(result.StdOut.Contains(" Hash: "), $"Expected hash in audit output. StdOut: {result.StdOut}");
+ Assert.That(result.StdOut.Contains("Custom processor path:"), Is.True, $"Expected audit header in output. StdOut: {result.StdOut}");
+ Assert.That(result.StdOut.Contains($" Path: {processorPath}"), Is.True, $"Expected path in audit output. StdOut: {result.StdOut}");
+ Assert.That(result.StdOut.Contains(" Hash: "), Is.True, $"Expected hash in audit output. StdOut: {result.StdOut}");
// dsc.exe is an app execution alias; the alias marker must be present.
- Assert.True(result.StdOut.Contains("Type: App execution alias"), $"Expected app execution alias marker. StdOut: {result.StdOut}");
+ Assert.That(result.StdOut.Contains("Type: App execution alias"), Is.True, $"Expected app execution alias marker. StdOut: {result.StdOut}");
}
///
@@ -102,7 +102,7 @@ public void ProcessorPath_AuditOutput_HashIsValidSHA256()
Command,
$"--accept-configuration-agreements --processor-path \"{processorPath}\" \"{configFile}\" --no-progress");
- Assert.True(result.StdOut.Contains(" Hash: "), $"Expected hash in audit output. StdOut: {result.StdOut}");
+ Assert.That(result.StdOut.Contains(" Hash: "), Is.True, $"Expected hash in audit output. StdOut: {result.StdOut}");
// Extract the hash value from " Hash: "
int hashLabelIndex = result.StdOut.IndexOf(" Hash: ");
@@ -114,10 +114,8 @@ public void ProcessorPath_AuditOutput_HashIsValidSHA256()
? result.StdOut.Substring(hashStart, hashEnd - hashStart).Trim()
: result.StdOut.Substring(hashStart).Trim();
- Assert.AreEqual(64, hashValue.Length, $"Expected 64-character SHA256 hash, got: '{hashValue}'");
- Assert.True(
- Regex.IsMatch(hashValue, "^[0-9a-f]{64}$"),
- $"Expected lowercase hex hash, got: '{hashValue}'");
+ Assert.That(hashValue.Length, Is.EqualTo(64), $"Expected 64-character SHA256 hash, got: '{hashValue}'");
+ Assert.That(Regex.IsMatch(hashValue, "^[0-9a-f]{64}$"), Is.True, $"Expected lowercase hex hash, got: '{hashValue}'");
}
///
diff --git a/src/AppInstallerCLIE2ETests/ConfigureShowCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureShowCommand.cs
index 3649d20a47..4b1599da88 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureShowCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureShowCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -45,8 +45,8 @@ public void ShowDetailsFromGallery()
TestCommon.EnsureModuleState(Constants.GalleryTestModuleName, present: false);
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\PSGallery_NoModule_NoSettings.yml")} --verbose", timeOut: 120000);
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(Constants.PSGalleryName));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain(Constants.PSGalleryName));
}
///
@@ -58,8 +58,8 @@ public void ShowDetailsFromTestRepo()
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")} --verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(Constants.TestRepoName));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain(Constants.TestRepoName));
}
///
@@ -81,8 +81,8 @@ public void ShowDetailsFromLocal(TestCommon.TestModuleLocation location)
}
var result = TestCommon.RunAICLICommand("configure show", args);
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(Constants.LocalModuleDescriptor));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain(Constants.LocalModuleDescriptor));
}
///
@@ -94,8 +94,8 @@ public void ShowDetails_Schema0_3_Succeeds()
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: false);
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo_0_3.yml")} --verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(Constants.TestRepoName));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain(Constants.TestRepoName));
}
///
@@ -105,8 +105,8 @@ public void ShowDetails_Schema0_3_Succeeds()
public void ShowDetails_Schema0_3_Parameters()
{
var result = TestCommon.RunAICLICommand("configure show", TestCommon.GetTestDataFile("Configuration\\WithParameters_0_3.yml"));
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains("Failed to get detailed information about the configuration."));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain("Failed to get detailed information about the configuration."));
}
///
@@ -116,8 +116,8 @@ public void ShowDetails_Schema0_3_Parameters()
public void ShowDetailsFromHttpsConfigurationFile()
{
var result = TestCommon.RunAICLICommand("configure show", $"{Constants.TestSourceUrl}/TestData/Configuration/ShowDetails_TestRepo.yml --verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(Constants.TestRepoName));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Does.Contain(Constants.TestRepoName));
}
///
@@ -127,10 +127,10 @@ public void ShowDetailsFromHttpsConfigurationFile()
public void ShowTruncatedDetailsAndFileContent()
{
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\LargeContentStrings.yml")} --verbose");
- Assert.AreEqual(0, result.ExitCode);
- Assert.True(result.StdOut.Contains(""));
- Assert.True(result.StdOut.Contains("Some of the data present in the configuration file was truncated for this output; inspect the file contents for the complete content."));
- Assert.False(result.StdOut.Contains("Line5"));
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains(""), Is.True);
+ Assert.That(result.StdOut.Contains("Some of the data present in the configuration file was truncated for this output; inspect the file contents for the complete content."), Is.True);
+ Assert.That(result.StdOut.Contains("Line5"), Is.False);
}
///
@@ -140,11 +140,11 @@ public void ShowTruncatedDetailsAndFileContent()
public void ShowFromHistory()
{
var result = TestCommon.RunAICLICommand("configure --accept-configuration-agreements --verbose", TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor("Configure_TestRepo.yml");
result = TestCommon.RunAICLICommand("configure show", $"-h {guid}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
}
///
@@ -154,7 +154,7 @@ public void ShowFromHistory()
public void ShowWithBadProcessorIdentifier()
{
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\Unknown_Processor.yml")} --verbose");
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE));
}
///
@@ -164,7 +164,7 @@ public void ShowWithBadProcessorIdentifier()
public void ShowDetails_DSCv3()
{
var result = TestCommon.RunAICLICommand("configure show", $"{TestCommon.GetTestDataFile("Configuration\\ShowDetails_DSCv3.yml")} --verbose");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
var outputLines = result.StdOut.Split('\n');
int startLine = -1;
@@ -176,11 +176,11 @@ public void ShowDetails_DSCv3()
}
}
- Assert.AreNotEqual(-1, startLine);
- Assert.LessOrEqual(3, outputLines.Length - startLine);
+ Assert.That(startLine, Is.Not.EqualTo(-1));
+ Assert.That(outputLines.Length - startLine, Is.GreaterThanOrEqualTo(3));
// outputLines[1] should contain the discovered resource string if working properly.
- Assert.AreEqual("Description 1.", outputLines[startLine + 2].Trim());
+ Assert.That(outputLines[startLine + 2].Trim(), Is.EqualTo("Description 1."));
}
///
@@ -190,11 +190,11 @@ public void ShowDetails_DSCv3()
public void ShowFromHistory_DSCv3()
{
var result = TestCommon.RunAICLICommand("configure --accept-configuration-agreements --verbose", TestCommon.GetTestDataFile("Configuration\\ShowDetails_DSCv3.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor("ShowDetails_DSCv3.yml");
result = TestCommon.RunAICLICommand("configure show", $"-h {guid} --");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
var outputLines = result.StdOut.Split('\n');
int startLine = -1;
@@ -206,11 +206,11 @@ public void ShowFromHistory_DSCv3()
}
}
- Assert.AreNotEqual(-1, startLine);
- Assert.LessOrEqual(3, outputLines.Length - startLine);
+ Assert.That(startLine, Is.Not.EqualTo(-1));
+ Assert.That(outputLines.Length - startLine, Is.GreaterThanOrEqualTo(3));
// outputLines[1] should contain the discovered resource string if working properly.
- Assert.AreEqual("Description 1.", outputLines[startLine + 2].Trim());
+ Assert.That(outputLines[startLine + 2].Trim(), Is.EqualTo("Description 1."));
}
private void DeleteResourceArtifacts()
diff --git a/src/AppInstallerCLIE2ETests/ConfigureTestCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureTestCommand.cs
index ca49d7a566..26658bf176 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureTestCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureTestCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -47,9 +47,9 @@ public void ConfigureTest_NotInDesiredState()
this.DeleteResourceArtifacts();
var result = TestCommon.RunAICLICommand(CommandAndAgreements, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("System is not in the described configuration state."));
- Assert.True(result.StdOut.Contains("Module: xE2ETestResource")); // Details from the resource should appear if the initial details are shown
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("System is not in the described configuration state."), Is.True);
+ Assert.That(result.StdOut.Contains("Module: xE2ETestResource"), Is.True); // Details from the resource should appear if the initial details are shown
}
///
@@ -65,9 +65,9 @@ public void ConfigureTest_InDesiredState()
File.WriteAllText(TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt"), "Contents!");
var result = TestCommon.RunAICLICommand(CommandAndAgreements, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("System is in the described configuration state."));
- Assert.True(result.StdOut.Contains("Module: xE2ETestResource")); // Details from the resource should appear if the initial details are shown
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("System is in the described configuration state."), Is.True);
+ Assert.That(result.StdOut.Contains("Module: xE2ETestResource"), Is.True); // Details from the resource should appear if the initial details are shown
}
///
@@ -77,9 +77,9 @@ public void ConfigureTest_InDesiredState()
public void ConfigureTest_TestFailure()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreements, TestCommon.GetTestDataFile("Configuration\\IndependentResources_OneFailure.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_TEST_FAILED, result.ExitCode);
- Assert.True(result.StdOut.Contains("Some of the configuration units failed while testing their state."));
- Assert.True(result.StdOut.Contains("System is not in the described configuration state."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_TEST_FAILED));
+ Assert.That(result.StdOut.Contains("Some of the configuration units failed while testing their state."), Is.True);
+ Assert.That(result.StdOut.Contains("System is not in the described configuration state."), Is.True);
}
///
@@ -89,8 +89,8 @@ public void ConfigureTest_TestFailure()
public void ConfigureTest_HttpsConfigurationFile()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreements, $"{Constants.TestSourceUrl}/TestData/Configuration/Configure_TestRepo_Location.yml");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("System is in the described configuration state."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("System is in the described configuration state."), Is.True);
}
///
@@ -100,21 +100,21 @@ public void ConfigureTest_HttpsConfigurationFile()
public void TestFromHistory()
{
var result = TestCommon.RunAICLICommand("configure --accept-configuration-agreements --verbose", TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
// The configuration creates a file next to itself with the given contents
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt");
- FileAssert.Exists(targetFilePath);
- Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
+ Assert.That(File.Exists(targetFilePath), Is.True);
+ Assert.That(File.ReadAllText(targetFilePath), Is.EqualTo("Contents!"));
string guid = TestCommon.GetConfigurationInstanceIdentifierFor("Configure_TestRepo.yml");
result = TestCommon.RunAICLICommand(CommandAndAgreements, $"-h {guid}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
File.WriteAllText(targetFilePath, "Changed contents!");
result = TestCommon.RunAICLICommand(CommandAndAgreements, $"-h {guid}");
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
}
///
@@ -124,8 +124,8 @@ public void TestFromHistory()
public void ConfigureTest_DSCv3()
{
var result = TestCommon.RunAICLICommand(CommandAndAgreements, $"{TestCommon.GetTestDataFile("Configuration\\ShowDetails_DSCv3.yml")} --verbose");
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("System is not in the described configuration state."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("System is not in the described configuration state."), Is.True);
}
///
@@ -135,8 +135,8 @@ public void ConfigureTest_DSCv3()
public void ConfigureTest_SuppressInitialDetails()
{
var result = TestCommon.RunAICLICommand("configure --accept-configuration-agreements --suppress-initial-details", TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(0, result.ExitCode);
- Assert.False(result.StdOut.Contains("Module: xE2ETestResource")); // Details from the resource should not appear if the initial details are suppressed
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut.Contains("Module: xE2ETestResource"), Is.False); // Details from the resource should not appear if the initial details are suppressed
}
private void DeleteResourceArtifacts()
diff --git a/src/AppInstallerCLIE2ETests/ConfigureValidateCommand.cs b/src/AppInstallerCLIE2ETests/ConfigureValidateCommand.cs
index 6c8dcd677e..0bc039a078 100644
--- a/src/AppInstallerCLIE2ETests/ConfigureValidateCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ConfigureValidateCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -41,7 +41,7 @@ public void BaseTeardown()
public void EmptyFile()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\Empty.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_YAML, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_YAML));
}
///
@@ -51,9 +51,9 @@ public void EmptyFile()
public void NotConfigurationYAML()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\NotConfig.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_MISSING_FIELD, result.ExitCode);
- Assert.True(result.StdOut.Contains("$schema"));
- Assert.True(result.StdOut.Contains("missing"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_MISSING_FIELD));
+ Assert.That(result.StdOut.Contains("$schema"), Is.True);
+ Assert.That(result.StdOut.Contains("missing"), Is.True);
}
///
@@ -63,9 +63,9 @@ public void NotConfigurationYAML()
public void NoVersion()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\NoVersion.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_MISSING_FIELD, result.ExitCode);
- Assert.True(result.StdOut.Contains("configurationVersion"));
- Assert.True(result.StdOut.Contains("missing"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_MISSING_FIELD));
+ Assert.That(result.StdOut.Contains("configurationVersion"), Is.True);
+ Assert.That(result.StdOut.Contains("missing"), Is.True);
}
///
@@ -75,9 +75,9 @@ public void NoVersion()
public void UnknownVersion()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\UnknownVersion.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_UNKNOWN_CONFIGURATION_FILE_VERSION, result.ExitCode);
- Assert.True(result.StdOut.Contains("Configuration file version"));
- Assert.True(result.StdOut.Contains("is not known."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_UNKNOWN_CONFIGURATION_FILE_VERSION));
+ Assert.That(result.StdOut.Contains("Configuration file version"), Is.True);
+ Assert.That(result.StdOut.Contains("is not known."), Is.True);
}
///
@@ -87,9 +87,9 @@ public void UnknownVersion()
public void ResourcesIsWrongType()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\ResourcesNotASequence.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_TYPE, result.ExitCode);
- Assert.True(result.StdOut.Contains("resources"));
- Assert.True(result.StdOut.Contains("wrong type"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_TYPE));
+ Assert.That(result.StdOut.Contains("resources"), Is.True);
+ Assert.That(result.StdOut.Contains("wrong type"), Is.True);
}
///
@@ -99,9 +99,9 @@ public void ResourcesIsWrongType()
public void UnitIsWrongType()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\UnitNotAMap.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_TYPE, result.ExitCode);
- Assert.True(result.StdOut.Contains("resources[0]"));
- Assert.True(result.StdOut.Contains("wrong type"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_TYPE));
+ Assert.That(result.StdOut.Contains("resources[0]"), Is.True);
+ Assert.That(result.StdOut.Contains("wrong type"), Is.True);
}
///
@@ -111,10 +111,10 @@ public void UnitIsWrongType()
public void NoResourceName()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\NoResourceName.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE, result.ExitCode);
- Assert.True(result.StdOut.Contains("resource"));
- Assert.True(result.StdOut.Contains("invalid value"));
- Assert.True(result.StdOut.Contains("Module/"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE));
+ Assert.That(result.StdOut.Contains("resource"), Is.True);
+ Assert.That(result.StdOut.Contains("invalid value"), Is.True);
+ Assert.That(result.StdOut.Contains("Module/"), Is.True);
}
///
@@ -124,10 +124,10 @@ public void NoResourceName()
public void ModuleMismatch()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\ModuleMismatch.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE, result.ExitCode);
- Assert.True(result.StdOut.Contains("module"));
- Assert.True(result.StdOut.Contains("invalid value"));
- Assert.True(result.StdOut.Contains("DifferentModule"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_INVALID_FIELD_VALUE));
+ Assert.That(result.StdOut.Contains("module"), Is.True);
+ Assert.That(result.StdOut.Contains("invalid value"), Is.True);
+ Assert.That(result.StdOut.Contains("DifferentModule"), Is.True);
}
///
@@ -137,9 +137,9 @@ public void ModuleMismatch()
public void DuplicateIdentifiers()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\DuplicateIdentifiers.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_DUPLICATE_IDENTIFIER, result.ExitCode);
- Assert.True(result.StdOut.Contains("The configuration contains the identifier `same` multiple times."));
- Assert.False(result.StdOut.Contains("NotMentioned"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_DUPLICATE_IDENTIFIER));
+ Assert.That(result.StdOut.Contains("The configuration contains the identifier `same` multiple times."), Is.True);
+ Assert.That(result.StdOut.Contains("NotMentioned"), Is.False);
}
///
@@ -149,9 +149,9 @@ public void DuplicateIdentifiers()
public void MissingDependency()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\MissingDependency.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_MISSING_DEPENDENCY, result.ExitCode);
- Assert.True(result.StdOut.Contains("The dependency `missing` was not found within the configuration."));
- Assert.False(result.StdOut.Contains("xE2ETestResource"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_MISSING_DEPENDENCY));
+ Assert.That(result.StdOut.Contains("The dependency `missing` was not found within the configuration."), Is.True);
+ Assert.That(result.StdOut.Contains("xE2ETestResource"), Is.False);
}
///
@@ -161,9 +161,9 @@ public void MissingDependency()
public void DependencyCycle()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\DependencyCycle.yml"));
- Assert.AreEqual(Constants.ErrorCode.CONFIG_ERROR_SET_DEPENDENCY_CYCLE, result.ExitCode);
- Assert.True(result.StdOut.Contains("This configuration unit is part of a dependency cycle."));
- Assert.False(result.StdOut.Contains("NotMentioned"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.CONFIG_ERROR_SET_DEPENDENCY_CYCLE));
+ Assert.That(result.StdOut.Contains("This configuration unit is part of a dependency cycle."), Is.True);
+ Assert.That(result.StdOut.Contains("NotMentioned"), Is.False);
}
///
@@ -173,8 +173,8 @@ public void DependencyCycle()
public void ResourceIsNotPublic()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.yml"));
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("not available publicly"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("not available publicly"), Is.True);
}
///
@@ -184,8 +184,8 @@ public void ResourceIsNotPublic()
public void ResourceIsNotFound()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\ResourceNotFound.yml"));
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("The configuration unit could not be found."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("The configuration unit could not be found."), Is.True);
}
///
@@ -195,8 +195,8 @@ public void ResourceIsNotFound()
public void ModuleNotProvided()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\PSGallery_NoModule_NoSettings.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("The module was not provided."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("The module was not provided."), Is.True);
}
///
@@ -206,8 +206,8 @@ public void ModuleNotProvided()
public void NoIssuesDetected()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\PSGallery_NoSettings.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Validation found no issues."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Validation found no issues."), Is.True);
}
///
@@ -217,8 +217,8 @@ public void NoIssuesDetected()
public void NoIssuesDetected_HttpsConfigurationFile()
{
var result = TestCommon.RunAICLICommand(Command, $"{Constants.TestSourceUrl}/TestData/Configuration/PSGallery_NoSettings.yml", timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Validation found no issues."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Validation found no issues."), Is.True);
}
///
@@ -228,8 +228,8 @@ public void NoIssuesDetected_HttpsConfigurationFile()
public void NoIssuesDetected_WinGetDscResource()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_Good.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Validation found no issues."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Validation found no issues."), Is.True);
}
///
@@ -239,8 +239,8 @@ public void NoIssuesDetected_WinGetDscResource()
public void ValidateWinGetDscResource_DependencySourceMissing()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_DependencySourceMissing.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage configuration unit package depends on a third-party source not previously configured. Package Id: AppInstallerTest.TestExeInstaller; Source: TestSource"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage configuration unit package depends on a third-party source not previously configured. Package Id: AppInstallerTest.TestExeInstaller; Source: TestSource"), Is.True);
}
///
@@ -250,8 +250,8 @@ public void ValidateWinGetDscResource_DependencySourceMissing()
public void ValidateWinGetDscResource_PackageNotFound()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_PackageNotFound.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Package not found. Package Id: AppInstallerTest.DoesNotExist"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Package not found. Package Id: AppInstallerTest.DoesNotExist"), Is.True);
}
///
@@ -261,8 +261,8 @@ public void ValidateWinGetDscResource_PackageNotFound()
public void ValidateWinGetDscResource_PackageVersionNotFound()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_PackageVersionNotFound.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Package version not found. Package Id: AppInstallerTest.TestExeInstaller; Version 101.0.101.0"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Package version not found. Package Id: AppInstallerTest.TestExeInstaller; Version 101.0.101.0"), Is.True);
}
///
@@ -272,8 +272,8 @@ public void ValidateWinGetDscResource_PackageVersionNotFound()
public void ValidateWinGetDscResource_SourceOpenFailed()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_SourceOpenFailed.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Source open failed. Package Id: AppInstallerTest.TestExeInstaller; Source: TestSourceV2"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage configuration unit package cannot be validated. Source open failed. Package Id: AppInstallerTest.TestExeInstaller; Source: TestSourceV2"), Is.True);
}
///
@@ -283,8 +283,8 @@ public void ValidateWinGetDscResource_SourceOpenFailed()
public void ValidateWinGetDscResource_VersionSpecifiedWithOnlyOneVersionAvailable()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_VersionSpecifiedWithOnlyOneVersionAvailable.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage configuration unit package specified with a specific version while only one package version is available. Package Id: AppInstallerTest.TestValidManifest; Version: 1.0.0.0"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage configuration unit package specified with a specific version while only one package version is available. Package Id: AppInstallerTest.TestValidManifest; Version: 1.0.0.0"), Is.True);
}
///
@@ -294,8 +294,8 @@ public void ValidateWinGetDscResource_VersionSpecifiedWithOnlyOneVersionAvailabl
public void ValidateWinGetDscResource_VersionSpecifiedWithUseLatest()
{
var result = TestCommon.RunAICLICommand(Command, TestCommon.GetTestDataFile("Configuration\\WinGetDscResourceValidate_VersionSpecifiedWithUseLatest.yml"), timeOut: 120000);
- Assert.AreEqual(Constants.ErrorCode.S_FALSE, result.ExitCode);
- Assert.True(result.StdOut.Contains("WinGetPackage declares both UseLatest and Version. Package Id: AppInstallerTest.TestExeInstaller"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_FALSE));
+ Assert.That(result.StdOut.Contains("WinGetPackage declares both UseLatest and Version. Package Id: AppInstallerTest.TestExeInstaller"), Is.True);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/DSCv3AdminSettingsResourceCommand.cs b/src/AppInstallerCLIE2ETests/DSCv3AdminSettingsResourceCommand.cs
index 71ba28ac2f..682a0f088d 100644
--- a/src/AppInstallerCLIE2ETests/DSCv3AdminSettingsResourceCommand.cs
+++ b/src/AppInstallerCLIE2ETests/DSCv3AdminSettingsResourceCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -77,11 +77,11 @@ public void AdminSettings_Get(string function)
AssertSuccessfulResourceRun(ref result);
AdminSettingsResourceData output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.IsNotNull(output.Settings);
- Assert.IsTrue(output.Settings.ContainsKey(LocalManifestFiles));
- Assert.IsFalse(output.Settings.ContainsKey(DefaultProxy));
- Assert.IsFalse(output.Settings.ContainsKey(NotAnAdminSettingName));
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Settings, Is.Not.Null);
+ Assert.That(output.Settings.ContainsKey(LocalManifestFiles), Is.True);
+ Assert.That(output.Settings.ContainsKey(DefaultProxy), Is.False);
+ Assert.That(output.Settings.ContainsKey(NotAnAdminSettingName), Is.False);
}
///
@@ -105,7 +105,7 @@ public void AdminSettings_Test_BoolSetting(string settingName)
result = RunDSCv3Command(AdminSettingsResource, TestFunction, resourceData);
AssertTestOfBoolSetting(ref result, settingName, false, false);
- Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("settings", $"--enable {settingName}").ExitCode);
+ Assert.That(TestCommon.RunAICLICommand("settings", $"--enable {settingName}").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
resourceData.Settings[settingName] = false;
result = RunDSCv3Command(AdminSettingsResource, TestFunction, resourceData);
@@ -136,7 +136,7 @@ public void AdminSettings_Test_StringSetting(string settingName)
result = RunDSCv3Command(AdminSettingsResource, TestFunction, resourceData);
AssertTestOfStringSetting(ref result, settingName, null, testValue);
- Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("settings set", $"{settingName} \"{testValue}\"").ExitCode);
+ Assert.That(TestCommon.RunAICLICommand("settings set", $"{settingName} \"{testValue}\"").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
resourceData.Settings[settingName] = null;
result = RunDSCv3Command(AdminSettingsResource, TestFunction, resourceData);
@@ -157,8 +157,8 @@ public void AdminSettings_Test_StringSetting(string settingName)
[Test]
public void AdminSettings_Test_Complex()
{
- Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("settings", $"--enable {LocalArchiveMalwareScanOverride}").ExitCode);
- Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("settings", $"--enable {LocalManifestFiles}").ExitCode);
+ Assert.That(TestCommon.RunAICLICommand("settings", $"--enable {LocalArchiveMalwareScanOverride}").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(TestCommon.RunAICLICommand("settings", $"--enable {LocalManifestFiles}").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
AdminSettingsResourceData resourceData = new AdminSettingsResourceData() { Settings = new JsonObject() };
resourceData.Settings[LocalArchiveMalwareScanOverride] = true;
@@ -169,9 +169,9 @@ public void AdminSettings_Test_Complex()
AssertSuccessfulResourceRun(ref result);
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.IsTrue(output.InDesiredState);
- Assert.IsNotNull(output.Settings);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.InDesiredState, Is.True);
+ Assert.That(output.Settings, Is.Not.Null);
AssertDiffState(diff, []);
}
@@ -254,11 +254,11 @@ public void AdminSettings_Set_Complex()
AssertSuccessfulResourceRun(ref result);
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.IsNotNull(output.Settings);
- Assert.AreEqual(JsonValueKind.True, output.Settings[LocalArchiveMalwareScanOverride].AsValue().GetValueKind());
- Assert.AreEqual(JsonValueKind.False, output.Settings[BypassCertificatePinningForMicrosoftStore].AsValue().GetValueKind());
- Assert.AreEqual(testValue, output.Settings[DefaultProxy].AsValue().GetValue());
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Settings, Is.Not.Null);
+ Assert.That(output.Settings[LocalArchiveMalwareScanOverride].AsValue().GetValueKind(), Is.EqualTo(JsonValueKind.True));
+ Assert.That(output.Settings[BypassCertificatePinningForMicrosoftStore].AsValue().GetValueKind(), Is.EqualTo(JsonValueKind.False));
+ Assert.That(output.Settings[DefaultProxy].AsValue().GetValue(), Is.EqualTo(testValue));
AssertDiffState(diff, [ SettingsPropertyName ]);
}
@@ -275,12 +275,12 @@ public void AdminSettings_Set_GroupPolicyBlocked()
resourceData.Settings[InstallerHashOverride] = true;
var result = RunDSCv3Command(AdminSettingsResource, SetFunction, resourceData);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
private static void ResetAllSettings()
{
- Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("settings reset", "--all").ExitCode);
+ Assert.That(TestCommon.RunAICLICommand("settings reset", "--all").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
private static void AssertTestOfBoolSetting(ref TestCommon.RunCommandResult result, string settingName, bool expectedState, bool testState)
@@ -290,11 +290,11 @@ private static void AssertTestOfBoolSetting(ref TestCommon.RunCommandResult resu
bool inDesiredState = expectedState == testState;
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.AreEqual(inDesiredState, output.InDesiredState);
- Assert.IsNotNull(output.Settings);
- Assert.IsTrue(output.Settings.ContainsKey(settingName));
- Assert.AreEqual(expectedState ? JsonValueKind.True : JsonValueKind.False, output.Settings[settingName].AsValue().GetValueKind());
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.InDesiredState, Is.EqualTo(inDesiredState));
+ Assert.That(output.Settings, Is.Not.Null);
+ Assert.That(output.Settings.ContainsKey(settingName), Is.True);
+ Assert.That(output.Settings[settingName].AsValue().GetValueKind(), Is.EqualTo(expectedState ? JsonValueKind.True : JsonValueKind.False));
AssertDiffState(diff, inDesiredState ? [] : [ SettingsPropertyName ]);
}
@@ -306,10 +306,10 @@ private static void AssertSetOfBoolSetting(ref TestCommon.RunCommandResult resul
bool inDesiredState = previousState == desiredState;
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.IsNotNull(output.Settings);
- Assert.IsTrue(output.Settings.ContainsKey(settingName));
- Assert.AreEqual(desiredState ? JsonValueKind.True : JsonValueKind.False, output.Settings[settingName].AsValue().GetValueKind());
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Settings, Is.Not.Null);
+ Assert.That(output.Settings.ContainsKey(settingName), Is.True);
+ Assert.That(output.Settings[settingName].AsValue().GetValueKind(), Is.EqualTo(desiredState ? JsonValueKind.True : JsonValueKind.False));
AssertDiffState(diff, inDesiredState ? [] : [ SettingsPropertyName ]);
}
@@ -321,17 +321,17 @@ private static void AssertTestOfStringSetting(ref TestCommon.RunCommandResult re
bool inDesiredState = expectedState == testState;
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.AreEqual(inDesiredState, output.InDesiredState);
- Assert.IsNotNull(output.Settings);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.InDesiredState, Is.EqualTo(inDesiredState));
+ Assert.That(output.Settings, Is.Not.Null);
if (expectedState != null)
{
- Assert.IsTrue(output.Settings.ContainsKey(settingName));
- Assert.AreEqual(expectedState, output.Settings[settingName].AsValue().GetValue());
+ Assert.That(output.Settings.ContainsKey(settingName), Is.True);
+ Assert.That(output.Settings[settingName].AsValue().GetValue(), Is.EqualTo(expectedState));
}
else
{
- Assert.IsFalse(output.Settings.ContainsKey(settingName));
+ Assert.That(output.Settings.ContainsKey(settingName), Is.False);
}
AssertDiffState(diff, inDesiredState ? [] : [SettingsPropertyName]);
@@ -344,16 +344,16 @@ private static void AssertSetOfStringSetting(ref TestCommon.RunCommandResult res
bool inDesiredState = previousState == desiredState;
(AdminSettingsResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.IsNotNull(output.Settings);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Settings, Is.Not.Null);
if (desiredState != null)
{
- Assert.IsTrue(output.Settings.ContainsKey(settingName));
- Assert.AreEqual(desiredState, output.Settings[settingName].AsValue().GetValue());
+ Assert.That(output.Settings.ContainsKey(settingName), Is.True);
+ Assert.That(output.Settings[settingName].AsValue().GetValue(), Is.EqualTo(desiredState));
}
else
{
- Assert.IsFalse(output.Settings.ContainsKey(settingName));
+ Assert.That(output.Settings.ContainsKey(settingName), Is.False);
}
AssertDiffState(diff, inDesiredState ? [] : [SettingsPropertyName]);
diff --git a/src/AppInstallerCLIE2ETests/DSCv3PackageResourceCommand.cs b/src/AppInstallerCLIE2ETests/DSCv3PackageResourceCommand.cs
index 4fbf1e789d..eb169d4f59 100644
--- a/src/AppInstallerCLIE2ETests/DSCv3PackageResourceCommand.cs
+++ b/src/AppInstallerCLIE2ETests/DSCv3PackageResourceCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -72,9 +72,9 @@ public void Package_Get_NotPresent()
AssertSuccessfulResourceRun(ref result);
PackageResourceData output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(packageResourceData.Identifier, output.Identifier);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Identifier, Is.EqualTo(packageResourceData.Identifier));
}
///
@@ -89,9 +89,9 @@ public void Package_Get_UnknownIdentifier()
AssertSuccessfulResourceRun(ref result);
PackageResourceData output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(packageResourceData.Identifier, output.Identifier);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Identifier, Is.EqualTo(packageResourceData.Identifier));
}
///
@@ -101,7 +101,7 @@ public void Package_Get_UnknownIdentifier()
public void Package_Get_Present()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData() { Identifier = DefaultPackageIdentifier };
@@ -119,7 +119,7 @@ public void Package_Get_Present()
public void Package_Get_MuchInput()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -147,10 +147,10 @@ public void Package_Test_NotPresent()
AssertSuccessfulResourceRun(ref result);
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(packageResourceData.Identifier, output.Identifier);
- Assert.False(output.InDesiredState);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Identifier, Is.EqualTo(packageResourceData.Identifier));
+ Assert.That(output.InDesiredState, Is.False);
AssertDiffState(diff, [ ExistPropertyName ]);
}
@@ -162,7 +162,7 @@ public void Package_Test_NotPresent()
public void Package_Test_SimplePresent()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData() { Identifier = DefaultPackageIdentifier };
@@ -171,7 +171,7 @@ public void Package_Test_SimplePresent()
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingPackageResourceData(output, DefaultPackageLowVersion);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -183,7 +183,7 @@ public void Package_Test_SimplePresent()
public void Package_Test_VersionMatch()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -196,7 +196,7 @@ public void Package_Test_VersionMatch()
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingPackageResourceData(output, DefaultPackageLowVersion);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -208,7 +208,7 @@ public void Package_Test_VersionMatch()
public void Package_Test_VersionMismatch()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -221,7 +221,7 @@ public void Package_Test_VersionMismatch()
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingPackageResourceData(output, DefaultPackageLowVersion);
- Assert.False(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.False);
AssertDiffState(diff, [ VersionPropertyName ]);
}
@@ -233,7 +233,7 @@ public void Package_Test_VersionMismatch()
public void Package_Test_Latest()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -246,7 +246,7 @@ public void Package_Test_Latest()
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingPackageResourceData(output, DefaultPackageHighVersion);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -258,7 +258,7 @@ public void Package_Test_Latest()
public void Package_Test_NotLatest()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageMidVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -271,7 +271,7 @@ public void Package_Test_NotLatest()
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingPackageResourceData(output, DefaultPackageMidVersion);
- Assert.False(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.False);
AssertDiffState(diff, [ UseLatestPropertyName ]);
}
@@ -323,8 +323,8 @@ public void Package_Set_SilentInstallMode_UsesSilentAndCustomSwitches()
var result = RunDSCv3Command(PackageResource, SetFunction, packageResourceData, environmentVariables: environmentVariables);
AssertSuccessfulResourceRun(ref result);
- Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "/execustom"));
- Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "/exesilent"));
+ Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "/execustom"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "/exesilent"), Is.True);
TestCommon.BestEffortTestExeCleanup(installDir);
}
@@ -346,8 +346,8 @@ public void Package_Set_InteractiveInstallMode_UsesInteractiveAndCustomSwitches(
var result = RunDSCv3Command(PackageResource, SetFunction, packageResourceData, environmentVariables: environmentVariables);
AssertSuccessfulResourceRun(ref result);
- Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "/execustom"));
- Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "/exeinteractive"));
+ Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "/execustom"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "/exeinteractive"), Is.True);
TestCommon.BestEffortTestExeCleanup(installDir);
}
@@ -358,7 +358,7 @@ public void Package_Set_InteractiveInstallMode_UsesInteractiveAndCustomSwitches(
public void Package_Set_Remove()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -370,9 +370,9 @@ public void Package_Set_Remove()
AssertSuccessfulResourceRun(ref result);
(PackageResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(packageResourceData.Identifier, output.Identifier);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Identifier, Is.EqualTo(packageResourceData.Identifier));
AssertDiffState(diff, [ ExistPropertyName ]);
@@ -386,9 +386,9 @@ public void Package_Set_Remove()
AssertSuccessfulResourceRun(ref result);
output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(packageResourceDataForGet.Identifier, output.Identifier);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Identifier, Is.EqualTo(packageResourceDataForGet.Identifier));
}
///
@@ -398,7 +398,7 @@ public void Package_Set_Remove()
public void Package_Set_Latest()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageMidVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -434,7 +434,7 @@ public void Package_Set_Latest()
public void Package_Set_SpecificVersionUpgrade()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -470,7 +470,7 @@ public void Package_Set_SpecificVersionUpgrade()
public void Package_Set_SpecificVersionDowngrade()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -506,7 +506,7 @@ public void Package_Set_SpecificVersionDowngrade()
public void Package_Export_NoInput()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
var result = RunDSCv3Command(PackageResource, ExportFunction, " ");
AssertSuccessfulResourceRun(ref result);
@@ -519,12 +519,12 @@ public void Package_Export_NoInput()
if (item.Identifier == DefaultPackageIdentifier)
{
foundDefaultPackage = true;
- Assert.IsNull(item.Version);
+ Assert.That(item.Version, Is.Null);
break;
}
}
- Assert.IsTrue(foundDefaultPackage);
+ Assert.That(foundDefaultPackage, Is.True);
}
///
@@ -534,7 +534,7 @@ public void Package_Export_NoInput()
public void Package_Export_RequestVersions()
{
var setupInstall = TestCommon.RunAICLICommand("install", $"--id {DefaultPackageIdentifier} --version {DefaultPackageLowVersion}");
- Assert.AreEqual(0, setupInstall.ExitCode);
+ Assert.That(setupInstall.ExitCode, Is.EqualTo(0));
PackageResourceData packageResourceData = new PackageResourceData()
{
@@ -552,16 +552,16 @@ public void Package_Export_RequestVersions()
if (item.Identifier == DefaultPackageIdentifier)
{
foundDefaultPackage = true;
- Assert.AreEqual(DefaultPackageLowVersion, item.Version);
+ Assert.That(item.Version, Is.EqualTo(DefaultPackageLowVersion));
}
else
{
- Assert.IsNotNull(item.Version);
- Assert.IsNotEmpty(item.Version);
+ Assert.That(item.Version, Is.Not.Null);
+ Assert.That(item.Version, Is.Not.Empty);
}
}
- Assert.IsTrue(foundDefaultPackage);
+ Assert.That(foundDefaultPackage, Is.True);
}
private static void RemoveTestPackage()
@@ -578,20 +578,20 @@ private static void RemoveTestPackage()
private static void AssertExistingPackageResourceData(PackageResourceData output, string version, bool ignoreLatest = false)
{
- Assert.IsNotNull(output);
- Assert.True(output.Exist);
- Assert.AreEqual(DefaultPackageIdentifier, output.Identifier);
- Assert.AreEqual(version, output.Version);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.True);
+ Assert.That(output.Identifier, Is.EqualTo(DefaultPackageIdentifier));
+ Assert.That(output.Version, Is.EqualTo(version));
if (!ignoreLatest)
{
if (version == DefaultPackageHighVersion)
{
- Assert.True(output.UseLatest);
+ Assert.That(output.UseLatest, Is.True);
}
else
{
- Assert.False(output.UseLatest);
+ Assert.That(output.UseLatest, Is.False);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/DSCv3ResourceTestBase.cs b/src/AppInstallerCLIE2ETests/DSCv3ResourceTestBase.cs
index 24786e006c..00db0accb6 100644
--- a/src/AppInstallerCLIE2ETests/DSCv3ResourceTestBase.cs
+++ b/src/AppInstallerCLIE2ETests/DSCv3ResourceTestBase.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -55,10 +55,10 @@ public class DSCv3ResourceTestBase
public static void EnsureTestResourcePresence()
{
string outputDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\WindowsApps");
- Assert.IsNotEmpty(outputDirectory);
+ Assert.That(outputDirectory, Is.Not.Empty);
var result = TestCommon.RunAICLICommand($"dscv3", $"--manifest -o {outputDirectory}");
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
}
///
@@ -88,8 +88,8 @@ protected static TestCommon.RunCommandResult RunDSCv3Command(
/// The result of a DSC v3 resource command run.
protected static void AssertSuccessfulResourceRun(ref TestCommon.RunCommandResult result)
{
- Assert.AreEqual(0, result.ExitCode);
- Assert.IsNotEmpty(result.StdOut);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
+ Assert.That(result.StdOut, Is.Not.Empty);
}
///
@@ -111,7 +111,7 @@ protected static string[] GetOutputLines(string output)
protected static T GetSingleOutputLineAs(string output)
{
string[] lines = GetOutputLines(output);
- Assert.AreEqual(1, lines.Length);
+ Assert.That(lines.Length, Is.EqualTo(1));
return JsonSerializer.Deserialize(lines[0], GetDefaultJsonOptions());
}
@@ -125,7 +125,7 @@ protected static T GetSingleOutputLineAs(string output)
protected static (T, List) GetSingleOutputLineAndDiffAs(string output)
{
string[] lines = GetOutputLines(output);
- Assert.AreEqual(2, lines.Length);
+ Assert.That(lines.Length, Is.EqualTo(2));
var options = GetDefaultJsonOptions();
return (JsonSerializer.Deserialize(lines[0], options), JsonSerializer.Deserialize>(lines[1], options));
@@ -158,12 +158,12 @@ protected static List GetOutputLinesAs(string output)
/// The expected strings.
protected static void AssertDiffState(List diff, IList expected)
{
- Assert.IsNotNull(diff);
- Assert.AreEqual(expected.Count, diff.Count);
+ Assert.That(diff, Is.Not.Null);
+ Assert.That(diff.Count, Is.EqualTo(expected.Count));
foreach (string item in expected)
{
- Assert.Contains(item, diff);
+ Assert.That(diff, Has.Member(item));
}
}
diff --git a/src/AppInstallerCLIE2ETests/DSCv3SourceResourceCommand.cs b/src/AppInstallerCLIE2ETests/DSCv3SourceResourceCommand.cs
index 51222af39e..26533f11d0 100644
--- a/src/AppInstallerCLIE2ETests/DSCv3SourceResourceCommand.cs
+++ b/src/AppInstallerCLIE2ETests/DSCv3SourceResourceCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -93,9 +93,9 @@ public void Source_Get_NotPresent()
AssertSuccessfulResourceRun(ref result);
SourceResourceData output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(resourceData.Name, output.Name);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Name, Is.EqualTo(resourceData.Name));
}
///
@@ -105,7 +105,7 @@ public void Source_Get_NotPresent()
public void Source_Get_Present()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType} --explicit");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData() { Name = DefaultSourceName };
@@ -128,10 +128,10 @@ public void Source_Test_NotPresent()
AssertSuccessfulResourceRun(ref result);
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(resourceData.Name, output.Name);
- Assert.False(output.InDesiredState);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Name, Is.EqualTo(resourceData.Name));
+ Assert.That(output.InDesiredState, Is.False);
AssertDiffState(diff, [ ExistPropertyName ]);
}
@@ -143,7 +143,7 @@ public void Source_Test_NotPresent()
public void Source_Test_SimplePresent()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData() { Name = DefaultSourceName };
@@ -152,7 +152,7 @@ public void Source_Test_SimplePresent()
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingSourceResourceData(output, DefaultSourceArgDirect, DefaultTrustLevel, DefaultExplicitState);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -173,7 +173,7 @@ public void Source_Test_SimplePresent()
public void Source_Test_PropertyMatch(bool useDefaultArgument, string trustLevel, bool isExplicit, int priority, string targetProperty)
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {(useDefaultArgument ? DefaultSourceArgForCmdLine : NonDefaultSourceArgForCmdLine)} --type {DefaultSourceType} --trust-level {trustLevel} {(isExplicit ? "--explicit" : string.Empty)} --priority {priority}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData() { Name = DefaultSourceName };
@@ -195,7 +195,7 @@ public void Source_Test_PropertyMatch(bool useDefaultArgument, string trustLevel
resourceData.Priority = priority;
break;
default:
- Assert.Fail($"{targetProperty} is not a handled case.");
+ Assert.That(false, Is.True, $"{targetProperty} is not a handled case.");
break;
}
@@ -204,7 +204,7 @@ public void Source_Test_PropertyMatch(bool useDefaultArgument, string trustLevel
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingSourceResourceData(output, useDefaultArgument ? DefaultSourceArgDirect : NonDefaultSourceArgDirect, trustLevel, isExplicit);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -225,7 +225,7 @@ public void Source_Test_PropertyMatch(bool useDefaultArgument, string trustLevel
public void Source_Test_PropertyMismatch(bool useDefaultArgument, string trustLevel, bool isExplicit, int priority, string targetProperty, object testValue)
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {(useDefaultArgument ? DefaultSourceArgForCmdLine : NonDefaultSourceArgForCmdLine)} --type {DefaultSourceType} --trust-level {trustLevel} {(isExplicit ? "--explicit" : string.Empty)} --priority {priority}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData() { Name = DefaultSourceName };
@@ -244,7 +244,7 @@ public void Source_Test_PropertyMismatch(bool useDefaultArgument, string trustLe
resourceData.Priority = (int)testValue;
break;
default:
- Assert.Fail($"{targetProperty} is not a handled case.");
+ Assert.That(false, Is.True, $"{targetProperty} is not a handled case.");
break;
}
@@ -253,7 +253,7 @@ public void Source_Test_PropertyMismatch(bool useDefaultArgument, string trustLe
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingSourceResourceData(output, useDefaultArgument ? DefaultSourceArgDirect : NonDefaultSourceArgDirect, trustLevel, isExplicit);
- Assert.False(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.False);
AssertDiffState(diff, [ targetProperty ]);
}
@@ -265,7 +265,7 @@ public void Source_Test_PropertyMismatch(bool useDefaultArgument, string trustLe
public void Source_Test_AllMatch()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {NonDefaultSourceArgForCmdLine} --type {DefaultSourceType} --trust-level {TrustedTrustLevel} --explicit --priority 42");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData()
{
@@ -282,7 +282,7 @@ public void Source_Test_AllMatch()
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
AssertExistingSourceResourceData(output, resourceData);
- Assert.True(output.InDesiredState);
+ Assert.That(output.InDesiredState, Is.True);
AssertDiffState(diff, []);
}
@@ -325,7 +325,7 @@ public void Source_Set_SimpleRepeated()
public void Source_Set_Remove()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType} --explicit");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData()
{
@@ -337,9 +337,9 @@ public void Source_Set_Remove()
AssertSuccessfulResourceRun(ref result);
(SourceResourceData output, List diff) = GetSingleOutputLineAndDiffAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(resourceData.Name, output.Name);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Name, Is.EqualTo(resourceData.Name));
AssertDiffState(diff, [ ExistPropertyName ]);
@@ -353,9 +353,9 @@ public void Source_Set_Remove()
AssertSuccessfulResourceRun(ref result);
output = GetSingleOutputLineAs(result.StdOut);
- Assert.IsNotNull(output);
- Assert.False(output.Exist);
- Assert.AreEqual(resourceDataForGet.Name, output.Name);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.False);
+ Assert.That(output.Name, Is.EqualTo(resourceDataForGet.Name));
}
///
@@ -365,7 +365,7 @@ public void Source_Set_Remove()
public void Source_Set_Replace()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData()
{
@@ -404,7 +404,7 @@ public void Source_Set_Replace()
public void Source_Set_Replace_Edit()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
SourceResourceData resourceData = new SourceResourceData()
{
@@ -441,7 +441,7 @@ public void Source_Set_Replace_Edit()
public void Source_Export_NoInput()
{
var setup = TestCommon.RunAICLICommand("source add", $"--name {DefaultSourceName} --arg {DefaultSourceArgForCmdLine} --type {DefaultSourceType}");
- Assert.AreEqual(0, setup.ExitCode);
+ Assert.That(setup.ExitCode, Is.EqualTo(0));
var result = RunDSCv3Command(SourceResource, ExportFunction, " ");
AssertSuccessfulResourceRun(ref result);
@@ -454,17 +454,17 @@ public void Source_Export_NoInput()
if (item.Name == DefaultSourceName)
{
foundDefaultSource = true;
- Assert.AreEqual(DefaultSourceName, item.Name);
- Assert.AreEqual(DefaultSourceArgDirect, item.Argument);
- Assert.AreEqual(DefaultSourceType, item.Type);
- Assert.AreEqual(DefaultTrustLevel, item.TrustLevel);
- Assert.AreEqual(DefaultExplicitState, item.Explicit);
- Assert.AreEqual(DefaultPriority, item.Priority);
+ Assert.That(item.Name, Is.EqualTo(DefaultSourceName));
+ Assert.That(item.Argument, Is.EqualTo(DefaultSourceArgDirect));
+ Assert.That(item.Type, Is.EqualTo(DefaultSourceType));
+ Assert.That(item.TrustLevel, Is.EqualTo(DefaultTrustLevel));
+ Assert.That(item.Explicit, Is.EqualTo(DefaultExplicitState));
+ Assert.That(item.Priority, Is.EqualTo(DefaultPriority));
break;
}
}
- Assert.IsTrue(foundDefaultSource);
+ Assert.That(foundDefaultSource, Is.True);
}
private static void RemoveTestSource()
@@ -486,30 +486,30 @@ private static void AssertExistingSourceResourceData(SourceResourceData output,
private static void AssertExistingSourceResourceData(SourceResourceData output, string argument, string trustLevel = null, bool? isExplicit = null, int? priority = null)
{
- Assert.IsNotNull(output);
- Assert.True(output.Exist);
- Assert.AreEqual(DefaultSourceName, output.Name);
+ Assert.That(output, Is.Not.Null);
+ Assert.That(output.Exist, Is.True);
+ Assert.That(output.Name, Is.EqualTo(DefaultSourceName));
if (argument != null)
{
- Assert.AreEqual(argument, output.Argument);
+ Assert.That(output.Argument, Is.EqualTo(argument));
}
- Assert.AreEqual(DefaultSourceType, output.Type);
+ Assert.That(output.Type, Is.EqualTo(DefaultSourceType));
if (trustLevel != null)
{
- Assert.AreEqual(trustLevel, output.TrustLevel);
+ Assert.That(output.TrustLevel, Is.EqualTo(trustLevel));
}
if (isExplicit != null)
{
- Assert.AreEqual(isExplicit, output.Explicit);
+ Assert.That(output.Explicit, Is.EqualTo(isExplicit));
}
if (priority != null)
{
- Assert.AreEqual(priority, output.Priority);
+ Assert.That(output.Priority, Is.EqualTo(priority));
}
}
diff --git a/src/AppInstallerCLIE2ETests/DSCv3UserSettingsFileResourceCommand.cs b/src/AppInstallerCLIE2ETests/DSCv3UserSettingsFileResourceCommand.cs
index 178a70aeed..9071ae74f7 100644
--- a/src/AppInstallerCLIE2ETests/DSCv3UserSettingsFileResourceCommand.cs
+++ b/src/AppInstallerCLIE2ETests/DSCv3UserSettingsFileResourceCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -67,8 +67,8 @@ public void UserSettingsFile_Get()
var expected = GetCurrentUserSettings();
var getOutput = Get(new ());
- Assert.IsNotNull(getOutput);
- Assert.IsNull(getOutput.Action);
+ Assert.That(getOutput, Is.Not.Null);
+ Assert.That(getOutput.Action, Is.Null);
AssertSettingsAreEqual(expected, getOutput.Settings);
}
@@ -87,8 +87,8 @@ public void UserSettingsFile_Set_NoDiff(string action)
var expected = GetCurrentUserSettings();
- Assert.IsNotNull(setOutput);
- Assert.AreEqual(action, setOutput.Action);
+ Assert.That(setOutput, Is.Not.Null);
+ Assert.That(setOutput.Action, Is.EqualTo(action));
AssertSettingsAreEqual(expected, setOutput.Settings);
AssertDiffState(setDiff, []);
}
@@ -111,8 +111,8 @@ public void UserSettingsFile_Set_AddFields(string action)
var expected = GetCurrentUserSettings();
// Assert that the settings are added
- Assert.IsNotNull(setOutput);
- Assert.AreEqual(action, setOutput.Action);
+ Assert.That(setOutput, Is.Not.Null);
+ Assert.That(setOutput.Action, Is.EqualTo(action));
AssertMockProperties(setOutput.Settings, "mock");
AssertSettingsAreEqual(expected, setOutput.Settings);
AssertDiffState(setDiff, [ SettingsPropertyName ]);
@@ -134,8 +134,8 @@ public void UserSettingsFile_Set_ActionIsPartialByDefault()
(var setOutput, var setDiff) = Set(new () { Settings = setSettings });
// Assert that the settings are added
- Assert.IsNotNull(setOutput);
- Assert.AreEqual(setOutput.Action, ActionPropertyValuePartial);
+ Assert.That(setOutput, Is.Not.Null);
+ Assert.That(ActionPropertyValuePartial, Is.EqualTo(setOutput.Action));
AssertMockProperties(setOutput.Settings, "mock");
AssertSettingsAreEqual(expected, setOutput.Settings);
AssertDiffState(setDiff, [ SettingsPropertyName ]);
@@ -164,8 +164,8 @@ public void UserSettingsFile_Set_UpdateFields(string action)
var expected = GetCurrentUserSettings();
// Assert that the settings are updated
- Assert.IsNotNull(setOutput);
- Assert.AreEqual(action, setOutput.Action);
+ Assert.That(setOutput, Is.Not.Null);
+ Assert.That(setOutput.Action, Is.EqualTo(action));
AssertMockProperties(setOutput.Settings, "mock_new");
AssertSettingsAreEqual(expected, setOutput.Settings);
AssertDiffState(setDiff, [ SettingsPropertyName ]);
@@ -194,11 +194,11 @@ public void UserSettingsFile_Test_InDesiredState(string action)
var expected = GetCurrentUserSettings();
// Assert that the settings are in desired state
- Assert.IsNotNull(testOutput);
- Assert.AreEqual(action, testOutput.Action);
+ Assert.That(testOutput, Is.Not.Null);
+ Assert.That(testOutput.Action, Is.EqualTo(action));
AssertMockProperties(testOutput.Settings, "mock");
AssertSettingsAreEqual(expected, testOutput.Settings);
- Assert.IsTrue(testOutput.InDesiredState);
+ Assert.That(testOutput.InDesiredState, Is.True);
AssertDiffState(testDiff, []);
}
@@ -225,11 +225,11 @@ public void UserSettingsFile_Test_NotInDesiredState(string action)
var expected = GetCurrentUserSettings();
// Assert that the settings are not in desired state
- Assert.IsNotNull(testOutput);
- Assert.AreEqual(action, testOutput.Action);
+ Assert.That(testOutput, Is.Not.Null);
+ Assert.That(testOutput.Action, Is.EqualTo(action));
AssertMockProperties(testOutput.Settings, "mock_set");
AssertSettingsAreEqual(expected, testOutput.Settings);
- Assert.IsFalse(testOutput.InDesiredState);
+ Assert.That(testOutput.InDesiredState, Is.False);
AssertDiffState(testDiff, [ SettingsPropertyName ]);
}
@@ -242,8 +242,8 @@ public void UserSettingsFile_Export()
var expected = GetCurrentUserSettings();
var exportOutput = Export(new ());
- Assert.IsNotNull(exportOutput);
- Assert.IsNull(exportOutput.Action);
+ Assert.That(exportOutput, Is.Not.Null);
+ Assert.That(exportOutput.Action, Is.Null);
AssertSettingsAreEqual(expected, exportOutput.Settings);
}
@@ -324,12 +324,12 @@ private static void AddOrModifyMockProperties(JsonObject settings, string value)
/// The expected mock value.
private static void AssertMockProperties(JsonObject settings, string value)
{
- Assert.IsNotNull(settings);
- Assert.IsTrue(settings.ContainsKey(SettingsMock));
- Assert.AreEqual(settings[SettingsMock].ToString(), value);
- Assert.IsTrue(settings.ContainsKey(SettingsMockObject));
- Assert.IsTrue(settings[SettingsMockObject].AsObject().ContainsKey(SettingsMockNested));
- Assert.AreEqual(settings[SettingsMockObject][SettingsMockNested].ToString(), value);
+ Assert.That(settings, Is.Not.Null);
+ Assert.That(settings.ContainsKey(SettingsMock), Is.True);
+ Assert.That(value, Is.EqualTo(settings[SettingsMock].ToString()));
+ Assert.That(settings.ContainsKey(SettingsMockObject), Is.True);
+ Assert.That(settings[SettingsMockObject].AsObject().ContainsKey(SettingsMockNested), Is.True);
+ Assert.That(value, Is.EqualTo(settings[SettingsMockObject][SettingsMockNested].ToString()));
}
///
@@ -339,7 +339,7 @@ private static void AssertMockProperties(JsonObject settings, string value)
/// The actual settings.
private static void AssertSettingsAreEqual(JsonObject expected, JsonObject actual)
{
- Assert.IsTrue(JsonNode.DeepEquals(expected, actual));
+ Assert.That(JsonNode.DeepEquals(expected, actual), Is.True);
}
///
diff --git a/src/AppInstallerCLIE2ETests/DownloadCommand.cs b/src/AppInstallerCLIE2ETests/DownloadCommand.cs
index f6c10373e0..692fad5813 100644
--- a/src/AppInstallerCLIE2ETests/DownloadCommand.cs
+++ b/src/AppInstallerCLIE2ETests/DownloadCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -25,7 +25,7 @@ public void DownloadDependencies()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.PackageDependency --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
var dependenciesDir = Path.Combine(downloadDir, Constants.Dependencies);
TestCommon.AssertInstallerDownload(dependenciesDir, "TestPortableExe", "3.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Portable, "en-US");
TestCommon.AssertInstallerDownload(downloadDir, "TestPackageDependency", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "en-US");
@@ -39,9 +39,9 @@ public void DownloadDependencies_Skip()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.PackageDependency --skip-dependencies --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Dependencies skipped."));
- Assert.IsFalse(Directory.Exists(Path.Combine(downloadDir, Constants.Dependencies)));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Dependencies skipped."), Is.True);
+ Assert.That(Directory.Exists(Path.Combine(downloadDir, Constants.Dependencies)), Is.False);
TestCommon.AssertInstallerDownload(downloadDir, "TestPackageDependency", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "en-US");
}
@@ -53,7 +53,7 @@ public void DownloadToDefaultDirectory()
{
var packageVersion = "2.0.0.0";
var result = TestCommon.RunAICLICommand("download", $"{Constants.ExeInstallerPackageId} --version {packageVersion}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
string downloadDir = Path.Combine(TestCommon.GetDefaultDownloadDirectory(), $"{Constants.ExeInstallerPackageId}_{packageVersion}");
TestCommon.AssertInstallerDownload(downloadDir, "TestExeInstaller", packageVersion, ProcessorArchitecture.X86, TestCommon.Scope.User, PackageInstallerType.Exe);
}
@@ -66,7 +66,7 @@ public void DownloadToDirectory()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"{Constants.ExeInstallerPackageId} --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestExeInstaller", "2.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.User, PackageInstallerType.Exe);
}
@@ -78,7 +78,7 @@ public void DownloadWithArm64()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --scope user --download-directory {downloadDir} --architecture Arm64");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
#pragma warning disable CA1416 // Validate platform compatibility. Arm64 is not reachable.
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.Arm64, TestCommon.Scope.User, PackageInstallerType.Nullsoft, "en-US");
#pragma warning restore CA1416
@@ -92,7 +92,7 @@ public void DownloadWithUserScope()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --scope user --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.User, PackageInstallerType.Nullsoft, "en-US");
}
@@ -104,7 +104,7 @@ public void DownloadWithMachineScope()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --scope machine --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -116,7 +116,7 @@ public void DownloadWithZipInstallerTypeArg()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --installer-type zip --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "zh-CN", true);
}
@@ -128,7 +128,7 @@ public void DownloadWithInstallerTypeArg()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --installer-type msi --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -140,7 +140,7 @@ public void DownloadWithArchitectureArg()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --architecture x86 --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -152,7 +152,7 @@ public void DownloadWithLocaleArg()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestMultipleInstallers --locale zh-CN --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "zh-CN", true);
}
@@ -164,7 +164,7 @@ public void DownloadWithHashMismatch()
{
var downloadDir = TestCommon.GetRandomTestDir();
var errorResult = TestCommon.RunAICLICommand("download", $"AppInstallerTest.TestExeSha256Mismatch --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH, errorResult.ExitCode);
+ Assert.That(errorResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH));
}
///
@@ -175,7 +175,7 @@ public void DownloadZeroByteFileWithHashMismatch()
{
var downloadDir = TestCommon.GetRandomTestDir();
var errorResult = TestCommon.RunAICLICommand("download", $"ZeroByteFile.IncorrectHash --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALLER_ZERO_BYTE_FILE, errorResult.ExitCode);
+ Assert.That(errorResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALLER_ZERO_BYTE_FILE));
}
///
@@ -186,7 +186,7 @@ public void DownloadZeroByteFile()
{
var downloadDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("download", $"ZeroByteFile.CorrectHash --download-directory {downloadDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.AssertInstallerDownload(downloadDir, "ZeroByteFile-CorrectHash", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "en-US");
}
}
diff --git a/src/AppInstallerCLIE2ETests/ErrorCommand.cs b/src/AppInstallerCLIE2ETests/ErrorCommand.cs
index a2504bbb63..f873129c9e 100644
--- a/src/AppInstallerCLIE2ETests/ErrorCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ErrorCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -30,8 +30,8 @@ public void OneTimeSetup()
public void Success()
{
var result = TestCommon.RunAICLICommand("error", "0");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("0x00000000"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x00000000"), Is.True);
}
///
@@ -41,9 +41,9 @@ public void Success()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a15c001"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"), Is.True);
}
///
@@ -53,8 +53,8 @@ public void HexError()
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."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.E_INVALIDARG));
+ Assert.That(result.StdOut.Contains("The given number is too large to be an HRESULT."), Is.True);
}
///
@@ -64,9 +64,9 @@ public void HexErrorTooBig()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a15c001"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"), Is.True);
}
///
@@ -76,9 +76,9 @@ public void DecimalError()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a150029"), Is.True);
+ Assert.That(result.StdOut.Contains("APPINSTALLER_CLI_ERROR_MANIFEST_VALIDATION_FAILURE"), Is.True);
}
///
@@ -88,9 +88,9 @@ public void NegativeDecimalError()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a15c000"), Is.True);
+ Assert.That(result.StdOut.Contains("Unknown error code"), Is.True);
}
///
@@ -100,9 +100,9 @@ public void HexErrorNotFound()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x0a150202"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_INSTALLED_STATUS_INSTALL_LOCATION_NOT_APPLICABLE"), Is.True);
}
///
@@ -112,10 +112,10 @@ public void NonError()
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);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a15c001"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"), Is.True);
+ Assert.That(result.StdOut.Split('\n', System.StringSplitOptions.RemoveEmptyEntries).Length, Is.EqualTo(2));
}
///
@@ -125,15 +125,15 @@ public void Symbol()
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"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("0x8a15c001"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_CONFIG_ERROR_INVALID_CONFIGURATION_FILE"), Is.True);
+ Assert.That(result.StdOut.Contains("0x8a15c110"), Is.True);
+ Assert.That(result.StdOut.Contains("WINGET_CONFIG_ERROR_UNIT_SETTING_CONFIG_ROOT"), Is.True);
// This contains config in it's message.
- Assert.True(result.StdOut.Contains("0x8a150038"));
- Assert.True(result.StdOut.Contains("APPINSTALLER_CLI_ERROR_UNSUPPORTED_RESTSOURCE"));
+ Assert.That(result.StdOut.Contains("0x8a150038"), Is.True);
+ Assert.That(result.StdOut.Contains("APPINSTALLER_CLI_ERROR_UNSUPPORTED_RESTSOURCE"), Is.True);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/FeaturesCommand.cs b/src/AppInstallerCLIE2ETests/FeaturesCommand.cs
index f8cf49c344..b33f4affe9 100644
--- a/src/AppInstallerCLIE2ETests/FeaturesCommand.cs
+++ b/src/AppInstallerCLIE2ETests/FeaturesCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -39,8 +39,8 @@ public void TearDown()
public void DisplayFeatures()
{
var result = TestCommon.RunAICLICommand("features", string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Direct MSI Installation"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Direct MSI Installation"), Is.True);
}
///
@@ -55,7 +55,7 @@ public void EnableExperimentalFeatures()
WinGetSettingsHelper.ConfigureFeature("resume", true);
WinGetSettingsHelper.ConfigureFeature("fonts", true);
var result = TestCommon.RunAICLICommand("features", string.Empty);
- Assert.True(result.StdOut.Contains("Enabled"));
+ Assert.That(result.StdOut.Contains("Enabled"), Is.True);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/FontCommand.cs b/src/AppInstallerCLIE2ETests/FontCommand.cs
index 11e68bad55..2d376ff8dd 100644
--- a/src/AppInstallerCLIE2ETests/FontCommand.cs
+++ b/src/AppInstallerCLIE2ETests/FontCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -32,12 +32,12 @@ public void InstallFont_UserScope()
var fontPackageName = "AppInstallerTest.TestFont";
var fontPackageVersion = "1.0.0.0";
var installResult = TestCommon.RunAICLICommand("install", fontPackageName);
- Assert.AreEqual(Constants.ErrorCode.S_OK, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("Successfully installed"));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installResult.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyFontPackage(fontPackageName, fontPackageVersion, TestCommon.Scope.User);
var uninstallResult = TestCommon.RunAICLICommand("uninstall", fontPackageName);
- Assert.AreEqual(Constants.ErrorCode.S_OK, uninstallResult.ExitCode);
+ Assert.That(uninstallResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.VerifyFontPackage(fontPackageName, fontPackageVersion, TestCommon.Scope.User, false);
}
@@ -50,12 +50,12 @@ public void InstallFont_MachineScope()
var fontPackageName = "AppInstallerTest.TestFont";
var fontPackageVersion = "1.0.0.0";
var result = TestCommon.RunAICLICommand("install", $"{fontPackageName} --scope Machine");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyFontPackage(fontPackageName, fontPackageVersion, TestCommon.Scope.Machine);
var uninstallResult = TestCommon.RunAICLICommand("uninstall", fontPackageName);
- Assert.AreEqual(Constants.ErrorCode.S_OK, uninstallResult.ExitCode);
+ Assert.That(uninstallResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
TestCommon.VerifyFontPackage(fontPackageName, fontPackageVersion, TestCommon.Scope.Machine, false);
}
@@ -66,8 +66,8 @@ public void InstallFont_MachineScope()
public void InstallInvalidFont()
{
var result = TestCommon.RunAICLICommand("install", "AppInstallerTest.TestInvalidFont");
- Assert.AreEqual(Constants.ErrorCode.ERROR_FONT_FILE_NOT_SUPPORTED, result.ExitCode);
- Assert.True(result.StdOut.Contains("One or more fonts in the font package is not supported and cannot be installed."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_FONT_FILE_NOT_SUPPORTED));
+ Assert.That(result.StdOut.Contains("One or more fonts in the font package is not supported and cannot be installed."), Is.True);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/GroupPolicy.cs b/src/AppInstallerCLIE2ETests/GroupPolicy.cs
index 1f2b874306..b29c798abe 100644
--- a/src/AppInstallerCLIE2ETests/GroupPolicy.cs
+++ b/src/AppInstallerCLIE2ETests/GroupPolicy.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -43,29 +43,29 @@ public void PolicyEnableWinget()
{
GroupPolicyHelper.EnableWinget.Disable();
var result = TestCommon.RunAICLICommand("search", "foo");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
// Scenario if Policy WinGet is disabled but Policy EnableWindowsPackageManagerCommandLineInterfaces is Enabled.
GroupPolicyHelper.EnableWinGetCommandLineInterfaces.Enable();
result = TestCommon.RunAICLICommand("search", "foo");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
// Scenario if Policy WinGet is disabled but Policy EnableWindowsPackageManagerCommandLineInterfaces is Not-Configured.
GroupPolicyHelper.EnableWinGetCommandLineInterfaces.SetNotConfigured();
result = TestCommon.RunAICLICommand("search", "foo");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
// Scenario if Policy WinGet is enabled but Policy EnableWindowsPackageManagerCommandLineInterfaces is disabled.
GroupPolicyHelper.EnableWinget.Enable();
GroupPolicyHelper.EnableWinGetCommandLineInterfaces.Disable();
result = TestCommon.RunAICLICommand("search", "foo");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
// Scenario if Policy WinGet is Not-Configured but Policy EnableWindowsPackageManagerCommandLineInterfaces is disabled.
GroupPolicyHelper.EnableWinget.SetNotConfigured();
GroupPolicyHelper.EnableWinGetCommandLineInterfaces.Disable();
result = TestCommon.RunAICLICommand("search", "foo");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -76,7 +76,7 @@ public void EnableSettings()
{
GroupPolicyHelper.EnableSettings.Disable();
var result = TestCommon.RunAICLICommand("settings", string.Empty);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -87,13 +87,13 @@ public void EnableExperimentalFeatures()
{
WinGetSettingsHelper.ConfigureFeature("experimentalCmd", true);
var result = TestCommon.RunAICLICommand("experimental", string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
// An experimental feature disabled by Group Policy behaves the same as one that is not enabled.
// The expected result is a command line error as the argument validation rejects this.
GroupPolicyHelper.EnableExperimentalFeatures.Disable();
result = TestCommon.RunAICLICommand("experimental", string.Empty);
- Assert.AreEqual(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS));
}
///
@@ -104,7 +104,7 @@ public void EnableLocalManifests()
{
GroupPolicyHelper.EnableLocalManifests.Disable();
var result = TestCommon.RunAICLICommand("install", $"-m {TestCommon.GetTestDataFile(@"Manifests\TestExeInstaller.yaml")}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -115,7 +115,7 @@ public void EnableHashOverride()
{
GroupPolicyHelper.EnableHashOverride.Disable();
var result = TestCommon.RunAICLICommand("install", "AnyPackage --ignore-security-hash");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -127,7 +127,7 @@ public void EnableIgnoreLocalArchiveMalwareScanOverride()
GroupPolicyHelper.EnableLocalArchiveMalwareScanOverride.Disable();
var result = TestCommon.RunAICLICommand("install", "AnyPackage --ignore-local-archive-malware-scan");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -138,11 +138,11 @@ public void EnableDefaultSource()
{
// Default sources are disabled during setup so they are missing.
var result = TestCommon.RunAICLICommand("source list", "winget");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
GroupPolicyHelper.EnableDefaultSource.Enable();
result = TestCommon.RunAICLICommand("source list", "winget");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
///
@@ -153,11 +153,11 @@ public void EnableMicrosoftStoreSource()
{
// Default sources are disabled during setup so they are missing.
var result = TestCommon.RunAICLICommand("source list", "msstore");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
GroupPolicyHelper.EnableMicrosoftStoreSource.Enable();
result = TestCommon.RunAICLICommand("source list", "msstore");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
///
@@ -168,11 +168,11 @@ public void EnableFontSource()
{
GroupPolicyHelper.EnableFontSource.Disable();
var result = TestCommon.RunAICLICommand("source list", "winget-font");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
GroupPolicyHelper.EnableFontSource.Enable();
result = TestCommon.RunAICLICommand("source list", "winget-font");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
///
@@ -184,7 +184,7 @@ public void EnableAdditionalSources()
// Remove the test source, then add it with policy.
TestCommon.RunAICLICommand("source remove", "TestSource");
var result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
GroupPolicyHelper.EnableAdditionalSources.SetEnabledList(new string[]
{
@@ -192,7 +192,7 @@ public void EnableAdditionalSources()
});
result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
///
@@ -204,7 +204,7 @@ public void EnableAdditionalSources_TrustLevel_Explicit()
// Remove the test source, then add it with policy.
TestCommon.RunAICLICommand("source remove", "TestSource");
var result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
GroupPolicyHelper.EnableAdditionalSources.SetEnabledList(new string[]
{
@@ -212,13 +212,13 @@ public void EnableAdditionalSources_TrustLevel_Explicit()
});
result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Trust Level"));
- Assert.True(result.StdOut.Contains("Trusted"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Trust Level"), Is.True);
+ Assert.That(result.StdOut.Contains("Trusted"), Is.True);
var searchResult = TestCommon.RunAICLICommand("search", "TestExampleInstaller");
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_SOURCES_DEFINED, searchResult.ExitCode);
- Assert.True(searchResult.StdOut.Contains("No sources defined; add one with 'source add' or reset to defaults with 'source reset'"));
+ Assert.That(searchResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_SOURCES_DEFINED));
+ Assert.That(searchResult.StdOut.Contains("No sources defined; add one with 'source add' or reset to defaults with 'source reset'"), Is.True);
}
///
@@ -231,7 +231,7 @@ public void EnableAllowedSources()
// With allowed sources disabled:
GroupPolicyHelper.EnableAllowedSources.Disable();
var result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
// With allowed sources enabled, but not listing the test source:
GroupPolicyHelper.EnableAdditionalSources.SetEnabledList(new string[]
@@ -240,7 +240,7 @@ public void EnableAllowedSources()
});
result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
// With the test source allowed:
GroupPolicyHelper.EnableAdditionalSources.SetEnabledList(new string[]
@@ -249,7 +249,7 @@ public void EnableAllowedSources()
});
result = TestCommon.RunAICLICommand("source list", "TestSource");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
}
///
@@ -261,8 +261,8 @@ public void SourceAutoUpdateInterval()
// Test this policy by inspecting the result of --info
GroupPolicyHelper.SourceAutoUpdateInterval.SetEnabledValue(123);
var result = TestCommon.RunAICLICommand(string.Empty, "--info");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.IsTrue(result.StdOut.Contains("Source Auto Update Interval In Minutes 123"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Source Auto Update Interval In Minutes 123"), Is.True);
}
///
@@ -273,10 +273,10 @@ public void EnableConfiguration()
{
GroupPolicyHelper.EnableConfiguration.Disable();
var result = TestCommon.RunAICLICommand("configure", TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
result = TestCommon.RunAICLICommand("configure show", TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
///
@@ -289,21 +289,21 @@ public void EnableConfigurationProcessorPath()
// --processor-path is rejected by policy at argument validation time across all configure subcommands.
var result = TestCommon.RunAICLICommand("configure", $"--processor-path C:\\dsc.exe {TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
result = TestCommon.RunAICLICommand("configure show", $"--processor-path C:\\dsc.exe {TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
result = TestCommon.RunAICLICommand("configure test", $"--processor-path C:\\dsc.exe {TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
result = TestCommon.RunAICLICommand("configure validate", $"--processor-path C:\\dsc.exe {TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
// When not configured, the argument is allowed by policy (admin setting governs).
GroupPolicyHelper.EnableConfigurationProcessorPath.SetNotConfigured();
result = TestCommon.RunAICLICommand("configure show", $"--processor-path C:\\dsc.exe {TestCommon.GetTestDataFile("Configuration\\ShowDetails_TestRepo.yml")}");
- Assert.AreNotEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, result.ExitCode);
+ Assert.That(result.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/HashCommand.cs b/src/AppInstallerCLIE2ETests/HashCommand.cs
index 8d44add3a8..ec4aa4dac6 100644
--- a/src/AppInstallerCLIE2ETests/HashCommand.cs
+++ b/src/AppInstallerCLIE2ETests/HashCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -22,8 +22,8 @@ public class HashCommand : BaseCommand
public void HashFile()
{
var result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile("AppInstallerTestMsiInstaller.msi"));
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("21d90ee9b3569590c624836ef50bf39791c7184869c227eedc00585e1f39b4de"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("21d90ee9b3569590c624836ef50bf39791c7184869c227eedc00585e1f39b4de"), Is.True);
}
///
@@ -33,9 +33,9 @@ public void HashFile()
public void HashMSIX()
{
var result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile(Constants.TestPackage) + " -m");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("08917b781939a7796746b5e2349e1f1d83b6c15599b60cd3f62816f15e565fc4"));
- Assert.True(result.StdOut.Contains("223b318c4b1154a1fb72b1bc23422810faa5ce899a8e774ba2a02834b2058f00"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("08917b781939a7796746b5e2349e1f1d83b6c15599b60cd3f62816f15e565fc4"), Is.True);
+ Assert.That(result.StdOut.Contains("223b318c4b1154a1fb72b1bc23422810faa5ce899a8e774ba2a02834b2058f00"), Is.True);
}
///
@@ -45,9 +45,9 @@ public void HashMSIX()
public void HashInvalidMSIX()
{
var result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile("AppInstallerTestMsiInstaller.msi") + " -m");
- Assert.AreEqual(Constants.ErrorCode.OPC_E_ZIP_MISSING_END_OF_CENTRAL_DIRECTORY, result.ExitCode);
- Assert.True(result.StdOut.Contains("21d90ee9b3569590c624836ef50bf39791c7184869c227eedc00585e1f39b4de"));
- Assert.True(result.StdOut.Contains("Please verify that the input file is a valid, signed MSIX."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.OPC_E_ZIP_MISSING_END_OF_CENTRAL_DIRECTORY));
+ Assert.That(result.StdOut.Contains("21d90ee9b3569590c624836ef50bf39791c7184869c227eedc00585e1f39b4de"), Is.True);
+ Assert.That(result.StdOut.Contains("Please verify that the input file is a valid, signed MSIX."), Is.True);
}
///
@@ -57,8 +57,8 @@ public void HashInvalidMSIX()
public void HashFileNotFound()
{
var result = TestCommon.RunAICLICommand("hash", TestCommon.GetTestDataFile("DoesNot.Exist"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_FILE_NOT_FOUND, result.ExitCode);
- Assert.True(result.StdOut.Contains("File does not exist"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_FILE_NOT_FOUND));
+ Assert.That(result.StdOut.Contains("File does not exist"), Is.True);
}
}
}
\ No newline at end of file
diff --git a/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs b/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs
index b0a8f84801..389f17bcab 100644
--- a/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs
+++ b/src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -392,7 +392,7 @@ public static void VerifyFontPackage(
using var winGetRootKey = fontsRegistryKey.OpenSubKey("Microsoft.DesktopAppInstaller_8wekyb3d8bbwe");
if (shouldExist)
{
- Assert.IsNotNull(winGetRootKey);
+ Assert.That(winGetRootKey, Is.Not.Null);
}
else
{
@@ -402,7 +402,7 @@ public static void VerifyFontPackage(
using var packageNameSubkey = winGetRootKey.OpenSubKey(packageName);
if (shouldExist)
{
- Assert.IsNotNull(packageNameSubkey);
+ Assert.That(packageNameSubkey, Is.Not.Null);
}
if (packageNameSubkey is not null)
@@ -411,11 +411,11 @@ public static void VerifyFontPackage(
if (shouldExist)
{
- Assert.IsNotNull(versionSubkey);
+ Assert.That(versionSubkey, Is.Not.Null);
}
else
{
- Assert.IsNull(versionSubkey);
+ Assert.That(versionSubkey, Is.Null);
}
if (versionSubkey is not null)
@@ -426,7 +426,7 @@ public static void VerifyFontPackage(
fileList.Add(versionSubkey.GetValue(valueName).ToString());
}
- Assert.AreEqual(valueNames.Length, fileList.Count);
+ Assert.That(fileList.Count, Is.EqualTo(valueNames.Length));
}
}
}
@@ -434,7 +434,7 @@ public static void VerifyFontPackage(
// Verify each package file we expect to exist actually exists.
foreach (var file in fileList)
{
- Assert.IsTrue(File.Exists(file));
+ Assert.That(File.Exists(file), Is.True);
}
}
@@ -489,10 +489,10 @@ public static void VerifyPortablePackage(
// Always clean up as best effort.
RunAICLICommand("uninstall", $"--product-code {productCode} --force");
- Assert.AreEqual(shouldExist, exeExists, $"Expected portable exe path: {exePath}");
- Assert.AreEqual(shouldExist && !installDirectoryAddedToPath, symlinkExists, $"Expected portable symlink path: {symlinkPath}");
- Assert.AreEqual(shouldExist, portableEntryExists, $"Expected {productCode} subkey in path: {uninstallSubKey}");
- Assert.AreEqual(shouldExist, isAddedToPath, $"Expected path variable: {(installDirectoryAddedToPath ? installDir : symlinkDirectory)}");
+ Assert.That(exeExists, Is.EqualTo(shouldExist), $"Expected portable exe path: {exePath}");
+ Assert.That(symlinkExists, Is.EqualTo(shouldExist && !installDirectoryAddedToPath), $"Expected portable symlink path: {symlinkPath}");
+ Assert.That(portableEntryExists, Is.EqualTo(shouldExist), $"Expected {productCode} subkey in path: {uninstallSubKey}");
+ Assert.That(isAddedToPath, Is.EqualTo(shouldExist), $"Expected path variable: {(installDirectoryAddedToPath ? installDir : symlinkDirectory)}");
}
///
@@ -645,9 +645,9 @@ public static void AssertInstallerDownload(
string installerDownloadPath = Path.Combine(downloadDir, expectedFileName + installerExtension);
string manifestDownloadPath = Path.Combine(downloadDir, expectedFileName + ".yaml");
- Assert.IsTrue(Directory.Exists(downloadDir), $"Download directory does not exist: {downloadDir}");
- Assert.IsTrue(File.Exists(installerDownloadPath), $"Installer file does not exist: {installerDownloadPath}");
- Assert.IsTrue(File.Exists(manifestDownloadPath), $"Manifest file does not exist: {manifestDownloadPath}");
+ Assert.That(Directory.Exists(downloadDir), Is.True, $"Download directory does not exist: {downloadDir}");
+ Assert.That(File.Exists(installerDownloadPath), Is.True, $"Installer file does not exist: {installerDownloadPath}");
+ Assert.That(File.Exists(manifestDownloadPath), Is.True, $"Manifest file does not exist: {manifestDownloadPath}");
if (cleanup)
{
@@ -1081,7 +1081,7 @@ public static string GetExpectedModulePath(TestModuleLocation location)
public static string GetConfigurationInstanceIdentifierFor(string name)
{
var result = TestCommon.RunAICLICommand("configure list", string.Empty);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
string[] lines = result.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries);
@@ -1092,9 +1092,9 @@ public static string GetConfigurationInstanceIdentifierFor(string name)
// Find the first GUID in the output
int left = line.IndexOf('{');
int right = line.IndexOfAny(new char[] { '}', '…' });
- Assert.AreNotEqual(-1, left);
- Assert.AreNotEqual(-1, right);
- Assert.LessOrEqual(right - left, 38);
+ Assert.That(left, Is.Not.EqualTo(-1));
+ Assert.That(right, Is.Not.EqualTo(-1));
+ Assert.That(right - left, Is.LessThanOrEqualTo(38));
return line.Substring(left, right - left);
}
diff --git a/src/AppInstallerCLIE2ETests/ImportCommand.cs b/src/AppInstallerCLIE2ETests/ImportCommand.cs
index 261f6a7c5e..bb0b73537d 100644
--- a/src/AppInstallerCLIE2ETests/ImportCommand.cs
+++ b/src/AppInstallerCLIE2ETests/ImportCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -31,8 +31,8 @@ public void Setup()
public void ImportSuccessful_1_0()
{
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Good.1.0.json"));
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(this.VerifyTestExeInstalled());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(this.VerifyTestExeInstalled(), Is.True);
this.UninstallTestExe();
}
@@ -43,8 +43,8 @@ public void ImportSuccessful_1_0()
public void ImportSuccessful_2_0()
{
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Good.2.0.json"));
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(this.VerifyTestExeInstalled());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(this.VerifyTestExeInstalled(), Is.True);
this.UninstallTestExe();
}
@@ -56,8 +56,8 @@ public void ImportInvalidFile()
{
// Verify failure when trying to import with an invalid file
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Bad-Invalid.json"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_JSON_INVALID_FILE, result.ExitCode);
- Assert.True(result.StdOut.Contains("JSON file is not valid"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_JSON_INVALID_FILE));
+ Assert.That(result.StdOut.Contains("JSON file is not valid"), Is.True);
}
///
@@ -68,8 +68,8 @@ public void ImportUnknownSource()
{
// Verify failure when trying to import from an unknown source
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Bad-UnknownSource.json"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode);
- Assert.True(result.StdOut.Contains("Source required for import is not installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST));
+ Assert.That(result.StdOut.Contains("Source required for import is not installed"), Is.True);
}
///
@@ -80,8 +80,8 @@ public void ImportUnavailablePackage()
{
// Verify failure when trying to import an unavailable package
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Bad-UnknownPackage.json"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_NOT_ALL_QUERIES_FOUND_SINGLE, result.ExitCode);
- Assert.True(result.StdOut.Contains("Package not found: MissingPackage"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NOT_ALL_QUERIES_FOUND_SINGLE));
+ Assert.That(result.StdOut.Contains("Package not found: MissingPackage"), Is.True);
}
///
@@ -92,8 +92,8 @@ public void ImportUnavailableVersion()
{
// Verify failure when trying to import an unavailable package
var result = TestCommon.RunAICLICommand("import", this.GetTestImportFile("ImportFile-Bad-UnknownPackageVersion.json"));
- Assert.AreEqual(Constants.ErrorCode.ERROR_NOT_ALL_QUERIES_FOUND_SINGLE, result.ExitCode);
- Assert.True(result.StdOut.Contains("Search failed for: AppInstallerTest.TestExeInstaller"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NOT_ALL_QUERIES_FOUND_SINGLE));
+ Assert.That(result.StdOut.Contains("Search failed for: AppInstallerTest.TestExeInstaller"), Is.True);
}
///
@@ -106,9 +106,9 @@ public void ImportAlreadyInstalled()
var installDir = TestCommon.GetRandomTestDir();
TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller -l {installDir}");
var result = TestCommon.RunAICLICommand("import", $"{this.GetTestImportFile("ImportFile-Good.1.0.json")}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Package is already installed"));
- Assert.False(this.VerifyTestExeInstalled());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Package is already installed"), Is.True);
+ Assert.That(this.VerifyTestExeInstalled(), Is.False);
this.UninstallTestExe();
}
@@ -130,8 +130,8 @@ public void ImportExportedFile()
// Import the file
var result = TestCommon.RunAICLICommand("import", jsonFile);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(this.VerifyTestExeInstalled());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(this.VerifyTestExeInstalled(), Is.True);
this.UninstallTestExe();
}
diff --git a/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs b/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
index 8e77c659d9..760e8625ad 100644
--- a/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
+++ b/src/AppInstallerCLIE2ETests/InprocTestbedTests.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -213,7 +213,7 @@ private void RunInprocTestbed(TestbedParameters parameters, int timeout = 300000
}
var result = TestCommon.RunProcess(this.InprocTestbedPath, this.TargetPackageInformation, builtParameters, null, timeout, true, null);
- Assert.AreEqual(0, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(0));
}
///
diff --git a/src/AppInstallerCLIE2ETests/InstallCommand.cs b/src/AppInstallerCLIE2ETests/InstallCommand.cs
index cdbc171082..2f59a83657 100644
--- a/src/AppInstallerCLIE2ETests/InstallCommand.cs
+++ b/src/AppInstallerCLIE2ETests/InstallCommand.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -42,8 +42,8 @@ public void Setup()
public void InstallAppDoesNotExist()
{
var result = TestCommon.RunAICLICommand("install", "DoesNotExist");
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
- Assert.True(result.StdOut.Contains("No package found matching input criteria."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND));
+ Assert.That(result.StdOut.Contains("No package found matching input criteria."), Is.True);
}
///
@@ -53,8 +53,8 @@ public void InstallAppDoesNotExist()
public void InstallWithMultipleAppsMatchingQuery()
{
var result = TestCommon.RunAICLICommand("install", "TestExeInstaller");
- Assert.AreEqual(Constants.ErrorCode.ERROR_MULTIPLE_APPLICATIONS_FOUND, result.ExitCode);
- Assert.True(result.StdOut.Contains("Multiple packages found matching input criteria. Please refine the input."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MULTIPLE_APPLICATIONS_FOUND));
+ Assert.That(result.StdOut.Contains("Multiple packages found matching input criteria. Please refine the input."), Is.True);
}
///
@@ -65,9 +65,9 @@ public void InstallExe()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"), Is.True);
}
///
@@ -80,8 +80,8 @@ public void InstallExeWithInsufficientMinOsVersion()
var result = TestCommon.RunAICLICommand("install", $"InapplicableOsVersion --silent -l {installDir}");
// MinOSVersion is moved to installer level, the check is performed during installer selection
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICABLE_INSTALLER, result.ExitCode);
- Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICABLE_INSTALLER));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.False);
}
///
@@ -92,9 +92,9 @@ public void InstallExeWithHashMismatch()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestExeSha256Mismatch --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH, result.ExitCode);
- Assert.True(result.StdOut.Contains("Installer hash does not match"));
- Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH));
+ Assert.That(result.StdOut.Contains("Installer hash does not match"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.False);
}
///
@@ -106,9 +106,9 @@ public void InstallWithInno()
// Install test inno, manifest does not provide silent switch, we should be populating the default
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestInnoInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/VERYSILENT"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/VERYSILENT"), Is.True);
}
///
@@ -120,9 +120,9 @@ public void InstallBurn()
// Install test burn, manifest does not provide silent switch, we should be populating the default
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestBurnInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/quiet"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/quiet"), Is.True);
}
///
@@ -134,9 +134,9 @@ public void InstallNullSoft()
// Install test Nullsoft, manifest does not provide silent switch, we should be populating the default
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestNullsoftInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/S"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/S"), Is.True);
}
///
@@ -147,9 +147,9 @@ public void InstallMSI()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"TestMsiInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir), Is.True);
}
///
@@ -159,9 +159,9 @@ public void InstallMSI()
public void InstallMSIX()
{
var result = TestCommon.RunAICLICommand("install", $"TestMsixInstaller");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True);
}
///
@@ -174,9 +174,9 @@ public void InstallMSIXMachineScope()
Assert.Ignore();
var result = TestCommon.RunAICLICommand("install", $"TestMsixInstaller --scope machine");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup(true));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(true), Is.True);
}
///
@@ -186,9 +186,9 @@ public void InstallMSIXMachineScope()
public void InstallMSIXWithSignature()
{
var result = TestCommon.RunAICLICommand("install", $"TestMsixWithSignatureHash");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True);
}
///
@@ -201,9 +201,9 @@ public void InstallMSIXWithSignatureMachineScope()
Assert.Ignore();
var result = TestCommon.RunAICLICommand("install", $"TestMsixWithSignatureHash --scope machine");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup(true));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(true), Is.True);
}
///
@@ -213,9 +213,9 @@ public void InstallMSIXWithSignatureMachineScope()
public void InstallMSIXWithSignatureHashMismatch()
{
var result = TestCommon.RunAICLICommand("install", $"TestMsixSignatureHashMismatch");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH, result.ExitCode);
- Assert.True(result.StdOut.Contains("Installer hash does not match"));
- Assert.False(TestCommon.VerifyTestMsixInstalledAndCleanup());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALLER_HASH_MISMATCH));
+ Assert.That(result.StdOut.Contains("Installer hash does not match"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.False);
}
///
@@ -230,11 +230,11 @@ public void InstallExeWithAlternateSourceFailure()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {installDir}");
- Assert.AreEqual(unchecked((int)0x80070002), result.ExitCode);
- Assert.True(result.StdOut.Contains("Failed when searching source: failSearch"));
- Assert.True(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"));
- Assert.False(result.StdOut.Contains("Successfully installed"));
- Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(unchecked((int)0x80070002)));
+ Assert.That(result.StdOut.Contains("Failed when searching source: failSearch"), Is.True);
+ Assert.That(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"), Is.True);
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.False);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.False);
}
finally
{
@@ -255,8 +255,8 @@ public void InstallPortableExe()
commandAlias = fileName = "AppInstallerTestExeInstaller.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
// If no location specified, default behavior is to create a package directory with the name "{packageId}_{sourceId}"
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
@@ -276,8 +276,8 @@ public void InstallPortableExeWithCommand()
commandAlias = "testCommand.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId} -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(installDir, commandAlias, fileName, productCode, true);
}
@@ -294,8 +294,8 @@ public void InstallPortableExeWithRename()
renameArgValue = "testRename.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId} -l {installDir} --rename {renameArgValue}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(installDir, renameArgValue, renameArgValue, productCode, true);
}
@@ -311,8 +311,8 @@ public void InstallPortableInvalidRename()
renameArgValue = "test?";
var result = TestCommon.RunAICLICommand("install", $"{packageId} -l {installDir} --rename {renameArgValue}");
- Assert.AreNotEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("The specified filename is not a valid filename"));
+ Assert.That(result.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("The specified filename is not a valid filename"), Is.True);
}
///
@@ -327,8 +327,8 @@ public void InstallPortableReservedNames()
renameArgValue = "CON";
var result = TestCommon.RunAICLICommand("install", $"{packageId} -l {installDir} --rename {renameArgValue}");
- Assert.AreNotEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("The specified filename is not a valid filename"));
+ Assert.That(result.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("The specified filename is not a valid filename"), Is.True);
}
///
@@ -347,8 +347,8 @@ public void InstallPortableToExistingDirectory()
commandAlias = fileName = "AppInstallerTestExeInstaller.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId} -l {existingDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(existingDir, commandAlias, fileName, productCode, true);
}
@@ -373,8 +373,8 @@ public void InstallPortableFailsWithCleanup()
// Remove directory prior to assertions as this will impact other tests if assertions fail.
Directory.Delete(conflictDirectory, true);
- Assert.AreNotEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Unable to create symlink"));
+ Assert.That(result.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Unable to create symlink"), Is.True);
}
///
@@ -390,19 +390,19 @@ public void ReinstallPortable()
commandAlias = fileName = "AppInstallerTestExeInstaller.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
string symlinkDirectory = TestCommon.GetPortableSymlinkDirectory(TestCommon.Scope.User);
string symlinkPath = Path.Combine(symlinkDirectory, commandAlias);
// Clean first install should not display file overwrite message.
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.False(result.StdOut.Contains($"Overwriting existing file: {symlinkPath}"));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(result.StdOut.Contains($"Overwriting existing file: {symlinkPath}"), Is.False);
// Perform second install and verify that file overwrite message is displayed.
var result2 = TestCommon.RunAICLICommand("install", $"{packageId} --force");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result2.ExitCode);
- Assert.True(result2.StdOut.Contains("Successfully installed"));
+ Assert.That(result2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result2.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
}
@@ -423,8 +423,8 @@ public void InstallPortable_UserScope()
var result = TestCommon.RunAICLICommand("install", $"{packageId} --scope user");
WinGetSettingsHelper.ConfigureInstallBehavior(Constants.PortablePackageUserRoot, string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
}
@@ -444,8 +444,8 @@ public void InstallPortable_MachineScope()
var result = TestCommon.RunAICLICommand("install", $"{packageId} --scope machine");
WinGetSettingsHelper.ConfigureInstallBehavior(Constants.PortablePackageMachineRoot, string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true, TestCommon.Scope.Machine);
}
@@ -466,8 +466,8 @@ public void InstallPortable_InstallScopePreference_User()
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
WinGetSettingsHelper.ConfigureInstallBehavior(Constants.PortablePackageUserRoot, string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
}
@@ -488,8 +488,8 @@ public void InstallPortable_InstallScopePreference_Machine()
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
WinGetSettingsHelper.ConfigureInstallBehavior(Constants.PortablePackageMachineRoot, string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true, TestCommon.Scope.Machine);
}
@@ -501,9 +501,9 @@ public void InstallZip_Exe()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInstallerWithExe --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"), Is.True);
}
///
@@ -520,8 +520,8 @@ public void InstallZip_Portable()
fileName = "AppInstallerTestExeInstaller.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true, TestCommon.Scope.User);
}
@@ -539,8 +539,8 @@ public void InstallZip_ArchivePortableWithBinariesDependentOnPath()
fileName = "AppInstallerTestExeInstaller.exe";
var result = TestCommon.RunAICLICommand("install", $"{packageId}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true, TestCommon.Scope.User, true);
}
@@ -551,8 +551,8 @@ public void InstallZip_ArchivePortableWithBinariesDependentOnPath()
public void InstallZipWithInvalidRelativeFilePath()
{
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInvalidRelativePath");
- Assert.AreNotEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Invalid relative file path to the nested installer; path points to a location outside of the install directory"));
+ Assert.That(result.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Invalid relative file path to the nested installer; path points to a location outside of the install directory"), Is.True);
}
///
@@ -563,9 +563,9 @@ public void InstallZipWithMsi()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInstallerWithMsi --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir), Is.True);
}
///
@@ -575,9 +575,9 @@ public void InstallZipWithMsi()
public void InstallZipWithMsix()
{
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInstallerWithMsix");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup());
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True);
}
///
@@ -590,9 +590,9 @@ public void InstallZip_ExtractWithTar()
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInstallerWithExe --silent -l {installDir}");
WinGetSettingsHelper.ConfigureInstallBehavior(Constants.ArchiveExtractionMethod, string.Empty);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"), Is.True);
}
///
@@ -603,18 +603,18 @@ public void InstallExeFoundExistingConvertToUpgrade()
{
var baseDir = TestCommon.GetRandomTestDir();
var baseResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller -v 1.0.0.0 --silent -l {baseDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, baseResult.ExitCode);
- Assert.True(baseResult.StdOut.Contains("Successfully installed"));
+ Assert.That(baseResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(baseResult.StdOut.Contains("Successfully installed"), Is.True);
// Install will convert to upgrade
var upgradeDir = TestCommon.GetRandomTestDir();
var upgradeResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {upgradeDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, upgradeResult.ExitCode);
- Assert.True(upgradeResult.StdOut.Contains("Trying to upgrade the installed package..."));
- Assert.True(upgradeResult.StdOut.Contains("Successfully installed"));
+ Assert.That(upgradeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(upgradeResult.StdOut.Contains("Trying to upgrade the installed package..."), Is.True);
+ Assert.That(upgradeResult.StdOut.Contains("Successfully installed"), Is.True);
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(upgradeDir, "/Version 2.0.0.0"));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(upgradeDir, "/Version 2.0.0.0"), Is.True);
}
///
@@ -625,17 +625,17 @@ public void InstallExeFoundExistingConvertToUpgradeNoAvailableUpgrade()
{
var baseDir = TestCommon.GetRandomTestDir();
var baseResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller -v 2.0.0.0 --silent -l {baseDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, baseResult.ExitCode);
- Assert.True(baseResult.StdOut.Contains("Successfully installed"));
+ Assert.That(baseResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(baseResult.StdOut.Contains("Successfully installed"), Is.True);
// Install will convert to upgrade
var upgradeDir = TestCommon.GetRandomTestDir();
var upgradeResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {upgradeDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_UPDATE_NOT_APPLICABLE, upgradeResult.ExitCode);
- Assert.True(upgradeResult.StdOut.Contains("Trying to upgrade the installed package..."));
- Assert.True(upgradeResult.StdOut.Contains("No available upgrade"));
+ Assert.That(upgradeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_UPDATE_NOT_APPLICABLE));
+ Assert.That(upgradeResult.StdOut.Contains("Trying to upgrade the installed package..."), Is.True);
+ Assert.That(upgradeResult.StdOut.Contains("No available upgrade"), Is.True);
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir), Is.True);
}
///
@@ -646,17 +646,17 @@ public void InstallExeWithLatestInstalledWithForce()
{
var baseDir = TestCommon.GetRandomTestDir();
var baseResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller -v 2.0.0.0 --silent -l {baseDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, baseResult.ExitCode);
- Assert.True(baseResult.StdOut.Contains("Successfully installed"));
+ Assert.That(baseResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(baseResult.StdOut.Contains("Successfully installed"), Is.True);
// Install will not convert to upgrade
var installDir = TestCommon.GetRandomTestDir();
var installResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller -v 1.0.0.0 --silent -l {installDir} --force");
- Assert.AreEqual(Constants.ErrorCode.S_OK, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("Successfully installed"));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installResult.StdOut.Contains("Successfully installed"), Is.True);
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(baseDir), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"), Is.True);
}
///
@@ -667,9 +667,9 @@ public void InstallWithWindowsFeatureDependency_FeatureNotFound()
{
var testDir = TestCommon.GetRandomTestDir();
var installResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.WindowsFeature -l {testDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALL_DEPENDENCIES, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("The feature [invalidFeature] was not found."));
- Assert.True(installResult.StdOut.Contains("Failed to enable Windows Feature dependencies. To proceed with installation, use '--force'."));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALL_DEPENDENCIES));
+ Assert.That(installResult.StdOut.Contains("The feature [invalidFeature] was not found."), Is.True);
+ Assert.That(installResult.StdOut.Contains("Failed to enable Windows Feature dependencies. To proceed with installation, use '--force'."), Is.True);
}
///
@@ -680,10 +680,10 @@ public void InstallWithWindowsFeatureDependency_Force()
{
var testDir = TestCommon.GetRandomTestDir();
var installResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.WindowsFeature --silent --force -l {testDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("Failed to enable Windows Feature dependencies; proceeding due to --force"));
- Assert.True(installResult.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(testDir));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installResult.StdOut.Contains("Failed to enable Windows Feature dependencies; proceeding due to --force"), Is.True);
+ Assert.That(installResult.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(testDir), Is.True);
}
///
@@ -695,8 +695,8 @@ public void InstallWithPackageDependency_RefreshPathVariable()
var testDir = TestCommon.GetRandomTestDir();
string installDir = TestCommon.GetPortablePackagesDirectory();
var installResult = TestCommon.RunAICLICommand("install", $"AppInstallerTest.PackageDependencyRequiresPathRefresh -l {testDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("Successfully installed"));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installResult.StdOut.Contains("Successfully installed"), Is.True);
// Portable package is used as a dependency. Ensure that it is installed and cleaned up successfully.
string portablePackageId, commandAlias, fileName, packageDirName, productCode;
@@ -706,7 +706,7 @@ public void InstallWithPackageDependency_RefreshPathVariable()
commandAlias = "testCommand.exe";
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(testDir));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(testDir), Is.True);
}
///
@@ -718,9 +718,9 @@ public void InstallWithPackageDependency_DependenciesOnly()
var testDir = TestCommon.GetRandomTestDir();
string installDir = TestCommon.GetPortablePackagesDirectory();
var installResult = TestCommon.RunAICLICommand("install", $"-q AppInstallerTest.PackageDependencyRequiresPathRefresh -l {testDir} --dependencies-only");
- Assert.AreEqual(Constants.ErrorCode.S_OK, installResult.ExitCode);
- Assert.True(installResult.StdOut.Contains("Installing dependencies only. The package itself will not be installed."));
- Assert.True(installResult.StdOut.Contains("Successfully installed"));
+ Assert.That(installResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installResult.StdOut.Contains("Installing dependencies only. The package itself will not be installed."), Is.True);
+ Assert.That(installResult.StdOut.Contains("Successfully installed"), Is.True);
// Portable package is used as a dependency. Ensure that it is installed and cleaned up successfully.
string portablePackageId, commandAlias, fileName, packageDirName, productCode;
@@ -730,7 +730,7 @@ public void InstallWithPackageDependency_DependenciesOnly()
commandAlias = "testCommand.exe";
TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
- Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(testDir));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(testDir), Is.False);
}
///
@@ -741,9 +741,9 @@ public void InstallWithInstallerTypeArgument()
{
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestMultipleInstallers --silent -l {installDir} --installer-type exe");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/execustom"), Is.True);
}
///
@@ -761,9 +761,9 @@ public void InstallWithInstallerTypePreference()
// Reset installer type preferences.
WinGetSettingsHelper.ConfigureInstallBehaviorPreferences(Constants.InstallerTypes, Array.Empty());
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), "/S");
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.True, "/S");
}
///
@@ -781,8 +781,8 @@ public void InstallWithInstallerTypeRequirement()
// Reset installer type requirements.
WinGetSettingsHelper.ConfigureInstallBehaviorRequirements(Constants.InstallerTypes, Array.Empty());
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICABLE_INSTALLER, result.ExitCode);
- Assert.True(result.StdOut.Contains("No applicable installer found; see logs for more details."));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICABLE_INSTALLER));
+ Assert.That(result.StdOut.Contains("No applicable installer found; see logs for more details."), Is.True);
}
///
@@ -808,25 +808,25 @@ public void InstallExeThatInstallsMSIX()
// We should not find it before installing because the normalized name doesn't match
var result = TestCommon.RunAICLICommand("list", targetPackageIdentifier);
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND));
// Add the MSIX to simulate an installer doing it
TestCommon.InstallMsix(TestIndex.MsixInstaller);
// Install our exe that "installs" the MSIX
result = TestCommon.RunAICLICommand("install", $"{targetPackageIdentifier} --force");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
// We should find the package now, and it should be correlated to the MSIX (although we don't actually know that from this probe)
result = TestCommon.RunAICLICommand("list", targetPackageIdentifier);
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
// Remove the MSIX outside of winget's knowledge to keep the tracking data.
TestCommon.RemoveMsix(Constants.MsixInstallerName);
// We should not find the package now that the MSIX is gone, confirming that it was correlated
result = TestCommon.RunAICLICommand("list", targetPackageIdentifier);
- Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode);
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND));
TestCommon.RemoveARPEntry(fakeProductCode);
}
@@ -845,17 +845,17 @@ public void InstallExeWithSourcePriority()
// Attempt install with equal (default) priorities
var installDir = TestCommon.GetRandomTestDir();
var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.ERROR_MULTIPLE_APPLICATIONS_FOUND, result.ExitCode);
- Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MULTIPLE_APPLICATIONS_FOUND));
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.False);
// Change the priority of the primary test source to be higher
TestCommon.RunAICLICommand("source edit", $"{Constants.TestSourceName} --priority 1");
result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --silent -l {installDir}");
- Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
- Assert.True(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"));
- Assert.True(result.StdOut.Contains("Successfully installed"));
- Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
+ Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"), Is.True);
+ Assert.That(result.StdOut.Contains("Successfully installed"), Is.True);
+ Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.True);
}
finally
{
diff --git a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs
index f336f935a5..ef0c79e348 100644
--- a/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/BaseInterop.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -46,7 +46,7 @@ public MatchResult FindOnePackage(
string value)
{
var findPackages = this.FindAllPackages(packageCatalogReference, field, option, value);
- Assert.AreEqual(1, findPackages.Count, $"Expected exactly one package but found {findPackages.Count}");
+ Assert.That(findPackages.Count, Is.EqualTo(1), $"Expected exactly one package but found {findPackages.Count}");
return findPackages.First();
}
@@ -64,7 +64,7 @@ protected IReadOnlyList FindAllPackages(
PackageFieldMatchOption option,
string value)
{
- Assert.NotNull(packageCatalogReference, "Package catalog reference cannot be null");
+ Assert.That(packageCatalogReference, Is.Not.Null, "Package catalog reference cannot be null");
// Prepare filter
var filter = this.TestFactory.CreatePackageMatchFilter();
diff --git a/src/AppInstallerCLIE2ETests/Interop/CheckInstalledStatusInterop.cs b/src/AppInstallerCLIE2ETests/Interop/CheckInstalledStatusInterop.cs
index aaf23d2f53..d1aa5379e0 100644
--- a/src/AppInstallerCLIE2ETests/Interop/CheckInstalledStatusInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/CheckInstalledStatusInterop.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -64,7 +64,7 @@ public async Task Cleanup()
{
var uninstallOptions = this.TestFactory.CreateUninstallOptions();
var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, uninstallOptions);
- Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
+ Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok));
}
// Remove default install location
@@ -86,7 +86,7 @@ public async Task CheckInstalledStatusArpVersionMatched()
var installOptions = this.TestFactory.CreateInstallOptions();
installOptions.ReplacementInstallerArguments = $"/InstallDir {this.installDir} /ProductID CheckInstalledStatusProductId /DisplayName TestCheckInstalledStatus /Version 1.0";
var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);
- Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
+ Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok));
// Add the data file listed in the manifest
File.WriteAllText(Path.Combine(this.installDir, "data.txt"), "Test");
@@ -100,31 +100,31 @@ public async Task CheckInstalledStatusArpVersionMatched()
// Check installed status
var checkResult = await searchResult.CatalogPackage.CheckInstalledStatusAsync();
- Assert.AreEqual(CheckInstalledStatusResultStatus.Ok, checkResult.Status);
- Assert.AreEqual(1, checkResult.PackageInstalledStatus.Count);
+ Assert.That(checkResult.Status, Is.EqualTo(CheckInstalledStatusResultStatus.Ok));
+ Assert.That(checkResult.PackageInstalledStatus.Count, Is.EqualTo(1));
// Installer info
var installerInstalledStatus = checkResult.PackageInstalledStatus[0];
- Assert.AreEqual(Windows.System.ProcessorArchitecture.Neutral, installerInstalledStatus.InstallerInfo.Architecture);
- Assert.AreEqual(PackageInstallerType.Exe, installerInstalledStatus.InstallerInfo.InstallerType);
- Assert.AreEqual(PackageInstallerType.Unknown, installerInstalledStatus.InstallerInfo.NestedInstallerType);
- Assert.AreEqual(PackageInstallerScope.Unknown, installerInstalledStatus.InstallerInfo.Scope);
+ Assert.That(installerInstalledStatus.InstallerInfo.Architecture, Is.EqualTo(Windows.System.ProcessorArchitecture.Neutral));
+ Assert.That(installerInstalledStatus.InstallerInfo.InstallerType, Is.EqualTo(PackageInstallerType.Exe));
+ Assert.That(installerInstalledStatus.InstallerInfo.NestedInstallerType, Is.EqualTo(PackageInstallerType.Unknown));
+ Assert.That(installerInstalledStatus.InstallerInfo.Scope, Is.EqualTo(PackageInstallerScope.Unknown));
// Installer status
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntry, installerInstalledStatus.InstallerInstalledStatus[0].Type);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocation, installerInstalledStatus.InstallerInstalledStatus[1].Type);
- Assert.AreEqual(this.installDir, installerInstalledStatus.InstallerInstalledStatus[1].Path);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[2].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "data.txt"), installerInstalledStatus.InstallerInstalledStatus[2].Path);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[3].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "TestExeInstalled.txt"), installerInstalledStatus.InstallerInstalledStatus[3].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]));
- Assert.AreEqual(InstalledStatusType.DefaultInstallLocation, installerInstalledStatus.InstallerInstalledStatus[4].Type);
- Assert.AreEqual(this.defaultInstallDir, Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[4].Path));
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_INSTALL_LOCATION_NOT_FOUND, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[4]));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[0].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntry));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocation));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Path, Is.EqualTo(this.installDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Path, Is.EqualTo(Path.Combine(this.installDir, "data.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Path, Is.EqualTo(Path.Combine(this.installDir, "TestExeInstalled.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[4].Type, Is.EqualTo(InstalledStatusType.DefaultInstallLocation));
+ Assert.That(Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[4].Path), Is.EqualTo(this.defaultInstallDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[4]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_INSTALL_LOCATION_NOT_FOUND));
}
///
@@ -139,7 +139,7 @@ public async Task CheckInstalledStatusArpVersionNotMatched()
var installOptions = this.TestFactory.CreateInstallOptions();
installOptions.ReplacementInstallerArguments = $"/InstallDir {this.installDir} /ProductID CheckInstalledStatusProductId /DisplayName TestCheckInstalledStatus /Version 2.0";
var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);
- Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
+ Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok));
// Add the data file listed in the manifest
File.WriteAllText(Path.Combine(this.installDir, "data.txt"), "Test");
@@ -153,21 +153,21 @@ public async Task CheckInstalledStatusArpVersionNotMatched()
// Check installed status
var checkResult = await searchResult.CatalogPackage.CheckInstalledStatusAsync(InstalledStatusType.AllAppsAndFeaturesEntryChecks);
- Assert.AreEqual(CheckInstalledStatusResultStatus.Ok, checkResult.Status);
- Assert.AreEqual(1, checkResult.PackageInstalledStatus.Count);
+ Assert.That(checkResult.Status, Is.EqualTo(CheckInstalledStatusResultStatus.Ok));
+ Assert.That(checkResult.PackageInstalledStatus.Count, Is.EqualTo(1));
var installerInstalledStatus = checkResult.PackageInstalledStatus[0];
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntry, installerInstalledStatus.InstallerInstalledStatus[0].Type);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocation, installerInstalledStatus.InstallerInstalledStatus[1].Type);
- Assert.AreEqual(this.installDir, installerInstalledStatus.InstallerInstalledStatus[1].Path);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[2].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "data.txt"), installerInstalledStatus.InstallerInstalledStatus[2].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[3].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "TestExeInstalled.txt"), installerInstalledStatus.InstallerInstalledStatus[3].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[0].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntry));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocation));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Path, Is.EqualTo(this.installDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Path, Is.EqualTo(Path.Combine(this.installDir, "data.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Path, Is.EqualTo(Path.Combine(this.installDir, "TestExeInstalled.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
}
///
@@ -182,7 +182,7 @@ public async Task CheckInstalledStatusArpVersionMatchedFileNotFound()
var installOptions = this.TestFactory.CreateInstallOptions();
installOptions.ReplacementInstallerArguments = $"/InstallDir {this.installDir} /ProductID CheckInstalledStatusProductId /DisplayName TestCheckInstalledStatus /Version 1.0";
var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);
- Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
+ Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok));
// Search from composite source again after installation
var options = this.TestFactory.CreateCreateCompositePackageCatalogOptions();
@@ -193,21 +193,21 @@ public async Task CheckInstalledStatusArpVersionMatchedFileNotFound()
// Check installed status
var checkResult = await searchResult.CatalogPackage.CheckInstalledStatusAsync(InstalledStatusType.AllAppsAndFeaturesEntryChecks);
- Assert.AreEqual(CheckInstalledStatusResultStatus.Ok, checkResult.Status);
- Assert.AreEqual(1, checkResult.PackageInstalledStatus.Count);
+ Assert.That(checkResult.Status, Is.EqualTo(CheckInstalledStatusResultStatus.Ok));
+ Assert.That(checkResult.PackageInstalledStatus.Count, Is.EqualTo(1));
var installerInstalledStatus = checkResult.PackageInstalledStatus[0];
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntry, installerInstalledStatus.InstallerInstalledStatus[0].Type);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocation, installerInstalledStatus.InstallerInstalledStatus[1].Type);
- Assert.AreEqual(this.installDir, installerInstalledStatus.InstallerInstalledStatus[1].Path);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[2].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "data.txt"), installerInstalledStatus.InstallerInstalledStatus[2].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_NOT_FOUND, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[3].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "TestExeInstalled.txt"), installerInstalledStatus.InstallerInstalledStatus[3].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[0].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntry));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocation));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Path, Is.EqualTo(this.installDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Path, Is.EqualTo(Path.Combine(this.installDir, "data.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_NOT_FOUND));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Path, Is.EqualTo(Path.Combine(this.installDir, "TestExeInstalled.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
}
///
@@ -222,7 +222,7 @@ public async Task CheckInstalledStatusArpVersionMatchedFileHashMisMatch()
var installOptions = this.TestFactory.CreateInstallOptions();
installOptions.ReplacementInstallerArguments = $"/InstallDir {this.installDir} /ProductID CheckInstalledStatusProductId /DisplayName TestCheckInstalledStatus /Version 1.0";
var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);
- Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
+ Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok));
// Add the data file listed in the manifest
File.WriteAllText(Path.Combine(this.installDir, "data.txt"), "WrongData");
@@ -236,21 +236,21 @@ public async Task CheckInstalledStatusArpVersionMatchedFileHashMisMatch()
// Check installed status
var checkResult = await searchResult.CatalogPackage.CheckInstalledStatusAsync(InstalledStatusType.AllAppsAndFeaturesEntryChecks);
- Assert.AreEqual(CheckInstalledStatusResultStatus.Ok, checkResult.Status);
- Assert.AreEqual(1, checkResult.PackageInstalledStatus.Count);
+ Assert.That(checkResult.Status, Is.EqualTo(CheckInstalledStatusResultStatus.Ok));
+ Assert.That(checkResult.PackageInstalledStatus.Count, Is.EqualTo(1));
var installerInstalledStatus = checkResult.PackageInstalledStatus[0];
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntry, installerInstalledStatus.InstallerInstalledStatus[0].Type);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocation, installerInstalledStatus.InstallerInstalledStatus[1].Type);
- Assert.AreEqual(this.installDir, installerInstalledStatus.InstallerInstalledStatus[1].Path);
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[2].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "data.txt"), installerInstalledStatus.InstallerInstalledStatus[2].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_HASH_MISMATCH, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]));
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[3].Type);
- Assert.AreEqual(Path.Combine(this.installDir, "TestExeInstalled.txt"), installerInstalledStatus.InstallerInstalledStatus[3].Path);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[0].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntry));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocation));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Path, Is.EqualTo(this.installDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Path, Is.EqualTo(Path.Combine(this.installDir, "data.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_HASH_MISMATCH));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntryInstallLocationFile));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Path, Is.EqualTo(Path.Combine(this.installDir, "TestExeInstalled.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
}
///
@@ -273,21 +273,21 @@ public async Task CheckInstalledStatusArpNotFoundDefaultInstallLocationFound()
// Check installed status
var checkResult = await searchResult.CatalogPackage.CheckInstalledStatusAsync();
- Assert.AreEqual(CheckInstalledStatusResultStatus.Ok, checkResult.Status);
- Assert.AreEqual(1, checkResult.PackageInstalledStatus.Count);
+ Assert.That(checkResult.Status, Is.EqualTo(CheckInstalledStatusResultStatus.Ok));
+ Assert.That(checkResult.PackageInstalledStatus.Count, Is.EqualTo(1));
var installerInstalledStatus = checkResult.PackageInstalledStatus[0];
- Assert.AreEqual(InstalledStatusType.AppsAndFeaturesEntry, installerInstalledStatus.InstallerInstalledStatus[0].Type);
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_ARP_ENTRY_NOT_FOUND, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]));
- Assert.AreEqual(InstalledStatusType.DefaultInstallLocation, installerInstalledStatus.InstallerInstalledStatus[1].Type);
- Assert.AreEqual(this.defaultInstallDir, Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[1].Path));
- Assert.AreEqual(Constants.ErrorCode.S_OK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]));
- Assert.AreEqual(InstalledStatusType.DefaultInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[2].Type);
- Assert.AreEqual(Path.Combine(this.defaultInstallDir, "data.txt"), Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[2].Path));
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]));
- Assert.AreEqual(InstalledStatusType.DefaultInstallLocationFile, installerInstalledStatus.InstallerInstalledStatus[3].Type);
- Assert.AreEqual(Path.Combine(this.defaultInstallDir, "TestExeInstalled.txt"), Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[3].Path));
- Assert.AreEqual(Constants.ErrorCode.INSTALLED_STATUS_FILE_NOT_FOUND, GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[0].Type, Is.EqualTo(InstalledStatusType.AppsAndFeaturesEntry));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[0]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_ARP_ENTRY_NOT_FOUND));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[1].Type, Is.EqualTo(InstalledStatusType.DefaultInstallLocation));
+ Assert.That(Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[1].Path), Is.EqualTo(this.defaultInstallDir));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[1]), Is.EqualTo(Constants.ErrorCode.S_OK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[2].Type, Is.EqualTo(InstalledStatusType.DefaultInstallLocationFile));
+ Assert.That(Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[2].Path), Is.EqualTo(Path.Combine(this.defaultInstallDir, "data.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[2]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK));
+ Assert.That(installerInstalledStatus.InstallerInstalledStatus[3].Type, Is.EqualTo(InstalledStatusType.DefaultInstallLocationFile));
+ Assert.That(Path.GetFullPath(installerInstalledStatus.InstallerInstalledStatus[3].Path), Is.EqualTo(Path.Combine(this.defaultInstallDir, "TestExeInstalled.txt")));
+ Assert.That(GetHResultFromInstalledStatus(installerInstalledStatus.InstallerInstalledStatus[3]), Is.EqualTo(Constants.ErrorCode.INSTALLED_STATUS_FILE_NOT_FOUND));
}
// CsWinrt maps success error codes(e.g. INSTALLED_STATUS_INSTALL_LOCATION_NOT_APPLICABLE) to null exception.
diff --git a/src/AppInstallerCLIE2ETests/Interop/ConnectionValidationInterop.cs b/src/AppInstallerCLIE2ETests/Interop/ConnectionValidationInterop.cs
index 0abe283e64..239fc5ad2f 100644
--- a/src/AppInstallerCLIE2ETests/Interop/ConnectionValidationInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/ConnectionValidationInterop.cs
@@ -76,20 +76,17 @@ public async Task ConnectionValidationCallback_AllowsConnection_ConnectSucceeds(
var connectResult = catalogRef.Connect();
- Assert.IsNotNull(connectResult);
- Assert.AreEqual(ConnectResultStatus.Ok, connectResult.Status, "Connect should succeed when handler returns Ok.");
- Assert.IsNotNull(connectResult.PackageCatalog, "PackageCatalog should be non-null on success.");
- Assert.IsNotNull(receivedCertDer, "Handler should have been called with a non-null certificate.");
+ Assert.That(connectResult, Is.Not.Null);
+ Assert.That(connectResult.Status, Is.EqualTo(ConnectResultStatus.Ok), "Connect should succeed when handler returns Ok.");
+ Assert.That(connectResult.PackageCatalog, Is.Not.Null, "PackageCatalog should be non-null on success.");
+ Assert.That(receivedCertDer, Is.Not.Null, "Handler should have been called with a non-null certificate.");
// Verify the received certificate matches the test server's known certificate.
if (!string.IsNullOrEmpty(TestSetup.Parameters.LocalServerCertPath) &&
File.Exists(TestSetup.Parameters.LocalServerCertPath))
{
byte[] expectedCertDer = File.ReadAllBytes(TestSetup.Parameters.LocalServerCertPath);
- Assert.AreEqual(
- expectedCertDer,
- receivedCertDer,
- "The certificate received in the callback should match the test server's certificate.");
+ Assert.That(receivedCertDer, Is.EqualTo(expectedCertDer), "The certificate received in the callback should match the test server's certificate.");
}
}
@@ -112,9 +109,9 @@ public async Task ConnectionValidationCallback_RejectsConnection_ConnectFails()
var connectResult = catalogRef.Connect();
- Assert.IsNotNull(connectResult);
- Assert.AreEqual(ConnectResultStatus.CatalogError, connectResult.Status, "Connect should fail when handler rejects the certificate.");
- Assert.IsTrue(handlerCalled, "Handler should have been called.");
+ Assert.That(connectResult, Is.Not.Null);
+ Assert.That(connectResult.Status, Is.EqualTo(ConnectResultStatus.CatalogError), "Connect should fail when handler rejects the certificate.");
+ Assert.That(handlerCalled, Is.True, "Handler should have been called.");
}
///
@@ -127,13 +124,13 @@ public void ConnectionValidationHandler_MicrosoftStore_PolicyEnabled_Allowed()
GroupPolicyHelper.BypassCertificatePinningForMicrosoftStore.Enable();
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.MicrosoftStore);
- Assert.IsNotNull(catalogRef);
+ Assert.That(catalogRef, Is.Not.Null);
// Policy enabled means the feature is allowed; setting the handler should not throw.
- Assert.DoesNotThrow(() =>
+ Assert.That((Action)(() =>
{
catalogRef.ConnectionValidationHandler = (args) => PackageCatalogConnectionValidationResult.Ok;
- });
+ }), Throws.Nothing);
}
///
@@ -146,17 +143,15 @@ public void ConnectionValidationHandler_MicrosoftStore_PolicyDisabled_ThrowsBloc
GroupPolicyHelper.BypassCertificatePinningForMicrosoftStore.Disable();
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.MicrosoftStore);
- Assert.IsNotNull(catalogRef);
+ Assert.That(catalogRef, Is.Not.Null);
- var ex = Assert.Throws(() =>
+ Assert.That(
+ (Action)(() =>
{
catalogRef.ConnectionValidationHandler = (args) => PackageCatalogConnectionValidationResult.Ok;
- });
-
- Assert.AreEqual(
- Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY,
- ex.HResult,
- "Setting ConnectionValidationHandler on MicrosoftStore with policy disabled should return ERROR_BLOCKED_BY_POLICY.");
+ }),
+ Throws.TypeOf()
+ .With.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY), "Setting ConnectionValidationHandler on MicrosoftStore with policy disabled should return ERROR_BLOCKED_BY_POLICY.");
}
///
@@ -172,10 +167,10 @@ public async Task ConnectionValidationHandler_NonStoreCatalog_PolicyEnabled_Allo
var catalogRef = await this.AddRestCatalogAsync();
// This should not throw — the policy only applies to the MicrosoftStore catalog.
- Assert.DoesNotThrow(() =>
+ Assert.That((Action)(() =>
{
catalogRef.ConnectionValidationHandler = (args) => PackageCatalogConnectionValidationResult.Ok;
- });
+ }), Throws.Nothing);
}
///
@@ -191,10 +186,10 @@ public async Task ConnectionValidationHandler_NonStoreCatalog_PolicyDisabled_All
var catalogRef = await this.AddRestCatalogAsync();
// The policy only applies to the MicrosoftStore catalog.
- Assert.DoesNotThrow(() =>
+ Assert.That((Action)(() =>
{
catalogRef.ConnectionValidationHandler = (args) => PackageCatalogConnectionValidationResult.Ok;
- });
+ }), Throws.Nothing);
}
///
@@ -208,7 +203,7 @@ public async Task IsConnectionValidationHandlerEnabled_NonStoreCatalog_ReturnsTr
GroupPolicyHelper.BypassCertificatePinningForMicrosoftStore.Disable();
var catalogRef = await this.AddRestCatalogAsync();
- Assert.IsTrue(catalogRef.IsConnectionValidationHandlerEnabled, "Non-store catalog should always report handler enabled.");
+ Assert.That(catalogRef.IsConnectionValidationHandlerEnabled, Is.True, "Non-store catalog should always report handler enabled.");
}
///
@@ -221,8 +216,8 @@ public void IsConnectionValidationHandlerEnabled_MicrosoftStore_PolicyDisabled_R
GroupPolicyHelper.BypassCertificatePinningForMicrosoftStore.Disable();
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.MicrosoftStore);
- Assert.IsNotNull(catalogRef);
- Assert.IsFalse(catalogRef.IsConnectionValidationHandlerEnabled, "MicrosoftStore catalog with policy disabled should report handler not enabled.");
+ Assert.That(catalogRef, Is.Not.Null);
+ Assert.That(catalogRef.IsConnectionValidationHandlerEnabled, Is.False, "MicrosoftStore catalog with policy disabled should report handler not enabled.");
}
///
@@ -235,8 +230,8 @@ public void IsConnectionValidationHandlerEnabled_MicrosoftStore_PolicyEnabled_Re
GroupPolicyHelper.BypassCertificatePinningForMicrosoftStore.Enable();
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.MicrosoftStore);
- Assert.IsNotNull(catalogRef);
- Assert.IsTrue(catalogRef.IsConnectionValidationHandlerEnabled, "MicrosoftStore catalog with policy enabled should report handler enabled.");
+ Assert.That(catalogRef, Is.Not.Null);
+ Assert.That(catalogRef.IsConnectionValidationHandlerEnabled, Is.True, "MicrosoftStore catalog with policy enabled should report handler enabled.");
}
///
@@ -248,8 +243,8 @@ public void IsConnectionValidationHandlerEnabled_MicrosoftStore_PolicyNotConfigu
{
// Policy is left at NotConfigured (set by SetUp).
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.MicrosoftStore);
- Assert.IsNotNull(catalogRef);
- Assert.IsTrue(catalogRef.IsConnectionValidationHandlerEnabled, "MicrosoftStore catalog with policy not configured should report handler enabled.");
+ Assert.That(catalogRef, Is.Not.Null);
+ Assert.That(catalogRef.IsConnectionValidationHandlerEnabled, Is.True, "MicrosoftStore catalog with policy not configured should report handler enabled.");
}
private static byte[] GetCertificateDerBytes(Certificate certificate)
@@ -275,11 +270,11 @@ private async Task AddRestCatalogAsync()
options.TrustLevel = PackageCatalogTrustLevel.Trusted;
var addResult = await this.packageManager.AddPackageCatalogAsync(options);
- Assert.IsNotNull(addResult);
- Assert.AreEqual(AddPackageCatalogStatus.Ok, addResult.Status, $"Failed to add REST test source. Error: {addResult.ExtendedErrorCode?.HResult:X}");
+ Assert.That(addResult, Is.Not.Null);
+ Assert.That(addResult.Status, Is.EqualTo(AddPackageCatalogStatus.Ok), $"Failed to add REST test source. Error: {addResult.ExtendedErrorCode?.HResult:X}");
var catalogRef = this.packageManager.GetPackageCatalogByName(Constants.RestTestSourceName);
- Assert.IsNotNull(catalogRef, "REST test source catalog reference should not be null after adding.");
+ Assert.That(catalogRef, Is.Not.Null, "REST test source catalog reference should not be null after adding.");
return catalogRef;
}
}
@@ -320,13 +315,13 @@ public void ConnectionValidationHandler_OutOfProcess_ThrowsAccessDenied()
{
// Use the default winget catalog -- we just need any catalog reference.
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.OpenWindowsCatalog);
- Assert.IsNotNull(catalogRef);
+ Assert.That(catalogRef, Is.Not.Null);
// Setting the handler from out-of-proc should be rejected with E_ACCESSDENIED.
- Assert.Throws(() =>
+ Assert.That((Action)(() =>
{
catalogRef.ConnectionValidationHandler = (args) => PackageCatalogConnectionValidationResult.Ok;
- });
+ }), Throws.TypeOf());
}
///
@@ -336,8 +331,8 @@ public void ConnectionValidationHandler_OutOfProcess_ThrowsAccessDenied()
public void IsConnectionValidationHandlerEnabled_OutOfProcess_ReturnsFalse()
{
var catalogRef = this.packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.OpenWindowsCatalog);
- Assert.IsNotNull(catalogRef);
- Assert.IsFalse(catalogRef.IsConnectionValidationHandlerEnabled, "Out-of-process callers should always see IsConnectionValidationHandlerEnabled as false.");
+ Assert.That(catalogRef, Is.Not.Null);
+ Assert.That(catalogRef.IsConnectionValidationHandlerEnabled, Is.False, "Out-of-process callers should always see IsConnectionValidationHandlerEnabled as false.");
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/Interop/DownloadInterop.cs b/src/AppInstallerCLIE2ETests/Interop/DownloadInterop.cs
index 0bd28b6ff4..23ac4d3c9d 100644
--- a/src/AppInstallerCLIE2ETests/Interop/DownloadInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/DownloadInterop.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -64,7 +64,7 @@ public async Task DownloadDependencies()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
var dependenciesDir = Path.Combine(downloadDir, Constants.Dependencies);
TestCommon.AssertInstallerDownload(dependenciesDir, "TestPortableExe", "3.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Portable, "en-US");
TestCommon.AssertInstallerDownload(downloadDir, "TestPackageDependency", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "en-US");
@@ -91,9 +91,9 @@ public async Task DownloadDependencies_Skip()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
var dependenciesDir = Path.Combine(downloadDir, Constants.Dependencies);
- Assert.IsFalse(Directory.Exists(dependenciesDir));
+ Assert.That(Directory.Exists(dependenciesDir), Is.False);
TestCommon.AssertInstallerDownload(downloadDir, "TestPackageDependency", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "en-US");
}
@@ -116,7 +116,7 @@ public async Task DownloadToDefaultDirectory()
// Assert
var packageVersion = "2.0.0.0";
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
string downloadDir = Path.Combine(TestCommon.GetDefaultDownloadDirectory(), $"{Constants.ExeInstallerPackageId}_{packageVersion}");
TestCommon.AssertInstallerDownload(downloadDir, "TestExeInstaller", packageVersion, ProcessorArchitecture.X86, TestCommon.Scope.User, PackageInstallerType.Exe);
}
@@ -141,7 +141,7 @@ public async Task DownloadToDirectory()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestExeInstaller", "2.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.User, PackageInstallerType.Exe);
}
@@ -166,7 +166,7 @@ public async Task DownloadWithUserScope()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.User, PackageInstallerType.Nullsoft, "en-US");
}
@@ -191,7 +191,7 @@ public async Task DownloadWithMachineScope()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -216,7 +216,7 @@ public async Task DownloadWithZipInstallerTypeArg()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "zh-CN", true);
}
@@ -241,7 +241,7 @@ public async Task DownloadWithInstallerTypeArg()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -266,7 +266,7 @@ public async Task DownloadWithArchitectureArg()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X86, TestCommon.Scope.Machine, PackageInstallerType.Msi, "en-US");
}
@@ -291,7 +291,7 @@ public async Task DownloadWithLocaleArg()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok));
TestCommon.AssertInstallerDownload(downloadDir, "TestMultipleInstallers", "1.0.0.0", ProcessorArchitecture.X64, TestCommon.Scope.Unknown, PackageInstallerType.Exe, "zh-CN", true);
}
@@ -315,7 +315,7 @@ public async Task DownloadWithHashMismatch()
var downloadResult = await this.packageManager.DownloadPackageAsync(searchResult.CatalogPackage, downloadOptions);
// Assert
- Assert.AreEqual(DownloadResultStatus.DownloadError, downloadResult.Status);
+ Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.DownloadError));
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs
index a0313727cd..dfc722186a 100644
--- a/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/FindPackagesInterop.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -50,7 +50,7 @@ public void FindPackageDoesNotExist()
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "DoesNotExist");
// Assert
- Assert.AreEqual(0, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(0));
}
///
@@ -63,7 +63,7 @@ public void FindPackagesMultipleMatchingQuery()
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestExeInstaller");
// Assert
- Assert.AreEqual(2, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(2));
}
///
@@ -74,60 +74,60 @@ public void FindPackagesVerifyDefaultLocaleFields()
{
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.CatalogPackageMetadata");
- Assert.AreEqual(1, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(1));
var catalogPackage = searchResult[0].CatalogPackage;
var packageVersionId = catalogPackage.AvailableVersions[0];
var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId);
var catalogPackageMetadata = packageVersionInfo.GetCatalogPackageMetadata();
- Assert.AreEqual("testAuthor", catalogPackageMetadata.Author);
- Assert.AreEqual("AppInstallerTest", catalogPackageMetadata.Publisher);
- Assert.AreEqual("https://testPublisherUrl.com", catalogPackageMetadata.PublisherUrl);
- Assert.AreEqual("https://testPublisherSupportUrl.com", catalogPackageMetadata.PublisherSupportUrl);
- Assert.AreEqual("https://testPrivacyUrl.com", catalogPackageMetadata.PrivacyUrl);
-
- Assert.AreEqual("https://testPackageUrl.com", catalogPackageMetadata.PackageUrl);
- Assert.AreEqual("testLicense", catalogPackageMetadata.License);
- Assert.AreEqual("https://testLicenseUrl.com", catalogPackageMetadata.LicenseUrl);
- Assert.AreEqual("testCopyright", catalogPackageMetadata.Copyright);
- Assert.AreEqual("https://testCopyrightUrl.com", catalogPackageMetadata.CopyrightUrl);
- Assert.AreEqual("testDescription", catalogPackageMetadata.Description);
- Assert.AreEqual("testShortDescription", catalogPackageMetadata.ShortDescription);
- Assert.AreEqual("https://testPurchaseUrl.com", catalogPackageMetadata.PurchaseUrl);
+ Assert.That(catalogPackageMetadata.Author, Is.EqualTo("testAuthor"));
+ Assert.That(catalogPackageMetadata.Publisher, Is.EqualTo("AppInstallerTest"));
+ Assert.That(catalogPackageMetadata.PublisherUrl, Is.EqualTo("https://testPublisherUrl.com"));
+ Assert.That(catalogPackageMetadata.PublisherSupportUrl, Is.EqualTo("https://testPublisherSupportUrl.com"));
+ Assert.That(catalogPackageMetadata.PrivacyUrl, Is.EqualTo("https://testPrivacyUrl.com"));
+
+ Assert.That(catalogPackageMetadata.PackageUrl, Is.EqualTo("https://testPackageUrl.com"));
+ Assert.That(catalogPackageMetadata.License, Is.EqualTo("testLicense"));
+ Assert.That(catalogPackageMetadata.LicenseUrl, Is.EqualTo("https://testLicenseUrl.com"));
+ Assert.That(catalogPackageMetadata.Copyright, Is.EqualTo("testCopyright"));
+ Assert.That(catalogPackageMetadata.CopyrightUrl, Is.EqualTo("https://testCopyrightUrl.com"));
+ Assert.That(catalogPackageMetadata.Description, Is.EqualTo("testDescription"));
+ Assert.That(catalogPackageMetadata.ShortDescription, Is.EqualTo("testShortDescription"));
+ Assert.That(catalogPackageMetadata.PurchaseUrl, Is.EqualTo("https://testPurchaseUrl.com"));
var tags = catalogPackageMetadata.Tags;
- Assert.AreEqual(2, tags.Count);
- Assert.AreEqual("tag1", tags[0]);
- Assert.AreEqual("tag2", tags[1]);
- Assert.AreEqual("testReleaseNotes", catalogPackageMetadata.ReleaseNotes);
- Assert.AreEqual("https://testReleaseNotes.net", catalogPackageMetadata.ReleaseNotesUrl);
- Assert.AreEqual("testInstallationNotes", catalogPackageMetadata.InstallationNotes);
+ Assert.That(tags.Count, Is.EqualTo(2));
+ Assert.That(tags[0], Is.EqualTo("tag1"));
+ Assert.That(tags[1], Is.EqualTo("tag2"));
+ Assert.That(catalogPackageMetadata.ReleaseNotes, Is.EqualTo("testReleaseNotes"));
+ Assert.That(catalogPackageMetadata.ReleaseNotesUrl, Is.EqualTo("https://testReleaseNotes.net"));
+ Assert.That(catalogPackageMetadata.InstallationNotes, Is.EqualTo("testInstallationNotes"));
var packageAgreements = catalogPackageMetadata.Agreements;
- Assert.AreEqual(1, packageAgreements.Count);
+ Assert.That(packageAgreements.Count, Is.EqualTo(1));
var agreement = packageAgreements[0];
- Assert.AreEqual("testAgreementLabel", agreement.Label);
- Assert.AreEqual("testAgreementText", agreement.Text);
- Assert.AreEqual("https://testAgreementUrl.net", agreement.Url);
+ Assert.That(agreement.Label, Is.EqualTo("testAgreementLabel"));
+ Assert.That(agreement.Text, Is.EqualTo("testAgreementText"));
+ Assert.That(agreement.Url, Is.EqualTo("https://testAgreementUrl.net"));
var documentations = catalogPackageMetadata.Documentations;
- Assert.AreEqual(1, documentations.Count);
+ Assert.That(documentations.Count, Is.EqualTo(1));
var documentation = documentations[0];
- Assert.AreEqual("testDocumentLabel", documentation.DocumentLabel);
- Assert.AreEqual("https://testDocumentUrl.com", documentation.DocumentUrl);
+ Assert.That(documentation.DocumentLabel, Is.EqualTo("testDocumentLabel"));
+ Assert.That(documentation.DocumentUrl, Is.EqualTo("https://testDocumentUrl.com"));
var icons = catalogPackageMetadata.Icons;
- Assert.AreEqual(1, icons.Count);
+ Assert.That(icons.Count, Is.EqualTo(1));
var icon = icons[0];
- Assert.AreEqual("https://testIcon", icon.Url);
- Assert.AreEqual(IconFileType.Ico, icon.FileType);
- Assert.AreEqual(IconTheme.Default, icon.Theme);
- Assert.AreEqual(IconResolution.Custom, icon.Resolution);
- Assert.AreEqual(Convert.FromHexString("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8123"), icon.Sha256);
+ Assert.That(icon.Url, Is.EqualTo("https://testIcon"));
+ Assert.That(icon.FileType, Is.EqualTo(IconFileType.Ico));
+ Assert.That(icon.Theme, Is.EqualTo(IconTheme.Default));
+ Assert.That(icon.Resolution, Is.EqualTo(IconResolution.Custom));
+ Assert.That(icon.Sha256, Is.EqualTo(Convert.FromHexString("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8123")));
}
///
@@ -140,7 +140,7 @@ public void FindPackagesInvalidLocale()
var catalogPackage = searchResult[0].CatalogPackage;
var packageVersionId = catalogPackage.AvailableVersions[0];
var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId);
- Assert.Throws(() => packageVersionInfo.GetCatalogPackageMetadata("badLocale"));
+ Assert.That((Action)(() => packageVersionInfo.GetCatalogPackageMetadata("badLocale")), Throws.TypeOf());
}
///
@@ -150,50 +150,50 @@ public void FindPackagesInvalidLocale()
public void FindPackagesGetCatalogPackageMetadataLocale()
{
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.MultipleLocale");
- Assert.AreEqual(1, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(1));
var catalogPackage = searchResult[0].CatalogPackage;
var packageVersionId = catalogPackage.AvailableVersions[0];
var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId);
var catalogPackageMetadata = packageVersionInfo.GetCatalogPackageMetadata("zh-CN");
- Assert.AreEqual("zh-CN", catalogPackageMetadata.Locale);
- Assert.AreEqual("localeLicense", catalogPackageMetadata.License);
- Assert.AreEqual("localePackageName", catalogPackageMetadata.PackageName);
- Assert.AreEqual("localePublisher", catalogPackageMetadata.Publisher);
- Assert.AreEqual("localeReleaseNotes", catalogPackageMetadata.ReleaseNotes);
- Assert.AreEqual("https://localeReleaseNotesUrl.com", catalogPackageMetadata.ReleaseNotesUrl);
- Assert.AreEqual("https://localePurchaseUrl.com", catalogPackageMetadata.PurchaseUrl);
+ Assert.That(catalogPackageMetadata.Locale, Is.EqualTo("zh-CN"));
+ Assert.That(catalogPackageMetadata.License, Is.EqualTo("localeLicense"));
+ Assert.That(catalogPackageMetadata.PackageName, Is.EqualTo("localePackageName"));
+ Assert.That(catalogPackageMetadata.Publisher, Is.EqualTo("localePublisher"));
+ Assert.That(catalogPackageMetadata.ReleaseNotes, Is.EqualTo("localeReleaseNotes"));
+ Assert.That(catalogPackageMetadata.ReleaseNotesUrl, Is.EqualTo("https://localeReleaseNotesUrl.com"));
+ Assert.That(catalogPackageMetadata.PurchaseUrl, Is.EqualTo("https://localePurchaseUrl.com"));
var tags = catalogPackageMetadata.Tags;
- Assert.AreEqual(2, tags.Count);
- Assert.AreEqual("tag1", tags[0]);
- Assert.AreEqual("tag2", tags[1]);
+ Assert.That(tags.Count, Is.EqualTo(2));
+ Assert.That(tags[0], Is.EqualTo("tag1"));
+ Assert.That(tags[1], Is.EqualTo("tag2"));
var packageAgreements = catalogPackageMetadata.Agreements;
- Assert.AreEqual(1, packageAgreements.Count);
+ Assert.That(packageAgreements.Count, Is.EqualTo(1));
var agreement = packageAgreements[0];
- Assert.AreEqual("localeAgreementLabel", agreement.Label);
- Assert.AreEqual("localeAgreement", agreement.Text);
- Assert.AreEqual("https://localeAgreementUrl.net", agreement.Url);
+ Assert.That(agreement.Label, Is.EqualTo("localeAgreementLabel"));
+ Assert.That(agreement.Text, Is.EqualTo("localeAgreement"));
+ Assert.That(agreement.Url, Is.EqualTo("https://localeAgreementUrl.net"));
var documentations = catalogPackageMetadata.Documentations;
- Assert.AreEqual(1, documentations.Count);
+ Assert.That(documentations.Count, Is.EqualTo(1));
var documentation = documentations[0];
- Assert.AreEqual("localeDocumentLabel", documentation.DocumentLabel);
- Assert.AreEqual("https://localeDocumentUrl.com", documentation.DocumentUrl);
+ Assert.That(documentation.DocumentLabel, Is.EqualTo("localeDocumentLabel"));
+ Assert.That(documentation.DocumentUrl, Is.EqualTo("https://localeDocumentUrl.com"));
var icons = catalogPackageMetadata.Icons;
- Assert.AreEqual(1, icons.Count);
+ Assert.That(icons.Count, Is.EqualTo(1));
var icon = icons[0];
- Assert.AreEqual("https://localeTestIcon", icon.Url);
- Assert.AreEqual(IconFileType.Png, icon.FileType);
- Assert.AreEqual(IconTheme.Light, icon.Theme);
- Assert.AreEqual(IconResolution.Square32, icon.Resolution);
- Assert.AreEqual(Convert.FromHexString("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8321"), icon.Sha256);
+ Assert.That(icon.Url, Is.EqualTo("https://localeTestIcon"));
+ Assert.That(icon.FileType, Is.EqualTo(IconFileType.Png));
+ Assert.That(icon.Theme, Is.EqualTo(IconTheme.Light));
+ Assert.That(icon.Resolution, Is.EqualTo(IconResolution.Square32));
+ Assert.That(icon.Sha256, Is.EqualTo(Convert.FromHexString("69D84CA8899800A5575CE31798293CD4FEBAB1D734A07C2E51E56A28E0DF8321")));
}
///
@@ -203,18 +203,18 @@ public void FindPackagesGetCatalogPackageMetadataLocale()
public void FindPackagesGetAllCatalogPackageMetadata()
{
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.MultipleLocale");
- Assert.AreEqual(1, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(1));
var catalogPackage = searchResult[0].CatalogPackage;
var packageVersionId = catalogPackage.AvailableVersions[0];
var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId);
var catalogPackageMetadata1 = packageVersionInfo.GetCatalogPackageMetadata("zh-CN");
- Assert.AreEqual("zh-CN", catalogPackageMetadata1.Locale);
+ Assert.That(catalogPackageMetadata1.Locale, Is.EqualTo("zh-CN"));
var catalogPackageMetadata2 = packageVersionInfo.GetCatalogPackageMetadata("en-GB");
- Assert.AreEqual("en-GB", catalogPackageMetadata2.Locale);
- Assert.AreEqual("packageNameUK", catalogPackageMetadata2.PackageName);
+ Assert.That(catalogPackageMetadata2.Locale, Is.EqualTo("en-GB"));
+ Assert.That(catalogPackageMetadata2.PackageName, Is.EqualTo("packageNameUK"));
}
///
@@ -224,14 +224,14 @@ public void FindPackagesGetAllCatalogPackageMetadata()
public void FindPackagesGetVersionMetadata()
{
var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.MultipleLocale");
- Assert.AreEqual(1, searchResult.Count);
+ Assert.That(searchResult.Count, Is.EqualTo(1));
var catalogPackage = searchResult[0].CatalogPackage;
var packageVersionId = catalogPackage.AvailableVersions[0];
var packageVersionInfo = catalogPackage.GetPackageVersionInfo(packageVersionId);
string metadata = packageVersionInfo.GetMetadata(PackageVersionMetadataField.SilentUninstallCommand);
- Assert.IsEmpty(metadata);
+ Assert.That(metadata, Is.Empty);
}
}
}
diff --git a/src/AppInstallerCLIE2ETests/Interop/GroupPolicyForInterop.cs b/src/AppInstallerCLIE2ETests/Interop/GroupPolicyForInterop.cs
index b807a7a083..9dd3320fa2 100644
--- a/src/AppInstallerCLIE2ETests/Interop/GroupPolicyForInterop.cs
+++ b/src/AppInstallerCLIE2ETests/Interop/GroupPolicyForInterop.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
//
@@ -70,56 +70,80 @@ public void DisableWinGetPolicy()
{
GroupPolicyHelper.EnableWinget.Disable();
- GroupPolicyException groupPolicyException = Assert.Catch(() => { PackageManager packageManager = this.TestFactory.CreatePackageManager(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { FindPackagesOptions findPackagesOptions = this.TestFactory.CreateFindPackagesOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { CreateCompositePackageCatalogOptions createCompositePackageCatalogOptions = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { InstallOptions installOptions = this.TestFactory.CreateInstallOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { UninstallOptions uninstallOptions = this.TestFactory.CreateUninstallOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { DownloadOptions downloadOptions = this.TestFactory.CreateDownloadOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { PackageMatchFilter packageMatchFilter = this.TestFactory.CreatePackageMatchFilter(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { RepairOptions repairOptions = this.TestFactory.CreateRepairOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { AddPackageCatalogOptions packageManagerSettings = this.TestFactory.CreateAddPackageCatalogOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { RemovePackageCatalogOptions packageManagerSettings = this.TestFactory.CreateRemovePackageCatalogOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
-
- groupPolicyException = Assert.Catch(() => { EditPackageCatalogOptions packageManagerSettings = this.TestFactory.CreateEditPackageCatalogOptions(); });
- Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message);
- Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult);
+ Assert.That(
+ (Action)(() => { PackageManager packageManager = this.TestFactory.CreatePackageManager(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { FindPackagesOptions findPackagesOptions = this.TestFactory.CreateFindPackagesOptions(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { CreateCompositePackageCatalogOptions createCompositePackageCatalogOptions = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { InstallOptions installOptions = this.TestFactory.CreateInstallOptions(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { UninstallOptions uninstallOptions = this.TestFactory.CreateUninstallOptions(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { DownloadOptions downloadOptions = this.TestFactory.CreateDownloadOptions(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { PackageMatchFilter packageMatchFilter = this.TestFactory.CreatePackageMatchFilter(); }),
+ Throws.TypeOf()
+ .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage)
+ .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY));
+
+ Assert.That(
+ (Action)(() => { RepairOptions repairOptions = this.TestFactory.CreateRepairOptions(); }),
+ Throws.TypeOf