示例#1
0
        public void GetAttributeValueUsingXPath()
        {
            string xpath = "//system.webServer/aspNetCore/@processPath";

            var expected = "aspnetcore.processpath";

            var actual = XmlEditorUtility.GetValueByXPath(_PathToSampleConfigFile, xpath);

            Assert.AreEqual <string>(expected, actual, "Wrong value.");
        }
示例#2
0
        public void GetElementValueUsingXPath()
        {
            string xpath = "//subelement1/subelement2";

            var expected = "subelement2.value";

            var actual = XmlEditorUtility.GetValueByXPath(_PathToSampleConfigFile, xpath);

            Assert.AreEqual <string>(expected, actual, "Wrong value.");
        }
示例#3
0
        public void SetElementValueForNewElement()
        {
            string xpath = "//childelement1/childelement2";

            var expected = "childelement2.value";

            XmlEditorUtility.SetElementValue(
                _PathToSampleConfigFile,
                "configuration", "childelement1", "childelement2", expected);

            var actual = XmlEditorUtility.GetValueByXPath(_PathToSampleConfigFile, xpath);

            Assert.AreEqual <string>(expected, actual, "Wrong value.");
        }
示例#4
0
        public void SetAttribueValueForExistingElement_TwoLevels()
        {
            string xpath = "//system.webServer/@processPath";

            var expected = "new value";

            XmlEditorUtility.SetAttributeValue(
                _PathToSampleConfigFile,
                "configuration", "system.webServer",
                "processPath", expected);

            var actual = XmlEditorUtility.GetValueByXPath(_PathToSampleConfigFile, xpath);

            Assert.AreEqual <string>(expected, actual, "Wrong value.");
        }
        public void SetAttributeUsingThreeLevelsOfElement()
        {
            string expectedValue = "new-value";

            Args = CreateArgsArray(
                CommandNameArgument,
                GetArgEntry(Constants.ArgumentNameConfigFilename, _PathToSampleConfigFile),
                GetArgEntry(Constants.ArgumentNameLevel1, "configuration"),
                GetArgEntry(Constants.ArgumentNameLevel2, "system.webServer"),
                GetArgEntry(Constants.ArgumentNameLevel3, "aspNetCore"),
                GetArgEntry(Constants.ArgumentNameAttributeName, "processPath"),
                GetArgEntry(Constants.ArgumentNameValue, expectedValue));

            SystemUnderTest.Run();

            string xpath  = "//system.webServer/aspNetCore/@processPath";
            var    actual = XmlEditorUtility.GetValueByXPath(_PathToSampleConfigFile, xpath);

            Assert.AreEqual <string>(expectedValue, actual, "Result was wrong.");
        }