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);
        }
        public static UnconfiguredProject Create(object hostObject = null, string filePath = null,
                                                 IProjectConfigurationsService projectConfigurationsService = null, ConfiguredProject configuredProject = null, Encoding projectEncoding = null,
                                                 IProjectCapabilitiesScope scope = null)
        {
            var service = IProjectServiceFactory.Create();

            var unconfiguredProjectServices = new Mock <UnconfiguredProjectServices>();

            unconfiguredProjectServices.Setup(u => u.HostObject)
            .Returns(hostObject);

            unconfiguredProjectServices.Setup(u => u.ProjectConfigurationsService)
            .Returns(projectConfigurationsService);

            var project = new Mock <UnconfiguredProject>();

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

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

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

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

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

            project.Setup(u => u.GetFileEncodingAsync()).ReturnsAsync(projectEncoding);

            return(project.Object);
        }
예제 #3
0
        public static UnconfiguredProject Create(object hostObject = null, IEnumerable <string> capabilities = null, string filePath = null,
                                                 IProjectConfigurationsService projectConfigurationsService = null, ConfiguredProject configuredProject = null)
        {
            capabilities = capabilities ?? Enumerable.Empty <string>();

            var service = IProjectServiceFactory.Create();

            var unconfiguredProjectServices = new Mock <IUnconfiguredProjectServices>();

            unconfiguredProjectServices.Setup(u => u.HostObject)
            .Returns(hostObject);

            unconfiguredProjectServices.Setup(u => u.ProjectConfigurationsService)
            .Returns(projectConfigurationsService);

            var unconfiguredProject = new Mock <UnconfiguredProject>();

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

            unconfiguredProject.Setup(u => u.Services)
            .Returns(unconfiguredProjectServices.Object);

            unconfiguredProject.SetupGet(u => u.FullPath)
            .Returns(filePath);

            unconfiguredProject.Setup(u => u.GetSuggestedConfiguredProjectAsync()).Returns(Task.FromResult(configuredProject));

            return(unconfiguredProject.Object);
        }
        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);
        }
예제 #5
0
        public static IProjectCommonServices ImplementThreadingPolicy(IProjectThreadingService threadingPolicy)
        {
            var services       = IProjectServicesFactory.Create(threadingPolicy);
            var projectService = IProjectServiceFactory.Create(services);

            var mock = new Mock <IProjectCommonServices>();

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

            return(mock.Object);
        }
        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);
        }
예제 #7
0
        public static UnconfiguredProjectServices Create(IProjectThreadingService threadingService)
        {
            var projectLockService = IProjectLockServiceFactory.Create();

            var mock = new Mock <UnconfiguredProjectServices>();

            mock.SetupGet(p => p.ProjectService)
            .Returns(IProjectServiceFactory.Create(ProjectServicesFactory.Create(threadingService, projectLockService: projectLockService)));

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

            return(mock.Object);
        }
예제 #8
0
        public static UnconfiguredProject Create(object?hostObject = null, string?filePath = null,
                                                 IProjectConfigurationsService?projectConfigurationsService = null,
                                                 ConfiguredProject?configuredProject = null, Encoding?projectEncoding = null,
                                                 IProjectCapabilitiesScope?scope     = null)
        {
            var service = IProjectServiceFactory.Create();


            var unconfiguredProjectServices = new Mock <UnconfiguredProjectServices>();

            unconfiguredProjectServices.Setup(u => u.HostObject)
            .Returns(hostObject !);

            unconfiguredProjectServices.Setup(u => u.ProjectConfigurationsService)
            .Returns(projectConfigurationsService !);

            var activeConfiguredProjectProvider = IActiveConfiguredProjectProviderFactory.Create(getActiveConfiguredProject: () => configuredProject !);

            unconfiguredProjectServices.Setup(u => u.ActiveConfiguredProjectProvider)
            .Returns(activeConfiguredProjectProvider);

            var project = new Mock <UnconfiguredProject>();

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

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

            project.SetupGet(u => u.FullPath)
            .Returns(filePath !);

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

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

            project.Setup(u => u.GetFileEncodingAsync()).ReturnsAsync(projectEncoding);

            return(project.Object);
        }