示例#1
0
        public int GetReadState()
        {
            ReloadSource();
            ReadState iState = ReadState.Initial;

            // EndOfFile State
            if ((IntegrityVer == EINTEGRITY.AFTER_READ_FALSE))
            {
                iState = ReadState.EndOfFile;
            }

            // Closed State
            if ((IntegrityVer == EINTEGRITY.AFTER_CLOSE) || (IntegrityVer == EINTEGRITY.CLOSE_IN_THE_MIDDLE))
            {
                iState = ReadState.Closed;
            }
            CError.Compare(DataReader.ReadState, iState, CurVariation.Desc);
            CError.Compare(DataReader.ReadState, iState, CurVariation.Desc);
            return(TEST_PASS);
        }
示例#2
0
        public int TestReadBinHex_27()
        {
            byte[] buffer = new byte[1];
            string strxml = "<abc>1=2</abc>";

            ReloadSource(new StringReader(strxml));
            DataReader.PositionOnElement("abc");
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }
            try
            {
                DataReader.ReadElementContentAsBinHex(buffer, 0, 1);
                CError.Compare(false, "ReadBinHex with = in the middle succeeded");
            }
            catch (XmlException) { return(TEST_PASS); }
            finally { DataReader.Close(); }
            return(TEST_FAIL);
        }
示例#3
0
        public int TestReadStartElement3()
        {
            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_ELEM_NS);
            DataReader.PositionOnElement("bar:check");
            CError.WriteLine(DataReader.NamespaceURI);
            DataReader.ReadStartElement();

            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_ELEM_NS);
            DataReader.PositionOnElement("bar:check");
            CError.WriteLine(DataReader.NamespaceURI);
            DataReader.ReadStartElement("check", "1");

            ReloadSource();
            DataReader.PositionOnElement(ST_TEST_ELEM_NS);
            DataReader.PositionOnElement("bar:check");
            DataReader.ReadStartElement("bar:check");
            return(TEST_PASS);
        }
示例#4
0
        //[Variation(Desc = "write start element and then close when the WriteEndDocumentOnClose = false", Pri = 1, Params = new object[] { false, "<root>" })]
        //[Variation(Desc = "write start element and then close when the WriteEndDocumentOnClose = true", Pri = 1, Params = new object[] { true, "<root />" })]
        public int TestWriteEndDocumentOnCoseForOneElement()
        {
            bool              writeEndDocument = (bool)CurVariation.Params[0];
            string            expected         = (string)CurVariation.Params[1];
            StringWriter      output           = new StringWriter();
            XmlWriterSettings ws = new XmlWriterSettings();

            ws.OmitXmlDeclaration      = true;
            ws.WriteEndDocumentOnClose = writeEndDocument;
            XmlWriter writer = XmlWriter.Create(output, ws);

            writer.WriteStartElement("root");
            writer.Dispose();

            string act = output.ToString();

            CError.Compare(act, expected, "FAILED: when one start element and WriteEndDocumentOnClose = " + ws.WriteEndDocumentOnClose + ", expected: " + expected + ", received: " + act);

            return(TEST_PASS);
        }
