internal LaunchSettingsUnderTest GetLaunchSettingsProvider(IFileSystem fileSystem, string appDesignerFolder = "Properties", string activeProfile = "")
        {
            var appDesignerData = new PropertyPageData()
            {
                Category     = AppDesigner.SchemaName,
                PropertyName = AppDesigner.FolderNameProperty,
                Value        = appDesignerFolder
            };

            Mock <IEnumValue> activeProfileValue = new Mock <IEnumValue>();

            activeProfileValue.Setup(s => s.Name).Returns(activeProfile);
            var debuggerData = new PropertyPageData()
            {
                Category     = ProjectDebugger.SchemaName,
                PropertyName = ProjectDebugger.ActiveDebugProfileProperty,
                Value        = activeProfileValue.Object
            };

            var unconfiguredProject = IUnconfiguredProjectFactory.Create(null, null, @"c:\\test\Project1\Project1.csproj");
            var properties          = ProjectPropertiesFactory.Create(unconfiguredProject, new[] { debuggerData, appDesignerData });
            var commonServices      = IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, null, new IProjectThreadingServiceMock(), null, properties);
            var projectServices     = IUnconfiguredProjectServicesFactory.Create(IProjectAsynchronousTasksServiceFactory.Create(CancellationToken.None));
            Lazy <ISourceCodeControlIntegration> sccIntegration = new Lazy <ISourceCodeControlIntegration>(() => ISourceCodeControlIntegrationFactory.Create());
            var provider = new LaunchSettingsUnderTest(unconfiguredProject, projectServices, fileSystem != null? fileSystem : new IFileSystemMock(), commonServices, null, sccIntegration);

            return(provider);
        }
Beispiel #2
0
        private static UnconfiguredProjectTasksService CreateInstance(IProjectAsynchronousTasksService?tasksService = null, ILoadedInHostListener?loadedInHostListener = null, ISolutionService?solutionService = null)
        {
            tasksService ??= IProjectAsynchronousTasksServiceFactory.Create();
            loadedInHostListener ??= ILoadedInHostListenerFactory.Create();
            solutionService ??= ISolutionServiceFactory.Create();

            return(new UnconfiguredProjectTasksService(tasksService, IProjectThreadingServiceFactory.Create(), loadedInHostListener, solutionService));
        }
        private static VsSafeProjectGuidService CreateInstance(IProjectAsynchronousTasksService tasksService = null, IProjectAsyncLoadDashboard loadDashboard = null)
        {
            var project = UnconfiguredProjectFactory.Create();

            tasksService  = tasksService ?? IProjectAsynchronousTasksServiceFactory.Create();
            loadDashboard = loadDashboard ?? IProjectAsyncLoadDashboardFactory.ImplementProjectLoadedInHost(() => Task.CompletedTask);

            return(new VsSafeProjectGuidService(project, tasksService, loadDashboard));
        }
Beispiel #4
0
        public void SolutionLoadedInHost_WhenProjectUnloaded_ReturnsCancelledTask()
        {
            var tasksService = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(new CancellationToken(true));
            var service      = CreateInstance(tasksService);

            var result = service.SolutionLoadedInHost;

            Assert.True(result.IsCanceled);
        }
        public void GetProjectGuidAsync_WhenProjectAlreadyUnloaded_ReturnsCancelledTask()
        {
            var tasksService  = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(new CancellationToken(canceled: true));
            var loadDashboard = IProjectAsyncLoadDashboardFactory.ImplementProjectLoadedInHost(() => Task.Delay(Timeout.Infinite));

            var accessor = CreateInstance(tasksService, loadDashboard);

            var result = accessor.GetProjectGuidAsync();

            Assert.True(result.IsCanceled);
        }
Beispiel #6
0
        private PackageRestoreInitiatorInstance CreateInstance(UnconfiguredProject project = null, IPackageRestoreUnconfiguredDataSource dataSource = null, IVsSolutionRestoreService3 solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create();
            dataSource ??= IPackageRestoreUnconfiguredDataSourceFactory.Create();
            IProjectThreadingService         threadingService = IProjectThreadingServiceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger = IProjectLoggerFactory.Create();

            return(new PackageRestoreInitiatorInstance(project, dataSource, threadingService, projectAsynchronousTasksService, solutionRestoreService, logger));
        }
