public void Preprocess_WhenReaderIsNull_Throws() { var preprocessor = new XmlPreprocessor(); var writer = XmlWriter.Create(new StringBuilder()); Assert.Throws <ArgumentNullException>(() => preprocessor.Preprocess(null, writer)); }
public void Preprocess_WhenWriterIsNull_Throws() { var preprocessor = new XmlPreprocessor(); var reader = XmlReader.Create(new StringReader("")); Assert.Throws <ArgumentNullException>(() => preprocessor.Preprocess(reader, null)); }
private static string PreprocessString(XmlPreprocessor preprocessor, string xml) { using (var reader = XmlReader.Create(new StringReader(xml))) { var xmlOutput = new StringBuilder(); using (var writer = XmlWriter.Create(xmlOutput, new XmlWriterSettings() { OmitXmlDeclaration = true })) { preprocessor.Preprocess(reader, writer); } return(xmlOutput.ToString()); } }
private Plugin PreprocessAndDeserialize(TextReader reader) { XmlPreprocessor preprocessor = new XmlPreprocessor(); foreach (string constant in initialPreprocessorConstants) { preprocessor.Define(constant); } StringBuilder preprocessedXml = new StringBuilder(); using (XmlReader xmlReader = XmlReader.Create(reader)) { using (XmlWriter xmlWriter = XmlWriter.Create(preprocessedXml)) preprocessor.Preprocess(xmlReader, xmlWriter); } var plugin = (Plugin)PluginXmlSerializer.Deserialize(new StringReader(preprocessedXml.ToString())); plugin.Validate(); return(plugin); }