public void ExtractSnippet(string fileName, string pattern, string expectedFile) { // Run the extraction ISnippetExtractor snippetExtractor; if (!this.extractorCache.TryGetValue(fileName, out snippetExtractor)) { snippetExtractor = new XmlSnippetExtractor(this.SourceDirectories); this.extractorCache[fileName] = snippetExtractor; } Projbook.Core.Model.Snippet snippet = snippetExtractor.Extract(fileName, pattern); // Load the expected file content MemoryStream memoryStream = new MemoryStream(); using (var fileReader = new StreamReader(new FileStream(Path.GetFullPath(Path.Combine("Resources", "Expected", expectedFile)), FileMode.Open))) using (var fileWriter = new StreamWriter(memoryStream)) { fileWriter.Write(fileReader.ReadToEnd()); } Console.WriteLine(System.Text.Encoding.UTF8.GetString(memoryStream.ToArray()).Replace("\r\n", Environment.NewLine)); Console.WriteLine(snippet.Content.Replace("\r\n", Environment.NewLine)); // Assert Assert.AreEqual( System.Text.Encoding.UTF8.GetString(memoryStream.ToArray()).Replace("\r\n", Environment.NewLine), snippet.Content.Replace("\r\n", Environment.NewLine)); }
public void ExtractSnippetNotFound(string fileName, string pattern) { // Run the extraction XmlSnippetExtractor extractor = new XmlSnippetExtractor(this.SourceDirectories); Projbook.Core.Model.Snippet snippet = extractor.Extract(fileName, pattern); }