Beispiel #7
0
        public void UnloadCancellationToken_WhenUnderlyingUnloadCancellationTokenCancelled_IsCancelled()
        {
            var source       = new CancellationTokenSource();
            var tasksService = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(source.Token);
            var service      = CreateInstance(tasksService);

            Assert.False(service.UnloadCancellationToken.IsCancellationRequested);

            source.Cancel();

            Assert.True(service.UnloadCancellationToken.IsCancellationRequested);
        }
        internal static LaunchSettingsUnderTest GetLaunchSettingsProvider(IFileSystem?fileSystem, string?appDesignerFolder = @"c:\test\Project1\Properties", string activeProfile = "")
        {
            var activeProfileValue = new Mock <IEnumValue>();

            activeProfileValue.Setup(s => s.Name).Returns(activeProfile);
            var debuggerData = new PropertyPageData(ProjectDebugger.SchemaName, ProjectDebugger.ActiveDebugProfileProperty, activeProfileValue.Object);

            var specialFilesManager = ActiveConfiguredProjectFactory.ImplementValue(() => IAppDesignerFolderSpecialFileProviderFactory.ImplementGetFile(appDesignerFolder));
            var project             = UnconfiguredProjectFactory.Create(filePath: @"c:\test\Project1\Project1.csproj");
            var properties          = ProjectPropertiesFactory.Create(project, new[] { debuggerData });
            var commonServices      = IUnconfiguredProjectCommonServicesFactory.Create(project, IProjectThreadingServiceFactory.Create(), null, properties);
            var projectServices     = IUnconfiguredProjectServicesFactory.Create(IProjectAsynchronousTasksServiceFactory.Create());
            var provider            = new LaunchSettingsUnderTest(project, projectServices, fileSystem ?? new IFileSystemMock(), commonServices, null, specialFilesManager);

            return(provider);
        }
        internal async Task RenameAsync(string sourceCode, string oldFilePath, string newFilePath,
                                        IUserNotificationServices userNotificationServices,
                                        IRoslynServices roslynServices,
                                        IVsOnlineServices vsOnlineServices,
                                        string language,
                                        IVsService <SVsSettingsPersistenceManager, ISettingsManager> settingsManagerService)
        {
            var unconfiguredProject = UnconfiguredProjectFactory.Create(fullPath: $@"C:\project1.{ProjectFileExtension}");
            var projectServices     = IUnconfiguredProjectVsServicesFactory.Implement(
                threadingServiceCreator: () => IProjectThreadingServiceFactory.Create(),
                unconfiguredProjectCreator: () => unconfiguredProject);

            using var ws = new AdhocWorkspace();
            ws.AddSolution(InitializeWorkspace(ProjectId.CreateNewId(), oldFilePath, sourceCode, language));

            var environmentOptionsFactory       = IEnvironmentOptionsFactory.Implement((string category, string page, string property, bool defaultValue) => { return(true); });
            var waitIndicator                   = (new Mock <IWaitIndicator>()).Object;
            var projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();
            var projectThreadingService         = IProjectThreadingServiceFactory.Create();
            var refactorNotifyService           = (new Mock <IRefactorNotifyService>()).Object;
            var extensibility                   = new Mock <IVsUIService <IVsExtensibility, IVsExtensibility3> >().Object;
            var operationProgressMock           = new Mock <IVsService <SVsOperationProgress, IVsOperationProgressStatusService> >().Object;
            var context = new Mock <IProjectTreeActionHandlerContext>().Object;

            var mockNode = new Mock <IProjectTree>();

            mockNode.SetupGet(x => x.FilePath).Returns(oldFilePath);
            mockNode.SetupGet(x => x.IsFolder).Returns(false);
            var node = mockNode.Object;

            var renamer = new TestRenamerProjectTreeActionHandler(unconfiguredProject,
                                                                  projectServices,
                                                                  ws,
                                                                  environmentOptionsFactory,
                                                                  userNotificationServices,
                                                                  roslynServices,
                                                                  waitIndicator,
                                                                  vsOnlineServices,
                                                                  projectAsynchronousTasksService,
                                                                  projectThreadingService,
                                                                  extensibility,
                                                                  operationProgressMock,
                                                                  settingsManagerService);

            await renamer.RenameAsync(context, node, newFilePath)
            .TimeoutAfter(TimeSpan.FromSeconds(1));
        }
