コード例 #1
0
        public static UnconfiguredProjectServices Create(IProjectThreadingService?threadingService = null, IProjectFaultHandlerService?projectFaultHandlerService = null,
                                                         IProjectService?projectService            = null)
        {
            projectFaultHandlerService ??= IProjectFaultHandlerServiceFactory.Create();
            threadingService ??= IProjectThreadingServiceFactory.Create();

            var projectLockService = IProjectLockServiceFactory.Create();

            var mock = new Mock <UnconfiguredProjectServices>();

            if (projectService == null)
            {
                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);

            return(mock.Object);
        }
コード例 #2
0
        public static UnconfiguredProject Create(object?hostObject = null, string?filePath = null,
                                                 IProjectConfigurationsService?projectConfigurationsService = null,
                                                 ConfiguredProject?configuredProject = null, Encoding?projectEncoding = null,
                                                 IProjectAsynchronousTasksService?projectAsynchronousTasksService = null,
                                                 IProjectCapabilitiesScope?scope = null,
                                                 UnconfiguredProjectServices?unconfiguredProjectServices = null)
        {
            var service = IProjectServiceFactory.Create();

            if (unconfiguredProjectServices == null)
            {
                var unconfiguredProjectServicesMock = new Mock <UnconfiguredProjectServices>();

                unconfiguredProjectServicesMock.SetupGet <object?>(u => u.FaultHandler)
                .Returns(IProjectFaultHandlerServiceFactory.Create());

                unconfiguredProjectServicesMock.SetupGet <object?>(u => u.HostObject)
                .Returns(hostObject);

                unconfiguredProjectServicesMock.SetupGet <IProjectConfigurationsService?>(u => u.ProjectConfigurationsService)
                .Returns(projectConfigurationsService);

                var activeConfiguredProjectProvider = IActiveConfiguredProjectProviderFactory.Create(getActiveConfiguredProject: () => configuredProject);
                unconfiguredProjectServicesMock.Setup(u => u.ActiveConfiguredProjectProvider)
                .Returns(activeConfiguredProjectProvider);

                unconfiguredProjectServicesMock.Setup(u => u.ProjectAsynchronousTasks)
                .Returns(projectAsynchronousTasksService !);

                unconfiguredProjectServices = unconfiguredProjectServicesMock.Object;
            }

            var project = CreateDefault();

            project.Setup(u => u.ProjectService)
            .Returns(service);

            project.Setup(u => u.Services)
            .Returns(unconfiguredProjectServices);

            project.SetupGet <string?>(u => u.FullPath)
            .Returns(filePath);

            project.Setup(u => u.Capabilities)
            .Returns(scope !);

            project.Setup(u => u.GetSuggestedConfiguredProjectAsync()).ReturnsAsync(configuredProject);

            if (projectEncoding != null)
            {
                project.Setup(u => u.GetFileEncodingAsync()).ReturnsAsync(projectEncoding);
            }

            return(project.Object);
        }
コード例 #3
0
        public static IProjectServices Create(IProjectThreadingService threadingService = null, IProjectFaultHandlerService faultHandlerService = null, IProjectService projectService = null)
        {
            threadingService    = threadingService ?? IProjectThreadingServiceFactory.Create();
            faultHandlerService = faultHandlerService ?? IProjectFaultHandlerServiceFactory.Create();

            var projectServices = new Mock <IProjectServices>();

            projectServices.Setup(u => u.ThreadingPolicy)
            .Returns(threadingService);

            projectServices.Setup(u => u.FaultHandler)
            .Returns(faultHandlerService);

            projectServices.Setup(u => u.ProjectService)
            .Returns(projectService);

            return(projectServices.Object);
        }
コード例 #4
0
        public static ProjectServices Create(IProjectThreadingService?threadingService = null, IProjectFaultHandlerService?faultHandlerService = null, IProjectService?projectService = null, IProjectLockService?projectLockService = null)
        {
            threadingService ??= IProjectThreadingServiceFactory.Create();
            faultHandlerService ??= IProjectFaultHandlerServiceFactory.Create();

            var projectServices = new Mock <ProjectServices>();

            projectServices.Setup(u => u.ThreadingPolicy)
            .Returns(threadingService);

            projectServices.Setup(u => u.FaultHandler)
            .Returns(faultHandlerService);

            projectServices.Setup <IProjectService?>(u => u.ProjectService)
            .Returns(projectService);

            projectServices.Setup(u => u.ProjectLockService)
            .Returns(projectLockService !);

            return(projectServices.Object);
        }