Exemple #1
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);
        }
Exemple #2
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>();

            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, IEnumerable <string> capabilities = null, string filePath = null,
                                                 IProjectConfigurationsService projectConfigurationsService = null, ConfiguredProject configuredProject = null, Encoding projectEncoding = null,
                                                 IProjectCapabilitiesScope scope = 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 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()).Returns(Task.FromResult(configuredProject));

            project.Setup(u => u.GetFileEncodingAsync()).Returns(Task.FromResult(projectEncoding));

            return(project.Object);
        }