Пример #1
0
        public async Task FilesChanged_SkipsNonRegisteredProjects()
        {
            string projectFile = @"c:\temp\project1.csproj";
            var    spMock      = new IServiceProviderMoq();

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100));
            spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150));

            var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object);

            var reloadableProjectMock = new Mock <IReloadableProject>(MockBehavior.Strict);

            reloadableProjectMock.Setup(x => x.ProjectFile).Returns(projectFile);

            await rlm.RegisterProjectAsync(reloadableProjectMock.Object);

            Assert.Equal <int>(1, rlm.RegisteredProjects.Count);

            rlm.FilesChanged(1, new string[1] {
                projectFile + ".csproj"
            }, new uint[1] {
                (uint)_VSFILECHANGEFLAGS.VSFILECHG_Size
            });
            Assert.True(rlm.ReloadDelayScheduler.LatestScheduledTask == null);
            reloadableProjectMock.VerifyAll();
        }
Пример #2
0
        public void GlobalJsonHasSdkElement_ElementIsRemoved()
        {
            var fileSystem = CreateFileSystem(withEntries: true, withGlobalJson: true);
            var solution   = IVsSolutionFactory.CreateWithSolutionDirectory(CreateSolutionInfo());
            var setup      = GlobalJsonSetupFactory.Create(true);

            var migrator = CreateInstance(ProcessRunnerFactory.CreateRunner(), fileSystem, globalJsonSetup: setup);

            var loggedMessages     = new List <LogMessage>();
            var logger             = IVsUpgradeLoggerFactory.CreateLogger(loggedMessages);
            var globalJsonBackedUp = Path.Combine(BackupLocation, "global.json");

            fileSystem.WriteAllText(GlobalJsonLocation, @"
{
    ""sdk"": {
        ""version"": ""1.0.0-preview2-003121""
    }
}");

            migrator.BackupAndDeleteGlobalJson(SlnLocation, solution, BackupLocation, XprojLocation, ProjectName, logger);
            Assert.True(fileSystem.FileExists(globalJsonBackedUp));
            Assert.Single(loggedMessages);
            Assert.Equal(new LogMessage
            {
                File    = GlobalJsonLocation,
                Level   = (uint)__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL,
                Message = string.Format(VSResources.MigrationBackupFile, GlobalJsonLocation, globalJsonBackedUp),
                Project = ProjectName
            }, loggedMessages[0]);
            Mock.Get(setup).Verify(g => g.SetupRemoval(solution, It.IsAny <IServiceProvider>(), fileSystem));
            Assert.True(JToken.DeepEquals(new JObject(), JsonConvert.DeserializeObject <JObject>(fileSystem.ReadAllText(GlobalJsonLocation))));
        }
Пример #3
0
        public void GlobalJsonRemover_RemovesJson_WhenExists()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var solution    = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback);
            var projectItem = ProjectItemFactory.Create();
            var dteSolution = SolutionFactory.ImplementFindProjectItem(path =>
            {
                Assert.Equal(Path.Combine(Directory, "global.json"), path);
                return(projectItem);
            });
            var dte = DteFactory.ImplementSolution(() => dteSolution);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(t =>
            {
                if (typeof(SVsSolution) == t)
                {
                    return(solution);
                }

                if (typeof(DTE) == t)
                {
                    return(dte);
                }

                Assert.False(true);
                throw new InvalidOperationException();
            });

            var remover = new GlobalJsonRemover(serviceProvider);

            Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0));
            Mock.Get(projectItem).Verify(p => p.Remove(), Times.Once);
        }
