Example #1
0
        public void ImportsAndEventsAsNonNull()
        {
            var imports     = Mock.Of <Imports>();
            var importsImpl = new OrderPrecedenceImportCollection <Imports>(ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesFirst, (UnconfiguredProject)null)
            {
                new Lazy <Imports, IOrderPrecedenceMetadataView>(() => imports, IOrderPrecedenceMetadataViewFactory.Create("VisualBasic"))
            };
            var events = Mock.Of <VSProjectEvents>();
            var vsProjectEventsImpl = new OrderPrecedenceImportCollection <VSProjectEvents>(ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesFirst, (UnconfiguredProject)null)
            {
                new Lazy <VSProjectEvents, IOrderPrecedenceMetadataView>(() => events, IOrderPrecedenceMetadataViewFactory.Create("VisualBasic"))
            };

            var innerVSProjectMock = new Mock <VSLangProj.VSProject>();

            var unconfiguredProjectMock = new Mock <UnconfiguredProject>();

            unconfiguredProjectMock.Setup(p => p.Capabilities)
            .Returns((IProjectCapabilitiesScope)null);

            var vsproject = new VSProjectTestImpl(
                innerVSProjectMock.Object,
                threadingService: Mock.Of <IProjectThreadingService>(),
                projectProperties: Mock.Of <ActiveConfiguredProject <ProjectProperties> >(),
                project: unconfiguredProjectMock.Object);

            vsproject.SetImportsImpl(importsImpl);
            vsproject.SetVSProjectEventsImpl(vsProjectEventsImpl);

            Assert.NotNull(vsproject);
            Assert.True(imports.Equals(vsproject.Imports));
            Assert.Equal(events, vsproject.Events);
        }
        public static void Add <T>(this OrderPrecedenceImportCollection <T> collection, T value, string?appliesTo = null, int orderPrecedence = 0)
        {
            var metadata = IOrderPrecedenceMetadataViewFactory.Create(appliesTo, orderPrecedence);

            var export = new Lazy <T, IOrderPrecedenceMetadataView>(() => value, metadata);

            collection.Add(export);
        }
        public static void Add <T>(this OrderPrecedenceExportFactoryCollection <T> collection, T value, string?appliesTo = null, int orderPrecedence = 0)
        {
            var metadata = IOrderPrecedenceMetadataViewFactory.Create(appliesTo, orderPrecedence);

            var factory = ExportFactoryFactory.ImplementCreateValueWithAutoDispose(() => value, metadata);

            collection.Add(factory);
        }
Example #4
0
        public void VSProjectEvents_Properties()
        {
            var referenceEvents    = Mock.Of <ReferencesEvents>();
            var buildManagerEvents = Mock.Of <BuildManagerEvents>();

            var projectEventsMock = new Mock <VSProjectEvents>();

            projectEventsMock.Setup(e => e.ReferencesEvents)
            .Returns(referenceEvents);
            projectEventsMock.Setup(e => e.BuildManagerEvents)
            .Returns(buildManagerEvents);

            var innerVSProjectMock = new Mock <VSLangProj.VSProject>();

            innerVSProjectMock.Setup(p => p.Events)
            .Returns(projectEventsMock.Object);

            var unconfiguredProjectMock = new Mock <UnconfiguredProject>();

            unconfiguredProjectMock.SetupGet <IProjectCapabilitiesScope?>(p => p.Capabilities)
            .Returns((IProjectCapabilitiesScope?)null);

            var importEvents      = Mock.Of <ImportsEvents>();
            var importsEventsImpl = new OrderPrecedenceImportCollection <ImportsEvents>(ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesFirst, (UnconfiguredProject?)null)
            {
                new Lazy <ImportsEvents, IOrderPrecedenceMetadataView>(() => importEvents, IOrderPrecedenceMetadataViewFactory.Create("VisualBasic"))
            };
            var vsProjectEvents = GetVSProjectEvents(innerVSProjectMock.Object, unconfiguredProjectMock.Object);

            vsProjectEvents.SetImportsEventsImpl(importsEventsImpl);

            Assert.NotNull(vsProjectEvents);
            Assert.Equal(referenceEvents, vsProjectEvents.ReferencesEvents);
            Assert.Equal(buildManagerEvents, vsProjectEvents.BuildManagerEvents);
            Assert.Equal(importEvents, vsProjectEvents.ImportsEvents);
        }