public void Visit(AssertMatch match) { if (!string.IsNullOrWhiteSpace(match.Comment)) { _xml.WriteComment(match.Comment); } _xml.WriteStartElement("AssertMatch"); if (!string.IsNullOrWhiteSpace(match.Match)) { _xml.WriteAttributeString("match", match.Match); } if (!match.RemoveSystemProperties) { _xml.WriteAttributeString("removeSysProps", "0"); } foreach (var remove in match.Removes) { _xml.WriteStartElement("Remove"); _xml.WriteAttributeString("match", remove); _xml.WriteEndElement(); } if (string.IsNullOrWhiteSpace(match.Expected)) { if (!string.IsNullOrEmpty(match.Actual)) { _xml.WriteStartElement("Actual"); WriteFormatted(match.Actual, match.IsXml, _xml); _xml.WriteEndElement(); } } else { _xml.WriteStartElement("Expected"); WriteFormatted(match.Expected, match.IsXml, _xml); _xml.WriteEndElement(); } _xml.WriteEndElement(); }
private static ITestCommand ReadTestCommand(System.Xml.XmlReader reader, string comment, string sessionId) { var cmd = ReadCommand(reader, comment, sessionId); if (cmd != null) { return(cmd); } switch (reader.LocalName) { case "AssertMatch": var result = new AssertMatch() { Comment = comment, Match = reader.GetAttribute("match") }; var removeSys = reader.GetAttribute("removeSysProps"); result.RemoveSystemProperties = (removeSys != "0"); using (var subReader = reader.ReadSubtree()) { subReader.Read(); while (!subReader.EOF) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "Remove": result.Removes.Add(reader.GetAttribute("match")); subReader.Read(); break; case "Expected": bool isXml; result.Expected = ProcessXmlValue(reader.ReadInnerXml(), out isXml); result.IsXml = isXml; break; default: subReader.Read(); break; } } else { subReader.Read(); } } } reader.Read(); return(result); case "DownloadFile": return(new DownloadFile() { Comment = comment, Text = reader.ReadInnerXml() }); } return(null); }