Beispiel #1
0
        private static IVsHierarchy CreateIVSHierarchy(string targetFrameworkMoniker = ".NETCoreApp,Version=v3.0")
        {
            var projectProperties  = IProjectPropertiesFactory.CreateWithPropertyAndValue("TargetFrameworkMoniker", targetFrameworkMoniker);
            var propertiesProvider = IProjectPropertiesProviderFactory.Create(commonProps: projectProperties);
            var project            = ConfiguredProjectFactory.Create(services: ConfiguredProjectServicesFactory.Create(projectPropertiesProvider: propertiesProvider));
            var scope        = IProjectCapabilitiesScopeFactory.Create(new[] { ProjectCapability.DotNet, ProjectCapability.PackageReferences });
            var ivsHierarchy = IVsHierarchyFactory.ImplementAsUnconfiguredProject(UnconfiguredProjectFactory.Create(scope: scope, configuredProject: project));

            return(ivsHierarchy);
        }
Beispiel #2
0
        public async Task OnAfterOpenProject_CompatibilityNotSet_DoNotShowWarning()
        {
            var compatibilityDetector = CreateCompatibilityDetector(out var dialogServices, isSolutionOpen: true);
            await compatibilityDetector.InitializeAsync();

            var ivsHierarchy = IVsHierarchyFactory.ImplementAsUnconfiguredProject(UnconfiguredProjectFactory.Create());

            compatibilityDetector.OnAfterOpenProject(ivsHierarchy, fAdded: 1);
            Mock.Get(dialogServices).Verify(x => x.DontShowAgainMessageBox(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }
        public void FrameOpenCloseListener_QueryUnloadCorrectProjectNoCancel_CallsCloseOnEditor()
        {
            var uiShell = IVsUIShell7Factory.ImplementAdviseUnadviseWindowEvents(l => 1234, c => Assert.Equal <uint>(1234, c));

            var solution = IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(4321);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(ServiceTypeChecker(uiShell, solution));

            var editorState = IProjectFileEditorPresenterFactory.ImplementCloseWindowAsync(true);

            var projPath            = @"C:\ConsoleApp\ConsoleApp1\ConsoleApp1.csproj";
            var unconfiguredProject = UnconfiguredProjectFactory.Create(filePath: projPath);
            var hierarchy           = IVsHierarchyFactory.ImplementAsUnconfiguredProject(unconfiguredProject);

            int shouldCancel = -1;

            var listener = new FrameOpenCloseListener(serviceProvider, editorState, new IProjectThreadingServiceMock(), unconfiguredProject);

            Assert.Equal(VSConstants.S_OK, listener.OnQueryUnloadProject(hierarchy, ref shouldCancel));
            Assert.Equal(0, shouldCancel);
            Mock.Get(editorState).Verify(e => e.CanCloseWindowAsync(), Times.Once);
        }