From 5db9b06e37163cfec216854ce56dd4d35ad48ae2 Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Fri, 29 May 2026 10:21:33 -0500 Subject: [PATCH 1/3] Update NUnit to v4 --- .../AppShutdownTests.cs | 20 +- .../ConfigureCommand.cs | 132 ++++---- .../ConfigureExportCommand.cs | 146 ++++----- .../ConfigureListCommand.cs | 30 +- .../ConfigureProcessorPathCommand.cs | 18 +- .../ConfigureShowCommand.cs | 58 ++-- .../ConfigureTestCommand.cs | 42 +-- .../ConfigureValidateCommand.cs | 116 +++---- .../DSCv3AdminSettingsResourceCommand.cs | 80 ++--- .../DSCv3PackageResourceCommand.cs | 102 +++---- .../DSCv3ResourceTestBase.cs | 20 +- .../DSCv3SourceResourceCommand.cs | 88 +++--- .../DSCv3UserSettingsFileResourceCommand.cs | 52 ++-- .../DownloadCommand.cs | 34 +-- src/AppInstallerCLIE2ETests/ErrorCommand.cs | 62 ++-- .../FeaturesCommand.cs | 8 +- src/AppInstallerCLIE2ETests/FontCommand.cs | 18 +- src/AppInstallerCLIE2ETests/GroupPolicy.cs | 76 ++--- src/AppInstallerCLIE2ETests/HashCommand.cs | 22 +- .../Helpers/TestCommon.cs | 36 +-- src/AppInstallerCLIE2ETests/ImportCommand.cs | 36 +-- .../InprocTestbedTests.cs | 4 +- src/AppInstallerCLIE2ETests/InstallCommand.cs | 282 +++++++++--------- .../Interop/BaseInterop.cs | 6 +- .../Interop/CheckInstalledStatusInterop.cs | 156 +++++----- .../Interop/ConnectionValidationInterop.cs | 77 +++-- .../Interop/DownloadInterop.cs | 26 +- .../Interop/FindPackagesInterop.cs | 136 ++++----- .../Interop/GroupPolicyForInterop.cs | 154 ++++++---- .../Interop/InstallInterop.cs | 112 +++---- .../Interop/PackageCatalogInterop.cs | 72 ++--- .../Interop/RepairInterop.cs | 24 +- .../Interop/Shutdown.cs | 20 +- .../Interop/UninstallInterop.cs | 64 ++-- .../Interop/UpgradeInterop.cs | 52 ++-- src/AppInstallerCLIE2ETests/ListCommand.cs | 92 +++--- src/AppInstallerCLIE2ETests/Pinning.cs | 106 +++---- src/AppInstallerCLIE2ETests/RepairCommand.cs | 108 +++---- src/AppInstallerCLIE2ETests/ResumeCommand.cs | 34 +-- src/AppInstallerCLIE2ETests/SearchCommand.cs | 66 ++-- src/AppInstallerCLIE2ETests/SetUpFixture.cs | 6 +- src/AppInstallerCLIE2ETests/ShowCommand.cs | 68 ++--- src/AppInstallerCLIE2ETests/SourceCommand.cs | 176 +++++------ .../UninstallCommand.cs | 60 ++-- src/AppInstallerCLIE2ETests/UpgradeCommand.cs | 70 ++--- .../ValidateCommand.cs | 62 ++-- .../WinGetUtil/WinGetUtilCompareVersions.cs | 4 +- .../WinGetUtil/WinGetUtilDownload.cs | 6 +- .../WinGetUtilInstallerMetadataCollection.cs | 18 +- .../WinGetUtil/WinGetUtilLog.cs | 4 +- .../WinGetUtil/WinGetUtilManifest.cs | 28 +- .../WinGetUtil/WinGetUtilSQLiteIndex.cs | 18 +- src/Directory.Packages.props | 4 +- .../ConfigurationProcessorTelemetryTests.cs | 1 + .../WinGetUtilInterop.UnitTests.csproj | 3 +- 55 files changed, 1667 insertions(+), 1648 deletions(-) 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() + .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage) + .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY)); + + Assert.That( + (Action)(() => { AddPackageCatalogOptions packageManagerSettings = this.TestFactory.CreateAddPackageCatalogOptions(); }), + Throws.TypeOf() + .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage) + .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY)); + + Assert.That( + (Action)(() => { RemovePackageCatalogOptions packageManagerSettings = this.TestFactory.CreateRemovePackageCatalogOptions(); }), + Throws.TypeOf() + .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage) + .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY)); + + Assert.That( + (Action)(() => { EditPackageCatalogOptions packageManagerSettings = this.TestFactory.CreateEditPackageCatalogOptions(); }), + Throws.TypeOf() + .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage) + .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY)); // PackageManagerSettings is not implemented in context OutOfProcDev if (this.TestFactory.Context == ClsidContext.InProc) { - groupPolicyException = Assert.Catch(() => { PackageManagerSettings packageManagerSettings = this.TestFactory.CreatePackageManagerSettings(); }); - Assert.AreEqual(Constants.BlockByWinGetPolicyErrorMessage, groupPolicyException.Message); - Assert.AreEqual(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY, groupPolicyException.HResult); + Assert.That( + (Action)(() => { PackageManagerSettings packageManagerSettings = this.TestFactory.CreatePackageManagerSettings(); }), + Throws.TypeOf() + .With.Message.EqualTo(Constants.BlockByWinGetPolicyErrorMessage) + .And.Property("HResult").EqualTo(Constants.ErrorCode.ERROR_BLOCKED_BY_POLICY)); } } @@ -138,7 +162,7 @@ public async Task DisableWinGetCommandLineInterfacesPolicy() // Create composite package catalog source var options = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); var testSource = packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.NotNull(testSource, $"{Constants.TestSourceName} cannot be null"); + Assert.That(testSource, Is.Not.Null, $"{Constants.TestSourceName} cannot be null"); options.Catalogs.Add(testSource); options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs; PackageCatalogReference compositeSource = packageManager.CreateCompositePackageCatalog(options); @@ -153,22 +177,22 @@ public async Task DisableWinGetCommandLineInterfacesPolicy() // Install var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ModifyRepairInstaller); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Repair var repairOptions = this.TestFactory.CreateRepairOptions(); repairOptions.PackageRepairMode = PackageRepairMode.Silent; var repairResult = await packageManager.RepairPackageAsync(searchResult.CatalogPackage, repairOptions); - Assert.AreEqual(RepairResultStatus.Ok, repairResult.Status); + Assert.That(repairResult.Status, Is.EqualTo(RepairResultStatus.Ok)); // Uninstall var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestExeUninstalled(installDir)); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeUninstalled(installDir), Is.True); // Clean up. if (Directory.Exists(installDir)) @@ -178,7 +202,7 @@ public async Task DisableWinGetCommandLineInterfacesPolicy() // Download var downloadResult = await packageManager.DownloadPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateDownloadOptions()); - Assert.AreEqual(DownloadResultStatus.Ok, downloadResult.Status); + Assert.That(downloadResult.Status, Is.EqualTo(DownloadResultStatus.Ok)); var packageVersion = "2.0.0.0"; string downloadDir = Path.Combine(TestCommon.GetDefaultDownloadDirectory(), $"{Constants.ModifyRepairInstaller}_{packageVersion}"); TestCommon.AssertInstallerDownload(downloadDir, "TestModifyRepair", packageVersion, ProcessorArchitecture.X86, TestCommon.Scope.Unknown, PackageInstallerType.Burn, "en-US"); @@ -201,15 +225,15 @@ private async Task AddUpdateRemovePackageCatalog() options.TrustLevel = PackageCatalogTrustLevel.Trusted; var addCatalogResult = await packageManager.AddPackageCatalogAsync(options); - Assert.IsNotNull(addCatalogResult); - Assert.AreEqual(AddPackageCatalogStatus.Ok, addCatalogResult.Status); + Assert.That(addCatalogResult, Is.Not.Null); + Assert.That(addCatalogResult.Status, Is.EqualTo(AddPackageCatalogStatus.Ok)); // Get package catalog var packageCatalog = packageManager.GetPackageCatalogByName(options.Name); - Assert.IsNotNull(packageCatalog); - Assert.AreEqual(options.Name, packageCatalog.Info.Name); - Assert.AreEqual(options.SourceUri, packageCatalog.Info.Argument); + Assert.That(packageCatalog, Is.Not.Null); + Assert.That(packageCatalog.Info.Name, Is.EqualTo(options.Name)); + Assert.That(packageCatalog.Info.Argument, Is.EqualTo(options.SourceUri)); var lastUpdatedTime = packageCatalog.Info.LastUpdateTime; // Update package catalog @@ -217,11 +241,11 @@ private async Task AddUpdateRemovePackageCatalog() Thread.Sleep(TimeSpan.FromSeconds(30)); var updateResult = await packageCatalog.RefreshPackageCatalogAsync(); - Assert.IsNotNull(updateResult); - Assert.AreEqual(RefreshPackageCatalogStatus.Ok, updateResult.Status); + Assert.That(updateResult, Is.Not.Null); + Assert.That(updateResult.Status, Is.EqualTo(RefreshPackageCatalogStatus.Ok)); packageCatalog = packageManager.GetPackageCatalogByName(options.Name); - Assert.IsTrue(packageCatalog.Info.LastUpdateTime > lastUpdatedTime); + Assert.That(packageCatalog.Info.LastUpdateTime > lastUpdatedTime, Is.True); // Remove package catalog await this.RemovePackageCatalog(); @@ -236,11 +260,11 @@ private async Task RemovePackageCatalog() removePackageCatalogOptions.Name = Constants.TestSourceName; var removeCatalogResult = await packageManager.RemovePackageCatalogAsync(removePackageCatalogOptions); - Assert.IsNotNull(removeCatalogResult); - Assert.AreEqual(RemovePackageCatalogStatus.Ok, removeCatalogResult.Status); + Assert.That(removeCatalogResult, Is.Not.Null); + Assert.That(removeCatalogResult.Status, Is.EqualTo(RemovePackageCatalogStatus.Ok)); var packageCatalog = packageManager.GetPackageCatalogByName(removePackageCatalogOptions.Name); - Assert.IsNull(packageCatalog); + Assert.That(packageCatalog, Is.Null); } } } diff --git a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs index dc613c7700..e8b7cfc44e 100644 --- a/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/InstallInterop.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -65,8 +65,8 @@ public async Task InstallExe() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); } /// @@ -88,8 +88,8 @@ public async Task InstallExeWithInsufficientMinOsVersion() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.NoApplicableInstallers, installResult.Status); - Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.NoApplicableInstallers)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.False); } /// @@ -111,8 +111,8 @@ public async Task InstallExeWithHashMismatch() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.DownloadError, installResult.Status); - Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.DownloadError)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.False); } /// @@ -134,8 +134,8 @@ public async Task InstallWithInno() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); } /// @@ -157,8 +157,8 @@ public async Task InstallBurn() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); } /// @@ -180,8 +180,8 @@ public async Task InstallNullSoft() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); } /// @@ -208,8 +208,8 @@ public async Task InstallMSI() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir), Is.True); } /// @@ -229,8 +229,8 @@ public async Task InstallMSIX() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True); } /// @@ -254,8 +254,8 @@ public async Task InstallMSIXMachineScope() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup(true)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(true), Is.True); } /// @@ -279,8 +279,8 @@ public async Task InstallMSIXWithSignature() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True); } /// @@ -304,8 +304,8 @@ public async Task InstallMSIXWithSignatureMachineScope() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup(true)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(true), Is.True); } /// @@ -325,8 +325,8 @@ public async Task InstallMSIXWithSignatureHashMismatch() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.DownloadError, installResult.Status); - Assert.False(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.DownloadError)); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.False); } /// @@ -345,8 +345,8 @@ public void InstallExeWithAlternateSourceFailure() var searchResult = this.FindAllPackages(failSearchSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); // Assert - Assert.NotNull(failSearchSource); - Assert.AreEqual(0, searchResult.Count); + Assert.That(failSearchSource, Is.Not.Null); + Assert.That(searchResult.Count, Is.EqualTo(0)); // Remove mock source TestCommon.RunAICLICommand("source remove", "failSearch"); @@ -374,7 +374,7 @@ public async Task InstallPortableExe() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); TestCommon.VerifyPortablePackage(Path.Combine(installDir, Constants.PortableExePackageDirName), commandAlias, fileName, productCode, true); } @@ -400,7 +400,7 @@ public async Task InstallPortableExeWithCommand() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); TestCommon.VerifyPortablePackage(this.installDir, commandAlias, fileName, productCode, true); } @@ -429,7 +429,7 @@ public async Task InstallPortableToExistingDirectory() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); TestCommon.VerifyPortablePackage(existingDir, commandAlias, fileName, productCode, true); } @@ -469,7 +469,7 @@ public async Task InstallPortableFailsWithCleanup() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.InstallError, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.InstallError)); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); Directory.Delete(conflictDirectory, true); } @@ -494,7 +494,7 @@ public async Task InstallRequireUserScope() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.NoApplicableInstallers, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.NoApplicableInstallers)); } /// @@ -517,7 +517,7 @@ public async Task InstallRequireUserScopeAndUnknown() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); } /// @@ -540,7 +540,7 @@ public async Task InstallWithAgreementsAccepted() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); } /// @@ -563,7 +563,7 @@ public async Task InstallWithAgreementsNotAccepted() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.PackageAgreementsNotAccepted, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.PackageAgreementsNotAccepted)); } /// @@ -587,8 +587,8 @@ public async Task InstallWithSkipDependencies() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert that only the exe installer is installed and not the portable package dependency. - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); string installDir = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet", "Packages"); string productCode = Constants.PortableExePackageDirName; @@ -618,8 +618,8 @@ public async Task InstallWithInstallerType() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); - Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir)); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir), Is.True); } /// @@ -630,7 +630,7 @@ public void GetApplicableInstaller() { // Find package var searchResult = this.FindAllPackages(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.PackageInstallerInfo"); - Assert.AreEqual(1, searchResult.Count); + Assert.That(searchResult.Count, Is.EqualTo(1)); // Configure installation var catalogPackage = searchResult[0].CatalogPackage; @@ -641,7 +641,7 @@ public void GetApplicableInstaller() var badInstallOptions = this.TestFactory.CreateInstallOptions(); badInstallOptions.PackageInstallScope = PackageInstallScope.System; - Assert.IsNull(packageVersionInfo.GetApplicableInstaller(badInstallOptions)); + Assert.That(packageVersionInfo.GetApplicableInstaller(badInstallOptions), Is.Null); // Use install options with valid applicable match. var installOptions = this.TestFactory.CreateInstallOptions(); @@ -649,13 +649,13 @@ public void GetApplicableInstaller() var packageInstallerInfo = packageVersionInfo.GetApplicableInstaller(installOptions); // Assert - Assert.IsNotNull(packageInstallerInfo); - Assert.AreEqual(ElevationRequirement.ElevationRequired, packageInstallerInfo.ElevationRequirement); - Assert.AreEqual(Windows.System.ProcessorArchitecture.X64, packageInstallerInfo.Architecture); - Assert.AreEqual(PackageInstallerType.Zip, packageInstallerInfo.InstallerType); - Assert.AreEqual(PackageInstallerType.Exe, packageInstallerInfo.NestedInstallerType); - Assert.AreEqual(PackageInstallerScope.User, packageInstallerInfo.Scope); - Assert.AreEqual("en-US", packageInstallerInfo.Locale); + Assert.That(packageInstallerInfo, Is.Not.Null); + Assert.That(packageInstallerInfo.ElevationRequirement, Is.EqualTo(ElevationRequirement.ElevationRequired)); + Assert.That(packageInstallerInfo.Architecture, Is.EqualTo(Windows.System.ProcessorArchitecture.X64)); + Assert.That(packageInstallerInfo.InstallerType, Is.EqualTo(PackageInstallerType.Zip)); + Assert.That(packageInstallerInfo.NestedInstallerType, Is.EqualTo(PackageInstallerType.Exe)); + Assert.That(packageInstallerInfo.Scope, Is.EqualTo(PackageInstallerScope.User)); + Assert.That(packageInstallerInfo.Locale, Is.EqualTo("en-US")); } /// @@ -669,8 +669,8 @@ public async Task InstallExe_VerifyInstalledCatalog() // Ensure package is not installed var installedResult = this.FindAllPackages(installedCatalogReference, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, Constants.ExeInstalledDefaultProductCode); - Assert.IsNotNull(installedResult); - Assert.AreEqual(0, installedResult.Count); + Assert.That(installedResult, Is.Not.Null); + Assert.That(installedResult.Count, Is.EqualTo(0)); // Find package var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); @@ -685,12 +685,12 @@ public async Task InstallExe_VerifyInstalledCatalog() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Check installed catalog after this.FindOnePackage(installedCatalogReference, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, Constants.ExeInstalledDefaultProductCode); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(this.installDir), Is.True); } /// @@ -704,8 +704,8 @@ public async Task InstallMSIX_VerifyInstalledCatalog() // Ensure package is not installed var installedResult = this.FindAllPackages(installedCatalogReference, PackageMatchField.PackageFamilyName, PackageFieldMatchOption.Equals, Constants.MsixInstallerPackageFamilyName); - Assert.IsNotNull(installedResult); - Assert.AreEqual(0, installedResult.Count); + Assert.That(installedResult, Is.Not.Null); + Assert.That(installedResult.Count, Is.EqualTo(0)); // Find package var searchResult = this.FindOnePackage(this.testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestMsixInstaller"); @@ -717,12 +717,12 @@ public async Task InstallMSIX_VerifyInstalledCatalog() var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); // Assert - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Check installed catalog after this.FindOnePackage(installedCatalogReference, PackageMatchField.PackageFamilyName, PackageFieldMatchOption.Equals, Constants.MsixInstallerPackageFamilyName); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/Interop/PackageCatalogInterop.cs b/src/AppInstallerCLIE2ETests/Interop/PackageCatalogInterop.cs index 72918b2fcb..ae926d5bdb 100644 --- a/src/AppInstallerCLIE2ETests/Interop/PackageCatalogInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/PackageCatalogInterop.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -63,11 +63,11 @@ public async Task AddRemovePackageCatalog() RemovePackageCatalogOptions removePackageCatalogOptions = this.TestFactory.CreateRemovePackageCatalogOptions(); removePackageCatalogOptions.Name = Constants.TestSourceName; var removeCatalogResult = await this.packageManager.RemovePackageCatalogAsync(removePackageCatalogOptions); - Assert.IsNotNull(removeCatalogResult); - Assert.AreEqual(RemovePackageCatalogStatus.Ok, removeCatalogResult.Status); + Assert.That(removeCatalogResult, Is.Not.Null); + Assert.That(removeCatalogResult.Status, Is.EqualTo(RemovePackageCatalogStatus.Ok)); var testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.IsNull(testSource); + Assert.That(testSource, Is.Null); } /// @@ -77,10 +77,10 @@ public async Task AddRemovePackageCatalog() public void AddPackageCatalogWithInvalidOptions() { // Add package catalog with null options. - Assert.ThrowsAsync(async () => await this.packageManager.AddPackageCatalogAsync(null)); + Assert.That((Func)(async () => await this.packageManager.AddPackageCatalogAsync(null)), Throws.TypeOf()); // Add package catalog with empty options. - Assert.ThrowsAsync(async () => await this.packageManager.AddPackageCatalogAsync(this.TestFactory.CreateAddPackageCatalogOptions())); + Assert.That((Func)(async () => await this.packageManager.AddPackageCatalogAsync(this.TestFactory.CreateAddPackageCatalogOptions())), Throws.TypeOf()); } /// @@ -196,11 +196,11 @@ public async Task AddUpdateRemovePackageCatalog() Thread.Sleep(TimeSpan.FromSeconds(30)); var updateResult = await packageCatalog.RefreshPackageCatalogAsync(); - Assert.IsNotNull(updateResult); - Assert.AreEqual(RefreshPackageCatalogStatus.Ok, updateResult.Status); + Assert.That(updateResult, Is.Not.Null); + Assert.That(updateResult.Status, Is.EqualTo(RefreshPackageCatalogStatus.Ok)); packageCatalog = this.GetAndValidatePackageCatalog(options); - Assert.IsTrue(packageCatalog.Info.LastUpdateTime > lastUpdatedTime); + Assert.That(packageCatalog.Info.LastUpdateTime > lastUpdatedTime, Is.True); RemovePackageCatalogOptions removePackageCatalogOptions = this.TestFactory.CreateRemovePackageCatalogOptions(); removePackageCatalogOptions.Name = Constants.TestSourceName; @@ -235,10 +235,10 @@ public async Task AddRemovePackageCatalogWithPreserveDataFiledSet() public void RemovePackageCatalogWithInvalidOptions() { // Remove package catalog with null options. - Assert.ThrowsAsync(async () => await this.packageManager.RemovePackageCatalogAsync(null)); + Assert.That((Func)(async () => await this.packageManager.RemovePackageCatalogAsync(null)), Throws.TypeOf()); // Remove package catalog with empty options. - Assert.ThrowsAsync(async () => await this.packageManager.RemovePackageCatalogAsync(this.TestFactory.CreateRemovePackageCatalogOptions())); + Assert.That((Func)(async () => await this.packageManager.RemovePackageCatalogAsync(this.TestFactory.CreateRemovePackageCatalogOptions())), Throws.TypeOf()); } /// @@ -261,10 +261,10 @@ public async Task RemoveNonExistingPackageCatalog() public void EditPackageCatalogWithInvalidOptions() { // Edit package catalog with null options. - Assert.Throws(() => this.packageManager.EditPackageCatalog(null)); + Assert.That((Action)(() => this.packageManager.EditPackageCatalog(null)), Throws.TypeOf()); // Edit package catalog with empty options. - Assert.Throws(() => this.packageManager.EditPackageCatalog(this.TestFactory.CreateEditPackageCatalogOptions())); + Assert.That((Action)(() => this.packageManager.EditPackageCatalog(this.TestFactory.CreateEditPackageCatalogOptions())), Throws.TypeOf()); } /// @@ -307,11 +307,11 @@ public async Task AddEditRemovePackageCatalog() RemovePackageCatalogOptions removePackageCatalogOptions = this.TestFactory.CreateRemovePackageCatalogOptions(); removePackageCatalogOptions.Name = Constants.TestSourceName; var removeCatalogResult = await this.packageManager.RemovePackageCatalogAsync(removePackageCatalogOptions); - Assert.IsNotNull(removeCatalogResult); - Assert.AreEqual(RemovePackageCatalogStatus.Ok, removeCatalogResult.Status); + Assert.That(removeCatalogResult, Is.Not.Null); + Assert.That(removeCatalogResult.Status, Is.EqualTo(RemovePackageCatalogStatus.Ok)); var testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.IsNull(testSource); + Assert.That(testSource, Is.Null); } /// @@ -327,12 +327,12 @@ public void TestClassTearDown() private async Task AddCatalogAndVerifyStatusAsync(AddPackageCatalogOptions addPackageCatalogOptions, AddPackageCatalogStatus expectedStatus, int expectedErrorCode = 0) { var addCatalogResult = await this.packageManager.AddPackageCatalogAsync(addPackageCatalogOptions); - Assert.IsNotNull(addCatalogResult); - Assert.AreEqual(expectedStatus, addCatalogResult.Status); + Assert.That(addCatalogResult, Is.Not.Null); + Assert.That(addCatalogResult.Status, Is.EqualTo(expectedStatus)); if (expectedStatus != AddPackageCatalogStatus.Ok && expectedErrorCode != 0) { - Assert.AreEqual(expectedErrorCode, addCatalogResult.ExtendedErrorCode.HResult); + Assert.That(addCatalogResult.ExtendedErrorCode.HResult, Is.EqualTo(expectedErrorCode)); } } @@ -340,11 +340,11 @@ private PackageCatalogReference GetAndValidatePackageCatalog(AddPackageCatalogOp { var packageCatalog = this.packageManager.GetPackageCatalogByName(addPackageCatalogOptions.Name); - Assert.IsNotNull(packageCatalog); - Assert.AreEqual(addPackageCatalogOptions.Name, packageCatalog.Info.Name); - Assert.AreEqual(addPackageCatalogOptions.SourceUri, packageCatalog.Info.Argument); - Assert.AreEqual(addPackageCatalogOptions.Explicit, packageCatalog.Info.Explicit); - Assert.AreEqual(addPackageCatalogOptions.Priority, packageCatalog.Info.Priority); + Assert.That(packageCatalog, Is.Not.Null); + Assert.That(packageCatalog.Info.Name, Is.EqualTo(addPackageCatalogOptions.Name)); + Assert.That(packageCatalog.Info.Argument, Is.EqualTo(addPackageCatalogOptions.SourceUri)); + Assert.That(packageCatalog.Info.Explicit, Is.EqualTo(addPackageCatalogOptions.Explicit)); + Assert.That(packageCatalog.Info.Priority, Is.EqualTo(addPackageCatalogOptions.Priority)); return packageCatalog; } @@ -353,15 +353,15 @@ private async Task AddAndValidatePackageCatalogAsync(AddPackageCatalogOptions ad { // Add the package catalog and verify the status var addCatalogResult = await this.packageManager.AddPackageCatalogAsync(addPackageCatalogOptions); - Assert.IsNotNull(addCatalogResult); - Assert.AreEqual(expectedStatus, addCatalogResult.Status); + Assert.That(addCatalogResult, Is.Not.Null); + Assert.That(addCatalogResult.Status, Is.EqualTo(expectedStatus)); if (expectedStatus != AddPackageCatalogStatus.Ok) { // Only validate the error code if the status is not Ok and the expected error code is not 0 if (expectedErrorCode != 0) { - Assert.AreEqual(expectedErrorCode, addCatalogResult.ExtendedErrorCode.HResult); + Assert.That(addCatalogResult.ExtendedErrorCode.HResult, Is.EqualTo(expectedErrorCode)); } return; @@ -374,28 +374,28 @@ private async Task AddAndValidatePackageCatalogAsync(AddPackageCatalogOptions ad private async Task RemoveAndValidatePackageCatalogAsync(RemovePackageCatalogOptions removePackageCatalogOptions, RemovePackageCatalogStatus expectedStatus, int expectedErrorCode = 0) { var removeCatalogResult = await this.packageManager.RemovePackageCatalogAsync(removePackageCatalogOptions); - Assert.IsNotNull(removeCatalogResult); - Assert.AreEqual(expectedStatus, removeCatalogResult.Status); + Assert.That(removeCatalogResult, Is.Not.Null); + Assert.That(removeCatalogResult.Status, Is.EqualTo(expectedStatus)); if (expectedStatus != RemovePackageCatalogStatus.Ok && expectedErrorCode != 0) { - Assert.AreEqual(expectedErrorCode, removeCatalogResult.ExtendedErrorCode.HResult); + Assert.That(removeCatalogResult.ExtendedErrorCode.HResult, Is.EqualTo(expectedErrorCode)); return; } var packageCatalog = this.packageManager.GetPackageCatalogByName(removePackageCatalogOptions.Name); - Assert.IsNull(packageCatalog); + Assert.That(packageCatalog, Is.Null); } private void EditAndValidatePackageCatalog(EditPackageCatalogOptions editPackageCatalogOptions, EditPackageCatalogStatus expectedStatus, int expectedErrorCode = 0) { var editCatalogResult = this.packageManager.EditPackageCatalog(editPackageCatalogOptions); - Assert.IsNotNull(editCatalogResult); - Assert.AreEqual(expectedStatus, editCatalogResult.Status); + Assert.That(editCatalogResult, Is.Not.Null); + Assert.That(editCatalogResult.Status, Is.EqualTo(expectedStatus)); if (expectedStatus != EditPackageCatalogStatus.Ok && expectedErrorCode != 0) { - Assert.AreEqual(expectedErrorCode, editCatalogResult.ExtendedErrorCode.HResult); + Assert.That(editCatalogResult.ExtendedErrorCode.HResult, Is.EqualTo(expectedErrorCode)); return; } @@ -403,12 +403,12 @@ private void EditAndValidatePackageCatalog(EditPackageCatalogOptions editPackage var packageCatalog = this.packageManager.GetPackageCatalogByName(editPackageCatalogOptions.Name); if (editPackageCatalogOptions.Explicit != null) { - Assert.AreEqual(packageCatalog.Info.Explicit, editPackageCatalogOptions.Explicit); + Assert.That(editPackageCatalogOptions.Explicit, Is.EqualTo(packageCatalog.Info.Explicit)); } if (editPackageCatalogOptions.Priority != null) { - Assert.AreEqual(packageCatalog.Info.Priority, editPackageCatalogOptions.Priority); + Assert.That(editPackageCatalogOptions.Priority, Is.EqualTo(packageCatalog.Info.Priority)); } } } diff --git a/src/AppInstallerCLIE2ETests/Interop/RepairInterop.cs b/src/AppInstallerCLIE2ETests/Interop/RepairInterop.cs index b563e3cb33..d5de689149 100644 --- a/src/AppInstallerCLIE2ETests/Interop/RepairInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/RepairInterop.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -48,7 +48,7 @@ public void Init() // Create a composite source var options = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); var testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.NotNull(testSource, $"{Constants.TestSourceName} cannot be null"); + Assert.That(testSource, Is.Not.Null, $"{Constants.TestSourceName} cannot be null"); options.Catalogs.Add(testSource); options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs; this.compositeSource = this.packageManager.CreateCompositePackageCatalog(options); @@ -75,7 +75,7 @@ public async Task RepairMSIInstaller() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, this.TestFactory.CreateRepairOptions(), RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir)); + Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(this.installDir), Is.True); if (installerSourceDir != null && Directory.Exists(installerSourceDir)) { @@ -97,7 +97,7 @@ public async Task RepairNonStoreMSIXPackage() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, this.TestFactory.CreateRepairOptions(), RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True); } /// @@ -145,7 +145,7 @@ public async Task RepairBurnInstallerWithModifyBehavior() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, repairOptions, RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Modify Repair operation")); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Modify Repair operation"), Is.True); } /// @@ -232,7 +232,7 @@ public async Task RepairExeInstallerWithUninstallerBehavior() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, this.TestFactory.CreateRepairOptions(), RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Uninstaller Repair operation")); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Uninstaller Repair operation"), Is.True); } /// @@ -266,7 +266,7 @@ public async Task RepairNullsoftInstallerWithUninstallerBehavior() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, this.TestFactory.CreateRepairOptions(), RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Uninstaller Repair operation")); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Uninstaller Repair operation"), Is.True); } /// @@ -283,7 +283,7 @@ public async Task RepairInnoInstallerWithInstallerRepairBehavior() await this.RepairPackageAndValidateStatus(searchResult.CatalogPackage, this.TestFactory.CreateRepairOptions(), RepairResultStatus.Ok); // Cleanup - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Installer Repair operation")); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(this.installDir, "Installer Repair operation"), Is.True); } private async Task FindAndInstallPackage(string packageId, string installDir, string replacementInstallerArguments) @@ -307,11 +307,11 @@ private async Task FindAndInstallPackage(string packageId, string i // Install the package var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should be detected as installed searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Return the search result return searchResult; @@ -320,11 +320,11 @@ private async Task FindAndInstallPackage(string packageId, string i private async Task RepairPackageAndValidateStatus(CatalogPackage package, RepairOptions repairOptions, RepairResultStatus expectedStatus, int expectedErrorCode = 0) { var repairResult = await this.packageManager.RepairPackageAsync(package, repairOptions); - Assert.AreEqual(expectedStatus, repairResult.Status); + Assert.That(repairResult.Status, Is.EqualTo(expectedStatus)); if (expectedStatus != RepairResultStatus.Ok) { - Assert.AreEqual(expectedErrorCode, repairResult.ExtendedErrorCode.HResult); + Assert.That(repairResult.ExtendedErrorCode.HResult, Is.EqualTo(expectedErrorCode)); } } diff --git a/src/AppInstallerCLIE2ETests/Interop/Shutdown.cs b/src/AppInstallerCLIE2ETests/Interop/Shutdown.cs index 6a443e2b27..d0d6bf690f 100644 --- a/src/AppInstallerCLIE2ETests/Interop/Shutdown.cs +++ b/src/AppInstallerCLIE2ETests/Interop/Shutdown.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -38,17 +38,17 @@ public void NoActiveOperations() var packageManager = this.TestFactory.CreatePackageManager(); var servers = WinGetServerInstance.GetInstances(); - Assert.AreEqual(1, servers.Count); + Assert.That(servers.Count, Is.EqualTo(1)); var server = servers[0]; - Assert.IsTrue(server.HasWindow); + Assert.That(server.HasWindow, Is.True); // This is the call pattern from Windows this.SendMessageAndLog(server, WindowMessage.QueryEndSession); this.SendMessageAndLog(server, WindowMessage.EndSession); this.SendMessageAndLog(server, WindowMessage.Close); - Assert.IsTrue(server.Process.WaitForExit(5000)); + Assert.That(server.Process.WaitForExit(5000), Is.True); } /// @@ -63,10 +63,10 @@ public async Task ActiveInstallOperation() var installDir = TestCommon.GetRandomTestDir(); var servers = WinGetServerInstance.GetInstances(); - Assert.AreEqual(1, servers.Count); + Assert.That(servers.Count, Is.EqualTo(1)); var server = servers[0]; - Assert.IsTrue(server.HasWindow); + Assert.That(server.HasWindow, Is.True); // Find package var searchResult = this.FindOnePackage(testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "InapplicableOsVersion"); @@ -84,7 +84,7 @@ public async Task ActiveInstallOperation() this.SendMessageAndLog(server, WindowMessage.EndSession); this.SendMessageAndLog(server, WindowMessage.Close); - Assert.IsTrue(server.Process.WaitForExit(5000)); + Assert.That(server.Process.WaitForExit(5000), Is.True); InstallResult installResult = null; Exception exception = null; @@ -101,14 +101,14 @@ public async Task ActiveInstallOperation() // We just expect some kind of signal to indicate the failed attempt. if (installResult != null) { - Assert.AreNotEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.Not.EqualTo(InstallResultStatus.Ok)); } else { - Assert.NotNull(exception); + Assert.That(exception, Is.Not.Null); } - Assert.False(TestCommon.VerifyTestExeInstalledAndCleanup(installDir)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.False); } private void SendMessageAndLog(WinGetServerInstance server, WindowMessage message) diff --git a/src/AppInstallerCLIE2ETests/Interop/UninstallInterop.cs b/src/AppInstallerCLIE2ETests/Interop/UninstallInterop.cs index 65a9d2a393..f1ee460cea 100644 --- a/src/AppInstallerCLIE2ETests/Interop/UninstallInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/UninstallInterop.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -46,7 +46,7 @@ public void Init() // Create composite package catalog source var options = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); var testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.NotNull(testSource, $"{Constants.TestSourceName} cannot be null"); + Assert.That(testSource, Is.Not.Null, $"{Constants.TestSourceName} cannot be null"); options.Catalogs.Add(testSource); options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs; this.compositeSource = this.packageManager.CreateCompositePackageCatalog(options); @@ -69,16 +69,16 @@ public async Task UninstallTestExe() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestExeUninstalled(this.installDir)); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeUninstalled(this.installDir), Is.True); } /// @@ -102,16 +102,16 @@ public async Task UninstallTestMsi() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.MsiInstallerPackageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestMsiUninstalled(this.installDir)); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsiUninstalled(this.installDir), Is.True); } /// @@ -129,16 +129,16 @@ public async Task UninstallTestMsix() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.MsixInstallerPackageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestMsixUninstalled()); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixUninstalled(), Is.True); } /// @@ -160,19 +160,19 @@ public async Task UninstallTestMsixMachineScope() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.MsixInstallerPackageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallOptions = this.TestFactory.CreateUninstallOptions(); uninstallOptions.PackageUninstallScope = PackageUninstallScope.System; var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, uninstallOptions); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestMsixUninstalled(true)); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestMsixUninstalled(true), Is.True); } /// @@ -196,15 +196,15 @@ public async Task UninstallPortable() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.PortableExePackageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -229,15 +229,15 @@ public async Task UninstallPortableWithProductCode() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, productCode); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -261,7 +261,7 @@ public async Task UninstallPortableModifiedSymlink() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Replace symlink with modified symlink File.Delete(symlinkPath); @@ -269,12 +269,12 @@ public async Task UninstallPortableModifiedSymlink() // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.UninstallError, uninstallResult.Status); - Assert.True(modifiedSymlinkInfo.Exists, "Modified symlink should still exist"); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.UninstallError)); + Assert.That(modifiedSymlinkInfo.Exists, Is.True, "Modified symlink should still exist"); // Remove modified symlink as to not interfere with other tests modifiedSymlinkInfo.Delete(); @@ -301,16 +301,16 @@ public async Task UninstallNotIndexed() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, customProductCode); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Uninstall var uninstallResult = await this.packageManager.UninstallPackageAsync(searchResult.CatalogPackage, this.TestFactory.CreateUninstallOptions()); - Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status); - Assert.True(TestCommon.VerifyTestExeUninstalled(this.installDir)); + Assert.That(uninstallResult.Status, Is.EqualTo(UninstallResultStatus.Ok)); + Assert.That(TestCommon.VerifyTestExeUninstalled(this.installDir), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/Interop/UpgradeInterop.cs b/src/AppInstallerCLIE2ETests/Interop/UpgradeInterop.cs index 5b528506f2..779f18e0ef 100644 --- a/src/AppInstallerCLIE2ETests/Interop/UpgradeInterop.cs +++ b/src/AppInstallerCLIE2ETests/Interop/UpgradeInterop.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -46,7 +46,7 @@ public void Init() // Create composite package catalog source var options = this.TestFactory.CreateCreateCompositePackageCatalogOptions(); var testSource = this.packageManager.GetPackageCatalogByName(Constants.TestSourceName); - Assert.NotNull(testSource, $"{Constants.TestSourceName} cannot be null"); + Assert.That(testSource, Is.Not.Null, $"{Constants.TestSourceName} cannot be null"); options.Catalogs.Add(testSource); options.CompositeSearchBehavior = CompositeSearchBehavior.AllCatalogs; this.compositeSource = this.packageManager.CreateCompositePackageCatalog(options); @@ -75,11 +75,11 @@ public async Task UpgradePortable() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("1.0.0.0", searchResult.CatalogPackage.InstalledVersion?.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion?.Version, Is.EqualTo("1.0.0.0")); // Configure upgrade options var upgradeOptions = this.TestFactory.CreateInstallOptions(); @@ -87,11 +87,11 @@ public async Task UpgradePortable() // Upgrade var upgradeResult = await this.packageManager.UpgradePackageAsync(searchResult.CatalogPackage, upgradeOptions); - Assert.AreEqual(InstallResultStatus.Ok, upgradeResult.Status); + Assert.That(upgradeResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the upgraded installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("2.0.0.0", searchResult.CatalogPackage.InstalledVersion?.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion?.Version, Is.EqualTo("2.0.0.0")); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true); } @@ -118,14 +118,14 @@ public async Task UpgradePortableARPMismatch() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Modify packageId to cause mismatch. TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, "testPackageId"); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Configure upgrade options var upgradeOptions = this.TestFactory.CreateInstallOptions(); @@ -133,12 +133,12 @@ public async Task UpgradePortableARPMismatch() // Upgrade var upgradeResult = await this.packageManager.UpgradePackageAsync(searchResult.CatalogPackage, upgradeOptions); - Assert.AreEqual(InstallResultStatus.InstallError, upgradeResult.Status); - Assert.AreEqual(Constants.ErrorCode.ERROR_PORTABLE_PACKAGE_ALREADY_EXISTS, upgradeResult.ExtendedErrorCode.HResult); + Assert.That(upgradeResult.Status, Is.EqualTo(InstallResultStatus.InstallError)); + Assert.That(upgradeResult.ExtendedErrorCode.HResult, Is.EqualTo(Constants.ErrorCode.ERROR_PORTABLE_PACKAGE_ALREADY_EXISTS)); // Find package again, it should have not been upgraded searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("1.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("1.0.0.0")); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true); } @@ -165,7 +165,7 @@ public async Task UpgradePortableForcedOverride() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Modify packageId and sourceId to cause mismatch. TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, "testPackageId"); @@ -173,7 +173,7 @@ public async Task UpgradePortableForcedOverride() // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.NotNull(searchResult.CatalogPackage.InstalledVersion); + Assert.That(searchResult.CatalogPackage.InstalledVersion, Is.Not.Null); // Configure upgrade options var upgradeOptions = this.TestFactory.CreateInstallOptions(); @@ -182,11 +182,11 @@ public async Task UpgradePortableForcedOverride() // Upgrade var upgradeResult = await this.packageManager.UpgradePackageAsync(searchResult.CatalogPackage, upgradeOptions); - Assert.AreEqual(InstallResultStatus.Ok, upgradeResult.Status); + Assert.That(upgradeResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the upgraded installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("2.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("2.0.0.0")); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true); } @@ -213,11 +213,11 @@ public async Task UpgradePortableUninstallPrevious() // Install var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("1.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("1.0.0.0")); // Configure upgrade options var upgradeOptions = this.TestFactory.CreateInstallOptions(); @@ -225,11 +225,11 @@ public async Task UpgradePortableUninstallPrevious() // Upgrade var upgradeResult = await this.packageManager.UpgradePackageAsync(searchResult.CatalogPackage, upgradeOptions); - Assert.AreEqual(InstallResultStatus.Ok, upgradeResult.Status); + Assert.That(upgradeResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the upgraded installed version searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId); - Assert.AreEqual("3.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("3.0.0.0")); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true); } @@ -247,16 +247,16 @@ public async Task TestIsUpdateAvailable_ApplicableTrue() installOptions.PreferredInstallLocation = installDir; installOptions.PackageVersionId = First(searchResult.CatalogPackage.AvailableVersions, i => i.Version == "1.0.0.0"); var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version. searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller"); // The installed version is 1.0.0.0. - Assert.AreEqual("1.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("1.0.0.0")); // IsUpdateAvailable is true. - Assert.True(searchResult.CatalogPackage.IsUpdateAvailable); + Assert.That(searchResult.CatalogPackage.IsUpdateAvailable, Is.True); // Uninstall to clean up. var uninstallOptions = this.TestFactory.CreateUninstallOptions(); @@ -277,19 +277,19 @@ public async Task TestIsUpdateAvailable_ApplicableFalse() installOptions.PreferredInstallLocation = installDir; installOptions.PackageVersionId = First(searchResult.CatalogPackage.AvailableVersions, i => i.Version == "1.0.0.0"); var installResult = await this.packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions); - Assert.AreEqual(InstallResultStatus.Ok, installResult.Status); + Assert.That(installResult.Status, Is.EqualTo(InstallResultStatus.Ok)); // Find package again, but this time it should detect the installed version. searchResult = this.FindOnePackage(this.compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestUpgradeApplicability"); // The installed version is 1.0.0.0. - Assert.AreEqual("1.0.0.0", searchResult.CatalogPackage.InstalledVersion.Version); + Assert.That(searchResult.CatalogPackage.InstalledVersion.Version, Is.EqualTo("1.0.0.0")); // There is version 2.0.0.0 in the package available versions. - Assert.NotNull(First(searchResult.CatalogPackage.AvailableVersions, i => i.Version == "2.0.0.0")); + Assert.That(First(searchResult.CatalogPackage.AvailableVersions, i => i.Version == "2.0.0.0"), Is.Not.Null); // IsUpdateAvailable is false due to applicability check. Only arm64 in version 2.0.0.0. - Assert.False(searchResult.CatalogPackage.IsUpdateAvailable); + Assert.That(searchResult.CatalogPackage.IsUpdateAvailable, Is.False); // Uninstall to clean up. var uninstallOptions = this.TestFactory.CreateUninstallOptions(); diff --git a/src/AppInstallerCLIE2ETests/ListCommand.cs b/src/AppInstallerCLIE2ETests/ListCommand.cs index 35441b6741..8016f1cbb0 100644 --- a/src/AppInstallerCLIE2ETests/ListCommand.cs +++ b/src/AppInstallerCLIE2ETests/ListCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -22,9 +22,9 @@ public class ListCommand : BaseCommand public void ListSelf() { var result = TestCommon.RunAICLICommand("list", Constants.AICLIPackageFamilyName); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.AICLIPackageName)); - Assert.True(result.StdOut.Contains(Constants.AICLIPackagePublisherHash)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.AICLIPackageName), Is.True); + Assert.That(result.StdOut.Contains(Constants.AICLIPackagePublisherHash), Is.True); } /// @@ -44,16 +44,16 @@ public void ListAfterInstall() logFilePath = System.IO.Path.Combine(logFilePath, "ListAfterInstall-" + System.IO.Path.GetRandomFileName() + ".log"); var result = TestCommon.RunAICLICommand("list", productCode); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestExeInstaller --override \"/InstallDir {installDir} /ProductID {productCode} /LogFile {logFilePath} /DisplayName {displayName}\""); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", productCode); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExeInstaller")); - Assert.True(result.StdOut.Contains("1.0.0.0")); - Assert.True(result.StdOut.Contains("2.0.0.0")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"), Is.True); + Assert.That(result.StdOut.Contains("1.0.0.0"), Is.True); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True); } /// @@ -92,11 +92,11 @@ public void ListWithUpgradeCode() } var installDir = TestCommon.GetRandomTestDir(); - Assert.AreEqual(Constants.ErrorCode.S_OK, TestCommon.RunAICLICommand("install", $"TestMsiInstaller --silent -l {installDir}").ExitCode); + Assert.That(TestCommon.RunAICLICommand("install", $"TestMsiInstaller --silent -l {installDir}").ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); var result = TestCommon.RunAICLICommand("list", "TestMsiInstallerUpgradeCode"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestMsiInstallerUpgradeCode")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestMsiInstallerUpgradeCode"), Is.True); } /// @@ -110,17 +110,17 @@ public void ListWithScopeExeInstalledAsMachine() string productCode = guid.ToString(); var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"{identifier} --override \"/InstallDir {installDir} /ProductID {productCode} /UseHKLM\""); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // List with user scope will not find the package result = TestCommon.RunAICLICommand("list", $"{productCode} --scope user"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); - Assert.False(result.StdOut.Contains(identifier)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); + Assert.That(result.StdOut.Contains(identifier), Is.False); // List with machine scope will find the package result = TestCommon.RunAICLICommand("list", $"{productCode} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(identifier)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(identifier), Is.True); TestCommon.RunCommand(Path.Combine(installDir, Constants.TestExeUninstallerFileName)); } @@ -136,17 +136,17 @@ public void ListWithScopeExeInstalledAsUser() string productCode = guid.ToString(); var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"{identifier} --override \"/InstallDir {installDir} /ProductID {productCode}\""); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // List with user scope will find the package result = TestCommon.RunAICLICommand("list", $"{productCode} --scope user"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(identifier)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(identifier), Is.True); // List with machine scope will not find the package result = TestCommon.RunAICLICommand("list", $"{productCode} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); - Assert.False(result.StdOut.Contains(identifier)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); + Assert.That(result.StdOut.Contains(identifier), Is.False); TestCommon.RunCommand(Path.Combine(installDir, Constants.TestExeUninstallerFileName)); } @@ -161,17 +161,17 @@ public void ListWithScopeMsixInstalledAsMachine() Assert.Ignore(); var result = TestCommon.RunAICLICommand("install", $"{Constants.MsixInstallerPackageId} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // List with user scope will also find the package because msix is provisioned for all users result = TestCommon.RunAICLICommand("list", $"{Constants.MsixInstallerPackageId} --scope user"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.MsixInstallerPackageId)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.MsixInstallerPackageId), Is.True); // List with machine scope will find the package result = TestCommon.RunAICLICommand("list", $"{Constants.MsixInstallerPackageId} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.MsixInstallerPackageId)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.MsixInstallerPackageId), Is.True); TestCommon.RemoveMsix(Constants.MsixInstallerName, true); } @@ -183,17 +183,17 @@ public void ListWithScopeMsixInstalledAsMachine() public void ListWithScopeMsixInstalledAsUser() { var result = TestCommon.RunAICLICommand("install", $"{Constants.MsixInstallerPackageId} --scope user"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // List with user scope will find the package result = TestCommon.RunAICLICommand("list", $"{Constants.MsixInstallerPackageId} --scope user"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.MsixInstallerPackageId)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.MsixInstallerPackageId), Is.True); // List with machine scope will not find the package result = TestCommon.RunAICLICommand("list", $"{Constants.MsixInstallerPackageId} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); - Assert.False(result.StdOut.Contains(Constants.MsixInstallerPackageId)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); + Assert.That(result.StdOut.Contains(Constants.MsixInstallerPackageId), Is.False); TestCommon.RemoveMsix(Constants.MsixInstallerName); } @@ -206,22 +206,22 @@ public void ListWithMappingWithArchitecture() { var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestMappingWithArchitectureX86 -l {installDir}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // List with AppInstallerTest.TestMappingWithArchitectureX64 (from available to installed scenario) will not find the package. result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestMappingWithArchitectureX64"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); - Assert.False(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX64")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX64"), Is.False); // List with AppInstallerTest.TestMappingWithArchitectureX86 (from available to installed scenario) will find the package. result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestMappingWithArchitectureX86"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX86")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX86"), Is.True); // List with product code (from installed to available scenario) will find the AppInstallerTest.TestMappingWithArchitectureX86 package. result = TestCommon.RunAICLICommand("list", "{0e426f01-b682-4e67-a357-52f9ecb4590d}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX86")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestMappingWithArchitectureX86"), Is.True); // best effort clean up TestCommon.RunCommand(Path.Combine(installDir, Constants.TestExeUninstallerFileName)); @@ -234,19 +234,19 @@ private void ArpVersionMappingTest(string packageIdentifier, string displayNameO var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("list", productCode); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); result = TestCommon.RunAICLICommand("install", $"{packageIdentifier} --override \"/InstallDir {installDir} /ProductID {productCode} /DisplayName {displayNameOverride} /Version {displayVersionOverride}\""); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", productCode); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); - Assert.True(result.StdOut.Contains(packageIdentifier)); - Assert.True(result.StdOut.Contains(expectedListVersion)); + Assert.That(result.StdOut.Contains(packageIdentifier), Is.True); + Assert.That(result.StdOut.Contains(expectedListVersion), Is.True); if (!string.IsNullOrEmpty(notExpectedListVersion)) { - Assert.False(result.StdOut.Contains(notExpectedListVersion)); + Assert.That(result.StdOut.Contains(notExpectedListVersion), Is.False); } // Try clean up diff --git a/src/AppInstallerCLIE2ETests/Pinning.cs b/src/AppInstallerCLIE2ETests/Pinning.cs index b95e3a696b..5f96024386 100644 --- a/src/AppInstallerCLIE2ETests/Pinning.cs +++ b/src/AppInstallerCLIE2ETests/Pinning.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -54,12 +54,12 @@ public void UpgradeWithNoPins() RunCommandResult result; result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "List shows the latest available version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "List shows the latest available version"); result = TestCommon.RunAICLICommand("upgrade", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "The latest upgrade-able version is the same if there are no pins"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "The latest upgrade-able version is the same if there are no pins"); } /// @@ -72,32 +72,32 @@ public void UpgradeWithPinningPin() string installDir = Path.GetTempPath(); // The base version of this app does not log /Version, but it still includes the version number in the log file name. - Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "1.0.0.0"), "Base version installed"); + Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "1.0.0.0"), Is.True, "Base version installed"); result = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "List shows the latest available version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "List shows the latest available version"); result = TestCommon.RunAICLICommand("upgrade", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsFalse(result.StdOut.Contains("2.0.0.0"), "Pin hides latest available version"); - Assert.IsTrue(result.StdOut.Contains("package(s) have pins that prevent upgrade")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.False, "Pin hides latest available version"); + Assert.That(result.StdOut.Contains("package(s) have pins that prevent upgrade"), Is.True); result = TestCommon.RunAICLICommand("upgrade", "--all"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode, "Upgrade succeeds with nothing to upgrade"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK), "Upgrade succeeds with nothing to upgrade"); - Assert.True(TestCommon.VerifyTestExeInstalled(installDir, "1.0.0.0"), "No newer version installed"); + Assert.That(TestCommon.VerifyTestExeInstalled(installDir, "1.0.0.0"), Is.True, "No newer version installed"); result = TestCommon.RunAICLICommand("upgrade", "--include-pinned"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "Argument makes available version show up"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "Argument makes available version show up"); result = TestCommon.RunAICLICommand("upgrade", "--all --include-pinned"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode, "Upgrade succeeds"); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK), "Upgrade succeeds"); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0"), Is.True); } /// @@ -110,20 +110,20 @@ public void UpgradeWithGatingPin() string installDir = Path.GetTempPath(); var pinResult = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller --version 1.0.*"); - Assert.AreEqual(Constants.ErrorCode.S_OK, pinResult.ExitCode); + Assert.That(pinResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "List shows the latest available version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "List shows the latest available version"); result = TestCommon.RunAICLICommand("upgrade", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsFalse(result.StdOut.Contains("2.0.0.0"), "Pin hides latest available version"); - Assert.IsTrue(result.StdOut.Contains("1.0.1.0"), "Version matching pin gated version shows up"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.False, "Pin hides latest available version"); + Assert.That(result.StdOut.Contains("1.0.1.0"), Is.True, "Version matching pin gated version shows up"); result = TestCommon.RunAICLICommand("upgrade", "--all"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode, "Upgrade succeeds"); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 1.0.1.0")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK), "Upgrade succeeds"); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 1.0.1.0"), Is.True); } /// @@ -135,19 +135,19 @@ public void UpgradeWithGatingPinToCurrent() RunCommandResult result; result = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller --version 1.0.0.*"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "List shows the latest available version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "List shows the latest available version"); result = TestCommon.RunAICLICommand("upgrade", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsFalse(result.StdOut.Contains("2.0.0.0"), "Pin hides latest available version"); - Assert.IsTrue(result.StdOut.Contains("package(s) have pins that prevent upgrade")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.False, "Pin hides latest available version"); + Assert.That(result.StdOut.Contains("package(s) have pins that prevent upgrade"), Is.True); result = TestCommon.RunAICLICommand("upgrade", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.ERROR_PACKAGE_IS_PINNED, result.ExitCode, "No upgrades available due to pin"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_PACKAGE_IS_PINNED), "No upgrades available due to pin"); } /// @@ -159,18 +159,18 @@ public void UpgradeWithBlockingPin() RunCommandResult result; var pinResult = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller --blocking"); - Assert.AreEqual(Constants.ErrorCode.S_OK, pinResult.ExitCode); + Assert.That(pinResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("list", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "List shows the latest available version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "List shows the latest available version"); result = TestCommon.RunAICLICommand("upgrade", string.Empty); - Assert.IsFalse(result.StdOut.Contains("2.0.0.0"), "Pin hides latest available version"); - Assert.IsTrue(result.StdOut.Contains("package(s) have pins that prevent upgrade")); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.False, "Pin hides latest available version"); + Assert.That(result.StdOut.Contains("package(s) have pins that prevent upgrade"), Is.True); result = TestCommon.RunAICLICommand("upgrade", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.ERROR_PACKAGE_IS_PINNED, result.ExitCode, "No upgrades available due to pin"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_PACKAGE_IS_PINNED), "No upgrades available due to pin"); } /// @@ -183,15 +183,15 @@ public void ForceUpgradeWithPinningPin() string installDir = Path.GetTempPath(); result = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("upgrade", "--force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "--force argument shows latest version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "--force argument shows latest version"); result = TestCommon.RunAICLICommand("upgrade", "--all --force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0"), "--force argument installs last version despite pin"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0"), Is.True, "--force argument installs last version despite pin"); } /// @@ -204,15 +204,15 @@ public void ForceUpgradeWithGatingPin() string installDir = Path.GetTempPath(); var pinResult = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller --version 1.0.*"); - Assert.AreEqual(Constants.ErrorCode.S_OK, pinResult.ExitCode); + Assert.That(pinResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("upgrade", "--force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "--force argument shows latest version"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "--force argument shows latest version"); result = TestCommon.RunAICLICommand("upgrade", "--all --force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode, "Upgrade succeeds"); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK), "Upgrade succeeds"); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0"), Is.True); } /// @@ -225,14 +225,14 @@ public void ForceUpgradeWithBlockingPin() string installDir = Path.GetTempPath(); var pinResult = TestCommon.RunAICLICommand("pin add", "AppInstallerTest.TestExeInstaller --blocking"); - Assert.AreEqual(Constants.ErrorCode.S_OK, pinResult.ExitCode); + Assert.That(pinResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("upgrade", "--force"); - Assert.IsTrue(result.StdOut.Contains("2.0.0.0"), "--force argument shows latest version"); + Assert.That(result.StdOut.Contains("2.0.0.0"), Is.True, "--force argument shows latest version"); result = TestCommon.RunAICLICommand("upgrade", "--all --force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode, "Upgrade succeeds"); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK), "Upgrade succeeds"); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir, "/Version 2.0.0.0"), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/RepairCommand.cs b/src/AppInstallerCLIE2ETests/RepairCommand.cs index f7166d8fff..7d9f90989f 100644 --- a/src/AppInstallerCLIE2ETests/RepairCommand.cs +++ b/src/AppInstallerCLIE2ETests/RepairCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -39,8 +39,8 @@ public void RepairMSIInstaller() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestMsiRepair --silent -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); // Note: The 'msiexec repair' command requires the original installer file to be present at the location registered in the ARP (Add/Remove Programs). // In our test scenario, the MSI installer file is initially placed in a temporary location and then deleted, which can cause the repair operation to fail. @@ -50,9 +50,9 @@ public void RepairMSIInstaller() string installerSourceDir = TestCommon.CopyInstallerFileToARPInstallSourceDirectory(TestCommon.GetTestDataFile("AppInstallerTestMsiInstallerV2.msi"), Constants.MsiInstallerProductCode, true); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestMsiRepair"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir), Is.True); if (installerSourceDir != null && Directory.Exists(installerSourceDir)) { @@ -70,13 +70,13 @@ public void RepairNonStoreMSIXPackage() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestMsixInstaller --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestMsixInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup()); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestMsixInstalledAndCleanup(), Is.True); } /// @@ -94,11 +94,11 @@ public void RepairNonStoreMsixPackageWithMachineScope() Assert.Ignore("Test skipped as Microsoft.Paint_8wekyb3d8bbwe is not installed."); } - Assert.True(result.StdOut.Contains("Microsoft.Paint")); + Assert.That(result.StdOut.Contains("Microsoft.Paint"), Is.True); result = TestCommon.RunAICLICommand("repair", "Microsoft.Paint_8wekyb3d8bbwe --scope machine"); - Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALL_SYSTEM_NOT_SUPPORTED, result.ExitCode); - Assert.True(result.StdOut.Contains("The current system configuration does not support the repair of this package.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALL_SYSTEM_NOT_SUPPORTED)); + Assert.That(result.StdOut.Contains("The current system configuration does not support the repair of this package."), Is.True); } /// @@ -111,13 +111,13 @@ public void RepairBurnInstallerWithModifyBehavior() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestModifyRepair -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestModifyRepair"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Modify Repair operation")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Modify Repair operation"), Is.True); } /// @@ -130,12 +130,12 @@ public void RepairBurnInstallerInAdminContextWithUserScopeInstall() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestUserScopeInstallRepairInAdminContext -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestUserScopeInstallRepairInAdminContext"); - Assert.AreEqual(Constants.ErrorCode.ERROR_ADMIN_CONTEXT_REPAIR_PROHIBITED, result.ExitCode); - Assert.True(result.StdOut.Contains("The package installed for user scope cannot be repaired when running with administrator privileges.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_ADMIN_CONTEXT_REPAIR_PROHIBITED)); + Assert.That(result.StdOut.Contains("The package installed for user scope cannot be repaired when running with administrator privileges."), Is.True); TestCommon.CleanupTestExeAndDirectory(installDir); } @@ -149,12 +149,12 @@ public void RepairBurnInstallerMissingRepairBehavior() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestMissingRepairBehavior -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestMissingRepairBehavior"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_REPAIR_INFO_FOUND, result.ExitCode); - Assert.True(result.StdOut.Contains("The repair command for this package cannot be found. Please reach out to the package publisher for support.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_REPAIR_INFO_FOUND)); + Assert.That(result.StdOut.Contains("The repair command for this package cannot be found. Please reach out to the package publisher for support."), Is.True); TestCommon.CleanupTestExeAndDirectory(installDir); } @@ -168,12 +168,12 @@ public void RepairBurnInstallerWithWithModifyBehaviorAndNoModifyFlag() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestModifyRepairWithNoModify -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestModifyRepairWithNoModify"); - Assert.AreEqual(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED, result.ExitCode); - Assert.True(result.StdOut.Contains("The installer technology in use does not support repair.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED)); + Assert.That(result.StdOut.Contains("The installer technology in use does not support repair."), Is.True); TestCommon.CleanupTestExeAndDirectory(installDir); } @@ -190,12 +190,12 @@ public void RepairOperationNotSupportedForPortableInstaller() 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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestPortableExe"); - Assert.AreEqual(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED, result.ExitCode); - Assert.True(result.StdOut.Contains("The installer technology in use does not support repair.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED)); + Assert.That(result.StdOut.Contains("The installer technology in use does not support repair."), 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); @@ -211,13 +211,13 @@ public void RepairExeInstallerWithUninstallerBehavior() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.UninstallerRepair -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.UninstallerRepair"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Uninstaller Repair operation")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Uninstaller Repair operation"), Is.True); } /// @@ -230,12 +230,12 @@ public void RepairExeInstallerWithUninstallerBehaviorAndNoRepairFlag() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.UninstallerRepairWithNoRepair -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.UninstallerRepairWithNoRepair"); - Assert.AreEqual(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED, result.ExitCode); - Assert.True(result.StdOut.Contains("The installer technology in use does not support repair.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_REPAIR_NOT_SUPPORTED)); + Assert.That(result.StdOut.Contains("The installer technology in use does not support repair."), Is.True); TestCommon.CleanupTestExeAndDirectory(installDir); } @@ -249,13 +249,13 @@ public void RepairNullsoftInstallerWithUninstallerBehavior() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.UninstallerRepair -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.UninstallerRepair"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Uninstaller Repair operation")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Uninstaller Repair operation"), Is.True); } /// @@ -268,13 +268,13 @@ public void RepairInnoInstallerWithInstallerBehavior() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestInstallerRepair -v 2.0.0.0 --silent -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); result = TestCommon.RunAICLICommand("repair", "AppInstallerTest.TestInstallerRepair"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Repair operation completed successfully")); - Assert.True(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Installer Repair operation")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Repair operation completed successfully"), Is.True); + Assert.That(TestCommon.VerifyTestExeRepairCompletedAndCleanup(installDir, "Installer Repair operation"), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/ResumeCommand.cs b/src/AppInstallerCLIE2ETests/ResumeCommand.cs index 6f39c78908..a3bf1ef980 100644 --- a/src/AppInstallerCLIE2ETests/ResumeCommand.cs +++ b/src/AppInstallerCLIE2ETests/ResumeCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -47,14 +47,14 @@ public void InstallExe_VerifyIndexDoesNotExist() 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); int actualCheckpointsCount = Directory.GetFiles(checkpointsDir).Length; // The checkpoints count should not change as the index file should be cleaned up after a successful install. - Assert.AreEqual(initialCheckpointsCount, actualCheckpointsCount); + Assert.That(actualCheckpointsCount, Is.EqualTo(initialCheckpointsCount)); } /// @@ -64,7 +64,7 @@ public void InstallExe_VerifyIndexDoesNotExist() public void ResumeIdNotFound() { var resumeResult = TestCommon.RunAICLICommand("resume", "-g invalidResumeId"); - Assert.AreEqual(Constants.ErrorCode.ERROR_RESUME_ID_NOT_FOUND, resumeResult.ExitCode); + Assert.That(resumeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_RESUME_ID_NOT_FOUND)); } /// @@ -80,14 +80,14 @@ public void InstallRequiresRebootToFinish() var result = TestCommon.RunAICLICommand("install", $"TestRebootRequired --custom \"/ExitCode 9\" -l {installDir}"); // REBOOT_REQUIRED_TO_FINISH is treated as a success. - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Restart your PC to finish installation.")); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Restart your PC to finish installation."), Is.True); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.True); int actualCheckpointsCount = Directory.GetDirectories(checkpointsDir).Length; // Checkpoint database should be cleaned up since resume is not needed to complete installation. - Assert.AreEqual(initialCheckpointsCount, actualCheckpointsCount); + Assert.That(actualCheckpointsCount, Is.EqualTo(initialCheckpointsCount)); } /// @@ -102,12 +102,12 @@ public void InstallRequiresRebootForInstall() var installDir = TestCommon.GetRandomTestDir(); var result = TestCommon.RunAICLICommand("install", $"TestRebootRequired --custom \"/ExitCode 10\" -l {installDir}"); - Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL, result.ExitCode); - Assert.True(result.StdOut.Contains("Your PC will restart to finish installation.")); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL)); + Assert.That(result.StdOut.Contains("Your PC will restart to finish installation."), Is.True); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.True); int actualCheckpointsCount = Directory.GetDirectories(checkpointsDir).Length; - Assert.AreEqual(initialCheckpointsCount + 1, actualCheckpointsCount); + Assert.That(actualCheckpointsCount, Is.EqualTo(initialCheckpointsCount + 1)); var checkpointsDirectoryInfo = new DirectoryInfo(checkpointsDir); @@ -117,9 +117,9 @@ public void InstallRequiresRebootForInstall() // Resume output should be the same as the install result. var resumeResult = TestCommon.RunAICLICommand("resume", $"-g {checkpoint.Name}"); - Assert.AreEqual(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL, resumeResult.ExitCode); - Assert.True(resumeResult.StdOut.Contains("Your PC will restart to finish installation.")); - Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir)); + Assert.That(resumeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INSTALL_REBOOT_REQUIRED_FOR_INSTALL)); + Assert.That(resumeResult.StdOut.Contains("Your PC will restart to finish installation."), Is.True); + Assert.That(TestCommon.VerifyTestExeInstalledAndCleanup(installDir), Is.True); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/SearchCommand.cs b/src/AppInstallerCLIE2ETests/SearchCommand.cs index 4a64ec26fd..8750c8f11a 100644 --- a/src/AppInstallerCLIE2ETests/SearchCommand.cs +++ b/src/AppInstallerCLIE2ETests/SearchCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -21,7 +21,7 @@ public class SearchCommand : BaseCommand public void SearchWithoutArgs() { var result = TestCommon.RunAICLICommand("search", string.Empty); - Assert.AreEqual(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS)); } /// @@ -31,9 +31,9 @@ public void SearchWithoutArgs() public void SearchQuery() { var result = TestCommon.RunAICLICommand("search", "TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -42,9 +42,9 @@ public void SearchQuery() public void SearchUsingAlias() { var result = TestCommon.RunAICLICommand("find", "TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -54,9 +54,9 @@ public void SearchUsingAlias() public void SearchWithName() { var result = TestCommon.RunAICLICommand("search", "--name testexampleinstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -66,9 +66,9 @@ public void SearchWithName() public void SearchWithID() { var result = TestCommon.RunAICLICommand("search", "--id appinstallertest.testexampleinstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -78,8 +78,8 @@ public void SearchWithID() public void SearchWithInvalidName() { var result = TestCommon.RunAICLICommand("search", "--name InvalidName"); - 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); } /// @@ -90,10 +90,10 @@ public void SearchReturnsMultiple() { // Search Microsoft should return multiple var result = TestCommon.RunAICLICommand("search", "AppInstallerTest"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExeInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestBurnInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExeInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestBurnInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -103,9 +103,9 @@ public void SearchReturnsMultiple() public void SearchWithExactName() { var result = TestCommon.RunAICLICommand("search", "--exact TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -115,9 +115,9 @@ public void SearchWithExactName() public void SearchWithExactID() { var result = TestCommon.RunAICLICommand("search", "--exact AppInstallerTest.TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -127,8 +127,8 @@ public void SearchWithExactID() public void SearchWithExactArgCaseSensitivity() { var result = TestCommon.RunAICLICommand("search", "--exact testexampleinstaller"); - 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); } /// @@ -142,10 +142,10 @@ public void SearchWithSingleSourceFailure() try { var result = TestCommon.RunAICLICommand("search", "--exact AppInstallerTest.TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Failed when searching source; results will not be included: failSearch")); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Failed when searching source; results will not be included: failSearch"), Is.True); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } finally { @@ -205,7 +205,7 @@ public void SearchStoreWithBadPin() try { var result = TestCommon.RunAICLICommand("search", $"-s {Constants.TestAlternateSourceName} foo --verbose-logs"); - Assert.AreEqual(Constants.ErrorCode.ERROR_PINNED_CERTIFICATE_MISMATCH, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_PINNED_CERTIFICATE_MISMATCH)); } finally { diff --git a/src/AppInstallerCLIE2ETests/SetUpFixture.cs b/src/AppInstallerCLIE2ETests/SetUpFixture.cs index ae52b7da35..8f5b3fa22e 100644 --- a/src/AppInstallerCLIE2ETests/SetUpFixture.cs +++ b/src/AppInstallerCLIE2ETests/SetUpFixture.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -45,11 +45,11 @@ public void Setup() { if (testParams.LooseFileRegistration) { - Assert.True(TestCommon.InstallMsixRegister(testParams.AICLIPackagePath), $"InstallMsixRegister : {testParams.AICLIPackagePath}"); + Assert.That(TestCommon.InstallMsixRegister(testParams.AICLIPackagePath), Is.True, $"InstallMsixRegister : {testParams.AICLIPackagePath}"); } else { - Assert.True(TestCommon.InstallMsix(testParams.AICLIPackagePath), $"InstallMsix : {testParams.AICLIPackagePath}"); + Assert.That(TestCommon.InstallMsix(testParams.AICLIPackagePath), Is.True, $"InstallMsix : {testParams.AICLIPackagePath}"); } } } diff --git a/src/AppInstallerCLIE2ETests/ShowCommand.cs b/src/AppInstallerCLIE2ETests/ShowCommand.cs index 1452e6aa1f..13cd58a7c0 100644 --- a/src/AppInstallerCLIE2ETests/ShowCommand.cs +++ b/src/AppInstallerCLIE2ETests/ShowCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -21,7 +21,7 @@ public class ShowCommand : BaseCommand public void ShowWithNoArgs() { var result = TestCommon.RunAICLICommand("show", string.Empty); - Assert.AreEqual(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_INVALID_CL_ARGUMENTS)); } /// @@ -32,8 +32,8 @@ public void ShowWithNoMatches() { // Show with 0 search match shows a "please refine input" var result = TestCommon.RunAICLICommand("show", $"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); } /// @@ -44,8 +44,8 @@ public void ShowWithSubstringMatch() { // Show with a substring match still returns 0 results var result = TestCommon.RunAICLICommand("show", $"AppInstallerTest"); - 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); } /// @@ -55,10 +55,10 @@ public void ShowWithSubstringMatch() public void ShowWithNameMatch() { var result = TestCommon.RunAICLICommand("show", $"--name testexampleinstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]")); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"), Is.True); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -68,10 +68,10 @@ public void ShowWithNameMatch() public void ShowWithIDMatch() { var result = TestCommon.RunAICLICommand("show", $"--id appinstallertest.testexampleinstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]")); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"), Is.True); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -82,10 +82,10 @@ public void ShowWithVersions() { // Show with --versions list the versions var result = TestCommon.RunAICLICommand("show", $"TestExampleInstaller --versions"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); - Assert.True(result.StdOut.Contains("1.2.3.4")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("1.2.3.4"), Is.True); } /// @@ -95,10 +95,10 @@ public void ShowWithVersions() public void ShowWithExactName() { var result = TestCommon.RunAICLICommand("show", $"--exact TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]")); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"), Is.True); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -108,10 +108,10 @@ public void ShowWithExactName() public void ShowWithExactID() { var result = TestCommon.RunAICLICommand("show", $"--exact AppInstallerTest.TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]")); - Assert.True(result.StdOut.Contains("TestExampleInstaller")); - Assert.True(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestExampleInstaller [AppInstallerTest.TestExampleInstaller]"), Is.True); + Assert.That(result.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(result.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); } /// @@ -121,8 +121,8 @@ public void ShowWithExactID() public void ShowWithExactArgCaseSensitivity() { var result = TestCommon.RunAICLICommand("show", $"--exact testexampleinstaller"); - 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); } /// @@ -132,9 +132,9 @@ public void ShowWithExactArgCaseSensitivity() public void ShowWithInstallerTypeArg() { var result = TestCommon.RunAICLICommand("show", $"--id AppInstallerTest.TestMultipleInstallers --installer-type msi"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]")); - Assert.True(result.StdOut.Contains("Installer Type: msi")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]"), Is.True); + Assert.That(result.StdOut.Contains("Installer Type: msi"), Is.True); } /// @@ -144,9 +144,9 @@ public void ShowWithInstallerTypeArg() public void ShowWithZipInstallerTypeArg() { var result = TestCommon.RunAICLICommand("show", $"--id AppInstallerTest.TestMultipleInstallers --installer-type zip"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]")); - Assert.True(result.StdOut.Contains("Installer Type: exe (zip)")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Found TestMultipleInstallers [AppInstallerTest.TestMultipleInstallers]"), Is.True); + Assert.That(result.StdOut.Contains("Installer Type: exe (zip)"), Is.True); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/SourceCommand.cs b/src/AppInstallerCLIE2ETests/SourceCommand.cs index 6f7a424d2e..c3d1e2a4f9 100644 --- a/src/AppInstallerCLIE2ETests/SourceCommand.cs +++ b/src/AppInstallerCLIE2ETests/SourceCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -43,8 +43,8 @@ public void SourceAdd() Assert.Ignore(); var result = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), Is.True); TestCommon.RunAICLICommand("source remove", $"-n SourceTest"); } @@ -58,13 +58,13 @@ public void SourceAddWithTrustLevel() TestCommon.RunAICLICommand("source remove", Constants.TestSourceName); var result = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl} --trust-level trusted"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), Is.True); var listResult = TestCommon.RunAICLICommand("source list", $"-n SourceTest"); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult.ExitCode); - Assert.True(listResult.StdOut.Contains("Trust Level")); - Assert.True(listResult.StdOut.Contains("Trusted")); + Assert.That(listResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(listResult.StdOut.Contains("Trust Level"), Is.True); + Assert.That(listResult.StdOut.Contains("Trusted"), Is.True); TestCommon.RunAICLICommand("source remove", $"-n SourceTest"); } @@ -78,8 +78,8 @@ public void SourceAddWithStoreOriginTrustLevel() TestCommon.RunAICLICommand("source remove", Constants.TestSourceName); var result = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl} --trust-level storeOrigin"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_DATA_INTEGRITY_FAILURE, result.ExitCode); - Assert.True(result.StdOut.Contains("The source data is corrupted or tampered")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_DATA_INTEGRITY_FAILURE)); + Assert.That(result.StdOut.Contains("The source data is corrupted or tampered"), Is.True); } /// @@ -92,17 +92,17 @@ public void SourceAddWithExplicit() TestCommon.RunAICLICommand("source remove", Constants.TestSourceName); var result = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl} --trust-level trusted --explicit"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), 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); var searchResult2 = TestCommon.RunAICLICommand("search", "TestExampleInstaller --source SourceTest"); - Assert.AreEqual(Constants.ErrorCode.S_OK, searchResult2.ExitCode); - Assert.True(searchResult2.StdOut.Contains("TestExampleInstaller")); - Assert.True(searchResult2.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(searchResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(searchResult2.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(searchResult2.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); TestCommon.RunAICLICommand("source remove", $"-n SourceTest"); } @@ -116,16 +116,16 @@ public void SourceAddWithPriority() TestCommon.RunAICLICommand("source remove", Constants.TestSourceName); var result = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl} --priority 42"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), Is.True); var listResult = TestCommon.RunAICLICommand("source list", "SourceTest"); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult.ExitCode); - Assert.True(listResult.StdOut.Contains("42")); + Assert.That(listResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(listResult.StdOut.Contains("42"), Is.True); var exportResult = TestCommon.RunAICLICommand("source export", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult.ExitCode); - Assert.True(exportResult.StdOut.Contains("42")); + Assert.That(listResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(exportResult.StdOut.Contains("42"), Is.True); } /// @@ -136,8 +136,8 @@ public void SourceAddWithDuplicateName() { // Add source with duplicate name should fail var result = TestCommon.RunAICLICommand("source add", $"{Constants.TestSourceName} https://microsoft.com"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_ALREADY_EXISTS, result.ExitCode); - Assert.True(result.StdOut.Contains("A source with the given name already exists and refers to a different location")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_ALREADY_EXISTS)); + Assert.That(result.StdOut.Contains("A source with the given name already exists and refers to a different location"), Is.True); } /// @@ -148,8 +148,8 @@ public void SourceAddWithDuplicateSourceUrl() { // Add source with duplicate url should fail var result = TestCommon.RunAICLICommand("source add", $"TestSource2 {Constants.TestSourceUrl}"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_ARG_ALREADY_EXISTS, result.ExitCode); - Assert.True(result.StdOut.Contains("A source with a different name already refers to this location")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_ARG_ALREADY_EXISTS)); + Assert.That(result.StdOut.Contains("A source with a different name already refers to this location"), Is.True); } /// @@ -160,8 +160,8 @@ public void SourceAddWithInvalidURL() { // Add source with invalid url should fail var result = TestCommon.RunAICLICommand("source add", $"AnotherSource {Constants.TestSourceUrl}/Invalid/Directory/Dont/Add/Me"); - Assert.AreEqual(Constants.ErrorCode.HTTP_E_STATUS_NOT_FOUND, result.ExitCode); - Assert.True(result.StdOut.Contains("An unexpected error occurred while executing the command")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.HTTP_E_STATUS_NOT_FOUND)); + Assert.That(result.StdOut.Contains("An unexpected error occurred while executing the command"), Is.True); } /// @@ -172,8 +172,8 @@ public void SourceAddWithHttpURL() { // Add source with an HTTP url should fail var result = TestCommon.RunAICLICommand("source add", "Insecure http://microsoft.com"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NOT_SECURE, result.ExitCode); - Assert.True(result.StdOut.Contains("error occurred while executing the command")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NOT_SECURE)); + Assert.That(result.StdOut.Contains("error occurred while executing the command"), Is.True); } /// @@ -184,8 +184,8 @@ public void SourceListWithNoArgs() { // List with no args should list all available sources var result = TestCommon.RunAICLICommand("source list", string.Empty); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.TestSourceUrl)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.TestSourceUrl), Is.True); } /// @@ -195,12 +195,12 @@ public void SourceListWithNoArgs() public void SourceListWithName() { var result = TestCommon.RunAICLICommand("source list", $"-n {Constants.TestSourceName}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains(Constants.TestSourceName)); - Assert.True(result.StdOut.Contains(Constants.TestSourceUrl)); - Assert.True(result.StdOut.Contains("Microsoft.PreIndexed.Package")); - Assert.True(result.StdOut.Contains("Trust Level")); - Assert.True(result.StdOut.Contains("Updated")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains(Constants.TestSourceName), Is.True); + Assert.That(result.StdOut.Contains(Constants.TestSourceUrl), Is.True); + Assert.That(result.StdOut.Contains("Microsoft.PreIndexed.Package"), Is.True); + Assert.That(result.StdOut.Contains("Trust Level"), Is.True); + Assert.That(result.StdOut.Contains("Updated"), Is.True); } /// @@ -210,8 +210,8 @@ public void SourceListWithName() public void SourceListNameMismatch() { var result = TestCommon.RunAICLICommand("source list", "-n UnknownName"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode); - Assert.True(result.StdOut.Contains("Did not find a source named")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST)); + Assert.That(result.StdOut.Contains("Did not find a source named"), Is.True); } /// @@ -221,8 +221,8 @@ public void SourceListNameMismatch() public void SourceUpdate() { var result = TestCommon.RunAICLICommand("source update", $"-n {Constants.TestSourceName}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), Is.True); } /// @@ -232,8 +232,8 @@ public void SourceUpdate() public void SourceUpdateWithInvalidName() { var result = TestCommon.RunAICLICommand("source update", "-n UnknownName"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode); - Assert.True(result.StdOut.Contains("Did not find a source named: UnknownName")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST)); + Assert.That(result.StdOut.Contains("Did not find a source named: UnknownName"), Is.True); } /// @@ -243,8 +243,8 @@ public void SourceUpdateWithInvalidName() public void SourceRemoveValidName() { var result = TestCommon.RunAICLICommand("source remove", $"-n {Constants.TestSourceName}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Done"), Is.True); this.ResetTestSource(false); } @@ -255,8 +255,8 @@ public void SourceRemoveValidName() public void SourceRemoveInvalidName() { var result = TestCommon.RunAICLICommand("source remove", "-n UnknownName"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, result.ExitCode); - Assert.True(result.StdOut.Contains("Did not find a source named: UnknownName")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST)); + Assert.That(result.StdOut.Contains("Did not find a source named: UnknownName"), Is.True); } /// @@ -266,9 +266,9 @@ public void SourceRemoveInvalidName() public void SourceReset() { var result = TestCommon.RunAICLICommand("source reset", string.Empty); - Assert.True(result.StdOut.Contains("The following sources will be reset if the --force option is given:")); - Assert.True(result.StdOut.Contains(Constants.TestSourceName)); - Assert.True(result.StdOut.Contains(Constants.TestSourceUrl)); + Assert.That(result.StdOut.Contains("The following sources will be reset if the --force option is given:"), Is.True); + Assert.That(result.StdOut.Contains(Constants.TestSourceName), Is.True); + Assert.That(result.StdOut.Contains(Constants.TestSourceUrl), Is.True); } /// @@ -279,15 +279,15 @@ public void SourceForceReset() { // Force Reset Sources var result = TestCommon.RunAICLICommand("source reset", "--force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Resetting all sources...Done")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Resetting all sources...Done"), Is.True); // Verify sources have been reset result = TestCommon.RunAICLICommand("source list", string.Empty); - Assert.True(result.StdOut.Contains("winget")); - Assert.True(result.StdOut.Contains("https://cdn.winget.microsoft.com/cache")); - Assert.False(result.StdOut.Contains(Constants.TestSourceName)); - Assert.False(result.StdOut.Contains(Constants.TestSourceUrl)); + Assert.That(result.StdOut.Contains("winget"), Is.True); + Assert.That(result.StdOut.Contains("https://cdn.winget.microsoft.com/cache"), Is.True); + Assert.That(result.StdOut.Contains(Constants.TestSourceName), Is.False); + Assert.That(result.StdOut.Contains(Constants.TestSourceUrl), Is.False); } /// @@ -301,28 +301,28 @@ public void SourceEdit() // Add source as explicit and verify it is explicit. var addResult = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl} --trust-level trusted --explicit"); - Assert.AreEqual(Constants.ErrorCode.S_OK, addResult.ExitCode); - Assert.True(addResult.StdOut.Contains("Done")); + Assert.That(addResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(addResult.StdOut.Contains("Done"), 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); // Run the edit, this should be S_OK with "Done" as it changed the state to not-explicit. var editResult = TestCommon.RunAICLICommand("source edit", $"SourceTest --explicit false"); - Assert.AreEqual(Constants.ErrorCode.S_OK, editResult.ExitCode); - Assert.True(editResult.StdOut.Contains("Explicit")); + Assert.That(editResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(editResult.StdOut.Contains("Explicit"), Is.True); // Run it again, this should result in S_OK with no changes and a message that the source is already in that state. var editResult2 = TestCommon.RunAICLICommand("source edit", $"SourceTest --explicit false"); - Assert.AreEqual(Constants.ErrorCode.S_OK, editResult2.ExitCode); - Assert.True(editResult2.StdOut.Contains("The source named 'SourceTest' is already in the desired state.")); + Assert.That(editResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(editResult2.StdOut.Contains("The source named 'SourceTest' is already in the desired state."), Is.True); // Now verify it is no longer explicit by running the search again without adding the source parameter. var searchResult2 = TestCommon.RunAICLICommand("search", "TestExampleInstaller"); - Assert.AreEqual(Constants.ErrorCode.S_OK, searchResult2.ExitCode); - Assert.True(searchResult2.StdOut.Contains("TestExampleInstaller")); - Assert.True(searchResult2.StdOut.Contains("AppInstallerTest.TestExampleInstaller")); + Assert.That(searchResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(searchResult2.StdOut.Contains("TestExampleInstaller"), Is.True); + Assert.That(searchResult2.StdOut.Contains("AppInstallerTest.TestExampleInstaller"), Is.True); TestCommon.RunAICLICommand("source remove", $"-n SourceTest"); } @@ -336,18 +336,18 @@ public void SourceEdit_Priority() TestCommon.RunAICLICommand("source remove", Constants.TestSourceName); var addResult = TestCommon.RunAICLICommand("source add", $"SourceTest {Constants.TestSourceUrl}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, addResult.ExitCode); - Assert.True(addResult.StdOut.Contains("Done")); + Assert.That(addResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(addResult.StdOut.Contains("Done"), Is.True); // Run the edit, this should be S_OK with "Done" as it changed the state var editResult = TestCommon.RunAICLICommand("source edit", $"SourceTest --priority 14"); - Assert.AreEqual(Constants.ErrorCode.S_OK, editResult.ExitCode); - Assert.True(editResult.StdOut.Contains("14")); + Assert.That(editResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(editResult.StdOut.Contains("14"), Is.True); // Run it again, this should result in S_OK with no changes and a message that the source is already in that state. var editResult2 = TestCommon.RunAICLICommand("source edit", $"SourceTest --priority 14"); - Assert.AreEqual(Constants.ErrorCode.S_OK, editResult2.ExitCode); - Assert.True(editResult2.StdOut.Contains("The source named 'SourceTest' is already in the desired state.")); + Assert.That(editResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(editResult2.StdOut.Contains("The source named 'SourceTest' is already in the desired state."), Is.True); } /// @@ -358,38 +358,38 @@ public void SourceEditOverrideDefault() { // Force Reset Sources var resetResult = TestCommon.RunAICLICommand("source reset", "--force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, resetResult.ExitCode); + Assert.That(resetResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // Verify it is explicit true. Explicit is the only boolean value in the output. var listResult = TestCommon.RunAICLICommand("source list", "winget-font"); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult.ExitCode); - Assert.True(listResult.StdOut.Contains("true")); + Assert.That(listResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(listResult.StdOut.Contains("true"), Is.True); var editResult = TestCommon.RunAICLICommand("source edit", "winget-font -e false"); - Assert.AreEqual(Constants.ErrorCode.S_OK, editResult.ExitCode); - Assert.True(editResult.StdOut.Contains("Explicit")); + Assert.That(editResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(editResult.StdOut.Contains("Explicit"), Is.True); // Verify that after edit it is now explicit false. var listResult2 = TestCommon.RunAICLICommand("source list", "winget-font"); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult2.ExitCode); - Assert.True(listResult2.StdOut.Contains("false")); + Assert.That(listResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(listResult2.StdOut.Contains("false"), Is.True); // Remove the source. This should correctly tombstone it, even though it is overridden. var removeResult = TestCommon.RunAICLICommand("source remove", "winget-font"); - Assert.AreEqual(Constants.ErrorCode.S_OK, removeResult.ExitCode); - Assert.True(removeResult.StdOut.Contains("Done")); + Assert.That(removeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(removeResult.StdOut.Contains("Done"), Is.True); var listResult3 = TestCommon.RunAICLICommand("source list", "winget-font"); - Assert.AreEqual(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST, listResult3.ExitCode); + Assert.That(listResult3.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_SOURCE_NAME_DOES_NOT_EXIST)); // Force Reset Sources var resetResult2 = TestCommon.RunAICLICommand("source reset", "--force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, resetResult2.ExitCode); + Assert.That(resetResult2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); // Verify it is back to being explicit true. var listResult4 = TestCommon.RunAICLICommand("source list", "winget-font"); - Assert.AreEqual(Constants.ErrorCode.S_OK, listResult4.ExitCode); - Assert.True(listResult4.StdOut.Contains("true")); + Assert.That(listResult4.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(listResult4.StdOut.Contains("true"), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/UninstallCommand.cs b/src/AppInstallerCLIE2ETests/UninstallCommand.cs index 4a8f70134d..a58f258862 100644 --- a/src/AppInstallerCLIE2ETests/UninstallCommand.cs +++ b/src/AppInstallerCLIE2ETests/UninstallCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -37,9 +37,9 @@ public void UninstallTestExe() var installDir = TestCommon.GetRandomTestDir(); TestCommon.RunAICLICommand("install", $"{Constants.ExeInstallerPackageId} --silent -l {installDir}"); var result = TestCommon.RunAICLICommand("uninstall", Constants.ExeInstallerPackageId); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); - Assert.True(TestCommon.VerifyTestExeUninstalled(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); + Assert.That(TestCommon.VerifyTestExeUninstalled(installDir), Is.True); } /// @@ -57,9 +57,9 @@ public void UninstallTestMsi() var installDir = TestCommon.GetRandomTestDir(); TestCommon.RunAICLICommand("install", $"{Constants.MsiInstallerPackageId} -l {installDir}"); var result = TestCommon.RunAICLICommand("uninstall", Constants.MsiInstallerPackageId); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); - Assert.True(TestCommon.VerifyTestMsiUninstalled(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); + Assert.That(TestCommon.VerifyTestMsiUninstalled(installDir), Is.True); } /// @@ -71,9 +71,9 @@ public void UninstallTestMsix() // Uninstall an MSIX TestCommon.RunAICLICommand("install", Constants.MsixInstallerPackageId); var result = TestCommon.RunAICLICommand("uninstall", Constants.MsixInstallerPackageId); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); - Assert.True(TestCommon.VerifyTestMsixUninstalled()); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); + Assert.That(TestCommon.VerifyTestMsixUninstalled(), Is.True); } /// @@ -88,9 +88,9 @@ public void UninstallTestMsixMachineScope() // Uninstall an MSIX TestCommon.RunAICLICommand("install", $"{Constants.MsixInstallerPackageId} --scope machine"); var result = TestCommon.RunAICLICommand("uninstall", $"{Constants.MsixInstallerPackageId} --scope machine"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); - Assert.True(TestCommon.VerifyTestMsixUninstalled(true)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); + Assert.That(TestCommon.VerifyTestMsixUninstalled(true), Is.True); } /// @@ -108,8 +108,8 @@ public void UninstallPortable() TestCommon.RunAICLICommand("install", $"{packageId}"); var result = TestCommon.RunAICLICommand("uninstall", $"{packageId}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -128,8 +128,8 @@ public void UninstallPortableWithProductCode() TestCommon.RunAICLICommand("install", $"{packageId}"); var result = TestCommon.RunAICLICommand("uninstall", $"--product-code {productCode}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -155,15 +155,15 @@ public void UninstallPortableModifiedSymlink() FileSystemInfo modifiedSymlinkInfo = File.CreateSymbolicLink(symlinkPath, "fakeTargetExe"); var result = TestCommon.RunAICLICommand("uninstall", $"{packageId}"); - Assert.AreEqual(Constants.ErrorCode.ERROR_PORTABLE_UNINSTALL_FAILED, result.ExitCode); - Assert.True(result.StdOut.Contains("Unable to remove Portable package as it has been modified; to override this check use --force")); - Assert.True(modifiedSymlinkInfo.Exists, "Modified symlink should still exist"); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_PORTABLE_UNINSTALL_FAILED)); + Assert.That(result.StdOut.Contains("Unable to remove Portable package as it has been modified; to override this check use --force"), Is.True); + Assert.That(modifiedSymlinkInfo.Exists, Is.True, "Modified symlink should still exist"); // Try again with --force var result2 = TestCommon.RunAICLICommand("uninstall", $"{packageId} --force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result2.ExitCode); - Assert.True(result2.StdOut.Contains("Portable package has been modified; proceeding due to --force")); - Assert.True(result2.StdOut.Contains("Successfully uninstalled")); + Assert.That(result2.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result2.StdOut.Contains("Portable package has been modified; proceeding due to --force"), Is.True); + Assert.That(result2.StdOut.Contains("Successfully uninstalled"), Is.True); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -183,8 +183,8 @@ public void UninstallZip_Portable() var testResult = TestCommon.RunAICLICommand("install", $"{packageId}"); var result = TestCommon.RunAICLICommand("uninstall", $"{packageId}"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false); } @@ -200,9 +200,9 @@ public void UninstallNotIndexed() var installDir = TestCommon.GetRandomTestDir(); TestCommon.RunAICLICommand("install", $"{Constants.ExeInstallerPackageId} --override \"/ProductID {CustomProductCode} /InstallDir {installDir}"); var result = TestCommon.RunAICLICommand("uninstall", CustomProductCode); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Successfully uninstalled")); - Assert.True(TestCommon.VerifyTestExeUninstalled(installDir)); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Successfully uninstalled"), Is.True); + Assert.That(TestCommon.VerifyTestExeUninstalled(installDir), Is.True); } /// @@ -213,8 +213,8 @@ public void UninstallAppNotInstalled() { // Verify failure when trying to uninstall an app that is not installed. var result = TestCommon.RunAICLICommand("uninstall", $"TestMsixInstaller"); - Assert.AreEqual(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND, result.ExitCode); - Assert.True(result.StdOut.Contains("No installed package found matching input criteria.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_NO_APPLICATIONS_FOUND)); + Assert.That(result.StdOut.Contains("No installed package found matching input criteria."), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/UpgradeCommand.cs b/src/AppInstallerCLIE2ETests/UpgradeCommand.cs index 4a62e0b7e2..8c56c829ab 100644 --- a/src/AppInstallerCLIE2ETests/UpgradeCommand.cs +++ b/src/AppInstallerCLIE2ETests/UpgradeCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -40,12 +40,12 @@ public void UpgradePortable() commandAlias = fileName = "AppInstallerTestExeInstaller.exe"; var result = TestCommon.RunAICLICommand("install", "AppInstallerTest.TestPortableExe -v 1.0.0.0"); - 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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0"); - 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); } @@ -62,12 +62,12 @@ public void UpgradePortableNonAsciiPath() commandAlias = fileName = "AppInstallerTestExeInstaller.exe"; var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestPortableExe -v 1.0.0.0 -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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0 -l {installDir}"); - 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(installDir, commandAlias, fileName, productCode, true); } @@ -81,8 +81,8 @@ public void UpgradePortableARPMismatch() string productCode = packageId + "_" + Constants.TestSourceIdentifier; var installResult = TestCommon.RunAICLICommand("install", "AppInstallerTest.TestPortableExe -v 1.0.0.0"); - 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); // Modify packageId to cause mismatch. TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, "testPackageId"); @@ -93,8 +93,8 @@ public void UpgradePortableARPMismatch() TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, packageId); TestCommon.RunAICLICommand("uninstall", $"--product-code {productCode}"); - Assert.AreNotEqual(Constants.ErrorCode.S_OK, upgradeResult.ExitCode); - Assert.True(upgradeResult.StdOut.Contains("Portable package from a different source already exists")); + Assert.That(upgradeResult.ExitCode, Is.Not.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(upgradeResult.StdOut.Contains("Portable package from a different source already exists"), Is.True); } /// @@ -110,16 +110,16 @@ public void UpgradePortableForcedOverride() commandAlias = fileName = "AppInstallerTestExeInstaller.exe"; var installResult = TestCommon.RunAICLICommand("install", "AppInstallerTest.TestPortableExe -v 1.0.0.0"); - 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); // Modify packageId and sourceId to cause mismatch. TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, "testPackageId"); TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetSourceIdentifier, "testSourceId"); var upgradeResult = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0 --force"); - Assert.AreEqual(Constants.ErrorCode.S_OK, upgradeResult.ExitCode); - Assert.True(upgradeResult.StdOut.Contains("Successfully installed")); + Assert.That(upgradeResult.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(upgradeResult.StdOut.Contains("Successfully installed"), Is.True); TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true); } @@ -136,12 +136,12 @@ public void UpgradePortableUninstallPrevious() commandAlias = fileName = "AppInstallerTestExeInstaller.exe"; var result = TestCommon.RunAICLICommand("install", $"{packageId} -v 1.0.0.0"); - 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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 3.0.0.0"); - 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); } @@ -154,12 +154,12 @@ public void UpgradeBehaviorDeny() string packageId = DenyUpgradePackage; var result = TestCommon.RunAICLICommand("install", $"{packageId} -v 1.0.0.0"); - 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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0"); - Assert.AreEqual(Constants.ErrorCode.APPINSTALLER_CLI_ERROR_INSTALL_UPGRADE_NOT_SUPPORTED, result2.ExitCode); - Assert.True(result2.StdOut.Contains("package cannot be upgraded using WinGet")); + Assert.That(result2.ExitCode, Is.EqualTo(Constants.ErrorCode.APPINSTALLER_CLI_ERROR_INSTALL_UPGRADE_NOT_SUPPORTED)); + Assert.That(result2.StdOut.Contains("package cannot be upgraded using WinGet"), Is.True); } /// @@ -177,13 +177,13 @@ public void UpgradePortableMachineScope() commandAlias = fileName = "AppInstallerTestExeInstaller.exe"; var result = TestCommon.RunAICLICommand("install", $"{packageId} -v 1.0.0.0 --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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0"); WinGetSettingsHelper.ConfigureInstallBehavior(Constants.PortablePackageMachineRoot, string.Empty); - 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, TestCommon.Scope.Machine); } @@ -201,12 +201,12 @@ public void UpgradeZip_Portable() fileName = "AppInstallerTestExeInstaller.exe"; var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestZipInstallerWithPortable -v 1.0.0.0"); - 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); var result2 = TestCommon.RunAICLICommand("upgrade", $"{packageId} -v 2.0.0.0"); - 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, TestCommon.Scope.User); } @@ -217,10 +217,10 @@ public void UpgradeZip_Portable() public void UpgradeAddsDependency() { var result = TestCommon.RunAICLICommand("install", $"AppInstallerTest.TestUpgradeAddsDependency -v 1.0 --verbose"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); result = TestCommon.RunAICLICommand("upgrade", $"AppInstallerTest.TestUpgradeAddsDependency"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); } } } diff --git a/src/AppInstallerCLIE2ETests/ValidateCommand.cs b/src/AppInstallerCLIE2ETests/ValidateCommand.cs index 725da15a41..e5c2c12c11 100644 --- a/src/AppInstallerCLIE2ETests/ValidateCommand.cs +++ b/src/AppInstallerCLIE2ETests/ValidateCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -21,8 +21,8 @@ public class ValidateCommand : BaseCommand public void ValidateManifest() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestValidManifest.yaml")); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded."), Is.True); } /// @@ -31,9 +31,9 @@ public void ValidateManifest() [Test] public void ValidateManifestWithExtendedCharacter() { - var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TëstExeInstaller.yaml")); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded.")); + var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TëstExeInstaller.yaml")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded."), Is.True); } /// @@ -43,8 +43,8 @@ public void ValidateManifestWithExtendedCharacter() public void ValidateInvalidManifest() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestInvalidManifest.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_FAILURE, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation failed.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_FAILURE)); + Assert.That(result.StdOut.Contains("Manifest validation failed."), Is.True); } /// @@ -54,8 +54,8 @@ public void ValidateInvalidManifest() public void ValidateManifestWithWarnings() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifest.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); } /// @@ -65,9 +65,9 @@ public void ValidateManifestWithWarnings() public void ValidateManifestSuppressWarnings() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifest.yaml") + " --ignore-warnings"); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); - Assert.False(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest validation succeeded.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.False); + Assert.That(result.StdOut.Contains("Manifest validation succeeded."), Is.True); } /// @@ -77,8 +77,8 @@ public void ValidateManifestSuppressWarnings() public void ValidateManifestDoesNotExist() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\DoesNotExist")); - Assert.AreEqual(Constants.ErrorCode.ERROR_PATH_NOT_FOUND, result.ExitCode); - Assert.True(result.StdOut.Contains("Path does not exist")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_PATH_NOT_FOUND)); + Assert.That(result.StdOut.Contains("Path does not exist"), Is.True); } /// @@ -88,29 +88,29 @@ public void ValidateManifestDoesNotExist() public void ValidateManifestV1_10_SchemaHeaderExpectWarnings() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderNotFound.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest Warning: Schema header not found.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); + Assert.That(result.StdOut.Contains("Manifest Warning: Schema header not found."), Is.True); result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderInvalid.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest Warning: The schema header is invalid. Please verify that the schema header is present and formatted correctly.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); + Assert.That(result.StdOut.Contains("Manifest Warning: The schema header is invalid. Please verify that the schema header is present and formatted correctly."), Is.True); result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderURLPatternMismatch.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest Warning: The schema header URL does not match the expected pattern")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); + Assert.That(result.StdOut.Contains("Manifest Warning: The schema header URL does not match the expected pattern"), Is.True); result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderManifestTypeMismatch.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest Warning: The manifest type in the schema header does not match the ManifestType property value in the manifest.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); + Assert.That(result.StdOut.Contains("Manifest Warning: The manifest type in the schema header does not match the ManifestType property value in the manifest."), Is.True); result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifestV1_10-SchemaHeaderVersionMismatch.yaml")); - Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode); - Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings.")); - Assert.True(result.StdOut.Contains("Manifest Warning: The manifest version in the schema header does not match the ManifestVersion property value in the manifest.")); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING)); + Assert.That(result.StdOut.Contains("Manifest validation succeeded with warnings."), Is.True); + Assert.That(result.StdOut.Contains("Manifest Warning: The manifest version in the schema header does not match the ManifestVersion property value in the manifest."), Is.True); } /// @@ -120,7 +120,7 @@ public void ValidateManifestV1_10_SchemaHeaderExpectWarnings() public void ValidateManifestV1_10_SchemaHeaderExpectNoWarning() { var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestGoodManifestV1_10-SchemaHeader.yaml")); - Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode); + Assert.That(result.ExitCode, Is.EqualTo(Constants.ErrorCode.S_OK)); } } } \ No newline at end of file diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilCompareVersions.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilCompareVersions.cs index 85a51c36ab..7a2fee8a6d 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilCompareVersions.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilCompareVersions.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -39,7 +39,7 @@ public void WinGetUtil_CompareVersions(string version1, string version2, int exp { // Compare versions WinGetUtilWrapper.WinGetCompareVersions(version1, version2, out int result); - Assert.AreEqual(expectedResult, result); + Assert.That(result, Is.EqualTo(expectedResult)); } } } diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilDownload.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilDownload.cs index ea09e2af10..204ca2b72e 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilDownload.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilDownload.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -30,8 +30,8 @@ public void WinGetUtil_Download() // Download WinGetUtilWrapper.WinGetDownload(installerUrl, filePath, sha256Hash, hashSize); - Assert.True(File.Exists(filePath)); - Assert.False(sha256Hash.All(byteVal => byteVal == 0)); + Assert.That(File.Exists(filePath), Is.True); + Assert.That(sha256Hash.All(byteVal => byteVal == 0), Is.False); } } } diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilInstallerMetadataCollection.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilInstallerMetadataCollection.cs index 2542644a7f..0f94f4410e 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilInstallerMetadataCollection.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilInstallerMetadataCollection.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -34,8 +34,8 @@ public void WinGetUtil_BeginCompleteInstallerMetadataCollection() WinGetUtilWrapper.WinGetBeginInstallerMetadataCollectionOptions.WinGetBeginInstallerMetadataCollectionOption_InputIsFilePath, out IntPtr collectionHandle); - Assert.AreNotEqual(IntPtr.Zero, collectionHandle); - Assert.True(File.Exists(logFilePath)); + Assert.That(collectionHandle, Is.Not.EqualTo(IntPtr.Zero)); + Assert.That(File.Exists(logFilePath), Is.True); WinGetUtilWrapper.WinGetCompleteInstallerMetadataCollection( collectionHandle, @@ -43,7 +43,7 @@ public void WinGetUtil_BeginCompleteInstallerMetadataCollection() WinGetUtilWrapper.WinGetCompleteInstallerMetadataCollectionOptions.WinGetCompleteInstallerMetadataCollectionOption_None); string outputJson = File.ReadAllText(outputFilePath); - Assert.IsNotEmpty(JsonConvert.DeserializeObject(outputJson).ToString()); + Assert.That(JsonConvert.DeserializeObject(outputJson).ToString(), Is.Not.Empty); } /// @@ -63,8 +63,8 @@ public void WinGetUtil_MergeInstallerMetadata_Success() logFilePath, WinGetUtilWrapper.WinGetMergeInstallerMetadataOptions.WinGetMergeInstallerMetadataOptions_None); - Assert.True(File.Exists(logFilePath)); - Assert.IsNotEmpty(JsonConvert.DeserializeObject(outputJson).ToString()); + Assert.That(File.Exists(logFilePath), Is.True); + Assert.That(JsonConvert.DeserializeObject(outputJson).ToString(), Is.Not.Empty); } /// @@ -77,7 +77,7 @@ public void WinGetUtil_MergeInstallerMetadata_Fail_SubmissionMismatch() string inputJsonPath = TestCommon.GetTestDataFile(@"WinGetUtil\InstallerMetadata\MergeSubmissionMismatch.json"); string inputJson = File.ReadAllText(inputJsonPath); - Assert.Throws(() => + Assert.That((Action)(() => { WinGetUtilWrapper.WinGetMergeInstallerMetadata( inputJson, @@ -85,9 +85,9 @@ public void WinGetUtil_MergeInstallerMetadata_Fail_SubmissionMismatch() 0, logFilePath, WinGetUtilWrapper.WinGetMergeInstallerMetadataOptions.WinGetMergeInstallerMetadataOptions_None); - }); + }), Throws.TypeOf()); - Assert.True(File.Exists(logFilePath)); + Assert.That(File.Exists(logFilePath), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilLog.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilLog.cs index 1e932f19ed..bbfd89cb53 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilLog.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilLog.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -25,7 +25,7 @@ public void WinGetUtil_Logging() // Init logging WinGetUtilWrapper.WinGetLoggingInit(filePath); - Assert.True(File.Exists(filePath)); + Assert.That(File.Exists(filePath), Is.True); // Terminate logging WinGetUtilWrapper.WinGetLoggingTerm(filePath); diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilManifest.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilManifest.cs index 16cdd8c5a7..4a251b40a6 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilManifest.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilManifest.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -61,10 +61,10 @@ public void WinGetUtil_ValidateManifest_Success(WinGetUtilWrapper.CreateManifest mergedManifestPath, createManifestOption); - Assert.True(succeeded); - Assert.AreNotEqual(IntPtr.Zero, manifestHandle); - Assert.IsNull(createFailureMessage); - Assert.True(File.Exists(mergedManifestPath)); + Assert.That(succeeded, Is.True); + Assert.That(manifestHandle, Is.Not.EqualTo(IntPtr.Zero)); + Assert.That(createFailureMessage, Is.Null); + Assert.That(File.Exists(mergedManifestPath), Is.True); // Validate manifest WinGetUtilWrapper.WinGetValidateManifestV3( @@ -75,8 +75,8 @@ public void WinGetUtil_ValidateManifest_Success(WinGetUtilWrapper.CreateManifest WinGetUtilWrapper.ValidateManifestOptionV2.ArpVersionValidation, WinGetUtilWrapper.ValidateManifestOperationType.Add); - Assert.AreEqual(WinGetUtilWrapper.ValidateManifestResultCode.Success, resultCode); - Assert.IsEmpty(validateFailureMessage); + Assert.That(resultCode, Is.EqualTo(WinGetUtilWrapper.ValidateManifestResultCode.Success)); + Assert.That(validateFailureMessage, Is.Empty); // Close manifest WinGetUtilWrapper.WinGetCloseManifest(manifestHandle); @@ -102,9 +102,9 @@ public void WinGetUtil_ValidateManifest_V1_10_WithSchemaHeader_Success(WinGetUti string.Empty, createManifestOption); - Assert.True(succeeded); - Assert.AreNotEqual(IntPtr.Zero, manifestHandle); - Assert.IsNull(createFailureMessage); + Assert.That(succeeded, Is.True); + Assert.That(manifestHandle, Is.Not.EqualTo(IntPtr.Zero)); + Assert.That(createFailureMessage, Is.Null); // Close manifest WinGetUtilWrapper.WinGetCloseManifest(manifestHandle); @@ -155,10 +155,10 @@ private static void ValidateSchemaHeaderFailure(string manifestsFilePath, WinGet string.Empty, createManifestOption); - Assert.False(succeeded); - Assert.AreEqual(IntPtr.Zero, manifestHandle); - Assert.IsNotNull(createFailureMessage); - Assert.IsTrue(createFailureMessage.Contains(expectedError)); + Assert.That(succeeded, Is.False); + Assert.That(manifestHandle, Is.EqualTo(IntPtr.Zero)); + Assert.That(createFailureMessage, Is.Not.Null); + Assert.That(createFailureMessage.Contains(expectedError), Is.True); } } } diff --git a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilSQLiteIndex.cs b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilSQLiteIndex.cs index 9f1e4fd4cd..f99efd50b4 100644 --- a/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilSQLiteIndex.cs +++ b/src/AppInstallerCLIE2ETests/WinGetUtil/WinGetUtilSQLiteIndex.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -62,7 +62,7 @@ public void WinGetUtil_SQLiteIndex_UpdateManifest_Success() // Update manifest WinGetUtilWrapper.WinGetSQLiteIndexUpdateManifest(indexHandle, this.updateManifestsFile, this.relativePath, out bool indexModified); - Assert.True(indexModified); + Assert.That(indexModified, Is.True); }); } @@ -75,10 +75,10 @@ public void WinGetUtil_SQLiteIndex_UpdateManifest_Fail_NotFound() this.SQLiteIndex((indexHandle) => { // Update non-existing manifest - Assert.Throws(() => + Assert.That((Action)(() => { WinGetUtilWrapper.WinGetSQLiteIndexUpdateManifest(indexHandle, this.updateManifestsFile, this.relativePath, out bool indexModified); - }); + }), Throws.TypeOf()); }); } @@ -107,10 +107,10 @@ public void WinGetUtil_SQLiteIndex_RemoveManifest_Fail_NotFound() this.SQLiteIndex((indexHandle) => { // Remove non-existing manifest - Assert.Throws(() => + Assert.That((Action)(() => { WinGetUtilWrapper.WinGetSQLiteIndexRemoveManifest(indexHandle, this.addManifestsFile, this.relativePath); - }); + }), Throws.TypeOf()); }); } @@ -149,7 +149,7 @@ public void WinGetUtil_SQLiteIndex_CheckConsistency() // Check consistency WinGetUtilWrapper.WinGetSQLiteIndexCheckConsistency(indexHandle, out bool succeeded); - Assert.True(succeeded); + Assert.That(succeeded, Is.True); }); } @@ -161,8 +161,8 @@ private void SQLiteIndex(Action execute) { // Create WinGetUtilWrapper.WinGetSQLiteIndexCreate(this.sqlitePath, this.majorVersion, this.minorVersion, out IntPtr indexHandle); - Assert.True(File.Exists(this.sqlitePath)); - Assert.AreNotEqual(IntPtr.Zero, indexHandle); + Assert.That(File.Exists(this.sqlitePath), Is.True); + Assert.That(indexHandle, Is.Not.EqualTo(IntPtr.Zero)); // Execute provided function execute(indexHandle); diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 7d9a37b900..717a086f81 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -22,8 +22,8 @@ - - + + diff --git a/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs b/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs index 79f7d75c6e..56cebee8d7 100644 --- a/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs +++ b/src/Microsoft.Management.Configuration.UnitTests/Tests/ConfigurationProcessorTelemetryTests.cs @@ -17,6 +17,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests using Microsoft.Management.Configuration.UnitTests.Helpers; using Microsoft.VisualBasic; using Microsoft.VisualStudio.TestPlatform.ObjectModel; + using TelemetryEvent = Microsoft.Management.Configuration.UnitTests.Helpers.TelemetryEvent; using Xunit; using Xunit.Abstractions; using static System.Collections.Specialized.BitVector32; diff --git a/src/WinGetUtilInterop.UnitTests/WinGetUtilInterop.UnitTests.csproj b/src/WinGetUtilInterop.UnitTests/WinGetUtilInterop.UnitTests.csproj index c30dc8e518..f412199740 100644 --- a/src/WinGetUtilInterop.UnitTests/WinGetUtilInterop.UnitTests.csproj +++ b/src/WinGetUtilInterop.UnitTests/WinGetUtilInterop.UnitTests.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -11,6 +11,7 @@ + From 86a30492fa17b32ff7751f278400ac36bc3114ea Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Mon, 15 Jun 2026 21:25:45 -0500 Subject: [PATCH 2/3] Bump version of ApplicationInsights as required by NUnit --- src/Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 717a086f81..baf25809b7 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -9,7 +9,7 @@ - + From d31b42fef38847efea5e8c2b2cef2d0285de46ae Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Mon, 15 Jun 2026 21:40:16 -0500 Subject: [PATCH 3/3] Release Notes --- doc/ReleaseNotes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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