Example #1
0
        /// <summary>
        /// Verify the pacakge Payload information in Burn_Manifest.xml
        /// </summary>
        /// <param name="embededResourcesDirectoryPath">Output folder where all the embeded resources are.</param>
        /// <param name="expectedParentPackageType">Parent Package type.</param>
        /// <param name="expectedParentPackageName">Parent Package name; this is the attribute used to locate the package.</param>
        /// <param name="expectedFileName">Payload name; this is the attribute used to locate the payload.</param>
        /// <param name="expectedDownloadURL">@DownloadURL expected value.</param>
        /// <param name="acctualFilePath">Path to the acctual file to compate against file in cab.</param>
        public static void VerifyPackagePayloadInformation(string embededResourcesDirectoryPath, PackageTests.PackageType expectedParentPackageType, string expectedParentPackageName, string expectedParentPackageId, string expectedFileName, string expectedDownloadURL, string acctualFilePath)
        {
            string expectedFileSize = new FileInfo(acctualFilePath).Length.ToString();
            string expectedHash     = FileVerifier.ComputeFileSHA1Hash(acctualFilePath);

            // find the Payload element
            string      payloadXPath = string.Format(@"//burn:Payload[@FilePath='{0}']", expectedFileName);
            XmlNodeList payloadNodes = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, payloadXPath);

            Assert.AreEqual(1, payloadNodes.Count, "No Package payload with the name: '{0}' was found in Burn_Manifest.xml.", expectedFileName);
            BundleTests.VerifyAttributeValue(payloadNodes[0], "FileSize", expectedFileSize);
            BundleTests.VerifyAttributeValue(payloadNodes[0], "Sha1Hash", expectedHash);
            BundleTests.VerifyAttributeValue(payloadNodes[0], "DownloadUrl", expectedDownloadURL);

            // make sure the payload is added to the package
            string      payloadId = payloadNodes[0].Attributes["Id"].Value;
            string      packagePayloadRefXPath = string.Format(@"//burn:{0}[@Id='{1}']/burn:PayloadRef[@Id='{2}']", GetPackageElementName(expectedParentPackageType), expectedParentPackageId, payloadId);
            XmlNodeList packagePayloadRefNodes = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, packagePayloadRefXPath);

            Assert.AreEqual(1, packagePayloadRefNodes.Count, "Package payload with the name: '{0}' was found under Package '{1}'.", expectedFileName, expectedParentPackageId);

            // verify the correct file is added to the attached container
            if (null == expectedDownloadURL)
            {
                string extractedFilePath = Path.Combine(Builder.AttachedContainerFolderName, expectedFileName);
                FileVerifier.VerifyFilesAreIdentical(acctualFilePath, extractedFilePath);
            }
        }
        /// <summary>
        /// Verifies UX Payload file information in Burn_Manifest.xml
        /// </summary>
        /// <param name="embededResourcesDirectoryPath">Output folder where all the embeded resources are.</param>
        /// <param name="acctualFilePath">Path to the acctual file that was packed in the cab.</param>
        /// <param name="expectedFileName">Expected file name of the file.</param>
        /// <param name="verifyFileIsPrimaryPayload">Check if this file is the primary payload for the UX.</param>
        public static void VerifyUXPayloadInformation(string embededResourcesDirectoryPath, string acctualFilePath, string expectedFileName, bool verifyFileIsPrimaryPayload)
        {
            string expectedFileSize = new FileInfo(acctualFilePath).Length.ToString();
            string expectedHash     = FileVerifier.ComputeFileSHA1Hash(acctualFilePath);

            string      burnManifestXPath = string.Format(@"//burn:UX/burn:Payload[@FilePath='{0}']", expectedFileName);
            XmlNodeList burnManifestNodes = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, burnManifestXPath);

            Assert.True(1 == burnManifestNodes.Count, String.Format("No UX payload with the name: '{0}' was found in Burn_Manifest.xml.", expectedFileName));
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "FileSize", expectedFileSize);
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "Sha1Hash", expectedHash);

            // verify the file is the primary payload for the UX
            if (verifyFileIsPrimaryPayload)
            {
                string      burnManifestPayloadsXPath = @"//burn:UX/burn:Payload";
                XmlNodeList burnManifestPayloadNodes  = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, burnManifestPayloadsXPath);
                if (null == burnManifestPayloadNodes[0].Attributes["FilePath"] || burnManifestPayloadNodes[0].Attributes["FilePath"].Value != expectedFileName)
                {
                    Assert.True(false, String.Format("The primary UX Payload in Burn_Manifest.xml is not '{0}'.", expectedFileName));
                }
            }

            // verify the correct file is added to the ux container
            string extractedFilePath = Path.Combine(Builder.UXContainerFolderName, expectedFileName);

            FileVerifier.VerifyFilesAreIdentical(acctualFilePath, extractedFilePath);
        }