Пример #4
0
        public void E2E_Works()
        {
            var fileSystem    = CreateFileSystem(withEntries: true, withXprojUser: true, withProjectLock: true, withGlobalJson: true);
            var processRunner = ProcessRunnerFactory.ImplementRunner(pInfo =>
            {
                ProcessVerifier(pInfo);
                fileSystem.Create(CsprojLocation);
            });

            var solution = IVsSolutionFactory.CreateWithSolutionDirectory(CreateSolutionInfo());
            var setup    = GlobalJsonSetupFactory.Create(true);

            var loggedMessages = new List <LogMessage>();
            var logger         = IVsUpgradeLoggerFactory.CreateLogger(loggedMessages);

            var migrator = CreateInstance(processRunner, fileSystem, solution, setup);

            Assert.Equal(VSConstants.S_OK, migrator.UpgradeProject(XprojLocation, 0, BackupLocation, out string outCsproj, logger, out int upgradeRequired, out Guid newProjectFactory));
            Assert.True(fileSystem.FileExists(CsprojLocation));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, $"{ProjectName}.xproj")));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, "project.json")));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, $"{ProjectName}.xproj.user")));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, $"global.json")));
            Assert.False(fileSystem.FileExists(XprojLocation));
            Assert.False(fileSystem.FileExists(ProjectJsonLocation));
            Assert.False(fileSystem.FileExists(XprojUserLocation));
            Assert.False(fileSystem.FileExists(ProjectLockJsonLocation));
            Assert.Equal(CsprojLocation, outCsproj);
            Assert.Equal((int)__VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE, upgradeRequired);
            Assert.Equal(Guid.Parse(CSharpProjectSystemPackage.ProjectTypeGuid), newProjectFactory);
            Mock.Get(setup).Verify(g => g.SetupRemoval(solution, It.IsAny <IServiceProvider>(), fileSystem));
        }
Пример #5
0
        public void MigrateXprojProjectFactory_GlobalJsonExists_BacksUpAndRemovesGlobalJson()
        {
            var fileSystem = CreateFileSystem(withEntries: true, withGlobalJson: true);

            var migrator = CreateInstance(ProcessRunnerFactory.CreateRunner(), fileSystem);

            GlobalJsonRemover remover = null;

            var solution = IVsSolutionFactory.Implement((IVsSolutionEvents events, out uint cookie) =>
            {
                remover = (GlobalJsonRemover)events;
                cookie  = 1234;
                return(VSConstants.S_OK);
            }, IVsSolutionFactory.DefaultUnadviseCallback, CreateSolutionInfo());

            var loggedMessages     = new List <LogMessage>();
            var logger             = IVsUpgradeLoggerFactory.CreateLogger(loggedMessages);
            var globalJsonBackedUp = Path.Combine(BackupLocation, "global.json");

            migrator.BackupAndDeleteGlobalJson(SlnLocation, solution, BackupLocation, XprojLocation, ProjectName, logger);
            Assert.False(fileSystem.FileExists(GlobalJsonLocation));
            Assert.True(fileSystem.FileExists(globalJsonBackedUp));
            Assert.Equal(1, loggedMessages.Count);
            Assert.Equal(new LogMessage
            {
                File    = GlobalJsonLocation,
                Level   = (uint)__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL,
                Message = string.Format(VSResources.MigrationBackupFile, GlobalJsonLocation, globalJsonBackedUp),
                Project = ProjectName
            }, loggedMessages[0]);
            Assert.NotNull(remover);
            Assert.Equal(1234u, remover.SolutionCookie);
        }
Пример #6
0
        public async Task FilesChanged_CallsProjectToReload(_VSFILECHANGEFLAGS flags)
        {
            string projectFile = @"c:\temp\project1.csproj";
            var    spMock      = new IServiceProviderMoq();

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100));
            spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150));

            var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object);

            var reloadableProjectMock = new Mock <IReloadableProject>(MockBehavior.Strict);

            reloadableProjectMock.Setup(x => x.ProjectFile).Returns(projectFile);
            reloadableProjectMock.Setup(x => x.ReloadProjectAsync()).Returns(Task.FromResult(ProjectReloadResult.ReloadCompleted));

            await rlm.RegisterProjectAsync(reloadableProjectMock.Object);

            Assert.Equal <int>(1, rlm.RegisteredProjects.Count);
            // Shorten the normal delay so unit tests run faster
            ((TaskDelayScheduler)rlm.ReloadDelayScheduler).TaskDelayTime = TimeSpan.FromMilliseconds(20);

            rlm.FilesChanged(1, new string[1] {
                projectFile
            }, new uint[1] {
                (uint)flags
            });
            await rlm.ReloadDelayScheduler.LatestScheduledTask;

            reloadableProjectMock.VerifyAll();
        }
        public void GlobalJsonRemover_NoJson_DoesntCrash()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var solution    = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback);
            var dteSolution = SolutionFactory.ImplementFindProjectItem(path =>
            {
                Assert.Equal(Path.Combine(Directory, "global.json"), path);
                return(null);
            });
            var dte = DteFactory.ImplementSolution(() => dteSolution);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(t =>
            {
                if (typeof(SVsSolution) == t)
                {
                    return(solution);
                }

                if (typeof(DTE) == t)
                {
                    return(dte);
                }

                Assert.False(true);
                throw new InvalidOperationException();
            });

            var remover = new GlobalJsonRemover(serviceProvider, IFileSystemFactory.Create());

            GlobalJsonRemover.Remover = remover;
            Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0));
        }
