Esempio n. 1
0
        private static DefaultRazorEditorFactoryService CreateFactoryService(
            VisualStudioDocumentTracker documentTracker = null,
            VisualStudioRazorParser parser   = null,
            BraceSmartIndenter smartIndenter = null)
        {
            documentTracker ??= Mock.Of <VisualStudioDocumentTracker>(MockBehavior.Strict);
            parser ??= Mock.Of <VisualStudioRazorParser>(MockBehavior.Strict);
            smartIndenter ??= Mock.Of <BraceSmartIndenter>(MockBehavior.Strict);

            var documentTrackerFactory = Mock.Of <VisualStudioDocumentTrackerFactory>(f => f.Create(It.IsAny <ITextBuffer>()) == documentTracker, MockBehavior.Strict);
            var parserFactory          = Mock.Of <VisualStudioRazorParserFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == parser, MockBehavior.Strict);
            var smartIndenterFactory   = Mock.Of <BraceSmartIndenterFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == smartIndenter, MockBehavior.Strict);

            var services = TestServices.Create(new ILanguageService[]
            {
                documentTrackerFactory,
                parserFactory,
                smartIndenterFactory
            });

            Workspace workspace         = TestWorkspace.Create(services);
            var       workspaceAccessor = new Mock <VisualStudioWorkspaceAccessor>(MockBehavior.Strict);

            workspaceAccessor.Setup(p => p.TryGetWorkspace(It.IsAny <ITextBuffer>(), out workspace))
            .Returns(true);

            var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object);

            return(factoryService);
        }
Esempio n. 2
0
        private static DefaultRazorEditorFactoryService CreateFactoryService(
            VisualStudioDocumentTracker documentTracker = null,
            VisualStudioRazorParser parser   = null,
            BraceSmartIndenter smartIndenter = null)
        {
            documentTracker = documentTracker ?? Mock.Of <VisualStudioDocumentTracker>();
            parser          = parser ?? Mock.Of <VisualStudioRazorParser>();
            smartIndenter   = smartIndenter ?? Mock.Of <BraceSmartIndenter>();

            var documentTrackerFactory = Mock.Of <VisualStudioDocumentTrackerFactory>(f => f.Create(It.IsAny <ITextBuffer>()) == documentTracker);
            var parserFactory          = Mock.Of <VisualStudioRazorParserFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == parser);
            var smartIndenterFactory   = Mock.Of <BraceSmartIndenterFactory>(f => f.Create(It.IsAny <VisualStudioDocumentTracker>()) == smartIndenter);
            var factoryService         = new DefaultRazorEditorFactoryService(documentTrackerFactory, parserFactory, smartIndenterFactory);

            return(factoryService);
        }
Esempio n. 3
0
        public void TryInitializeTextBuffer_WorkspaceAccessorCanNotAccessWorkspace_ReturnsFalse()
        {
            // Arrange
            Workspace workspace         = null;
            var       workspaceAccessor = new Mock <VisualStudioWorkspaceAccessor>(MockBehavior.Strict);

            workspaceAccessor.Setup(provider => provider.TryGetWorkspace(It.IsAny <ITextBuffer>(), out workspace))
            .Returns(false);
            var factoryService = new DefaultRazorEditorFactoryService(workspaceAccessor.Object);
            var textBuffer     = Mock.Of <ITextBuffer>(b => b.ContentType == RazorCoreContentType && b.Properties == new PropertyCollection(), MockBehavior.Strict);

            // Act
            var result = factoryService.TryInitializeTextBuffer(textBuffer);

            // Assert
            Assert.False(result);
        }