public void ExtractSnippet()
        {
            // Declare content
            const string content =
                @"Some
Content
Here";
            // Mock file system
            IFileSystem fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { "Content.txt", new MockFileData(content) }
            });

            // Run the extraction
            DefaultSnippetExtractor extractor    = new DefaultSnippetExtractor();
            FileInfoBase            fileInfoBase = fileSystem.FileInfo.FromFileName("Content.txt");

            Extension.Model.PlainTextSnippet snippet = extractor.Extract(fileInfoBase, null) as Extension.Model.PlainTextSnippet;

            // Load the expected file content
            MemoryStream memoryStream = new MemoryStream();

            using (var fileReader = new StreamReader(fileInfoBase.OpenRead()))
                using (var fileWriter = new StreamWriter(memoryStream))
                {
                    fileWriter.Write(fileReader.ReadToEnd());
                }

            // Assert
            Assert.AreEqual(content, snippet.Text);
        }
Beispiel #2
0
        public void CreateExtractorUnknownLanguage()
        {
            // Process
            DefaultSnippetExtractor extractor = this.SnippetExtractorFactory.CreateExtractor(SnippetExtractionRule.Parse("foo [File.cs]")) as DefaultSnippetExtractor;

            Assert.IsNotNull(extractor);
            Assert.IsTrue(extractor is DefaultSnippetExtractor);
        }