Пример #8
0
        private MigrateXprojProjectFactory CreateInstance(ProcessRunner processRunner, IFileSystem fileSystem, IVsSolution solutionParam = null)
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var solution        = solutionParam ?? IVsSolutionFactory.CreateWithSolutionDirectory(CreateSolutionInfo());
            var serviceProvider = IServiceProviderFactory.Create(typeof(SVsSolution), solution);

            var migrator = new MigrateXprojProjectFactory(processRunner, fileSystem, serviceProvider);

            return(migrator);
        }
        public void GlobalJsonSetup_ExistingRemover_ReturnsSameRemover()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var remover = new GlobalJsonRemover(IServiceProviderFactory.Create(), IFileSystemFactory.Create());

            GlobalJsonRemover.Remover = remover;
            Assert.False(new GlobalJsonRemover.GlobalJsonSetup().SetupRemoval(IVsSolutionFactory.Create(),
                                                                              IServiceProviderFactory.Create(), IFileSystemFactory.Create()));
            Assert.True(ReferenceEquals(remover, GlobalJsonRemover.Remover));
        }
        public void GlobaJsonSetup_NoExistingRemover_RegistersForAdvise()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            GlobalJsonRemover.Remover         = null;

            var solution      = IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(1234);
            var setupOccurred = new GlobalJsonRemover.GlobalJsonSetup().SetupRemoval(solution, IServiceProviderFactory.Create(), IFileSystemFactory.Create());

            Assert.True(setupOccurred);
            Assert.Equal(1234u, GlobalJsonRemover.Remover.SolutionCookie);
        }
Пример #11
0
        public async Task Dispose_ValidateSolutionEventsEstablished()
        {
            var spMock = new IServiceProviderMoq();

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100));
            spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150));

            var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object);

            await rlm.DisposeAsync();

            Assert.Equal <uint>(0, rlm.SolutionEventsCookie);
        }
Пример #12
0
        public async Task Dispose_ValidateProjectIsUnRegistered()
        {
            var spMock = new IServiceProviderMoq();

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100));
            spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150));

            var rlmMock = new Mock <IProjectReloadManager>(MockBehavior.Strict);

            rlmMock.Setup(x => x.UnregisterProjectAsync(It.IsAny <IReloadableProject>())).Returns(Task.CompletedTask);

            var project = new ReloadableProject(IUnconfiguredProjectVsServicesFactory.Implement(), rlmMock.Object);

            await project.DisposeAsync();

            rlmMock.VerifyAll();
        }
        public async Task FrameOpenCloseListener_InitializeEventsAsync_SetsUpWindowFrameEvents()
        {
            var uiShell = IVsUIShell7Factory.ImplementAdviseWindowEvents(l => 1);

            uint eventsCookie = 2;
            var  solution     = IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(eventsCookie);

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

            var listener = new FrameOpenCloseListener(serviceProvider,
                                                      IProjectFileEditorPresenterFactory.Create(),
                                                      new IProjectThreadingServiceMock(),
                                                      UnconfiguredProjectFactory.Create());

            await listener.InitializeEventsAsync(IVsWindowFrameFactory.Create());

            Mock.Get(uiShell).Verify(u => u.AdviseWindowFrameEvents(listener), Times.Once);
            Mock.Get(solution).Verify(s => s.AdviseSolutionEvents(listener, out eventsCookie), Times.Once);
        }
