예제 #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));
        }