public void ExtractSnippetInvalidRule(string pattern)
 {
     // Run the extraction
     CSharpSnippetExtractor extractor = new CSharpSnippetExtractor(pattern, this.SourceDirectories);
     Projbook.Core.Model.Snippet snippet = extractor.Extract();
 }
Ejemplo n.º 2
0
 public void ExtractSnippetNotFound(string fileName, string pattern)
 {
     // Run the extraction
     CSharpSnippetExtractor extractor = new CSharpSnippetExtractor(this.SourceDirectories);
     Projbook.Core.Model.Snippet snippet = extractor.Extract(fileName, pattern);
 }
        public void ExtractSnippet(string pattern, string expectedFile)
        {
            // Run the extraction
            CSharpSnippetExtractor extractor = new CSharpSnippetExtractor(pattern, this.SourceDirectories);
            Projbook.Core.Model.Snippet snippet = extractor.Extract();

            // 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());
            }

            // Assert
            Assert.AreEqual(
                System.Text.Encoding.UTF8.GetString(memoryStream.ToArray()).Replace("\r\n", Environment.NewLine),
                snippet.Content.Replace("\r\n", Environment.NewLine));
        }