Example #3
0
        /// <summary>
        /// Verifies Package information in Burn-Manifest.xml and Burn-UxManifest.xml.
        /// </summary>
        /// <param name="embededResourcesDirectoryPath">Output folder where all the embeded resources are.</param>
        /// <param name="expectedPackageName">Package name; this is the attribute used to locate the package.</param>
        /// <param name="expectedPackageType">Package type MSI, MSP, MSU or EXE.</param>
        /// <param name="expectedId">Expected Package @Id value.</param>
        /// <param name="expectedInstallCondition">Expected Package @InstallCondition value.</param>
        /// <param name="expectedProductCode">Expected Package @ProductCode value.</param>
        /// <param name="expecteVital">Package is viatal or not.</param>
        /// <param name="expectedPermanent">Expected Package @Permanent value.</param>
        /// <param name="expectedCacheId">Expected Package @CacheId value.</param>
        /// <param name="expectedInstallCommmand">Expected @InstallCommand value.</param>
        /// <param name="expectedUninstallCommmand">Expected @UninstallCommand value.</param>
        /// <param name="expectedRepairCommand">Expected @RepairCommand value.</param>
        /// <param name="expectedDownloadURL">Expected Package @DownloadURL value.</param>
        /// <param name="acctualFilePath">Path to the acctual file for comparison.</param>
        private static void VerifyPackageInformation(string embededResourcesDirectoryPath, string expectedPackageName, PackageType expectedPackageType, string expectedId,
                                                     string expectedInstallCondition, string expectedProductCode, bool expecteVital, bool expectedPermanent, string expectedCacheId,
                                                     string expectedInstallCommmand, string expectedUninstallCommmand, string expectedRepairCommand, string expectedDownloadURL,
                                                     string acctualFilePath)
        {
            string expectedFileSize    = new FileInfo(acctualFilePath).Length.ToString();
            string expectedHash        = FileVerifier.ComputeFileSHA1Hash(acctualFilePath);
            string expectedProductSize = expectedFileSize;

            // verify the Burn_Manifest has the correct information
            string      burnManifestXPath = string.Format(@"//burn:{0}[@Id='{1}']", GetPackageElementName(expectedPackageType), expectedId);
            XmlNodeList burnManifestNodes = BundleTests.QueryBurnManifest(embededResourcesDirectoryPath, burnManifestXPath);

            Assert.AreEqual(1, burnManifestNodes.Count, "No MsiPackage with the Id: '{0}' was found in Burn_Manifest.xml.", expectedId);
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "InstallCondition", expectedInstallCondition);
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "Permanent", expectedPermanent ? "yes" : "no");
            BundleTests.VerifyAttributeValue(burnManifestNodes[0], "Vital", expecteVital ? "yes" : "no");

            if (expectedPackageType == PackageType.MSI)
            {
                BundleTests.VerifyAttributeValue(burnManifestNodes[0], "ProductCode", expectedProductCode);
            }

            if (expectedPackageType == PackageType.EXE)
            {
                BundleTests.VerifyAttributeValue(burnManifestNodes[0], "InstallArguments", expectedInstallCommmand);
                BundleTests.VerifyAttributeValue(burnManifestNodes[0], "UninstallArguments", expectedUninstallCommmand);
                BundleTests.VerifyAttributeValue(burnManifestNodes[0], "RepairArguments", expectedRepairCommand);
            }

            if (!String.IsNullOrEmpty(expectedCacheId))
            {
                BundleTests.VerifyAttributeValue(burnManifestNodes[0], "CacheId", expectedCacheId);
            }

            // verify payload information
            PackageTests.VerifyPackagePayloadInformation(embededResourcesDirectoryPath, expectedPackageType, expectedPackageName, expectedId, expectedPackageName, expectedDownloadURL, acctualFilePath);

            // verify the Burn-UxManifest has the correct information
            string expectedProductName = null;
            string expectedDiscription = null;

            if (expectedPackageType == PackageType.EXE)
            {
                FileVersionInfo fileInfo = FileVersionInfo.GetVersionInfo(acctualFilePath);
                expectedProductName = string.IsNullOrEmpty(fileInfo.ProductName) ? null : fileInfo.ProductName;
                expectedDiscription = string.IsNullOrEmpty(fileInfo.FileDescription) ? null : fileInfo.FileDescription;
            }
            else if (expectedPackageType == PackageType.MSI)
            {
                string subject = Verifier.GetMsiSummaryInformationProperty(acctualFilePath, Verifier.MsiSummaryInformationProperty.Subject);
                expectedProductName = string.IsNullOrEmpty(subject) ? null : subject;
            }

            string      burnUxManifestXPath = string.Format(@"//burnUx:WixPackageProperties[@Package='{0}']", expectedId);
            XmlNodeList burnUxManifestNodes = BundleTests.QueryBurnUxManifest(embededResourcesDirectoryPath, burnUxManifestXPath);

            Assert.AreEqual(1, burnUxManifestNodes.Count, "No WixPackageProperties for Package: '{0}' was found in Burn-UxManifest.xml.", expectedId);
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "Vital", expecteVital ? "yes" : "no");
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "DownloadSize", expectedFileSize);
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "PackageSize", expectedFileSize);
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "InstalledSize", expectedFileSize);
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "DisplayName", expectedProductName);
            BundleTests.VerifyAttributeValue(burnUxManifestNodes[0], "Description", expectedDiscription);
        }