Пример #14
0
        public async Task Dispose_ValidateRegisterProject()
        {
            var spMock = new IServiceProviderMoq();

            spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100));
            spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150));

            var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object);

            var reloadableProjectMock = new Mock <IReloadableProject>(MockBehavior.Strict);

            reloadableProjectMock.Setup(x => x.ProjectFile).Returns(@"c:\temp\project1.csproj");

            await rlm.RegisterProjectAsync(reloadableProjectMock.Object);

            Assert.Equal <int>(1, rlm.RegisteredProjects.Count);
            Assert.Same(reloadableProjectMock.Object, rlm.RegisteredProjects.First().Key);
            reloadableProjectMock.VerifyAll();
        }
        public void GlobalJsonRemover_AfterRemoval_UnadvisesEvents()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var globalJsonPath = Path.Combine(Directory, "global.json");
            var solution       = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback);
            var projectItem    = ProjectItemFactory.Create();
            var dteSolution    = SolutionFactory.ImplementFindProjectItem(path =>
            {
                Assert.Equal(globalJsonPath, path);
                return(projectItem);
            });
            var dte = DteFactory.ImplementSolution(() => dteSolution);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(t =>
            {
                if (typeof(SVsSolution) == t)
                {
                    return(solution);
                }

                if (typeof(DTE) == t)
                {
                    return(dte);
                }

                Assert.False(true);
                throw new InvalidOperationException();
            });

            var fileSystem = IFileSystemFactory.Create();

            fileSystem.Create(globalJsonPath);

            var remover = new GlobalJsonRemover(serviceProvider, fileSystem)
            {
                SolutionCookie = 1234
            };

            GlobalJsonRemover.Remover = remover;
            Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0));
            Mock.Get(solution).Verify(s => s.UnadviseSolutionEvents(1234), Times.Once);
        }
        public async Task FrameOpenCloseListener_Dispose_UnsubscribesCorrectly()
        {
            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 listener = new FrameOpenCloseListener(serviceProvider,
                                                      IProjectFileEditorPresenterFactory.Create(),
                                                      new IProjectThreadingServiceMock(),
                                                      UnconfiguredProjectFactory.Create());

            await listener.InitializeEventsAsync(IVsWindowFrameFactory.Create());

            await listener.DisposeAsync();

            Mock.Get(uiShell).Verify(u => u.UnadviseWindowFrameEvents(1234), Times.Once);
            Mock.Get(solution).Verify(s => s.UnadviseSolutionEvents(4321), Times.Once);
        }
        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);
        }
Пример #18
0
        public void MigrateXprojProjectFactory_E2E_Works()
        {
            var fileSystem    = CreateFileSystem(withEntries: true, withXprojUser: true, withProjectLock: true, withGlobalJson: true);
            var processRunner = ProcessRunnerFactory.ImplementRunner(pInfo =>
            {
                ProcessVerifier(pInfo);
                fileSystem.Create(CsprojLocation);
            });

            GlobalJsonRemover remover = null;
            var solution = IVsSolutionFactory.Implement((IVsSolutionEvents events, out uint cookie) =>
            {
                remover = (GlobalJsonRemover)events;
                cookie  = 1234;
                return(VSConstants.S_OK);
            }, IVsSolutionFactory.DefaultUnadviseCallback, CreateSolutionInfo());

            var loggedMessages = new List <LogMessage>();
            var logger         = IVsUpgradeLoggerFactory.CreateLogger(loggedMessages);

            var migrator = CreateInstance(processRunner, fileSystem, solution);

            Assert.Equal(VSConstants.S_OK, migrator.UpgradeProject(XprojLocation, 0, BackupLocation, out string outCsproj, logger, out int upgradeRequired, out Guid newProjectFactory));
            Assert.True(fileSystem.FileExists(CsprojLocation));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, $"{ProjectName}.xproj")));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, "project.json")));
            Assert.True(fileSystem.FileExists(Path.Combine(BackupLocation, $"{ProjectName}.xproj.user")));
            Assert.False(fileSystem.FileExists(XprojLocation));
            Assert.False(fileSystem.FileExists(ProjectJsonLocation));
            Assert.False(fileSystem.FileExists(XprojUserLocation));
            Assert.False(fileSystem.FileExists(ProjectLockJsonLocation));
            Assert.False(fileSystem.FileExists(GlobalJsonLocation));
            Assert.Equal(CsprojLocation, outCsproj);
            Assert.Equal((int)__VSPPROJECTUPGRADEVIAFACTORYREPAIRFLAGS.VSPUVF_PROJECT_ONEWAYUPGRADE, upgradeRequired);
            Assert.Equal(Guid.Parse(CSharpProjectSystemPackage.ProjectTypeGuid), newProjectFactory);
            Assert.NotNull(remover);
            Assert.Equal(1234u, remover.SolutionCookie);
        }
