Пример #1
0
        private void ClassifyFile(MarkdownTestFilesFixture fixture, string fileName) {
            string testFile = fixture.GetDestinationPath(fileName);
            string content = fixture.LoadDestinationFile(fileName);

            TextBufferMock textBuffer = new TextBufferMock(content, MdContentTypeDefinition.ContentType);

            var crs = _exportProvider.GetExportedValue<IClassificationTypeRegistryService>();
            var ctrs = _exportProvider.GetExportedValue<IContentTypeRegistryService>();
            var cnp = _exportProvider.GetExports<IClassificationNameProvider, IComponentContentTypes>();

            MdClassifierProvider classifierProvider = new MdClassifierProvider(crs, ctrs, cnp, _exportProvider.GetExportedValue<ICoreShell>());
            _exportProvider.GetExportedValue<ICoreShell>().CompositionService.SatisfyImportsOnce(classifierProvider);

            IClassifier cls = classifierProvider.GetClassifier(textBuffer);

            IList<ClassificationSpan> spans = cls.GetClassificationSpans(new SnapshotSpan(textBuffer.CurrentSnapshot, new Span(0, textBuffer.CurrentSnapshot.Length)));
            string actual = ClassificationWriter.WriteClassifications(spans);

            string baselineFile = testFile + ".colors";

            if (_regenerateBaselineFiles) {
                baselineFile = Path.Combine(fixture.SourcePath, @"Classification\", Path.GetFileName(testFile)) + ".colors";
                TestFiles.UpdateBaseline(baselineFile, actual);
            } else {
                TestFiles.CompareToBaseLine(baselineFile, actual);
            }
        }
Пример #2
0
 public RendererTest(MarkdownTestFilesFixture files)
 {
     _files = files;
     _shell = TestCoreShell.CreateSubstitute();
     _shell.SetupSettingsSubstitute();
     _shell.SetupSessionSubstitute();
 }
Пример #3
0
        private static void ClassifyFile(MarkdownTestFilesFixture fixture, string fileName)
        {
            string testFile = fixture.GetDestinationPath(fileName);
            string content = fixture.LoadDestinationFile(fileName);

            TextBufferMock textBuffer = new TextBufferMock(content, MdContentTypeDefinition.ContentType);

            MdClassifierProvider classifierProvider = new MdClassifierProvider();
            EditorShell.Current.CompositionService.SatisfyImportsOnce(classifierProvider);

            IClassifier cls = classifierProvider.GetClassifier(textBuffer);

            IList<ClassificationSpan> spans = cls.GetClassificationSpans(new SnapshotSpan(textBuffer.CurrentSnapshot, new Span(0, textBuffer.CurrentSnapshot.Length)));
            string actual = ClassificationWriter.WriteClassifications(spans);

            string baselineFile = testFile + ".colors";

            if (_regenerateBaselineFiles)
            {
                // Update this to your actual enlistment if you need to update baseline
                string enlistmentPath = @"F:\RTVS\src\Markdown\Editor\Test\Files\Classification";
                baselineFile = Path.Combine(enlistmentPath, Path.GetFileName(testFile)) + ".colors";

                TestFiles.UpdateBaseline(baselineFile, actual);
            }
            else
            {
                TestFiles.CompareToBaseLine(baselineFile, actual);
            }
        }
Пример #4
0
        private void ClassifyFile(MarkdownTestFilesFixture fixture, string fileName)
        {
            string testFile = fixture.GetDestinationPath(fileName);
            string content  = fixture.LoadDestinationFile(fileName);

            TextBufferMock textBuffer = new TextBufferMock(content, MdContentTypeDefinition.ContentType);

            var crs  = _exportProvider.GetExportedValue <IClassificationTypeRegistryService>();
            var ctrs = _exportProvider.GetExportedValue <IContentTypeRegistryService>();
            var cnp  = _exportProvider.GetExports <IClassificationNameProvider, IComponentContentTypes>();

            MdClassifierProvider classifierProvider = new MdClassifierProvider(crs, ctrs, cnp, _exportProvider.GetExportedValue <ICoreShell>());

            _exportProvider.GetExportedValue <ICoreShell>().CompositionService.SatisfyImportsOnce(classifierProvider);

            IClassifier cls = classifierProvider.GetClassifier(textBuffer);

            IList <ClassificationSpan> spans = cls.GetClassificationSpans(new SnapshotSpan(textBuffer.CurrentSnapshot, new Span(0, textBuffer.CurrentSnapshot.Length)));
            string actual = ClassificationWriter.WriteClassifications(spans);

            string baselineFile = testFile + ".colors";

            if (_regenerateBaselineFiles)
            {
                baselineFile = Path.Combine(fixture.SourcePath, @"Classification\", Path.GetFileName(testFile)) + ".colors";
                TestFiles.UpdateBaseline(baselineFile, actual);
            }
            else
            {
                TestFiles.CompareToBaseLine(baselineFile, actual);
            }
        }
Пример #5
0
        private void ClassifyFile(MarkdownTestFilesFixture fixture, string fileName)
        {
            var testFile = fixture.GetDestinationPath(fileName);
            var content  = fixture.LoadDestinationFile(fileName);

            var textBuffer = new TextBufferMock(content, MdContentTypeDefinition.ContentType);

            var crs  = _coreShell.GetService <IClassificationTypeRegistryService>();
            var ctrs = _coreShell.GetService <IContentTypeRegistryService>();
            var classifierProvider = new MdClassifierProvider(crs, ctrs);
            var cls = classifierProvider.GetClassifier(textBuffer);

            var spans        = cls.GetClassificationSpans(new SnapshotSpan(textBuffer.CurrentSnapshot, new Span(0, textBuffer.CurrentSnapshot.Length)));
            var actual       = ClassificationWriter.WriteClassifications(spans);
            var baselineFile = testFile + ".colors";

            if (_regenerateBaselineFiles)
            {
                baselineFile = Path.Combine(fixture.SourcePath, @"Classification\", Path.GetFileName(testFile)) + ".colors";
                TestFiles.UpdateBaseline(baselineFile, actual);
            }
            else
            {
                TestFiles.CompareToBaseLine(baselineFile, actual);
            }
        }
Пример #6
0
        public static void TokenizeFile <TToken, TTokenType, TTokenizer>(MarkdownTestFilesFixture fixture, string name, string language)
            where TTokenizer : ITokenizer <TToken>, new()
            where TToken : IToken <TTokenType>
        {
            Action a = () => TokenizeFileImplementation <TToken, TTokenType, TTokenizer>(fixture, name);

            a.ShouldNotThrow();
        }
 public TokenizeSampleMdFilesTest(MarkdownTestFilesFixture files) {
     _files = files;
 }
Пример #8
0
 public MarkdownClassifierTest(MarkdownTestFilesFixture files) {
     _files = files;
 }
Пример #9
0
 public MarkdownClassifierTest(MarkdownEditorMefCatalogFixture catalogFixture, MarkdownTestFilesFixture files)
 {
     _exportProvider = catalogFixture.CreateExportProvider();
     _files          = files;
 }
Пример #10
0
        private static void TokenizeFileImplementation <TToken, TTokenType, TTokenizer>(MarkdownTestFilesFixture fixture, string name)
            where TTokenizer : ITokenizer <TToken>, new() where TToken : IToken <TTokenType>
        {
            string testFile     = fixture.GetDestinationPath(name);
            string baselineFile = testFile + ".tokens";
            string text         = fixture.LoadDestinationFile(name);

            ITextProvider textProvider = new TextStream(text);
            var           tokenizer    = new TTokenizer();

            var    tokens = tokenizer.Tokenize(textProvider, 0, textProvider.Length);
            string actual = DebugWriter.WriteTokens <TToken, TTokenType>(tokens);

            if (_regenerateBaselineFiles)
            {
                // Update this to your actual enlistment if you need to update baseline
                baselineFile = Path.Combine(fixture.SourcePath, Path.GetFileName(testFile)) + ".tokens";
                TestFiles.UpdateBaseline(baselineFile, actual);
            }
            else
            {
                TestFiles.CompareToBaseLine(baselineFile, actual);
            }
        }
Пример #11
0
 public MarkdownClassifierTest(IServiceContainer serviceProvider, MarkdownTestFilesFixture files)
 {
     _coreShell = serviceProvider.GetService <ICoreShell>();
     _files     = files;
 }
Пример #12
0
 public MarkdownClassifierTest(MarkdownEditorMefCatalogFixture catalogFixture, MarkdownTestFilesFixture files) {
     _exportProvider = catalogFixture.CreateExportProvider();
     _files = files;
 }
Пример #13
0
 public TokenizeSampleMdFilesTest(MarkdownTestFilesFixture files)
 {
     _files = files;
 }
Пример #14
0
 public MarkdownClassifierTest(MarkdownTestFilesFixture files)
 {
     _files = files;
 }
Пример #15
0
 public MarkdownClassifierTest(IExportProvider exportProvider, MarkdownTestFilesFixture files)
 {
     _exportProvider = exportProvider;
     _files          = files;
 }