From c3b8bca411a76b25906f30b1a777b72d50ba0c33 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Tue, 17 Oct 2023 12:50:41 +0000 Subject: [PATCH 1/4] Update dependencies from https://github.com/dotnet/arcade build 20231016.5 Microsoft.DotNet.Arcade.Sdk From Version 8.0.0-beta.23463.1 -> To Version 9.0.0-beta.23516.5 Dependency coherency updates Microsoft.DotNet.XliffTasks From Version 1.0.0-beta.23426.1 -> To Version 1.0.0-beta.23509.1 (parent: Microsoft.DotNet.Arcade.Sdk --- eng/Version.Details.xml | 4 ++-- eng/common/build.sh | 2 +- eng/common/cross/build-rootfs.sh | 2 +- eng/common/cross/riscv64/tizen/tizen.patch | 9 +++++++++ eng/common/cross/tizen-build-rootfs.sh | 21 +++++++++++++++++++++ eng/common/cross/tizen-fetch.sh | 17 ++++++++++++++--- eng/common/cross/toolchain.cmake | 19 +++++++++++++------ eng/common/sdk-task.ps1 | 2 +- eng/common/templates/job/job.yml | 2 +- eng/common/tools.ps1 | 4 ++-- global.json | 4 ++-- 11 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 eng/common/cross/riscv64/tizen/tizen.patch diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ed899324b8..2008c022df 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -29,9 +29,9 @@ - + https://github.com/dotnet/arcade - 0e89c8d7ddbb54510d9d0a757fda5126021b79f0 + a672b7bba499394acf218dc59171e2d53e754237 diff --git a/eng/common/build.sh b/eng/common/build.sh index 50af40cdd2..2c17ba529b 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -105,7 +105,7 @@ while [[ $# > 0 ]]; do -binarylog|-bl) binary_log=true ;; - -excludeCIBinarylog|-nobl) + -excludecibinarylog|-nobl) exclude_ci_binary_log=true ;; -pipelineslog|-pl) diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 9caf9b021d..4228f202e5 100755 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -487,7 +487,7 @@ if [[ "$__CodeName" == "alpine" ]]; then -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \ - search 'llvm*-libs' | sort | tail -1 | sed 's/-[^-]*//2g')" + search 'llvm*-libs' | grep -E '^llvm' | sort | tail -1 | sed 's/-[^-]*//2g')" fi # install all packages in one go diff --git a/eng/common/cross/riscv64/tizen/tizen.patch b/eng/common/cross/riscv64/tizen/tizen.patch new file mode 100644 index 0000000000..eb6d1c0747 --- /dev/null +++ b/eng/common/cross/riscv64/tizen/tizen.patch @@ -0,0 +1,9 @@ +diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so +--- a/usr/lib64/libc.so 2016-12-30 23:00:08.284951863 +0900 ++++ b/usr/lib64/libc.so 2016-12-30 23:00:32.140951815 +0900 +@@ -2,4 +2,4 @@ + Use the shared library, but some functions are only in + the static library, so try that secondarily. */ + OUTPUT_FORMAT(elf64-littleriscv) +-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-riscv64-lp64d.so.1 ) ) ++GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-riscv64-lp64d.so.1 ) ) diff --git a/eng/common/cross/tizen-build-rootfs.sh b/eng/common/cross/tizen-build-rootfs.sh index ac84173d44..ba31c93285 100644 --- a/eng/common/cross/tizen-build-rootfs.sh +++ b/eng/common/cross/tizen-build-rootfs.sh @@ -22,6 +22,10 @@ case "$ARCH" in TIZEN_ARCH="x86_64" LINK_ARCH="x86" ;; + riscv64) + TIZEN_ARCH="riscv64" + LINK_ARCH="riscv" + ;; *) echo "Unsupported architecture for tizen: $ARCH" exit 1 @@ -58,4 +62,21 @@ rm -rf $TIZEN_TMP_DIR echo ">>Start configuring Tizen rootfs" ln -sfn asm-${LINK_ARCH} ./usr/include/asm patch -p1 < $__TIZEN_CROSSDIR/tizen.patch +if [[ "$TIZEN_ARCH" == "riscv64" ]]; then + echo "Fixing broken symlinks in $PWD" + rm ./usr/lib64/libresolv.so + ln -s ../../lib64/libresolv.so.2 ./usr/lib64/libresolv.so + rm ./usr/lib64/libpthread.so + ln -s ../../lib64/libpthread.so.0 ./usr/lib64/libpthread.so + rm ./usr/lib64/libdl.so + ln -s ../../lib64/libdl.so.2 ./usr/lib64/libdl.so + rm ./usr/lib64/libutil.so + ln -s ../../lib64/libutil.so.1 ./usr/lib64/libutil.so + rm ./usr/lib64/libm.so + ln -s ../../lib64/libm.so.6 ./usr/lib64/libm.so + rm ./usr/lib64/librt.so + ln -s ../../lib64/librt.so.1 ./usr/lib64/librt.so + rm ./lib/ld-linux-riscv64-lp64d.so.1 + ln -s ../lib64/ld-linux-riscv64-lp64d.so.1 ./lib/ld-linux-riscv64-lp64d.so.1 +fi echo "< Date: Tue, 17 Oct 2023 18:18:52 -0700 Subject: [PATCH 2/4] Fix dotnet_diagnostic.xUnit2020.severity errors. --- .editorconfig | 5 ++--- test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs | 2 +- .../ValueFormTests/TemplateJsonDefinedFormsTests.cs | 4 ++-- .../NuGetTests.cs | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index 67136b82ee..ae68ddadb7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -204,6 +204,8 @@ dotnet_diagnostic.IDE0290.severity = suggestion dotnet_diagnostic.IDE0300.severity = suggestion #Collection initialization can be simplified dotnet_diagnostic.IDE0301.severity = suggestion +#Collection initialization can be simplified +dotnet_diagnostic.IDE0305.severity = suggestion # License header file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license. @@ -593,9 +595,6 @@ dotnet_diagnostic.xUnit2013.severity = suggestion # Do not use obsolete throws check to check for asynchronously thrown exception dotnet_diagnostic.xUnit2019.severity = warning -# Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. -dotnet_diagnostic.xUnit2020.severity = suggestion - # test code files [test/**/*.{cs,vb}] # Use literals where appropriate diff --git a/test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs b/test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs index 6343cb267f..43fe88da60 100644 --- a/test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs +++ b/test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs @@ -70,7 +70,7 @@ protected static void Verify(Encoding encoding, Stream output, bool changed, str string modifier = expectedChange ? string.Empty : "not "; if (expectedChange ^ changed) { - Assert.False(true, $"Expected value to {modifier} be changed"); + Assert.Fail($"Expected value to {modifier} be changed"); } } } diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/TemplateJsonDefinedFormsTests.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/TemplateJsonDefinedFormsTests.cs index 4b18294b67..1ebb94acf0 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/TemplateJsonDefinedFormsTests.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/ValueFormTests/TemplateJsonDefinedFormsTests.cs @@ -50,7 +50,7 @@ public void UnknownFormNameOnParameterSymbolDoesNotThrow() } catch { - Assert.True(false, "Should not throw on unknown value form name"); + Assert.Fail("Should not throw on unknown value form name"); } Assert.NotNull(runConfig); @@ -94,7 +94,7 @@ public void UnknownFormNameForDerivedSymbolValueDoesThrow() } catch { - Assert.True(false, "Should not throw on unknown value form name"); + Assert.Fail("Should not throw on unknown value form name"); } Assert.NotNull(runConfig); diff --git a/test/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs b/test/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs index a233ec85be..1096a22487 100644 --- a/test/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs +++ b/test/Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/NuGetTests.cs @@ -44,7 +44,7 @@ public async Task CanReadPackageInfo() } else { - Assert.True(false, "HTTP request failed."); + Assert.Fail("HTTP request failed."); } } } From c8d5b57920af8a76a35373925122c56af73fe3c5 Mon Sep 17 00:00:00 2001 From: Michael Yanni Date: Tue, 17 Oct 2023 18:44:04 -0700 Subject: [PATCH 3/4] Fix dotnet_diagnostic.xUnit2013.severity errors. --- .editorconfig | 3 - .../ScannerTests.cs | 12 ++-- .../TemplateConstraintManagerTests.cs | 2 +- .../TemplatePackageManagerTests.cs | 4 +- .../ConfigurationTests.cs | 2 +- .../TemplatePackagesTests.cs | 68 +++++++++---------- .../MacroTests/GeneratePortMacroTests.cs | 10 +-- .../MacroTests/NowMacroTests.cs | 4 +- .../MacroTests/RandomMacroTests.cs | 4 +- .../CustomConditionalTests.cs | 18 ++--- .../TemplateConfigTests/FileRenameTests.cs | 2 +- .../TemplateConfigTests/PostActionTests.cs | 4 +- .../TemplateConfigTests/SourceConfigTests.cs | 8 +-- .../TemplateConfigTests/SymbolConfigTests.cs | 2 +- .../NuGetMetadataSearchProviderTests.cs | 20 +++--- .../TemplateSearchCacheReaderTests.cs | 6 +- 16 files changed, 83 insertions(+), 86 deletions(-) diff --git a/.editorconfig b/.editorconfig index ae68ddadb7..e4814101db 100644 --- a/.editorconfig +++ b/.editorconfig @@ -589,9 +589,6 @@ dotnet_diagnostic.xUnit1031.severity = suggestion # Do not use invalid equality check dotnet_diagnostic.xUnit2001.severity = warning -# Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. -dotnet_diagnostic.xUnit2013.severity = suggestion - # Do not use obsolete throws check to check for asynchronously thrown exception dotnet_diagnostic.xUnit2019.severity = warning diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs index 8cf326cca2..7140516d2b 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/ScannerTests.cs @@ -33,9 +33,9 @@ public async Task CanLogValidationMessagesOnInstall_MissingIdentity() ScanResult result = await scanner.ScanAsync(templatesLocation, default).ConfigureAwait(false); - Assert.Equal(0, result.Templates.Count); + Assert.Empty(result.Templates); #pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal(0, result.Localizations.Count); + Assert.Empty(result.Localizations); #pragma warning restore CS0618 // Type or member is obsolete string errorMessage = Assert.Single(loggedMessages, l => l.Level is LogLevel.Error).Message; @@ -56,9 +56,9 @@ public async Task CanLogValidationMessagesOnInstall_ErrorsInTemplateConfig() ScanResult result = await scanner.ScanAsync(templatesLocation, default).ConfigureAwait(false); - Assert.Equal(0, result.Templates.Count); + Assert.Empty(result.Templates); #pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal(0, result.Localizations.Count); + Assert.Empty(result.Localizations); #pragma warning restore CS0618 // Type or member is obsolete List errorMessages = loggedMessages.Where(lm => lm.Level == LogLevel.Error).Select(e => e.Message).ToList(); @@ -108,9 +108,9 @@ public async Task CanLogValidationMessagesOnInstall_Localization() ScanResult result = await scanner.ScanAsync(templatesLocation, default).ConfigureAwait(false); - Assert.Equal(1, result.Templates.Count); + Assert.Single(result.Templates); #pragma warning disable CS0618 // Type or member is obsolete - Assert.Equal(0, result.Localizations.Count); + Assert.Empty(result.Localizations); #pragma warning restore CS0618 // Type or member is obsolete List errorMessages = loggedMessages.Where(lm => lm.Level == LogLevel.Error).Select(e => e.Message).OrderBy(em => em).ToList(); diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs index 7054f071c9..d398b3bf21 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplateConstraintManagerTests.cs @@ -81,7 +81,7 @@ public async Task CanGetConstraints_Filter() var constraints = await constraintManager.GetConstraintsAsync(new[] { templateInfo }, default).ConfigureAwait(false); - Assert.Equal(1, constraints.Count); + Assert.Single(constraints); Assert.Equal("test-1", constraints.Single().Type); } diff --git a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplatePackageManagerTests.cs b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplatePackageManagerTests.cs index e9051ce781..60fc11584f 100644 --- a/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplatePackageManagerTests.cs +++ b/test/Microsoft.TemplateEngine.Edge.UnitTests/TemplatePackageManagerTests.cs @@ -47,7 +47,7 @@ public async Task OrderOfScanningIsCorrect() var templates = await new TemplatePackageManager(engineEnvironmentSettings).GetTemplatesAsync(default) .ConfigureAwait(false); - Assert.Equal(1, templates.Count); + Assert.Single(templates); Assert.Equal("sample99", templates.Single().ShortNameList[0]); } @@ -78,7 +78,7 @@ public async Task OrderOfScanningIsCorrectWithPriority() var templates = await new TemplatePackageManager(engineEnvironmentSettings).GetTemplatesAsync(default) .ConfigureAwait(false); - Assert.Equal(1, templates.Count); + Assert.Single(templates); Assert.Equal("sample49", templates.Single().ShortNameList[0]); } diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/ConfigurationTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/ConfigurationTests.cs index 40d3f0cf2e..ef403a90c8 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/ConfigurationTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/ConfigurationTests.cs @@ -61,7 +61,7 @@ internal async Task VirtualConfigurationTest() InstallRequest installRequest = new InstallRequest("Microsoft.DotNet.Web.ProjectTemplates.5.0", "5.0.0"); IReadOnlyList installResult = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, installResult.Count); + Assert.Single(installResult); Assert.True(installResult[0].Success); bootstrapper.Dispose(); diff --git a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/TemplatePackagesTests.cs b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/TemplatePackagesTests.cs index 1c9f251a0b..f81e6be403 100644 --- a/test/Microsoft.TemplateEngine.IDE.IntegrationTests/TemplatePackagesTests.cs +++ b/test/Microsoft.TemplateEngine.IDE.IntegrationTests/TemplatePackagesTests.cs @@ -59,7 +59,7 @@ internal async Task CanInstall_LocalNuGetPackage() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -75,12 +75,12 @@ internal async Task CanInstall_LocalNuGetPackage() IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, templatePackages.Count); + Assert.Single(templatePackages); Assert.IsAssignableFrom(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)source); } @@ -99,7 +99,7 @@ internal async Task CanInstall_RemoteNuGetPackage() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); Assert.True(string.IsNullOrEmpty(result[0].ErrorMessage)); @@ -116,12 +116,12 @@ internal async Task CanInstall_RemoteNuGetPackage() IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, templatePackages.Count); + Assert.Single(templatePackages); Assert.IsAssignableFrom(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)source); } @@ -136,7 +136,7 @@ internal async Task CanInstall_Folder() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -151,12 +151,12 @@ internal async Task CanInstall_Folder() IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, templatePackages.Count); + Assert.Single(templatePackages); Assert.IsAssignableFrom(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)source); } @@ -169,13 +169,13 @@ internal async Task CanCheckForLatestVersion_NuGetPackage() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); IManagedTemplatePackage? source = result[0].TemplatePackage; Assert.NotNull(source); IReadOnlyList checkUpdateResults = await bootstrapper.GetLatestVersionsAsync(new[] { source! }, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, checkUpdateResults.Count); + Assert.Single(checkUpdateResults); Assert.True(checkUpdateResults[0].Success); Assert.Equal(InstallerErrorCode.Success, checkUpdateResults[0].Error); Assert.True(string.IsNullOrEmpty(checkUpdateResults[0].ErrorMessage)); @@ -194,13 +194,13 @@ internal async Task CanCheckForLatestVersion_Folder() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); IManagedTemplatePackage? source = result[0].TemplatePackage; Assert.NotNull(source); IReadOnlyList checkUpdateResults = await bootstrapper.GetLatestVersionsAsync(new[] { source! }, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, checkUpdateResults.Count); + Assert.Single(checkUpdateResults); Assert.True(checkUpdateResults[0].Success); Assert.Equal(InstallerErrorCode.Success, checkUpdateResults[0].Error); Assert.True(string.IsNullOrEmpty(checkUpdateResults[0].ErrorMessage)); @@ -265,7 +265,7 @@ internal async Task CanUpdate_NuGetPackage() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); IManagedTemplatePackage? source = result[0].TemplatePackage; Assert.NotNull(source); @@ -273,7 +273,7 @@ internal async Task CanUpdate_NuGetPackage() IReadOnlyList updateResults = await bootstrapper.UpdateTemplatePackagesAsync(new[] { updateRequest }, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, updateResults.Count); + Assert.Single(updateResults); Assert.True(updateResults[0].Success); Assert.Equal(InstallerErrorCode.Success, updateResults[0].Error); Assert.True(string.IsNullOrEmpty(updateResults[0].ErrorMessage)); @@ -287,12 +287,12 @@ internal async Task CanUpdate_NuGetPackage() IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(updatedSource); IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, templatePackages.Count); + Assert.Single(templatePackages); Assert.IsAssignableFrom(templatePackages[0]); templatePackages[0].Should().BeEquivalentTo((ITemplatePackage)updatedSource); } @@ -305,18 +305,18 @@ internal async Task CanUninstall_NuGetPackage() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); IManagedTemplatePackage? source = result[0].TemplatePackage; Assert.NotNull(source); IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList uninstallResults = await bootstrapper.UninstallTemplatePackagesAsync(new[] { source! }, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, uninstallResults.Count); + Assert.Single(uninstallResults); Assert.True(uninstallResults[0].Success); Assert.Equal(InstallerErrorCode.Success, uninstallResults[0].Error); uninstallResults[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -324,7 +324,7 @@ internal async Task CanUninstall_NuGetPackage() IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(0, templatePackages.Count); + Assert.Empty(templatePackages); } [Fact] @@ -337,7 +337,7 @@ internal async Task CanUninstall_Folder() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); IManagedTemplatePackage? source = result[0].TemplatePackage; Assert.NotNull(source); @@ -345,12 +345,12 @@ internal async Task CanUninstall_Folder() IReadOnlyList managedTemplatesPackages = await bootstrapper.GetManagedTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, managedTemplatesPackages.Count); + Assert.Single(managedTemplatesPackages); managedTemplatesPackages[0].Should().BeEquivalentTo(source); IReadOnlyList uninstallResults = await bootstrapper.UninstallTemplatePackagesAsync(new[] { source }, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, uninstallResults.Count); + Assert.Single(uninstallResults); Assert.True(uninstallResults[0].Success); Assert.Equal(InstallerErrorCode.Success, uninstallResults[0].Error); uninstallResults[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -358,7 +358,7 @@ internal async Task CanUninstall_Folder() IReadOnlyList templatePackages = await bootstrapper.GetTemplatePackagesAsync(CancellationToken.None).ConfigureAwait(false); - Assert.Equal(0, templatePackages.Count); + Assert.Empty(templatePackages); Directory.Exists(templateLocation); } @@ -373,7 +373,7 @@ internal async Task CanReInstallPackage_WhenForceIsSpecified() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -383,7 +383,7 @@ internal async Task CanReInstallPackage_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -393,7 +393,7 @@ internal async Task CanReInstallPackage_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequestWithoutForce }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.False(result[0].Success); Assert.Equal(InstallerErrorCode.DownloadFailed, result[0].Error); } @@ -406,7 +406,7 @@ internal async Task CanReInstallRemotePackage_WhenForceIsSpecified() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); Assert.True(string.IsNullOrEmpty(result[0].ErrorMessage)); @@ -416,7 +416,7 @@ internal async Task CanReInstallRemotePackage_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -426,7 +426,7 @@ internal async Task CanReInstallRemotePackage_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequestWithoutForce }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.False(result[0].Success); Assert.Equal(InstallerErrorCode.AlreadyInstalled, result[0].Error); } @@ -441,7 +441,7 @@ internal async Task CanReInstallFolder_WhenForceIsSpecified() IReadOnlyList result = await bootstrapper.InstallTemplatePackagesAsync(new[] { installRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -451,7 +451,7 @@ internal async Task CanReInstallFolder_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequest }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.True(result[0].Success); Assert.Equal(InstallerErrorCode.Success, result[0].Error); result[0].ErrorMessage.Should().BeNullOrEmpty(); @@ -461,7 +461,7 @@ internal async Task CanReInstallFolder_WhenForceIsSpecified() result = await bootstrapper.InstallTemplatePackagesAsync(new[] { repeatedInstallRequestWithoutForce }, InstallationScope.Global, CancellationToken.None).ConfigureAwait(false); - Assert.Equal(1, result.Count); + Assert.Single(result); Assert.False(result[0].Success); Assert.Equal(InstallerErrorCode.AlreadyInstalled, result[0].Error); } diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GeneratePortMacroTests.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GeneratePortMacroTests.cs index 3a38a9396e..df5bf95727 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GeneratePortMacroTests.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/GeneratePortMacroTests.cs @@ -27,7 +27,7 @@ public void BasicMacroTest() GeneratePortNumberConfig config = new(macro, "test", "integer", 3000, 4000, 5000); macro.Evaluate(_engineEnvironmentSettings, variables, config); - Assert.Equal(1, variables.Count); + Assert.Single(variables); int result = (int)variables["test"]; @@ -50,7 +50,7 @@ public void GeneratedSymbolTest() GeneratedSymbol symbol = new("test", macro.Type, jsonParameters); macro.Evaluate(_engineEnvironmentSettings, variables, symbol); - Assert.Equal(1, variables.Count); + Assert.Single(variables); int result = (int)variables["test"]; @@ -66,7 +66,7 @@ public void TestDeterministicMode() GeneratePortNumberConfig config = new(macro, "test", "integer", 3000, 4000, 5000); macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, config); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal(4000, variables["test"]); } @@ -86,7 +86,7 @@ public void TestDeterministicMode_GenSymbol() GeneratePortNumberMacro macro = new(); macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, macro.CreateConfig(_engineEnvironmentSettings, deferredConfig)); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal(4000, variables["test"]); } @@ -102,7 +102,7 @@ public void TestDeterministicMode_GenSymbol_Default() GeneratePortNumberMacro macro = new(); macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, macro.CreateConfig(_engineEnvironmentSettings, deferredConfig)); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal(GeneratePortNumberConfig.LowPortDefault, variables["test"]); } diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/NowMacroTests.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/NowMacroTests.cs index 16e6b98c5d..091f35e3a2 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/NowMacroTests.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/NowMacroTests.cs @@ -101,7 +101,7 @@ public void TestDeterministicMode() NowMacroConfig config = new(macro, "test", "yyyy-MM-dd HH:mm:ss"); macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, config); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("1900-01-01 00:00:00", variables["test"].ToString()); } @@ -123,7 +123,7 @@ public void TestDeterministicMode_GenSymbol() macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, macro.CreateConfig(_engineEnvironmentSettings, deferredConfig)); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal("1900-01-01 00:00:00", variables["test"].ToString()); } diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RandomMacroTests.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RandomMacroTests.cs index 3a0664f576..a668b9d07a 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RandomMacroTests.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/MacroTests/RandomMacroTests.cs @@ -84,7 +84,7 @@ public void TestDeterministicMode() RandomMacroConfig config = new(macro, "test", "integer", 10, 100); macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, config); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal(10, variables["test"]); } @@ -104,7 +104,7 @@ public void TestDeterministicMode_GenSymbol() macro.EvaluateDeterministically(_engineEnvironmentSettings, variables, macro.CreateConfig(_engineEnvironmentSettings, deferredConfig)); - Assert.Equal(1, variables.Count); + Assert.Single(variables); Assert.Equal(10, variables["test"]); } diff --git a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/CustomConditionalTests.cs b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/CustomConditionalTests.cs index ae4f6f51f7..6a8e230ed6 100644 --- a/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/CustomConditionalTests.cs +++ b/test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/TemplateConfigTests/CustomConditionalTests.cs @@ -87,12 +87,12 @@ public void TestCustomConditionalSetupNoStyleSpecification() IEnumerable ops = new ConditionalConfig().ConfigureFromJson(CustomConditionalSetupNoStyleSpecification.ToString(), A.Fake()); IList operations = new List(ops); - Assert.Equal(1, operations.Count); + Assert.Single(operations); Assert.True(operations[0] is Conditional); Conditional? conditionalOp = operations[0] as Conditional; Assert.NotNull(conditionalOp); - Assert.Equal(1, conditionalOp!.Tokens.ActionableIfTokens.Count); + Assert.Single(conditionalOp!.Tokens.ActionableIfTokens); Assert.Equal("