コード例 #1
0
        public void XmlFile_ExistingFile()
        {
            string sourceFile = Path.Combine(XmlFileTests.TestDataDirectory, @"product.wxs");
            string targetFile = Utilities.FileUtilities.GetUniqueFileName();

            // Create new test.xml file to be used.
            File.Copy(Path.Combine(XmlFileTests.TestDataDirectory, @"test.xml"), targetFile, true);
            FileInfo file = new FileInfo(targetFile);

            if (file.IsReadOnly)
            {
                file.IsReadOnly = false;
            }

            // build the msi and pass targetfile as a param to the .wxs file
            string msiFile = Builder.BuildPackage(Environment.CurrentDirectory, sourceFile, "test.msi", string.Format("-dTargetFile=\"{0}\" -ext WixUtilExtension", targetFile), "-ext WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify XML File Transformation.
            VerifyXMLFileTransformation(targetFile);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify that the file was removed
            Assert.True(File.Exists(targetFile), String.Format("XMLFile '{0}' was removed on Uninstall.", targetFile));

            // Verify that the changes were reverted except for permenant changes
            XMLVerifier.VerifyXMLFile(targetFile, Path.Combine(XmlFileTests.TestDataDirectory, @"expected.xml"));
        }
コード例 #2
0
        /// <summary>
        /// Verify XML File Transformation on Install.
        /// </summary>
        /// <param name="fileName">XML file path</param>
        private static void VerifyXMLConfigInstallTransformation(string fileName)
        {
            // /Root
            // Verify new attribute was added to root node (New=”hello”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root", "New", "hello");

            // /Root/Child
            // Verify “Child” node was created
            XMLVerifier.VerifyElementExists(fileName, "/Root/Child[@key='foo']");

            // Verify “Child” node has the right text
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child[@key='foo']", "this is text");

            // /Root/Child/GrandChild
            // Verify “GrandChild” has an attribute (“name=Junior”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Child/GrandChild", "name", "Junior");

            // Verify “GrandChild” has the right text
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child/GrandChild", "hi mom");

            // /Root/Fragment/Child
            // Verify Fragment/Child element has a new attribute added (Id=”XmlConfig”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Fragment/Child", "Id", "XmlConfig");

            // Verify Fragment/Child element has no inner text
            XMLVerifier.VerifyElementValue(fileName, "/Root/Fragment/Child", string.Empty);
        }
コード例 #3
0
        public void XmlConfig_InstallFailure()
        {
            string sourceFile = Path.Combine(XmlConfigTests.TestDataDirectory, @"product_fail.wxs");
            string targetFile = Utilities.FileUtilities.GetUniqueFileName();

            // Create new test.xml file to be used.
            File.Copy(Path.Combine(XmlConfigTests.TestDataDirectory, @"test.xml"), targetFile, true);
            FileInfo file = new FileInfo(targetFile);

            if (file.IsReadOnly)
            {
                file.IsReadOnly = false;
            }

            // build the msi and pass targetfile as a param to the .wxs file
            string msiFile = Builder.BuildPackage(Environment.CurrentDirectory, sourceFile, "test.msi", string.Format("-dTargetFile=\"{0}\" -ext WixUtilExtension", targetFile), "-ext WixUtilExtension -sice:ICE03");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify that the file was removed
            Assert.True(File.Exists(targetFile), string.Format("XML file '{0}' was removed on Rollback.", targetFile));

            // Verify XML File has not changed.
            XMLVerifier.VerifyXMLFile(targetFile, Path.Combine(XmlConfigTests.TestDataDirectory, @"test.xml"));
        }
コード例 #4
0
        /// <summary>
        /// verifies the transformation done using XMLFile in XMLFile.wix
        /// </summary>
        /// <param name="fileName">XML file Path</param>
        private static void VerifyXMLFileTransformation(string fileName)
        {
            // /Root
            // Verify new attribute was added to root node (New=”hello”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root", "New", "hello");

            // Verify new Text was added to the root element
            XMLVerifier.VerifyElementValue(fileName, "/Root", "this is text");

            // /Root/Child
            // Verify “Child” node has a childnode created ”NewElement”
            XMLVerifier.VerifyElementExists(fileName, "/Root/Child/NewElement");

            // /Root/Child/NewElement
            // Verify “NewElement” as an attribute (“EmptyAttr=”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Child/NewElement", "EmptyAttr", string.Empty);

            // Verify “NewElement” has text value “new element text”
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child/NewElement", "new element text");

            // Verify “NewElement” node has a childnode created ”NewElementchild”
            XMLVerifier.VerifyElementExists(fileName, "/Root/Child/NewElement/NewElementChild");

            // /Root/Child/NewElement/NewElementChild
            // Verify all test1 node have the text value “Allarethesame”
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child/NewElement/NewElementChild/test1[1]", "Allarethesame");
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child/NewElement/NewElementChild/test1[2]", "Allarethesame");
            XMLVerifier.VerifyElementValue(fileName, "/Root/Child/NewElement/NewElementChild/test1[3]", "Allarethesame");

            // /Root/Child[2]
            // Verify second child element has a new attribute added (foo=”bar”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Child[2]", "foo", "bar");

            // /Root/Config
            // Verify the node(<Config key='abc'/>) text has been deleted
            XMLVerifier.VerifyElementValue(fileName, "/Root/Config[@key='abc']", string.Empty);

            // Verify the attribute value has been changed from (<Config key='ghi' value='CN=Users'/>) to (<Config key='ghi' value='CN=Something else'/>
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Config[@key='ghi']", "value", "CN=Something Else");
        }
コード例 #5
0
        /// <summary>
        /// Verify XML File Transformation on Uninstall.
        /// </summary>
        /// <param name="fileName">XML file path</param>
        private static void VerifyXMLConfigUninstallTransformation(string fileName)
        {
            // Verify XML File Transformation on Uninstall.
            // /Root
            // Verify new attribute 'New' was removed from Root
            XMLVerifier.VerifyElementExists(fileName, "/Root[New='hello']", false);

            // /Root/Child
            // Verify “Child” node was deleted
            XMLVerifier.VerifyElementExists(fileName, "/Root/Child[@key='foo']", false);

            // /Root/Child/GrandChild
            // Verify “GrandChild” was deleted
            XMLVerifier.VerifyElementExists(fileName, "/Root/Child/GrandChild", false);

            // /Root/Fragment/Child
            // Verify Fragment/Child element still has a new attribute added (Id=”XmlConfig”)
            XMLVerifier.VerifyAttributeValue(fileName, "/Root/Fragment/Child", "Id", "XmlConfig");

            // Verify Fragment/Child element still has no inner text
            XMLVerifier.VerifyElementValue(fileName, "/Root/Fragment/Child", string.Empty);
        }
コード例 #6
0
 public SimplePatchTool UsePatchInfoVerifier(XMLVerifier verifierFunction)
 {
     PatchInfoVerifier = verifierFunction;
     return(this);
 }