public void Execute() { var worker = new RemoveComments(); var data = new Dictionary <string, string> { { "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>" }, { "<!-- Generator: Adobe Illustrator 15.0.0, SVG Export --><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>" }, { "<!-- Generator: Adobe Illustrator 15.0.0, SVG Export --><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><!-- Another comment --><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>" }, { "<!-- Comment <here> ?&* --><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>", "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 16\"><path d=\"M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z\"></path></svg>" }, }; foreach (var input in data.Keys) { Assert.AreEqual(data[input], worker.Work(input)); } }
/// <summary> /// Constructs a command file from the command file header. /// </summary> /// <param name="commandFile"> /// A header (CMDF) containing the lines of a command file. /// </param> /// <param name="sets"> /// /// </param> public ModelCommandFile(IHeaderArray <string> commandFile, IEnumerable <KeyValuePair <string, IImmutableList <string> > > sets) { CommandText = commandFile.Values .AsParallel() .AsOrdered() .Select(x => RemoveComments.Replace(x, string.Empty)) .Aggregate( new StringBuilder(), (current, next) => current.Append(next + ' '), result => result.ToString()); ExogenousCommands = ExogenousVariableSection.Matches(CommandText) .Cast <Match>() .Aggregate( new StringBuilder(), (current, next) => current.Append(next.Value + ' '), result => result.ToString()); ShockedCommands = ShockedVariablesSection.Match(CommandText).Value; ExogenousDefinitions = SetExogenousVariables(ExogenousCommands, sets).ToImmutableArray(); ShockedDefinitions = SetShockedVariables(ShockedCommands).ToImmutableArray(); foreach (VariableDefinition def in ExogenousDefinitions) { Console.WriteLine(def); } foreach (VariableDefinition def in ShockedDefinitions) { Console.WriteLine(def); } }