示例#5
0
        public int v17()
        {
            ReloadSource(new StringReader("<root><child1 xmlns='foo'/>blah<child1 xmlns='bar'>blah</child1></root>"));
            DataReader.Read();
            if (IsBinaryReader())
            {
                DataReader.Read();
            }

            DataReader.ReadToDescendant("child1", "bar");
            CError.Compare(DataReader.IsEmptyElement, false, "Not on the correct node");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
示例#6
0
        //[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "1000000" })]
        //[Variation("ReadBinHex runs into an Overflow", Params = new object[] { "10000000" })]
        public int TestReadBinHex_105376()
        {
            int totalfilesize = Convert.ToInt32(CurVariation.Params[0].ToString());

            CError.WriteLine(" totalfilesize = " + totalfilesize);

            string ascii = new string('c', totalfilesize);

            byte[] bits = Encoding.Unicode.GetBytes(ascii);
            CError.WriteLineIgnore("Count = " + bits.Length);
            string base64str = Convert.ToBase64String(bits);

            string       fileName = "bug105376c_" + CurVariation.Params[0].ToString() + ".xml";
            MemoryStream mems     = new MemoryStream();
            StreamWriter sw       = new StreamWriter(mems);

            sw.Write("<root><base64>");
            sw.Write(base64str);
            sw.Write("</base64></root>");
            sw.Flush();//sw.Close();
            FilePathUtil.addStream(fileName, mems);
            ReloadSource(fileName);

            int SIZE   = (totalfilesize - 30);
            int SIZE64 = SIZE * 3 / 4;

            DataReader.PositionOnElement("base64");
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }
            byte[] base64 = new byte[SIZE64];

            try
            {
                DataReader.ReadElementContentAsBinHex(base64, 0, 4096);
                return(TEST_FAIL);
            }
            catch (XmlException) { DataReader.Close(); return(TEST_PASS); }
            finally { DataReader.Close(); }
        }
示例#7
0
        public int TestReadBinHex_16()
        {
            ReloadSource(EREADER_TYPE.BINHEX_TEST);

            DataReader.PositionOnElement("ElemNum");
            DataReader.Read();
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }

            byte[] buffer = new byte[10];
            int    nRead  = DataReader.ReadContentAsBinHex(buffer, 0, 8);

            CError.Compare(nRead, 8, "0");

            DataReader.Read();
            CError.Compare(DataReader.VerifyNode(XmlNodeType.Element, "ElemText", String.Empty), "1vn");

            return(TEST_PASS);
        }
示例#8
0
        public int XmlSubtreeReaderDoesntAddMultipleNamespaceDeclarations()
        {
            ReloadSource(new StringReader("<r xmlns:a='X'><a:e/></r>"));
            DataReader.Read();
            DataReader.Read();
            if (IsBinaryReader())
            {
                DataReader.Read();
            }

            XmlReader r1 = DataReader.ReadSubtree();

            r1.Read();
            XmlReader r2 = r1.ReadSubtree();

            r2.Read();
            string xml = r2.ReadOuterXml();

            CError.Compare(xml, "<a:e xmlns:a=\"X\" />", "Mismatch");
            return(TEST_PASS);
        }
示例#9
0
        public int TestTextReadInnerXml18()
        {
            String strp = "a                                                             ";

            strp += strp;
            strp += strp;
            strp += strp;
            strp += strp;
            strp += strp;
            strp += strp;
            strp += strp;

            string strxml = "<Name a=\"b\">" + strp + "</Name>";

            ReloadSourceStr(strxml);

            DataReader.Read();
            CError.Compare(DataReader.ReadInnerXml(), strp, "rix");

            return(TEST_PASS);
        }
