From 0e71bdd637a6b3c34f18d4b3630d55fa4cdfd2a3 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 18 Dec 2020 22:04:48 -0600 Subject: Enable XML doc. --- src/WixToolset.Core.TestPackage/BundleExtractor.cs | 44 +++++++++++++++++++++ .../ExtractBAContainerResult.cs | 45 ++++++++++++++++++++++ .../TestMessageListener.cs | 27 +++++++++++++ src/WixToolset.Core.TestPackage/WixRunner.cs | 22 ++++++++++- src/WixToolset.Core.TestPackage/WixRunnerResult.cs | 13 +++++++ .../WixToolset.Core.TestPackage.csproj | 1 + .../XmlNodeExtensions.cs | 15 ++++++++ 7 files changed, 166 insertions(+), 1 deletion(-) (limited to 'src/WixToolset.Core.TestPackage') diff --git a/src/WixToolset.Core.TestPackage/BundleExtractor.cs b/src/WixToolset.Core.TestPackage/BundleExtractor.cs index 8a56f117..ad97f113 100644 --- a/src/WixToolset.Core.TestPackage/BundleExtractor.cs +++ b/src/WixToolset.Core.TestPackage/BundleExtractor.cs @@ -7,8 +7,19 @@ namespace WixToolset.Core.TestPackage using WixToolset.Core.Burn.Bundles; using WixToolset.Extensibility.Services; + /// + /// Class to extract bundle contents for testing. + /// public class BundleExtractor { + /// + /// Extracts the BA container. + /// + /// + /// Path to the bundle. + /// Path to extract to. + /// Temp path for extraction. + /// public static ExtractBAContainerResult ExtractBAContainer(IMessaging messaging, string bundleFilePath, string destinationFolderPath, string tempFolderPath) { var result = new ExtractBAContainerResult(); @@ -33,6 +44,12 @@ namespace WixToolset.Core.TestPackage return result; } + /// + /// Gets an for BootstrapperApplicationData.xml with the given prefix assigned to the root namespace. + /// + /// + /// + /// public static XmlNamespaceManager GetBADataNamespaceManager(XmlDocument document, string prefix) { var namespaceManager = new XmlNamespaceManager(document.NameTable); @@ -40,6 +57,12 @@ namespace WixToolset.Core.TestPackage return namespaceManager; } + /// + /// Gets an for BundleExtensionData.xml with the given prefix assigned to the root namespace. + /// + /// + /// + /// public static XmlNamespaceManager GetBundleExtensionDataNamespaceManager(XmlDocument document, string prefix) { var namespaceManager = new XmlNamespaceManager(document.NameTable); @@ -47,6 +70,12 @@ namespace WixToolset.Core.TestPackage return namespaceManager; } + /// + /// Gets an for the Burn manifest.xml with the given prefix assigned to the root namespace. + /// + /// + /// + /// public static XmlNamespaceManager GetBurnNamespaceManager(XmlDocument document, string prefix) { var namespaceManager = new XmlNamespaceManager(document.NameTable); @@ -54,6 +83,11 @@ namespace WixToolset.Core.TestPackage return namespaceManager; } + /// + /// Loads an XmlDocument with the BootstrapperApplicationData.xml from the given folder that contains the contents of the BA container. + /// + /// + /// public static XmlDocument LoadBAData(string baFolderPath) { var document = new XmlDocument(); @@ -61,6 +95,11 @@ namespace WixToolset.Core.TestPackage return document; } + /// + /// Loads an XmlDocument with the BootstrapperApplicationData.xml from the given folder that contains the contents of the BA container. + /// + /// + /// public static XmlDocument LoadBundleExtensionData(string baFolderPath) { var document = new XmlDocument(); @@ -68,6 +107,11 @@ namespace WixToolset.Core.TestPackage return document; } + /// + /// Loads an XmlDocument with the BootstrapperApplicationData.xml from the given folder that contains the contents of the BA container. + /// + /// + /// public static XmlDocument LoadBurnManifest(string baFolderPath) { var document = new XmlDocument(); diff --git a/src/WixToolset.Core.TestPackage/ExtractBAContainerResult.cs b/src/WixToolset.Core.TestPackage/ExtractBAContainerResult.cs index 63d7bb31..277861ff 100644 --- a/src/WixToolset.Core.TestPackage/ExtractBAContainerResult.cs +++ b/src/WixToolset.Core.TestPackage/ExtractBAContainerResult.cs @@ -6,22 +6,61 @@ namespace WixToolset.Core.TestPackage using System.Xml; using Xunit; + /// + /// The result of extracting the BA container. + /// public class ExtractBAContainerResult { + /// + /// for BundleExtensionData.xml. + /// public XmlDocument BundleExtensionDataDocument { get; set; } + + /// + /// for BundleExtensionData.xml. + /// public XmlNamespaceManager BundleExtensionDataNamespaceManager { get; set; } + + /// + /// for BootstrapperApplicationData.xml. + /// public XmlDocument BADataDocument { get; set; } + + /// + /// for BootstrapperApplicationData.xml. + /// public XmlNamespaceManager BADataNamespaceManager { get; set; } + + /// + /// for the Burn manifest.xml. + /// public XmlDocument ManifestDocument { get; set; } + + /// + /// for the Burn manifest.xml. + /// public XmlNamespaceManager ManifestNamespaceManager { get; set; } + + /// + /// Whether extraction succeeded. + /// public bool Success { get; set; } + /// + /// + /// + /// public ExtractBAContainerResult AssertSuccess() { Assert.True(this.Success); return this; } + /// + /// Returns the relative path of the BA entry point dll in the given folder. + /// + /// + /// public string GetBAFilePath(string extractedBAContainerFolderPath) { var uxPayloads = this.SelectManifestNodes("/burn:BurnManifest/burn:UX/burn:Payload"); @@ -30,6 +69,12 @@ namespace WixToolset.Core.TestPackage return Path.Combine(extractedBAContainerFolderPath, relativeBAPath); } + /// + /// Returns the relative path of the BundleExtension entry point dll in the given folder. + /// + /// + /// + /// public string GetBundleExtensionFilePath(string extractedBAContainerFolderPath, string extensionId) { var uxPayloads = this.SelectManifestNodes($"/burn:BurnManifest/burn:UX/burn:Payload[@Id='{extensionId}']"); diff --git a/src/WixToolset.Core.TestPackage/TestMessageListener.cs b/src/WixToolset.Core.TestPackage/TestMessageListener.cs index b5863869..7040fe82 100644 --- a/src/WixToolset.Core.TestPackage/TestMessageListener.cs +++ b/src/WixToolset.Core.TestPackage/TestMessageListener.cs @@ -5,24 +5,51 @@ using WixToolset.Extensibility.Services; namespace WixToolset.Core.TestPackage { + /// + /// An that simply stores all the messages. + /// public sealed class TestMessageListener : IMessageListener { + /// + /// All messages that have been received. + /// public List Messages { get; } = new List(); + /// + /// + /// public string ShortAppName => "TEST"; + /// + /// + /// public string LongAppName => "Test"; + /// + /// Stores the message in . + /// + /// public void Write(Message message) { this.Messages.Add(message); } + /// + /// Stores the message in . + /// + /// public void Write(string message) { this.Messages.Add(new Message(null, MessageLevel.Information, 0, message)); } + /// + /// Always returns defaultMessageLevel. + /// + /// + /// + /// + /// public MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel) => defaultMessageLevel; } } diff --git a/src/WixToolset.Core.TestPackage/WixRunner.cs b/src/WixToolset.Core.TestPackage/WixRunner.cs index 940b55a8..a3883cd5 100644 --- a/src/WixToolset.Core.TestPackage/WixRunner.cs +++ b/src/WixToolset.Core.TestPackage/WixRunner.cs @@ -9,11 +9,19 @@ namespace WixToolset.Core.TestPackage using WixToolset.Core.Burn; using WixToolset.Core.WindowsInstaller; using WixToolset.Data; - using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; + /// + /// Utility class to emulate wix.exe with standard backends. + /// public static class WixRunner { + /// + /// Emulates calling wix.exe with standard backends. + /// + /// + /// + /// public static int Execute(string[] args, out List messages) { var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); @@ -21,6 +29,11 @@ namespace WixToolset.Core.TestPackage return task.Result; } + /// + /// Emulates calling wix.exe with standard backends. + /// + /// + /// public static WixRunnerResult Execute(params string[] args) { var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); @@ -28,6 +41,13 @@ namespace WixToolset.Core.TestPackage return new WixRunnerResult { ExitCode = exitCode.Result, Messages = messages.ToArray() }; } + /// + /// Emulates calling wix.exe with standard backends. + /// + /// + /// + /// + /// public static Task Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List messages) { coreProvider.AddWindowsInstallerBackend() diff --git a/src/WixToolset.Core.TestPackage/WixRunnerResult.cs b/src/WixToolset.Core.TestPackage/WixRunnerResult.cs index 88f20158..13e3a9e0 100644 --- a/src/WixToolset.Core.TestPackage/WixRunnerResult.cs +++ b/src/WixToolset.Core.TestPackage/WixRunnerResult.cs @@ -7,12 +7,25 @@ namespace WixToolset.Core.TestPackage using WixToolset.Data; using Xunit; + /// + /// The result of an Execute method of . + /// public class WixRunnerResult { + /// + /// ExitCode for the operation. + /// public int ExitCode { get; set; } + /// + /// Messages from the operation. + /// public Message[] Messages { get; set; } + /// + /// + /// + /// public WixRunnerResult AssertSuccess() { Assert.True(0 == this.ExitCode, $"\r\n\r\nWixRunner failed with exit code: {this.ExitCode}\r\n Output: {String.Join("\r\n ", FormatMessages(this.Messages))}\r\n"); diff --git a/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj b/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj index 06793ffd..b64b4075 100644 --- a/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj +++ b/src/WixToolset.Core.TestPackage/WixToolset.Core.TestPackage.csproj @@ -8,6 +8,7 @@ Internal WiX Toolset Test Package embedded true + true diff --git a/src/WixToolset.Core.TestPackage/XmlNodeExtensions.cs b/src/WixToolset.Core.TestPackage/XmlNodeExtensions.cs index a7f04508..f4966f74 100644 --- a/src/WixToolset.Core.TestPackage/XmlNodeExtensions.cs +++ b/src/WixToolset.Core.TestPackage/XmlNodeExtensions.cs @@ -7,13 +7,28 @@ namespace WixToolset.Core.TestPackage using System.Text.RegularExpressions; using System.Xml; + /// + /// Utility class to help compare XML in tests using string comparisons by using single quotes and stripping all namespaces. + /// public static class XmlNodeExtensions { + /// + /// Returns the node's outer XML using single quotes and stripping all namespaces. + /// + /// + /// Attributes for which the value should be set to '*'. + /// public static string GetTestXml(this XmlNode node, Dictionary> ignoredAttributesByElementName = null) { return node.OuterXml.GetTestXml(ignoredAttributesByElementName); } + /// + /// Returns the XML using single quotes and stripping all namespaces. + /// + /// + /// Attributes for which the value should be set to '*'. + /// public static string GetTestXml(this string xml, Dictionary> ignoredAttributesByElementName = null) { string formattedXml; -- cgit v1.2.3-55-g6feb