Exemplo n.º 1
0
        public static UnconfiguredProjectServices Create(
            IProjectThreadingService?threadingService = null,
            IProjectFaultHandlerService?projectFaultHandlerService = null,
            IProjectService?projectService = null,
            IProjectConfigurationsService?projectConfigurationsService = null)
        {
            projectFaultHandlerService ??= IProjectFaultHandlerServiceFactory.Create();
            threadingService ??= IProjectThreadingServiceFactory.Create();

            var projectLockService = IProjectLockServiceFactory.Create();

            var mock = new Mock <UnconfiguredProjectServices>();

            projectService ??= IProjectServiceFactory.Create(ProjectServicesFactory.Create(threadingService, projectLockService: projectLockService));

            mock.SetupGet(p => p.ProjectService)
            .Returns(projectService);

            mock.Setup(p => p.ProjectLockService)
            .Returns(projectLockService);

            mock.Setup(p => p.FaultHandler)
            .Returns(projectFaultHandlerService);

            mock.Setup(p => p.ThreadingPolicy)
            .Returns(threadingService);

            if (projectConfigurationsService is not null)
            {
                mock.SetupGet(p => p.ProjectConfigurationsService)
                .Returns(projectConfigurationsService);
            }

            return(mock.Object);
        }
Exemplo n.º 2
0
        public static IProjectCommonServices Create(IProjectThreadingService?threadingService = null, IProjectLockService?projectLockService = null)
        {
            threadingService ??= IProjectThreadingServiceFactory.Create();

            var services       = ProjectServicesFactory.Create(threadingService: threadingService, projectLockService: projectLockService);
            var projectService = IProjectServiceFactory.Create(services);

            var mock = new Mock <IProjectCommonServices>();

            mock.SetupGet(s => s.ProjectService)
            .Returns(projectService);

            return(mock.Object);
        }
Exemplo n.º 3
0
        public static IProjectService Create(IEnumerable <UnconfiguredProject> loadedUnconfiguredProjects, ProjectServices?services = null, IProjectCapabilitiesScope?scope = null)
        {
            var mock = new Mock <IProjectService>();

            services ??= ProjectServicesFactory.Create(projectService: mock.Object);

            mock.Setup(p => p.Services)
            .Returns(services);


            mock.Setup(p => p.LoadedUnconfiguredProjects)
            .Returns(loadedUnconfiguredProjects);

            return(mock.Object);
        }
        private static DesignTimeInputsDataSource CreateDesignTimeInputsDataSource(out ProjectValueDataSource <IProjectSubscriptionUpdate> sourceItemsRuleSource)
        {
            var unconfiguredProjectServices = UnconfiguredProjectServicesFactory.Create(
                projectService: IProjectServiceFactory.Create(
                    services: ProjectServicesFactory.Create(
                        threadingService: IProjectThreadingServiceFactory.Create(),
                        projectLockService: IProjectLockServiceFactory.Create())));
            var unconfiguredProject = UnconfiguredProjectFactory.Create(unconfiguredProjectServices: unconfiguredProjectServices);

            sourceItemsRuleSource = new ProjectValueDataSource <IProjectSubscriptionUpdate>(unconfiguredProjectServices);

            var projectSubscriptionService = IActiveConfiguredProjectSubscriptionServiceFactory.Create(sourceItemsRuleSource: sourceItemsRuleSource);

            var dataSource = new DesignTimeInputsDataSource(unconfiguredProject, unconfiguredProjectServices, projectSubscriptionService);

            return(dataSource);
        }
Exemplo n.º 5
0
        public static IProjectService Create(ProjectServices?services = null, IProjectCapabilitiesScope?scope = null, ConfiguredProject?configuredProject = null)
        {
            var mock = new Mock <IProjectService>();

            services ??= ProjectServicesFactory.Create(projectService: mock.Object);

            mock.Setup(p => p.Services)
            .Returns(services);

            if (scope != null)
            {
                mock.Setup(p => p.LoadedUnconfiguredProjects)
                .Returns(new[] { UnconfiguredProjectFactory.Create(scope: scope, configuredProject: configuredProject) });
            }

            return(mock.Object);
        }
Exemplo n.º 6
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 static DesignTimeInputsFileWatcher CreateDesignTimeInputsFileWatcher(IVsAsyncFileChangeEx fileChangeService, out ProjectValueDataSource <DesignTimeInputs> source)
        {
            // Create our mock design time inputs data source, but with a source we can actually use
            var services = IProjectCommonServicesFactory.CreateWithDefaultThreadingPolicy();

            source = ProjectValueDataSourceFactory.Create <DesignTimeInputs>(services);

            var mock = new Mock <IDesignTimeInputsDataSource>();

            mock.SetupGet(s => s.SourceBlock)
            .Returns(source.SourceBlock);

            var dataSource = mock.Object;

            var threadingService            = IProjectThreadingServiceFactory.Create();
            var unconfiguredProject         = UnconfiguredProjectFactory.Create(fullPath: @"C:\MyProject\MyProject.csproj");
            var unconfiguredProjectServices = IUnconfiguredProjectServicesFactory.Create(
                projectService: IProjectServiceFactory.Create(
                    services: ProjectServicesFactory.Create(
                        threadingService: threadingService)));

            // Create our class under test
            return(new DesignTimeInputsFileWatcher(unconfiguredProject, unconfiguredProjectServices, threadingService, dataSource, IVsServiceFactory.Create <SVsFileChangeEx, IVsAsyncFileChangeEx>(fileChangeService)));
        }