示例#10
0
        public int v5()
        {
            ReloadSource(new StringReader(_xmlStr));
            DataReader.PositionOnElement("child3");

            CError.Compare(DataReader.ReadToNextSibling("child1"), false, "Reader returned true for an invalid name");
            CError.Compare(DataReader.NodeType, XmlNodeType.EndElement, "Wrong node type");

            DataReader.PositionOnElement("child3");

            CError.Compare(DataReader.ReadToNextSibling("child2", "child2"), false, "Reader returned true for an invalid name,ns");
            CError.Compare(DataReader.NodeType, XmlNodeType.EndElement, "Wrong node type for name,ns");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
示例#11
0
        public int SubtreeReaderReadsProperlyNodeTypeOfAttributes()
        {
            string xmlStr = "<root xmlns='foo'><b blah='blah'/><b/></root>";

            ReloadSource(new StringReader(xmlStr));
            DataReader.PositionOnElement("root");
            XmlReader xxr = DataReader.ReadSubtree();

            xxr.Read(); //Now on root.
            CError.Compare(xxr.Name, "root", "Root Elem");
            CError.Compare(xxr.MoveToNextAttribute(), true, "MTNA 1");

            CError.Compare(xxr.NodeType, XmlNodeType.Attribute, "XMLNS NT");
            CError.Compare(xxr.Name, "xmlns", "XMLNS Attr");
            CError.Compare(xxr.Value, "foo", "XMLNS Value");
            CError.Compare(xxr.MoveToNextAttribute(), false, "MTNA 2");

            xxr.Read(); //Now on b.
            CError.Compare(xxr.Name, "b", "b Elem");
            CError.Compare(xxr.MoveToNextAttribute(), true, "MTNA 3");

            CError.Compare(xxr.NodeType, XmlNodeType.Attribute, "blah NT");
            CError.Compare(xxr.Name, "blah", "blah Attr");
            CError.Compare(xxr.Value, "blah", "blah Value");
            CError.Compare(xxr.MoveToNextAttribute(), false, "MTNA 4");

            xxr.Read(); //Now on /b.
            CError.Compare(xxr.Name, "b", "b EndElem");
            CError.Compare(xxr.NodeType, XmlNodeType.Element, "b Elem NT");
            CError.Compare(xxr.MoveToNextAttribute(), false, "MTNA 5");

            xxr.Read(); //Now on /root.
            CError.Compare(xxr.Name, "root", "root EndElem");
            CError.Compare(xxr.NodeType, XmlNodeType.EndElement, "root EndElem NT");
            CError.Compare(xxr.MoveToNextAttribute(), false, "MTNA 6");

            DataReader.Close();

            return(TEST_PASS);
        }
示例#12
0
        public int TestReadBinHex_33()
        {
            string xml = "<elem0>123 $^ 56789 abcdefg hij klmn opqrst  12345 uvw xy ^ z</elem0>";

            ReloadSource(new StringReader(xml));
            byte[] buffer = new byte[5];

            DataReader.Read();
            DataReader.Read();
            try
            {
                CError.Compare(DataReader.ReadContentAsBinHex(buffer, 0, 5), 5, "size");
                DataReader.Read();
            }
            catch (XmlException) { return(TEST_PASS); }
            catch (NotSupportedException) { return(TEST_PASS); }
            finally
            {
                DataReader.Close();
            }
            return(TEST_FAIL);
        }
示例#13
0
        public int v8()
        {
            ReloadSource(new StringReader(_xmlStr));
            DataReader.PositionOnElement("root");

            CError.Compare(DataReader.ReadToDescendant("e:elem"), true, "Cant find elem");
            CError.Compare(DataReader.ReadToDescendant("e:child1"), true, "Cant find child1");
            CError.Compare(DataReader.ReadToDescendant("e:child2"), true, "Cant find child2");
            CError.Compare(DataReader.ReadToDescendant("e:child3"), true, "Cant find child3");
            CError.Compare(DataReader.ReadToDescendant("e:child4"), false, "shouldnt find child4");
            CError.Compare(DataReader.NodeType, XmlNodeType.Element, "Not on EndElement");
            DataReader.Read();
            CError.Compare(DataReader.NodeType, XmlNodeType.Text, "Not on Element");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
示例#14
0
        public int TestReadInnerXml11()
        {
            XmlNodeType nt;
            string      name;
            string      value;

            ReloadSource();
            DataReader.PositionOnNodeType(XmlNodeType.Text);
            CError.Compare(DataReader.ReadInnerXml(), String.Empty, CurVariation.Desc);

            // save status and compare with Read
            nt    = DataReader.NodeType;
            name  = DataReader.Name;
            value = DataReader.Value;

            ReloadSource();
            DataReader.PositionOnNodeType(XmlNodeType.Text);
            DataReader.Read();
            CError.Compare(DataReader.VerifyNode(nt, name, value), "vn");

            return(TEST_PASS);
        }
示例#15
0
        public int pi00()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            if (settings.IgnoreProcessingInstructions == true)
            {
                CError.WriteLineIgnore("RS default value = true");
                return(TEST_FAIL);
            }
            if (settings.IgnoreComments == true)
            {
                CError.WriteLineIgnore("RS Comm default value = true");
                return(TEST_FAIL);
            }
            if (settings.IgnoreWhitespace == true)
            {
                CError.WriteLineIgnore("RS WS default value = true");
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
示例#16
0
        /// <summary>
        /// Similar to the XmlWriter WriteDocType
        /// </summary>
        /// <param name="name">Doctype name</param>
        /// <param name="sysid">System ID</param>
        /// <param name="pubid">Public ID</param>
        /// <param name="subset">Content Model</param>
        public void WriteDocType(string name, string sysid, string pubid, string subset)
        {
            StringBuilder dt = new StringBuilder();

            dt.Append("<!DOCTYPE ");
            dt.Append(name);

            if (pubid == null)
            {
                if (sysid != null)
                {
                    dt.Append(" SYSTEM " + sysid);
                }
            }
            else
            {
                dt.Append(" PUBLIC " + pubid);
                if (sysid != null)
                {
                    dt.Append(" " + sysid);
                }
            }

            dt.Append("[");
            if (subset != null)
            {
                dt.Append(subset);
            }

            dt.Append("]>");

            if (DEBUG)
            {
                CError.WriteLine(dt.ToString());
            }

            _q.Append(dt.ToString());
        }
示例#17
0
        public int v2_1()
        {
            ManagedNodeWriter mnw = new ManagedNodeWriter();

            mnw.PutPattern("X");

            int count = 0;

            do
            {
                mnw.PutPattern("E/");
                count++;
            } while (count < 65536);
            mnw.PutText("<a/><b/>");
            mnw.Finish();

            CError.WriteIgnore(mnw.GetNodes() + "\n");

            ReloadSource(new StringReader(mnw.GetNodes()));
            DataReader.PositionOnElement("ELEMENT_0");

            CError.Compare(DataReader.ReadToDescendant("a"), "Couldnt go to Descendant");
            int depth = DataReader.Depth;

            CError.Compare(DataReader.ReadToNextSibling("b"), "Couldnt go to NextSibling");


            CError.Compare(DataReader.Depth, depth, "Depth is not correct");
            CError.Compare(DataReader.NodeType, XmlNodeType.Element, "Nodetype is not correct");

            while (DataReader.Read())
            {
                ;
            }
            DataReader.Close();

            return(TEST_PASS);
        }
示例#18
0
        public int v101()
        {
            string xml = @"<a xmlns:f='urn:foobar' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
                         "<b><c xsi:type='f:mytype'>some content</c></b></a>";

            ReloadSourceStr(xml);

            DataReader.Read(); CError.Compare(DataReader.Name, "a", "a");
            DataReader.Read(); CError.Compare(DataReader.Name, "b", "b");
            using (XmlReader subtree = DataReader.ReadSubtree())
            {
                subtree.Read(); CError.Compare(subtree.Name, "b", "b2");
                subtree.Read(); CError.Compare(subtree.Name, "c", "c");
                subtree.MoveToAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
                CError.Compare(subtree.Value, "f:mytype", "value");
                string ns = subtree.LookupNamespace("f");
                if (ns == null)
                {
                    return(TEST_PASS);
                }
            }
            return(TEST_FAIL);
        }
示例#19
0
        protected void TestInvalidNodeType(XmlNodeType nt)
        {
            ReloadSource();

            PositionOnNodeType(nt);
            string name  = DataReader.Name;
            string value = DataReader.Value;

            byte[] buffer = new byte[1];
            if (CheckCanReadBinaryContent())
            {
                return;
            }
            try
            {
                int nBytes = DataReader.ReadElementContentAsBinHex(buffer, 0, 1);
            }
            catch (InvalidOperationException)
            {
                return;
            }
            CError.Compare(false, "Invalid OP exception not thrown on wrong nodetype");
        }
示例#20
0
        public int c03()
        {
            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutPattern("XE/");
            mn.PutText("--&gt;");
            mn.PutPattern("e");

            CError.WriteLineIgnore(mn.GetNodes());
            XmlReaderSettings rs     = new XmlReaderSettings();
            XmlReader         reader = null;

            rs.IgnoreComments = true;
            reader            = ReaderHelper.Create(new StringReader(mn.GetNodes()), rs, (string)null);

            while (reader.Read())
            {
                ;
            }
            reader.Dispose();

            return(TEST_PASS);
        }
示例#21
0
        public bool CompareString(string strExpected)
        {
            string strActual = this.GetString();

            if (strExpected != strActual)
            {
                int expLen = (strExpected == null ? 0 : strExpected.Length);
                int actLen = (strActual == null ? 0 : strActual.Length);

                int minLen = (expLen < actLen ? expLen : actLen);

                // find the first different character
                int i;
                for (i = 0; i < minLen; i++)
                {
                    if (strExpected[i] != strActual[i])
                    {
                        CError.WriteLine("Position:" + i);
                        CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")");
                        CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")");
                        break;
                    }
                }
                if (i == minLen)
                {
                    // one string contains the other
                    CError.WriteLine("Expected length:" + expLen + " Actual length:" + actLen);
                    return(false);
                }
                CError.WriteLine("Expected string:" + strExpected);
                CError.WriteLine("Actual string:" + strActual);
                CError.Compare(false, "CompareString failed");
                return(false);
            }
            return(true);
        }
示例#22
0
        public int TestTextReadInnerXml16()
        {
            if (IsXsltReader() || IsXPathNavigatorReader() || IsSubtreeReader())
            {
                return(TEST_SKIPPED);
            }

            ReloadSource();
            DataReader.PositionOnNodeType(XmlNodeType.XmlDeclaration);
            DataReader.MoveToAttribute(DataReader.AttributeCount / 2);

            if (IsBinaryReader())
            {
                CError.Compare(DataReader.ReadInnerXml(), "utf-8", "inner");
                CError.Compare(DataReader.VerifyNode(XmlNodeType.Attribute, "encoding", "utf-8"), true, "vn");
            }
            else
            {
                CError.Compare(DataReader.ReadInnerXml(), "UTF-8", "inner");
                CError.Compare(DataReader.VerifyNode(XmlNodeType.Attribute, "encoding", "UTF-8"), true, "vn");
            }

            return(TEST_PASS);
        }
示例#23
0
        public int TestReadBinHex_13()
        {
            int BinHexlen = 10;

            byte[] BinHex = new byte[BinHexlen];

            ReloadSource(EREADER_TYPE.BINHEX_TEST);
            DataReader.PositionOnElement(ST_ELEM_NAME4);
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }

            string strActbinhex = "";

            for (int i = 0; i < BinHexlen; i = i + 2)
            {
                DataReader.ReadElementContentAsBinHex(BinHex, i, 2);
                strActbinhex = (System.BitConverter.ToChar(BinHex, i)).ToString();
                CError.WriteLine("Actual: " + strActbinhex + " Exp: " + strTextBinHex);
                CError.Compare(String.Compare(strActbinhex, 0, strTextBinHex, i / 2, 1), 0, "Compare All Valid Base64");
            }
            return(TEST_PASS);
        }