Пример #19
0
        public void GlobalJsonExists_BacksUpAndRemovesGlobalJson()
        {
            var fileSystem = CreateFileSystem(withEntries: true, withGlobalJson: true);
            var solution   = IVsSolutionFactory.CreateWithSolutionDirectory(CreateSolutionInfo());
            var setup      = GlobalJsonSetupFactory.Create(true);

            var migrator = CreateInstance(ProcessRunnerFactory.CreateRunner(), fileSystem, globalJsonSetup: setup);

            var loggedMessages     = new List <LogMessage>();
            var logger             = IVsUpgradeLoggerFactory.CreateLogger(loggedMessages);
            var globalJsonBackedUp = Path.Combine(BackupLocation, "global.json");

            migrator.BackupAndDeleteGlobalJson(SlnLocation, solution, BackupLocation, XprojLocation, ProjectName, logger);
            Assert.True(fileSystem.FileExists(globalJsonBackedUp));
            Assert.Single(loggedMessages);
            Assert.Equal(new LogMessage
            {
                File    = GlobalJsonLocation,
                Level   = (uint)__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL,
                Message = string.Format(VSResources.MigrationBackupFile, GlobalJsonLocation, globalJsonBackedUp),
                Project = ProjectName
            }, loggedMessages[0]);
            Mock.Get(setup).Verify(g => g.SetupRemoval(solution, It.IsAny <IServiceProvider>(), fileSystem));
        }
Пример #20
0
        private static DotNetCoreProjectCompatibilityDetector CreateCompatibilityDetector(out IDialogServices dialogServices,
                                                                                          string versionDataString      = null,
                                                                                          Version vsVersion             = null,
                                                                                          bool isSolutionOpen           = false,
                                                                                          bool hasNewProjects           = false,
                                                                                          bool usingPreviewSDK          = false,
                                                                                          string targetFrameworkMoniker = ".NETCoreApp,Version=v3.0")
        {
            dialogServices = IDialogServicesFactory.Create();
            var additionalReference = dialogServices;
            var projectProperties   = IProjectPropertiesFactory.CreateWithPropertyAndValue("TargetFrameworkMoniker", targetFrameworkMoniker);
            var propertiesProvider  = IProjectPropertiesProviderFactory.Create(commonProps: projectProperties);
            var project             = ConfiguredProjectFactory.Create(services: ConfiguredProjectServicesFactory.Create(projectPropertiesProvider: propertiesProvider));
            var scope                  = hasNewProjects ? IProjectCapabilitiesScopeFactory.Create(new[] { ProjectCapability.DotNet, ProjectCapability.PackageReferences }) : null;
            var projectAccessor        = new Lazy <IProjectServiceAccessor>(() => IProjectServiceAccessorFactory.Create(scope, project));
            var lazyDialogServices     = new Lazy <IDialogServices>(() => additionalReference);
            var threadHandling         = new Lazy <IProjectThreadingService>(() => IProjectThreadingServiceFactory.Create(verifyOnUIThread: false));
            var vsShellUtilitiesHelper = new Lazy <IVsShellUtilitiesHelper>(() => IVsShellUtilitiesHelperFactory.Create(string.Empty, vsVersion ?? new Version("16.1")));
            var fileSystem             = new Lazy <IFileSystem>(() => IFileSystemFactory.Create(existsFunc: x => true, readAllTextFunc: x => versionDataString ?? defaultVersionDataString));
            var httpClient             = new Lazy <IHttpClient>(() => IHttpClientFactory.Create(versionDataString ?? defaultVersionDataString));
            var vsUIShellService       = IVsServiceFactory.Create <SVsUIShell, IVsUIShell>(Mock.Of <IVsUIShell>());
            var settingsManagerService = IVsServiceFactory.Create <SVsSettingsPersistenceManager, ISettingsManager>(Mock.Of <ISettingsManager>());
            var vsSolutionService      = IVsServiceFactory.Create <SVsSolution, IVsSolution>(IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(1, isFullyLoaded: isSolutionOpen));
            var vsAppIdService         = IVsServiceFactory.Create <SVsAppId, IVsAppId>(Mock.Of <IVsAppId>());
            var vsShellService         = IVsServiceFactory.Create <SVsShell, IVsShell>(Mock.Of <IVsShell>());

            var compatibilityDetector = new TestDotNetCoreProjectCompatibilityDetector(projectAccessor,
                                                                                       lazyDialogServices,
                                                                                       threadHandling,
                                                                                       vsShellUtilitiesHelper,
                                                                                       fileSystem,
                                                                                       httpClient,
                                                                                       vsUIShellService,
                                                                                       settingsManagerService,
                                                                                       vsSolutionService,
                                                                                       vsAppIdService,
                                                                                       vsShellService,
                                                                                       hasNewProjects,
                                                                                       usingPreviewSDK);

            return(compatibilityDetector);
        }