示例#1
0
        public void Define_WhenConstantAlreadyDefined_DoesNothing()
        {
            var preprocessor = new XmlPreprocessor();

            preprocessor.Define("CONSTANT");

            preprocessor.Define("CONSTANT");

            Assert.IsTrue(preprocessor.IsDefined("CONSTANT"));
        }
示例#2
0
        public void IsDefined_WhenConstantIsDefined_ReturnsTrue()
        {
            var preprocessor = new XmlPreprocessor();

            preprocessor.Define("CONSTANT");

            Assert.IsTrue(preprocessor.IsDefined("CONSTANT"));
        }
示例#3
0
        public void Preprocess_WhenPresetDefinesBeforeProcessing_UsesThem()
        {
            var preprocessor = new XmlPreprocessor();

            preprocessor.Define("CONSTANT");
            string input = "<root><?ifdef CONSTANT?>Text<?endif?></root>";

            string output = PreprocessString(preprocessor, input);

            Assert.AreEqual("<root>Text</root>", output);
        }
示例#4
0
        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);
        }
示例#5
0
        public void Define_WhenConstantIsNull_Throws()
        {
            var preprocessor = new XmlPreprocessor();

            Assert.Throws <ArgumentNullException>(() => preprocessor.Define(null));
        }