示例#24
0
        public int TestTextReadBinHex_22()
        {
            byte[] buffer = new byte[1];
            string strxml = "<abc>11B</abc>";

            ReloadSource(new StringReader(strxml));
            DataReader.PositionOnElement("abc");
            if (CheckCanReadBinaryContent())
            {
                return(TEST_PASS);
            }
            int result = 0;
            int nRead;

            while ((nRead = DataReader.ReadElementContentAsBinHex(buffer, 0, 1)) > 0)
            {
                result += nRead;
            }

            CError.Compare(result, 1, "res");
            CError.Compare(buffer[0], (byte)17, "buffer[0]");

            return(TEST_PASS);
        }
示例#25
0
        public bool CompareStringWithPrefixes(string strExpected)
        {
            MyDict <string, object> AutoIDs   = new MyDict <string, object>();
            List <string>           AttNames  = new List <string>();
            List <string>           AttScopes = new List <string>();

            string strActual = this.GetString();

            int expLen = (strExpected == null ? 0 : strExpected.Length);
            int actLen = (strActual == null ? 0 : strActual.Length);

            int minLen = (expLen < actLen ? expLen : actLen);

            // find the first different character
            int i, j = 0;

            for (i = 0; i < actLen; i++)
            {
                if (j >= expLen)
                {
                    CError.WriteLine("Output longer than expected!");
                    CError.WriteLine("Actual string: '" + strActual + "'");
                    return(false);
                }

                if (strExpected[j] != strActual[i])
                {
                    if (strExpected[j] != PREFIX_CHAR)
                    {
                        CError.WriteLine("Position:" + i);
                        CError.WriteLine("Expected char:'" + strExpected[i] + "'(" + Convert.ToInt32(strExpected[i]) + ")");
                        CError.WriteLine("Actual char:'" + strActual[i] + "'(" + Convert.ToInt32(strActual[i]) + ")");
                        return(false);
                    }

                    bool AutoGenerated = strExpected[++j] == AUTOGENERATED;
                    j += 2;
                    string ActName = "";
                    string ExpName = "";
                    string Scope   = "";
                    while (i <= actLen)
                    {
                        if (strActual[i] == '=' || strActual[i] == ' ' || strActual[i] == ':')
                        {
                            i--;
                            break;
                        }
                        else
                        {
                            ActName += strActual[i];
                        }
                        i++;
                    }
                    while (strExpected[j] != ' ')
                    {
                        ExpName += strExpected[j++];
                    }
                    j++;
                    while (strExpected[j] != PREFIX_CHAR)
                    {
                        Scope += strExpected[j++];
                    }

                    if (AutoGenerated)
                    {
                        if (AutoIDs.ContainsKey(ExpName))
                        {
                            if ((string)AutoIDs[ExpName] != ActName)
                            {
                                CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                return(false);
                            }
                        }
                        else
                        {
                            AutoIDs.Add(ExpName, ActName);
                        }
                    }
                    else
                    {
                        if (ExpName != ActName)
                        {
                            CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                            return(false);
                        }
                    }

                    for (int k = 0; k < AttNames.Count; k++)
                    {
                        if ((string)AttNames[k] == ActName)
                        {
                            for (int m = 0; m < ((string)AttScopes[k]).Length; m++)
                            {
                                for (int n = 0; n < Scope.Length; n++)
                                {
                                    if (((string)AttScopes[k])[m] == Scope[n])
                                    {
                                        CError.WriteLine("Invalid Prefix: '" + ActName + "'");
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    AttNames.Add(ActName);
                    AttScopes.Add(Scope);
                }
                j++;
            }
            if (j != expLen)
            {
                CError.WriteLine("Output shorter than expected!");
                CError.WriteLine("Actual string: '" + strActual + "'");
                return(false);
            }

            return(true);
        }
示例#26
0
        //[Variation("Simple positive test", Pri = 0, Params = new object[] { "NNS" })]
        //[Variation("Simple positive test", Pri = 0, Params = new object[] { "DNS" })]
        //[Variation("Simple positive test", Pri = 0, Params = new object[] { "NS" })]
        public int v()
        {
            string type = CurVariation.Params[0].ToString();

            CError.WriteLine("Test Type : " + type);

            ReloadSource(new StringReader(_xmlStr));
            DataReader.PositionOnElement("root");

            switch (type)
            {
            case "NNS":
                DataReader.ReadToDescendant("elem");
                if (DataReader.HasAttributes)
                {
                    CError.WriteLine("Positioned on wrong element");
                    CError.WriteIgnore(DataReader.ReadInnerXml() + "\n");
                    return(TEST_FAIL);
                }
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();
                return(TEST_PASS);

            case "DNS":
                DataReader.ReadToDescendant("elem", "elem");
                if (DataReader.HasAttributes)
                {
                    if (DataReader.GetAttribute("xmlns") == null)
                    {
                        CError.WriteLine("Positioned on wrong element, not on DNS");
                        return(TEST_FAIL);
                    }
                }
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();
                return(TEST_PASS);

            case "NS":
                DataReader.ReadToDescendant("e:elem");
                if (DataReader.HasAttributes)
                {
                    if (DataReader.GetAttribute("xmlns:e") == null)
                    {
                        CError.WriteLine("Positioned on wrong element, not on NS");
                        return(TEST_FAIL);
                    }
                }
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();
                return(TEST_PASS);

            default:
                throw new CTestFailedException("Error in Test type");
            }
        }
示例#27
0
 public CError CreateError(ErrorCode iErrorIndex, params string[] args)
 {
     CError output = new CError();
     output.Initialize(iErrorIndex, args);
     return output;
 }
示例#28
0
        //[Variation("Read on descendant with same names", Pri = 1, Params = new object[] { "NNS" })]
        //[Variation("Read on descendant with same names", Pri = 1, Params = new object[] { "DNS" })]
        //[Variation("Read on descendant with same names", Pri = 1, Params = new object[] { "NS" })]
        public int v3()
        {
            string type = CurVariation.Params[0].ToString();

            CError.WriteLine("Test Type : " + type);

            ReloadSource(new StringReader(_xmlStr));
            DataReader.PositionOnElement("root");

            //Doing a sequential read.
            switch (type)
            {
            case "NNS":
                DataReader.ReadToDescendant("elem");
                int depth = DataReader.Depth;
                if (DataReader.HasAttributes)
                {
                    CError.WriteLine("Positioned on wrong element");
                    return(TEST_FAIL);
                }
                CError.Compare(DataReader.ReadToDescendant("elem"), false, "There are no more descendants");
                CError.Compare(DataReader.NodeType, XmlNodeType.EndElement, "Wrong node type");
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();

                return(TEST_PASS);

            case "DNS":
                DataReader.ReadToDescendant("elem", "elem");
                if (DataReader.HasAttributes)
                {
                    if (DataReader.GetAttribute("xmlns") == null)
                    {
                        CError.WriteLine("Positioned on wrong element, not on DNS");
                        return(TEST_FAIL);
                    }
                }
                CError.Compare(DataReader.ReadToDescendant("elem", "elem"), false, "There are no more descendants");
                CError.Compare(DataReader.NodeType, XmlNodeType.EndElement, "Wrong node type");
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();

                return(TEST_PASS);

            case "NS":
                DataReader.ReadToDescendant("e:elem");
                if (DataReader.HasAttributes)
                {
                    if (DataReader.GetAttribute("xmlns:e") == null)
                    {
                        CError.WriteLine("Positioned on wrong element, not on DNS");
                        return(TEST_FAIL);
                    }
                }
                CError.Compare(DataReader.ReadToDescendant("e:elem"), false, "There are no more descendants");
                CError.Compare(DataReader.NodeType, XmlNodeType.EndElement, "Wrong node type");
                while (DataReader.Read())
                {
                    ;
                }
                DataReader.Close();

                return(TEST_PASS);

            default:
                throw new CTestFailedException("Error in Test type");
            }
        }
示例#29
0
 public void Log(string str)
 {
     CError.WriteLineIgnore(str);
 }
示例#30
0
        ////////////////////////////////////////////////////////////////////////////////
        //
        // This function places a fully-constructed CError object into an error container
        // and sends it to the compiler host (this would be the place to batch these guys
        // up if we decide to.
        //
        // Note that if the error can't be put into a container (if, for example, we
        // can't create a container) the error is destroyed and the host is notified via
        // exception.

        public abstract void SubmitError(CError pError);
示例#31
0
        public override XmlReader Create(MyDict <string, object> options)
        {
            string tcDesc = (string)options[ReaderFactory.HT_CURDESC];
            string tcVar  = (string)options[ReaderFactory.HT_CURVAR];

            CError.Compare(tcDesc == "subtreereader", "Invalid testcase");

            XmlReaderSettings rs         = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
            Stream            stream     = (Stream)options[ReaderFactory.HT_STREAM];
            string            filename   = (string)options[ReaderFactory.HT_FILENAME];
            object            readerType = options[ReaderFactory.HT_READERTYPE];
            object            vt         = options[ReaderFactory.HT_VALIDATIONTYPE];
            string            fragment   = (string)options[ReaderFactory.HT_FRAGMENT];
            StringReader      sr         = (StringReader)options[ReaderFactory.HT_STRINGREADER];

            if (rs == null)
            {
                rs = new XmlReaderSettings();
            }

            rs.DtdProcessing = DtdProcessing.Ignore;
            if (sr != null)
            {
                CError.WriteLine("SubtreeReader String");

                XmlReader r = ReaderHelper.Create(sr, rs, string.Empty);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (stream != null)
            {
                CError.WriteLine("SubtreeReader Stream");

                XmlReader r = ReaderHelper.Create(stream, rs, filename);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (fragment != null)
            {
                CError.WriteLine("SubtreeReader Fragment");
                rs.ConformanceLevel = ConformanceLevel.Fragment;
                StringReader tr = new StringReader(fragment);

                XmlReader r = ReaderHelper.Create(tr, rs, (string)null);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            if (filename != null)
            {
                CError.WriteLine("SubtreeReader Filename");

                Stream    fs = FilePathUtil.getStream(filename);
                XmlReader r  = ReaderHelper.Create(fs, rs, filename);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                XmlReader wr = r.ReadSubtree();
                return(wr);
            }

            throw new CTestFailedException("SubtreeReader not created");
        }
示例#32
0
        /// <summary>
        /// This method is a conveinience method and a shortcut to create an XML string. Each character in the pattern
        ///	maps to a particular Put/Open function and calls it for you. For e.g. XEAA/ will call PutDecl, OpenElement,
        ///	PutAttribute, PutAttribute and CloseElement for you.
        ///	The following is the list of all allowed characters and their function mappings :
        ///
        ///'X' :	PutDecl()
        ///'E' :	OpenElement()
        ///'M' :	CloseEmptyElement()
        ///'/' :	CloseElement()
        ///'e' :	PutEndElement()
        ///'A' :	PutAttribute()
        ///'P' :	PutPI()
        ///'T' :	PutText()
        ///'C' :	PutComment()
        ///'R' :	PutRoot()
        ///'r' :	PutEndRoot()
        ///'B' :	PutEndRoot()
        ///'W' :	PutWhiteSpace()
        ///
        /// </summary>
        /// <param name="pattern">String containing the pattern which you want to use to create
        /// the XML string. Refer to table above for supported chars.</param>

        public void PutPattern(string pattern)
        {
            char[] patternArr = pattern.ToCharArray();
            foreach (char ch in patternArr)
            {
                switch (ch)
                {
                case 'X':
                    PutDecl();
                    break;

                case 'E':
                    OpenElement();
                    break;

                case 'M':
                    CloseEmptyElement();
                    break;

                case '/':
                    CloseElement();
                    break;

                case 'e':
                    PutEndElement();
                    break;

                case 'A':
                    PutAttribute();
                    break;

                case 'P':
                    PutPI();
                    break;

                case 'T':
                    PutText();
                    break;

                case 'C':
                    PutComment();
                    break;

                case 'R':
                    PutRoot();
                    break;

                case 'r':
                    PutEndRoot();
                    break;

                case 'B':
                    PutEndRoot();
                    break;

                case 'W':
                    PutWhiteSpace();
                    break;

                default:
                    CError.WriteLine("Skipping Character : " + ch);
                    break;
                }
            }
        }