Example #1
0
 public virtual void DumpVariationInfo()
 {
     CError.WriteIgnore(this.IsVariationValid + "\n");
     CError.WriteIgnore(this.TestFileName + "\n");
     CError.WriteIgnore(this.PExceptionType + "\n");
     CError.WriteIgnore(this.PExceptionMsg + "\n");
 }
Example #2
0
        public int v2()
        {
            ManagedNodeWriter mnw = new ManagedNodeWriter();

            mnw.PutPattern("X");

            int count = 0;

            do
            {
                mnw.PutPattern("E/");
                count++;
            }while (mnw.GetNodes().Length < 4096);
            mnw.PutText("<a/>");
            mnw.Finish();
            CError.WriteIgnore(mnw.GetNodes() + "\n");


            ReloadSource(new StringReader(mnw.GetNodes()));
            DataReader.PositionOnElement("ELEMENT_1");
            CError.WriteLine("Reading to : " + "a");
            DataReader.ReadToDescendant("a");

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

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

            return(TEST_PASS);
        }
Example #3
0
        /// <summary>
        /// Reads the value of the tag in the Spec file under the Data Section
        /// </summary>
        /// <param name="tag">Name of the tag to read.</param>
        /// <param name="throwOnNull">IF true, will check for null and throw,
        /// set to true if you want to throw an exception if value is not found.
        /// If set to false, the return value can be null</param>
        /// <returns>Value of the tag under Data Section</returns>
        protected string ReadData(string tag, bool throwOnNull)
        {
            CError.WriteIgnore("Loading .. " + tag + " : ");
            string s = null;

            if (throwOnNull)
            {
                s = varInfo.SelectExistingValue(tag, "Data");
                Log(s);
            }
            else
            {
                s = varInfo.SelectValue(tag, "Data");
                Log(s);
            }
            return(s);
        }
Example #4
0
        /// <summary>
        /// Reads the value of the tag in the Spec file under the FilterCriteria Section
        /// </summary>
        /// <param name="tag">Name of the tag to read.</param>
        /// <param name="throwOnNull">IF true, will check for null and throw,
        /// set to true if you want to throw an exception if value is not found.
        /// If set to false, the return value can be null</param>
        /// <returns>Value of the tag under FilterCriteria Section</returns>
        protected string ReadFilterCriteria(string tag, bool throwOnNull)
        {
            CError.WriteIgnore("Filtering " + tag + " : ");
            string s = null;

            if (throwOnNull)
            {
                s = varInfo.SelectExistingValue(tag, "FilterCriteria");
                Log(s);
            }
            else
            {
                s = varInfo.SelectValue(tag, "FilterCriteria");
                Log(s);
            }
            return(s);
        }
        //[Variation("Default Reader, Check Characters On and pass invalid characters in text", Pri = 0, Params = new object[] { "CoreValidatingReader" })]
        //[Variation("Default Reader, Check Characters On and pass invalid characters in text", Pri = 0, Params = new object[] { "CoreReader" })]
        public int v5()
        {
            string readerType      = (string)this.CurVariation.Params[0];
            bool   exceptionThrown = false;

            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutDecl();
            mn.OpenElement();
            mn.CloseElement();
            mn.PutText("&#xd800;"); //This is invalid char in XML.
            mn.PutEndElement();
            string invalidCharXml = mn.GetNodes();

            XmlReaderSettings rs = new XmlReaderSettings();

            rs.CheckCharacters = true;

            XmlReader reader = ReaderHelper.CreateReader(readerType, new StringReader(invalidCharXml), false, null, rs);

            try
            {
                while (reader.Read())
                {
                    ;
                }
            }
            catch (XmlException xe)
            {
                CError.WriteIgnore(invalidCharXml);
                CError.WriteLine(xe.Message);
                CError.WriteLine(xe.StackTrace);
                exceptionThrown = true;
            }

            mn.Close();
            reader.Dispose();

            if (!exceptionThrown)
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
        //[Variation("Default Reader, Check Characters Off and pass invalid characters in element", Pri = 0, Params = new object[] { "CoreValidatingReader" })]
        //[Variation("Default Reader, Check Characters Off and pass invalid characters in element", Pri = 0, Params = new object[] {"CoreReader"})]
        public int v4()
        {
            string readerType      = (string)this.CurVariation.Params[0];
            bool   exceptionThrown = false;

            ManagedNodeWriter mn = new ManagedNodeWriter();

            mn.PutDecl();
            mn.OpenElement("&#xd800;");
            mn.CloseEmptyElement();

            XmlReaderSettings rs = new XmlReaderSettings();

            rs.CheckCharacters = false;
            XmlReader reader = ReaderHelper.CreateReader(readerType, new StringReader(mn.GetNodes()), false, null, rs);

            try
            {
                while (reader.Read())
                {
                    ;
                }
            }
            catch (XmlException xe)
            {
                CError.WriteIgnore(xe.Message + "\n");
                exceptionThrown = true;
            }

            mn.Close();
            reader.Dispose();

            if (!exceptionThrown)
            {
                return(TEST_FAIL);
            }

            return(TEST_PASS);
        }
        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);
        }
Example #8
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");
            }
        }