Exemplo n.º 1
0
        public void CreateCompletionSource_CreatesACompletionSourceWithTextBuffersParser()
        {
            // Arrange
            var razorBuffer = Mock.Of <ITextBuffer>(buffer => buffer.ContentType == RazorContentType && buffer.Properties == new PropertyCollection(), MockBehavior.Strict);
            var completionSourceProvider = new RazorDirectiveCompletionSourceProvider(CompletionFactsService);

            // Act
            var completionSource = completionSourceProvider.CreateCompletionSource(razorBuffer);

            // Assert
            Assert.Null(completionSource);
        }
Exemplo n.º 2
0
        public void GetOrCreate_ReturnsNullIfRazorBufferHasNotBeenAssociatedWithTextView()
        {
            // Arrange
            var textView = CreateTextView(NonRazorContentType, new PropertyCollection());
            var completionSourceProvider = new RazorDirectiveCompletionSourceProvider(CompletionFactsService);

            // Act
            var completionSource = completionSourceProvider.GetOrCreate(textView);

            // Assert
            Assert.Null(completionSource);
        }
Exemplo n.º 3
0
        public void GetOrCreate_CachesCompletionSource()
        {
            // Arrange
            var expectedParser = Mock.Of <VisualStudioRazorParser>(MockBehavior.Strict);
            var properties     = new PropertyCollection();

            properties.AddProperty(typeof(VisualStudioRazorParser), expectedParser);
            var textView = CreateTextView(RazorContentType, properties);
            var completionSourceProvider = new RazorDirectiveCompletionSourceProvider(CompletionFactsService);

            // Act
            var completionSource1 = completionSourceProvider.GetOrCreate(textView);
            var completionSource2 = completionSourceProvider.GetOrCreate(textView);

            // Assert
            Assert.Same(completionSource1, completionSource2);
        }
Exemplo n.º 4
0
        public void CreateCompletionSource_ReturnsNullIfParserHasNotBeenAssocitedWithRazorBuffer()
        {
            // Arrange
            var expectedParser = Mock.Of <VisualStudioRazorParser>(MockBehavior.Strict);
            var properties     = new PropertyCollection();

            properties.AddProperty(typeof(VisualStudioRazorParser), expectedParser);
            var razorBuffer = Mock.Of <ITextBuffer>(buffer => buffer.ContentType == RazorContentType && buffer.Properties == properties, MockBehavior.Strict);
            var completionSourceProvider = new RazorDirectiveCompletionSourceProvider(CompletionFactsService);

            // Act
            var completionSource = completionSourceProvider.CreateCompletionSource(razorBuffer);

            // Assert
            var completionSourceImpl = Assert.IsType <RazorDirectiveCompletionSource>(completionSource);

            Assert.Same(expectedParser, completionSourceImpl.Parser);
        }