Exemple #1
0
        public void GetClassifierRegistersForNotificationReturnsSameInstance()
        {
            var mockTextManager2             = new Mock <IVsTextManager2>();
            var mockConnectionPointContainer = mockTextManager2.As <IConnectionPointContainer>();

            TextManagerEvents.Override = mockTextManager2.Object;
            try
            {
                var eventGuid = typeof(IVsTextManagerEvents).GUID;
                var mockTextManagerEventsConnection = new Mock <IConnectionPoint>();
                var textManagerEventsConnection     = mockTextManagerEventsConnection.Object;
                mockConnectionPointContainer
                .Setup(cpc => cpc.FindConnectionPoint(ref eventGuid, out textManagerEventsConnection));

                uint cookie;
                mockTextManagerEventsConnection
                .Setup(tm => tm.Advise(It.IsAny <TextManagerEvents>(), out cookie));

                var ocp        = new OutputClassifierProvider();
                var classifier = ocp.GetClassifier(null);
                classifier.Should().NotBeNull();
                classifier.Should().BeSameAs(ocp.GetClassifier(null));

                mockTextManager2.VerifyAll();
                mockConnectionPointContainer.VerifyAll();
                mockTextManagerEventsConnection.VerifyAll();
                textManagerEventsConnection.Should().BeSameAs(mockTextManagerEventsConnection.Object);
            }
            finally
            {
                TextManagerEvents.Override = null;
            }
        }
Exemple #2
0
        public void GetClassifier_DoesNotThrowWhenTextBufferIsNull()
        {
            // Arrange
            var classificationTypeRegistryServiceMock = new Mock <IClassificationTypeRegistryService>();
            IClassifierProvider provider = new OutputClassifierProvider
            {
                ClassificationTypeRegistryService = classificationTypeRegistryServiceMock.Object
            };

            // Act & Assert
            Assert.DoesNotThrow(() => provider.GetClassifier(null));
        }
Exemple #3
0
        public void GetClassifier_ReturnSameInstance()
        {
            // Arrange
            var classificationTypeRegistryServiceMock = new Mock <IClassificationTypeRegistryService>();
            IClassifierProvider provider = new OutputClassifierProvider
            {
                ClassificationTypeRegistryService = classificationTypeRegistryServiceMock.Object
            };

            // Act
            var instance1 = provider.GetClassifier(null);
            var instance2 = provider.GetClassifier(null);

            // Assert
            Assert.IsNotNull(instance1);
            Assert.IsNotNull(instance2);
            Assert.AreSame(instance1, instance2);
        }