Beispiel #10
0
        public DesignTimeInputsChangeTrackerTests()
        {
            var services = IProjectCommonServicesFactory.CreateWithDefaultThreadingPolicy();

            using var designTimeInputsSource = ProjectValueDataSourceFactory.Create <DesignTimeInputs>(services);

            var dataSourceMock = new Mock <IDesignTimeInputsDataSource>();

            dataSourceMock.SetupGet(s => s.SourceBlock)
            .Returns(designTimeInputsSource.SourceBlock);

            using var fileWatcherSource = ProjectValueDataSourceFactory.Create <string[]>(services);

            var watcherMock = new Mock <IDesignTimeInputsFileWatcher>();

            watcherMock.SetupGet(s => s.SourceBlock)
            .Returns(fileWatcherSource.SourceBlock);

            var threadingService           = IProjectThreadingServiceFactory.Create();
            var projectSubscriptionService = IActiveConfiguredProjectSubscriptionServiceFactory.Create();
            var unconfiguredProject        = UnconfiguredProjectFactory.Create(
                filePath: Path.Combine(_projectFolder, "MyTestProj.csproj"),
                projectAsynchronousTasksService: IProjectAsynchronousTasksServiceFactory.Create());

            var unconfiguredProjectServices = IUnconfiguredProjectServicesFactory.Create(
                projectService: IProjectServiceFactory.Create(
                    services: ProjectServicesFactory.Create(
                        threadingService: threadingService)));

            _changeTracker = new DesignTimeInputsChangeTracker(unconfiguredProject,
                                                               unconfiguredProjectServices,
                                                               threadingService,
                                                               projectSubscriptionService,
                                                               dataSourceMock.Object,
                                                               watcherMock.Object)
            {
                AllowSourceBlockCompletion = true
            };


            // Create a block to receive the output
            var receiver = DataflowBlockSlim.CreateActionBlock <IProjectVersionedValue <DesignTimeInputsDelta> >(OutputProduced);

            _changeTracker.SourceBlock.LinkTo(receiver, DataflowOption.PropagateCompletion);
        }
        private PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger     = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem = IFileSystemFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger));
        }
        public async Task GetProjectGuidAsync_WhenProjectUnloads_CancelsTask()
        {
            var projectUnloaded = new CancellationTokenSource();
            var tasksService    = IProjectAsynchronousTasksServiceFactory.ImplementUnloadCancellationToken(projectUnloaded.Token);
            var loadDashboard   = IProjectAsyncLoadDashboardFactory.ImplementProjectLoadedInHost(() => Task.Delay(Timeout.Infinite));

            var accessor = CreateInstance(tasksService, loadDashboard);

            var result = accessor.GetProjectGuidAsync();

            Assert.False(result.IsCanceled);

            // Now "unload" the project
            projectUnloaded.Cancel();

            await Assert.ThrowsAsync <OperationCanceledException>(() =>
            {
                return(result);
            });
        }
Beispiel #13
0
        private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create();
            IFileSystem fileSystem = IFileSystemFactory.Create();
            var         projectDependentFileChangeNotificationService = IProjectDependentFileChangeNotificationServiceFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       projectDependentFileChangeNotificationService));
        }
Beispiel #14
0
        internal LaunchSettingsUnderTest GetLaunchSettingsProvider(IFileSystem fileSystem, string appDesignerFolder = @"c:\test\Project1\Properties", string activeProfile = "")
        {
            Mock <IEnumValue> activeProfileValue = new Mock <IEnumValue>();

            activeProfileValue.Setup(s => s.Name).Returns(activeProfile);
            var debuggerData = new PropertyPageData()
            {
                Category     = ProjectDebugger.SchemaName,
                PropertyName = ProjectDebugger.ActiveDebugProfileProperty,
                Value        = activeProfileValue.Object
            };

            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(appDesignerFolder);
            var unconfiguredProject = UnconfiguredProjectFactory.Create(null, null, @"c:\test\Project1\Project1.csproj");
            var properties          = ProjectPropertiesFactory.Create(unconfiguredProject, new[] { debuggerData });
            var commonServices      = IUnconfiguredProjectCommonServicesFactory.Create(unconfiguredProject, null, new IProjectThreadingServiceMock(), null, properties);
            var projectServices     = IUnconfiguredProjectServicesFactory.Create(IProjectAsynchronousTasksServiceFactory.Create(CancellationToken.None));
            var provider            = new LaunchSettingsUnderTest(unconfiguredProject, projectServices, fileSystem ?? new IFileSystemMock(), commonServices, null, specialFilesManager);

            return(provider);
        }
        private PackageRestoreServiceInstance CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create();
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectThreadingService         threadingService = IProjectThreadingServiceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger         = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem     = IFileSystemFactory.Create();
            var            broadcastBlock = DataflowBlockSlim.CreateBroadcastBlock <IProjectVersionedValue <RestoreData> >();

            return(new PackageRestoreServiceInstance(
                       project,
                       dataSource,
                       threadingService,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       broadcastBlock));
        }
        private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.CreateWithActiveConfiguredProjectProvider(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create();
            IFileSystem fileSystem = IFileSystemFactory.Create();
            var         vsSolutionRestoreService4    = IVsSolutionRestoreService4Factory.ImplementRegisterRestoreInfoSourceAsync();
            var         sharedJoinableTaskCollection = new PackageRestoreSharedJoinableTaskCollection(IProjectThreadingServiceFactory.Create());

            return(new PackageRestoreDataSourceMocked(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       vsSolutionRestoreService4,
                       sharedJoinableTaskCollection));
        }
        private PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger          = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem      = IFileSystemFactory.Create();
            var            hintService     = new Lazy <IProjectChangeHintSubmissionService>(() => IProjectChangeHintSubmissionServiceFactory.Create());
            var            projectAccessor = IProjectAccessorFactory.Create();
            var            packageReferenceTelemetryService = IUnconfiguredProjectPackageRestoreTelemetryServiceFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       hintService,
                       projectAccessor,
                       logger,
                       packageReferenceTelemetryService));
        }