public int TestTextReadInnerXml2() { bool bPassed = false; string strExpected; if (IsXsltReader() || IsXmlNodeReaderDataDoc() || IsCoreReader() || IsXPathNavigatorReader()) { strExpected = ST_EXPAND_ENTITIES2; } else { if (IsXmlNodeReader()) { strExpected = ST_EXPAND_ENTITIES3; } else { strExpected = ST_EXPAND_ENTITIES3; } } ReloadSource(); DataReader.PositionOnElement(ST_ENTTEST_NAME); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); return(BoolToLTMResult(bPassed)); }
public void Reset_1() { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.Encoding = Encoding.UTF8; wSettings.OmitXmlDeclaration = true; wSettings.NewLineHandling = NewLineHandling.None; wSettings.NewLineChars = "\n"; wSettings.IndentChars = "\t\t"; wSettings.NewLineOnAttributes = true; wSettings.CloseOutput = true; wSettings.CheckCharacters = false; wSettings.ConformanceLevel = ConformanceLevel.Document; wSettings.WriteEndDocumentOnClose = false; wSettings.Reset(); CError.Equals(wSettings.Encoding, Encoding.UTF8, "Encoding"); CError.Equals(wSettings.OmitXmlDeclaration, false, "OmitXmlDeclaration"); CError.Equals(wSettings.NewLineHandling, NewLineHandling.Replace, "NewLineHandling"); CError.Equals(wSettings.NewLineChars, Environment.NewLine, "NewLineChars"); CError.Equals(wSettings.Indent, false, "Indent"); CError.Equals(wSettings.IndentChars, " ", "IndentChars"); CError.Equals(wSettings.NewLineOnAttributes, false, "NewLineOnAttributes"); CError.Equals(wSettings.CloseOutput, false, "CloseOutput"); CError.Equals(wSettings.CheckCharacters, true, "CheckCharacters"); CError.Equals(wSettings.ConformanceLevel, ConformanceLevel.Document, "ConformanceLevel"); CError.Equals(wSettings.WriteEndDocumentOnClose, true, "WriteEndDocumentOnClose"); }
public int TestLinePos43() { string strXml = "<foo\n attr1='bar'\n attr2='foo'\n/>"; ReloadSourceStr(strXml); if (!IsCustomReader()) { DataReader.Read(); CError.Equals(DataReader.LineNumber, 1, null); CError.Equals(DataReader.LinePosition, 2, null); DataReader.MoveToFirstAttribute(); CError.Equals(DataReader.LineNumber, 2, null); CError.Equals(DataReader.LinePosition, 5, null); DataReader.MoveToNextAttribute(); CError.Equals(DataReader.LineNumber, 3, null); CError.Equals(DataReader.LinePosition, 5, null); DataReader.Read(); CError.Equals(DataReader.LineNumber, IsSubtreeReader() ? 0 : 4, null); CError.Equals(DataReader.LinePosition, IsSubtreeReader() ? 0 : 3, null); } return(TEST_PASS); }
public int TestReadInnerXml10() { bool bPassed = false; string strExpected; if (IsXsltReader() || IsXmlNodeReaderDataDoc() || IsXmlValidatingReader() || IsCoreReader() || IsXPathNavigatorReader()) { strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES4; } else if (IsXmlNodeReader()) { strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES2; } else { strExpected = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES2; } string strExpectedAttValue = ST_ENT1_ATT_EXPAND_ENTITIES; if (IsXmlTextReader()) { strExpectedAttValue = ST_ENT1_ATT_EXPAND_CHAR_ENTITIES; } ReloadSource(); DataReader.PositionOnElement(ST_ENTTEST_NAME); bPassed = DataReader.MoveToFirstAttribute(); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Attribute, "att1", strExpectedAttValue); return(BoolToLTMResult(bPassed)); }
//[Variation("ReadContentAsBinHex on an xmlns attribute", Param = "<foo xmlns='default'> <bar > id='1'/> </foo>")] //[Variation("ReadContentAsBinHex on an xmlns:k attribute", Param = "<k:foo xmlns:k='default'> <k:bar id='1'/> </k:foo>")] //[Variation("ReadContentAsBinHex on an xml:space attribute", Param = "<foo xml:space='default'> <bar > id='1'/> </foo>")] //[Variation("ReadContentAsBinHex on an xml:lang attribute", Param = "<foo xml:lang='default'> <bar > id='1'/> </foo>")] public int TestBinHex_34() { string xml = (string)CurVariation.Param; byte[] buffer = new byte[8]; try { ReloadSource(new StringReader(xml)); DataReader.Read(); if (IsBinaryReader()) { DataReader.Read(); } DataReader.MoveToAttribute(0); CError.Compare(DataReader.Value, "default", "value"); CError.Equals(DataReader.ReadContentAsBinHex(buffer, 0, 8), 5, "size"); CError.Equals(false, "No exception"); } catch (XmlException) { return(TEST_PASS); } catch (NotSupportedException) { return(TEST_PASS); } finally { DataReader.Close(); } return(TEST_FAIL); }
public int XmlExceptionAndXmlTextReaderLineNumberShouldBeSameAfterExceptionIsThrown() { string filename = TestData + "Common/invalid-ucs4.xml"; if (!IsCustomReader()) { try { ReloadSource(filename); while (DataReader.Read()) { ; } return(TEST_FAIL); } catch (XmlException e) { CError.WriteLine(e.Message); CError.WriteLine("Reader Line : {0}, Exception Line {1}", DataReader.LineNumber, e.LinePosition); CError.Equals(DataReader.LineNumber, IsSubtreeReader() ? 0 : e.LineNumber, "Reader line number and Exception line number must be same"); CError.WriteLine("Reader Position : {0}, Exception Position {1}", DataReader.LinePosition, e.LinePosition); CError.Equals(DataReader.LinePosition, IsSubtreeReader() ? 0 : e.LinePosition, "Reader line position and Exception line position must be same"); return(TEST_PASS); } } return(TEST_PASS); }
public int TestReadBinHex_36() { string xml = @"<elem0> 123" + "\n" + @" <elem1>" + "\r" + @"123 <elem2> 123 </elem2>" + "\r\n" + @" 123</elem1> 123 </elem0>"; ReloadSource(new StringReader(xml)); if (CheckCanReadBinaryContent()) { return(TEST_PASS); } byte[] buffer = new byte[3]; int startPos = 0; int readSize = 3; int currentSize = 0; DataReader.Read(); while (DataReader.Read()) { CError.Equals(DataReader.Value.Contains("123"), "Value"); currentSize = DataReader.ReadContentAsBinHex(buffer, startPos, readSize); CError.Equals(currentSize, 1, "size"); CError.Equals(buffer[0], (byte)18, "buffer"); if (!(IsXPathNavigatorReader() || IsXmlNodeReader() || IsXmlNodeReaderDataDoc())) { CError.WriteLine("LineNumber" + DataReader.LineNumber); CError.WriteLine("LinePosition" + DataReader.LinePosition); } } DataReader.Close(); return(TEST_PASS); }
public int TestReadValue_5() { string xml = "<elem0>123<elem1>123<elem2>123</elem2>123</elem1>123</elem0>"; ReloadSource(new StringReader(xml)); char[] chars = new char[100]; int startPos = 0; int readSize = 3; int currentSize = 0; while (DataReader.Read()) { DataReader.Read(); if (DataReader.NodeType == XmlNodeType.Text || DataReader.NodeType == XmlNodeType.None) { continue; } currentSize = DataReader.ReadValueChunk(chars, startPos, readSize); CError.Equals(currentSize, 3, "size"); CError.Equals(chars[0].ToString(), "1", "buffer1"); CError.Equals(chars[1].ToString(), "2", "buffer2"); CError.Equals(chars[2].ToString(), "3", "buffer3"); CError.Equals(DataReader.LineNumber, 0, "LineNumber"); CError.Equals(DataReader.LinePosition, 0, "LinePosition"); } DataReader.Close(); return(TEST_PASS); }
public int TestReadValue_8() { string xml = @"<elem0> 123" + "\n" + @" <elem1>" + "\r" + @"123 <elem2> 123 </elem2>" + "\r\n" + @" 123</elem1> 123 </elem0>"; ReloadSource(new StringReader(xml)); char[] chars = new char[100]; int startPos = 0; int readSize = 3; int currentSize = 0; try { while (DataReader.Read()) { DataReader.Read(); if (DataReader.NodeType == XmlNodeType.Text || DataReader.NodeType == XmlNodeType.None) { continue; } CError.Equals(DataReader.Value.Contains("123"), "Value"); currentSize = DataReader.ReadValueChunk(chars, startPos, readSize); CError.Equals(currentSize, 3, "size"); CError.Equals(DataReader.LineNumber, 0, "LineNumber"); CError.Equals(DataReader.LinePosition, 0, "LinePosition"); } } catch (NotSupportedException e) { CError.WriteLine(e); } DataReader.Close(); return(TEST_PASS); }
public void Clone_1() { XmlWriterSettings wSettings = new XmlWriterSettings(); wSettings.Encoding = Encoding.UTF8; wSettings.OmitXmlDeclaration = true; wSettings.NewLineHandling = NewLineHandling.Entitize; wSettings.NewLineChars = "\n"; wSettings.IndentChars = " "; wSettings.NewLineOnAttributes = true; wSettings.CloseOutput = true; wSettings.CheckCharacters = false; wSettings.ConformanceLevel = ConformanceLevel.Document; wSettings.WriteEndDocumentOnClose = false; XmlWriterSettings newSettings = wSettings.Clone(); CError.Equals(wSettings.Encoding, newSettings.Encoding, "Encoding"); CError.Equals(wSettings.OmitXmlDeclaration, newSettings.OmitXmlDeclaration, "OmitXmlDeclaration"); CError.Equals(wSettings.NewLineHandling, newSettings.NewLineHandling, "NewLineHandling"); CError.Equals(wSettings.NewLineChars, newSettings.NewLineChars, "NewLineChars"); CError.Equals(wSettings.Indent, newSettings.Indent, "Indent"); CError.Equals(wSettings.IndentChars, newSettings.IndentChars, "IndentChars"); CError.Equals(wSettings.NewLineOnAttributes, newSettings.NewLineOnAttributes, "NewLineOnAttributes"); CError.Equals(wSettings.CloseOutput, newSettings.CloseOutput, "CloseOutput"); CError.Equals(wSettings.CheckCharacters, newSettings.CheckCharacters, "CheckCharacters"); CError.Equals(wSettings.ConformanceLevel, newSettings.ConformanceLevel, "ConformanceLevel"); CError.Equals(wSettings.WriteEndDocumentOnClose, newSettings.WriteEndDocumentOnClose, "WriteEndDocumentOnClose"); }
public void close_2(XmlWriterUtils utils) { XmlWriter w = utils.CreateWriter(); w.Dispose(); CError.Equals(w.Settings.Indent, utils.IsIndent(), "Incorrect default value of Indent"); CError.Equals(w.Settings.CheckCharacters, true, "Incorrect default value of CheckCharacters"); }
public int v7() { CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), GetParserContext()), true, "StreamOverload3"); CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), GetParserContext()), true, "TextOverload3"); return(TEST_PASS); }
//[Variation("DecodeName with uppercase/lowercase")] public int v4() { CError.Equals(XmlConvert.EncodeName("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeName"); CError.Equals(XmlConvert.EncodeLocalName("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeLocalName"); CError.Equals(XmlConvert.EncodeNmToken("_xFF71__xff71_"), "_x005F_xFF71__x005F_xff71_", "EncodeNmToken"); CError.Equals(XmlConvert.DecodeName("_xFF71__xff71_"), "\uFF71\uFF71", "DecodeName"); return(TEST_PASS); }
public int TestNormalization5() { bool bPassed = false; ReloadSource(); DataReader.PositionOnElement(ST_ATTR_TEST_NAME); bPassed = CError.Equals(DataReader.GetAttribute("TAB"), ST_ATTR_EXP_STRING, CurVariation.Desc); return(BoolToLTMResult(bPassed)); }
public int TestNormalization6() { bool bPassed = false; ReloadSource(); DataReader.PositionOnElement("ENDOFLINE1"); DataReader.Read(); bPassed = CError.Equals(DataReader.Value, ST_ELEM_EXP_STRING, CurVariation.Desc); return(BoolToLTMResult(bPassed)); }
public int TestNormalization4() { bool bPassed = false; ReloadSource(); DataReader.PositionOnElement(ST_ATTR_TEST_NAME); // as far as the MS attribute is CDATA internal spaces are not compacted bPassed = CError.Equals(DataReader.GetAttribute("MS"), ST_ATTR_EXP_STRING_MS, CurVariation.Desc); return(BoolToLTMResult(bPassed)); }
public void default_6(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.IndentChars, " ", "Incorrect default value of IndentChars"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.IndentChars, " ", "Incorrect default value of IndentChars"); return; }
public int TestReadInnerXml4() { bool bPassed = false; string strExpected = "1234"; ReloadSource(); DataReader.PositionOnElement("NONEMPTY2"); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Element, "ACT2", string.Empty); return(BoolToLTMResult(bPassed)); }
public void default_5(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.Indent, false, "Incorrect default value of wSettings.Indent"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.Indent, utils.IsIndent(), "Incorrect default value of w.Settings.Indent"); w.Dispose(); return; }
public void default_7(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.NewLineOnAttributes, false, "Incorrect default value of NewLineOnAttributes"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.NewLineOnAttributes, false, "Incorrect default value of NewLineOnAttributes"); return; }
public void default_10(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.CheckCharacters, true, "Incorrect default value of CheckCharacters"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.CheckCharacters, true, "Incorrect default value of CheckCharacters"); w.Dispose(); return; }
public void default_11(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.ConformanceLevel, ConformanceLevel.Document, "Incorrect default value of ConformanceLevel"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.ConformanceLevel, ConformanceLevel.Document, "Incorrect default value of ConformanceLevel"); w.Dispose(); return; }
public void default_4(XmlWriterUtils utils) { XmlWriterSettings wSettings = new XmlWriterSettings(); CError.Equals(wSettings.NewLineChars, Environment.NewLine, "Incorrect default value of NewLineChars"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.NewLineChars, Environment.NewLine, "Incorrect default value of NewLineChars"); w.Dispose(); return; }
public void default_13(XmlWriterUtils utils) { XmlWriterSettings ws = new XmlWriterSettings(); CError.Equals(ws.WriteEndDocumentOnClose, true, "Incorrect default value of WriteEndDocumentOnClose"); XmlWriter w = utils.CreateWriter(); CError.Equals(w.Settings.WriteEndDocumentOnClose, true, "Incorrect default value of WriteEndDocumentOnClose"); w.Dispose(); return; }
public int v6() { CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), (string)null), true, "StreamOverload2"); CError.Equals(ReaderDelegate.Create(GetStream(), GetSettings(), (XmlParserContext)null), true, "StreamOverload2"); CError.Equals(ReaderDelegate.Create(GetUrl(), GetSettings()), true, "URL Overload 1"); CError.Equals(ReaderDelegate.Create(GetUrl(), GetSettings(), GetParserContext()), true, "URL Overload 2"); CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), (string)null), true, "TextReader Overload2"); CError.Equals(ReaderDelegate.Create(GetTextReader(), GetSettings(), (XmlParserContext)null), true, "TextReader Overload2"); CError.Equals(ReaderDelegate.Create(GetXmlReader(), GetSettings()), true, "XmlReader Overload1"); return(TEST_PASS); }
public int v3() { CError.Equals(ReaderDelegate.Create(GetStream(), null, GetParserContext()), true, "StreamOverload2"); CError.Equals(ReaderDelegate.Create(GetStream(), null), true, "StreamOverload3"); CError.Equals(ReaderDelegate.Create(GetUrl(), null), true, "URL Overload 1"); CError.Equals(ReaderDelegate.Create(GetUrl(), null, GetParserContext()), true, "URL Overload 2"); CError.Equals(ReaderDelegate.Create(GetTextReader(), null, GetParserContext()), true, "TextReader Overload2"); CError.Equals(ReaderDelegate.Create(GetTextReader(), null), true, "TextReader Overload3"); CError.Equals(ReaderDelegate.Create(GetXmlReader(), null), true, "XmlReader Overload1"); return(TEST_PASS); }
public int TestReadInnerXml9() { bool bPassed = false; string strExpected = "a1value"; ReloadSource(); DataReader.PositionOnElement("ATTRIBUTE2"); bPassed = DataReader.MoveToFirstAttribute(); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Attribute, "a1", strExpected); return(BoolToLTMResult(bPassed)); }
public int TestReadInnerXml5() { bool bPassed = false; string strExpected; strExpected = "xxx<MARKUP />yyy"; ReloadSource(); DataReader.PositionOnElement("CHARS2"); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Element, "CHARS_ELEM1", string.Empty); return(BoolToLTMResult(bPassed)); }
public int TestReadInnerXml6() { bool bPassed = false; string strExpected; strExpected = "<ELEM1 /><ELEM2>xxx yyy</ELEM2><ELEM3 />"; ReloadSource(); DataReader.PositionOnElement("SKIP3"); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Element, "AFTERSKIP3", string.Empty); return(BoolToLTMResult(bPassed)); }
public int TestReadInnerXml7() { bool bPassed = false; string strExpected = "<e1 a1='a1value' a2='a2value'><e2 a1='a1value' a2='a2value'><e3 a1='a1value' a2='a2value'>leave</e3></e2></e1>"; strExpected = strExpected.Replace('\'', '"'); ReloadSource(); DataReader.PositionOnElement("CONTENT"); bPassed = CError.Equals(DataReader.ReadInnerXml(), strExpected, CurVariation.Desc); VerifyNextNode(XmlNodeType.Element, "TITLE", string.Empty); return(BoolToLTMResult(bPassed)); }