SplitText() public method

public SplitText ( int offset ) : XmlText
offset int
return XmlText
示例#1
0
        public void core0007T()
        {
            string computedValue = "";

            System.Xml.XmlText oldTextNode   = null;
            System.Xml.XmlText newTextNode   = null;
            System.Xml.XmlNode testNode      = null;
            string             expectedValue = "System.ArgumentOutOfRangeException";//util.INDEX_SIZE_ERR;

            testResults results = new testResults("Core0007T");

            try
            {
                results.description = "The \"splitText(offset)\" method raises an " +
                                      "INDEX_SIZE_ERR Exception if the specified " +
                                      "offset is negative.";

                //
                // Retrieve the targeted data
                //
                testNode    = util.nodeObject(util.THIRD, util.SECOND);
                oldTextNode = (System.Xml.XmlText)testNode.FirstChild;
                //
                // Call the "spitText(offset)" method with "offset" equal to a negative
                // number should raise an exception.
                //
                try
                {
                    oldTextNode.SplitText(-69);
                }
                catch (System.Exception ex)
                {
                    computedValue = ex.GetType().FullName;
                }
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }

            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }
示例#2
0
        public void core0008T()
        {
            string computedValue = "";

            System.Xml.XmlText oldTextNode   = null;
            System.Xml.XmlNode testNode      = null;
            string             expectedValue = "System.ArgumentOutOfRangeException";

            testResults results = new testResults("Core0008T");

            try
            {
                results.description = "The \"splitText(offset)\" method raises an " +
                                      "ArgumentOutOfRangeException if the specified " +
                                      "offset is greater than the number of 16-bit units " +
                                      "in the Text node.";
                //
                // Retrieve the targeted data.
                //
                testNode    = util.nodeObject(util.THIRD, util.SECOND);
                oldTextNode = (System.Xml.XmlText)testNode.FirstChild;
                //
                // Call the "spitText(offset)" method with "offset" greater than the numbers
                // of characters in the Text node, it should raise an exception.

                try
                {
                    oldTextNode.SplitText(300);
                }
                catch (System.Exception ex)
                {
                    computedValue = ex.GetType().ToString();
                }
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }

            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }
示例#3
0
        [Ignore(".NET DOM implementation does not match W3C DOM specification.")] // MS DOM is buggy
        public void core0009T()
        {
            string computedValue = "";

            System.Xml.XmlNode testNode      = null;
            System.Xml.XmlText readOnlyText  = null;
            string             expectedValue = "System.ArgumentException";//util.NO_MODIFICATION_ALLOWED_ERR;

            testResults results = new testResults("Core0009T");

            try
            {
                results.description = "The \"splitText(offset)\" method raises a " +
                                      "NO_MODIFICATION_ALLOWED_ERR Exception if the " +
                                      "node is readonly.";
                //
                // Attempt to modify descendants of an EntityReference node should raise
                // an exception.
                //
                testNode     = util.nodeObject(util.SECOND, util.SIXTH);
                readOnlyText = (System.Xml.XmlText)testNode.ChildNodes.Item(util.FIRST).FirstChild;

                try
                {
                    readOnlyText.SplitText(5);
                }
                catch (ArgumentException ex)
                {
                    computedValue = ex.GetType().FullName;
                }
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }

            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }
示例#4
0
        public void core0005T()
        {
            string computedValue = "";
            string expectedValue = " Jones";

            System.Xml.XmlText oldTextNode = null;
            System.Xml.XmlText newTextNode = null;
            System.Xml.XmlNode testNode    = null;

            testResults results = new testResults("Core0005T");

            try
            {
                results.description = "After the \"splitText(offset)\" method is invoked, the " +
                                      "new Text node contains all of the content from the offset " +
                                      "point to the end of the text.";
                //
                // Retrieve the targeted data.
                //
                testNode    = util.nodeObject(util.THIRD, util.SECOND);
                oldTextNode = (System.Xml.XmlText)testNode.FirstChild;
                //
                // Split the two lines of text into two different Text nodes.
                //
                newTextNode   = oldTextNode.SplitText(util.SEVENTH);
                computedValue = newTextNode.Value;
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }

            //
            // Write out results
            //
            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }
示例#5
0
        public void core0003T()
        {
            string computedValue = "";
            string expectedValue = "Jones";

            System.Xml.XmlText oldTextNode = null;
            System.Xml.XmlNode testNode    = null;

            testResults results = new testResults("Core0003T");

            try
            {
                results.description = "The \"splitText(offset)\" method breaks the Text node " +
                                      "into two Text nodes at the specified offset, keeping each " +
                                      "node in the tree as siblings.";
                //
                // Retrieve the targeted data.
                //
                testNode    = util.nodeObject(util.THIRD, util.SECOND);
                oldTextNode = (System.Xml.XmlText)testNode.FirstChild;
                //
                // Split the two lines of text into two different Text nodes.
                //
                oldTextNode.SplitText(util.EIGHT);
                computedValue = oldTextNode.NextSibling.Value;
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }

            //
            //  Write out results
            //
            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }
示例#6
0
        public void core0006T()
        {
            string computedValue = "";
            string expectedValue = "98551";

            System.Xml.XmlText oldTextNode = null;
            System.Xml.XmlText newTextNode = null;
            System.Xml.XmlNode testNode    = null;

            testResults results = new testResults("Core0006T");

            try
            {
                results.description = "The \"splitText(offset)\" method returns the " +
                                      "new Text node.";
                //
                // Retrieve the targeted data.
                //
                testNode    = util.nodeObject(util.FIRST, util.SIXTH);
                oldTextNode = (System.Xml.XmlText)testNode.FirstChild;
                //
                // Split the two lines of text into two different Text nodes.
                //
                newTextNode   = oldTextNode.SplitText(30);
                computedValue = newTextNode.Value;
            }
            catch (System.Exception ex)
            {
                computedValue = "Exception " + ex.Message;
            }
            //
            // Write out results
            //
            results.expected = expectedValue;
            results.actual   = computedValue;

            util.resetData();

            Assert.AreEqual(results.expected, results.actual);
        }