public override object InformationToProperty(IInformation information, Type propertyType) { var value = information as IInformationValue; if (value == null) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, $"'{information.Name}' must be a value type."); } try { // Change .md or .markdown extensions to .html and change macros to an XML form. var menuString = MarkdownProcessor.Transform( ParsingUtils.ReplaceMacros( Regex.Replace( OtherUtils.ReadAllText(value.Value), @"\w+?\.(?:md|markdown)", match => PathUtils.ChangeExtension(match.Value, "html")))); return XmlUtils.WrapAndParse("Menu", menuString); } catch (Exception e) { throw new OptionReaderException(information.Lines.First().Number, information.Lines.Last().Number, e.Message); } }
public void ModifiedOutput(string source, string expected) { // Run the replacement on the string case and compare results. var actual = ParsingUtils.ReplaceMacros(source); Assert.AreEqual(expected, actual, "Lower-case case failed."); // Run the replacement on the string with random case and compare the lowercase results. var actualRandomCase = ParsingUtils.ReplaceMacros(source.ToRandomCase()).ToLower(); Assert.AreEqual(expected, actualRandomCase, "Randomized case failed."); }
public void UnchangedOutput(string source) { var actual = ParsingUtils.ReplaceMacros(source); Assert.AreEqual(source, actual); }