Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
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);
            }
        }