From ca6e44d496b0c589fdaabad69a00643f539c47cd Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Fri, 14 Feb 2025 22:29:39 -0500 Subject: Convert ext\ to MSTest and traversal projects. - Move ext\ unit tests to MSTest. - MSBuildify ext projects with MSTest execution. - Fork test support projects for MSTest: - WixInternal.TestSupport - WixInternal.Core.TestPackage --- .../BalExtensionFixture.cs | 49 +++++------ .../InternalUIBAFixture.cs | 95 +++++++++++----------- .../WixToolsetTest.BootstrapperApplications.csproj | 7 +- 3 files changed, 77 insertions(+), 74 deletions(-) (limited to 'src/ext/Bal/test/WixToolsetTest.BootstrapperApplications') diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/BalExtensionFixture.cs b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/BalExtensionFixture.cs index 2e21ef90..6e24ad72 100644 --- a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/BalExtensionFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/BalExtensionFixture.cs @@ -6,13 +6,14 @@ namespace WixToolsetTest.BootstrapperApplications using System.Collections.Generic; using System.IO; using System.Linq; - using WixInternal.Core.TestPackage; - using WixInternal.TestSupport; - using Xunit; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using WixInternal.Core.MSTestPackage; + using WixInternal.MSTestSupport; + [TestClass] public class BalExtensionFixture { - [Fact] + [TestMethod] public void CanBuildUsingDisplayInternalUICondition() { using (var fs = new DisposableFileSystem()) @@ -35,7 +36,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -46,11 +47,11 @@ namespace WixToolsetTest.BootstrapperApplications "", }, balPackageInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "thm.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "thm.wxl"))); } } - [Fact] + [TestMethod] public void CanBuildUsingBootstrapperApplicationId() { using (var fs = new DisposableFileSystem()) @@ -73,7 +74,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -91,7 +92,7 @@ namespace WixToolsetTest.BootstrapperApplications } } - [Fact] + [TestMethod] public void CanBuildUsingOverridable() { using (var fs = new DisposableFileSystem()) @@ -113,7 +114,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -132,7 +133,7 @@ namespace WixToolsetTest.BootstrapperApplications } } - [Fact] + [TestMethod] public void CanBuildUsingWixStdBa() { using (var fs = new DisposableFileSystem()) @@ -152,11 +153,11 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); } } - //[Fact] + // [TestMethod] //public void CanBuildUsingMBAWithAlwaysInstallPrereqs() //{ // using (var fs = new DisposableFileSystem()) @@ -179,7 +180,7 @@ namespace WixToolsetTest.BootstrapperApplications // compileResult.AssertSuccess(); - // Assert.True(File.Exists(bundleFile)); + // Assert.IsTrue(File.Exists(bundleFile)); // var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); // extractResult.AssertSuccess(); @@ -198,7 +199,7 @@ namespace WixToolsetTest.BootstrapperApplications // } //} - [Fact] + [TestMethod] public void CannotBuildUsingMBAWithNoPrereqs() { using (var fs = new DisposableFileSystem()) @@ -223,14 +224,14 @@ namespace WixToolsetTest.BootstrapperApplications { "The WixManagedBootstrapperApplicationHost element has been deprecated.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(1130, compileResult.ExitCode); + Assert.AreEqual(1130, compileResult.ExitCode); - Assert.False(File.Exists(bundleFile)); - Assert.False(File.Exists(Path.Combine(intermediateFolder, "test.exe"))); + Assert.IsFalse(File.Exists(bundleFile)); + Assert.IsFalse(File.Exists(Path.Combine(intermediateFolder, "test.exe"))); } } - [Fact] + [TestMethod] public void CannotBuildUsingDncbaMissingBAFactoryPayload() { using (var fs = new DisposableFileSystem()) @@ -254,14 +255,14 @@ namespace WixToolsetTest.BootstrapperApplications "The WixDotNetCoreBootstrapperApplicationHost element has been deprecated.", "The BootstrapperApplication element's Name or SourceFile attribute was not found; one of these is required." }, compileResult.Messages.Select(x => x.ToString()).ToArray()); - Assert.Equal(44, compileResult.ExitCode); + Assert.AreEqual(44, compileResult.ExitCode); - Assert.False(File.Exists(bundleFile)); - Assert.False(File.Exists(Path.Combine(intermediateFolder, "test.exe"))); + Assert.IsFalse(File.Exists(bundleFile)); + Assert.IsFalse(File.Exists(Path.Combine(intermediateFolder, "test.exe"))); } } - [Fact] + [TestMethod] public void CannotBuildUsingOverridableWrongCase() { using (var fs = new DisposableFileSystem()) @@ -284,7 +285,7 @@ namespace WixToolsetTest.BootstrapperApplications "-o", bundleFile, }); - Assert.InRange(result.ExitCode, 2, Int32.MaxValue); + Assert.IsTrue(result.ExitCode >= 2 && result.ExitCode <= Int32.MaxValue); var messages = result.Messages.Select(m => m.ToString()).ToList(); messages.Sort(); diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs index 58d5d551..72e31540 100644 --- a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs @@ -5,13 +5,14 @@ namespace WixToolsetTest.BootstrapperApplications using System.IO; using System.Linq; using System.Xml; - using WixInternal.Core.TestPackage; - using WixInternal.TestSupport; - using Xunit; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using WixInternal.Core.MSTestPackage; + using WixInternal.MSTestSupport; + [TestClass] public class InternalUIBAFixture { - [Fact] + [TestMethod] public void CanBuildUsingWixIuiBa() { using (var fs = new DisposableFileSystem()) @@ -34,7 +35,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -45,12 +46,12 @@ namespace WixToolsetTest.BootstrapperApplications "", }, balPackageInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); } } - [Fact] + [TestMethod] public void CanBuildUsingWixIuiBaWithUrlPrereqPackage() { using (var fs = new DisposableFileSystem()) @@ -73,7 +74,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -90,12 +91,12 @@ namespace WixToolsetTest.BootstrapperApplications "", }, mbaPrereqInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); } } - [Fact] + [TestMethod] public void CanBuildUsingWixIuiBaWithImplicitPrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -118,7 +119,7 @@ namespace WixToolsetTest.BootstrapperApplications }); compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -135,12 +136,12 @@ namespace WixToolsetTest.BootstrapperApplications "", }, mbaPrereqInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); } } - [Fact] + [TestMethod] public void CanBuildUsingWixIuiBaWithWarnings() { using (var fs = new DisposableFileSystem()) @@ -172,7 +173,7 @@ namespace WixToolsetTest.BootstrapperApplications compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -189,12 +190,12 @@ namespace WixToolsetTest.BootstrapperApplications "", }, mbaPrereqInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); } } - [Fact] + [TestMethod] public void CanBuildUsingWixIuiBaAndForcedCachePrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -218,7 +219,7 @@ namespace WixToolsetTest.BootstrapperApplications compileResult.AssertSuccess(); - Assert.True(File.Exists(bundleFile)); + Assert.IsTrue(File.Exists(bundleFile)); var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -239,8 +240,8 @@ namespace WixToolsetTest.BootstrapperApplications "", }, mbaPrereqInfos); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); - Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); } static void AssertCacheType(XmlNode node) @@ -251,16 +252,16 @@ namespace WixToolsetTest.BootstrapperApplications if (package == "test.msi") { - Assert.Equal("force", cache); + Assert.AreEqual("force", cache); } else if (package == "wixnative.exe") { - Assert.Equal("keep", cache); + Assert.AreEqual("keep", cache); } } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithAllPrereqPackages() { using (var fs = new DisposableFileSystem()) @@ -285,11 +286,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6808, compileResult.ExitCode); + Assert.AreEqual(6808, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithImplicitNonMsiPrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -314,11 +315,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6811, compileResult.ExitCode); + Assert.AreEqual(6811, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithImplicitPrimaryPackageEnableFeatureSelection() { using (var fs = new DisposableFileSystem()) @@ -343,11 +344,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6811, compileResult.ExitCode); + Assert.AreEqual(6811, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithMultipleNonPermanentNonPrimaryPackages() { using (var fs = new DisposableFileSystem()) @@ -373,11 +374,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6811, compileResult.ExitCode); + Assert.AreEqual(6811, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithMultiplePrimaryPackagesOfSameType() { using (var fs = new DisposableFileSystem()) @@ -403,11 +404,11 @@ namespace WixToolsetTest.BootstrapperApplications "The location of the package related to the previous error.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6810, compileResult.ExitCode); + Assert.AreEqual(6810, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithNoDefaultPrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -432,11 +433,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6808, compileResult.ExitCode); + Assert.AreEqual(6808, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithNonMsiPrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -461,11 +462,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, each primary package must be an MsiPackage.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6814, compileResult.ExitCode); + Assert.AreEqual(6814, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithNonPermanentPrereqPackage() { using (var fs = new DisposableFileSystem()) @@ -490,11 +491,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication and bal:PrereqPackage is set to 'yes', the package must be permanent.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6812, compileResult.ExitCode); + Assert.AreEqual(6812, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithPermanentPrimaryPackage() { using (var fs = new DisposableFileSystem()) @@ -520,11 +521,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6808, compileResult.ExitCode); + Assert.AreEqual(6808, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithPrimaryPackageEnableFeatureSelection() { using (var fs = new DisposableFileSystem()) @@ -550,11 +551,11 @@ namespace WixToolsetTest.BootstrapperApplications "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(6808, compileResult.ExitCode); + Assert.AreEqual(6808, compileResult.ExitCode); } } - [Fact] + [TestMethod] public void CannotBuildUsingWixIuiBaWithPrimaryPrereqPackage() { using (var fs = new DisposableFileSystem()) @@ -578,7 +579,7 @@ namespace WixToolsetTest.BootstrapperApplications "The MsiPackage/@PrereqPackage attribute's value, 'yes', cannot be specified with attribute PrimaryPackageType present.", }, compileResult.Messages.Select(m => m.ToString()).ToArray()); - Assert.Equal(193, compileResult.ExitCode); + Assert.AreEqual(193, compileResult.ExitCode); } } } diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/WixToolsetTest.BootstrapperApplications.csproj b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/WixToolsetTest.BootstrapperApplications.csproj index 64fc297c..6a9b5856 100644 --- a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/WixToolsetTest.BootstrapperApplications.csproj +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/WixToolsetTest.BootstrapperApplications.csproj @@ -1,10 +1,10 @@ - + net6.0 - true + true @@ -20,6 +20,7 @@ - + + -- cgit v1.2.3-55-g6feb