private static WorkspaceProjectContextProvider CreateInstance(UnconfiguredProject project = null, IProjectThreadingService threadingService = null, IWorkspaceProjectContextFactory workspaceProjectContextFactory = null, ISafeProjectGuidService projectGuidService = null, IProjectRuleSnapshot projectRuleSnapshot = null)
        {
            projectRuleSnapshot = projectRuleSnapshot ?? IProjectRuleSnapshotFactory.FromJson(
                @"{
    ""Properties"": {
        ""MSBuildProjectFullPath"": ""C:\\Project\\Project.csproj"",
        ""LanguageServiceName"": ""CSharp"",
        ""TargetPath"": ""C:\\Target.dll""
    }
}");

            var projectFaultService = IProjectFaultHandlerServiceFactory.Create();

            project          = project ?? UnconfiguredProjectFactory.Create();
            threadingService = threadingService ?? IProjectThreadingServiceFactory.Create();
            workspaceProjectContextFactory = workspaceProjectContextFactory ?? IWorkspaceProjectContextFactoryFactory.Create();
            projectGuidService             = projectGuidService ?? ISafeProjectGuidServiceFactory.ImplementGetProjectGuidAsync(Guid.NewGuid());

            var mock = new Mock <WorkspaceProjectContextProvider>(project, threadingService, projectGuidService, projectFaultService, workspaceProjectContextFactory.AsLazy());

            mock.Protected().Setup <Task <IProjectRuleSnapshot> >("GetLatestSnapshotAsync", ItExpr.IsAny <ConfiguredProject>())
            .ReturnsAsync(projectRuleSnapshot);

            return(mock.Object);
        }
Пример #2
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);
        }
        private static ProjectHotReloadSessionManager CreateHotReloadSessionManager(ConfiguredProject activeConfiguredProject, Action <string>?outputServiceCallback = null)
        {
            var activeDebugFrameworkServices = new IActiveDebugFrameworkServicesMock()
                                               .ImplementGetConfiguredProjectForActiveFrameworkAsync(activeConfiguredProject)
                                               .Object;

            var manager = new ProjectHotReloadSessionManager(
                UnconfiguredProjectFactory.Create(),
                IProjectThreadingServiceFactory.Create(),
                IProjectFaultHandlerServiceFactory.Create(),
                activeDebugFrameworkServices,
                new Lazy <IProjectHotReloadAgent>(() => IProjectHotReloadAgentFactory.Create()),
                new Lazy <IHotReloadDiagnosticOutputService>(() => IHotReloadDiagnosticOutputServiceFactory.Create(outputServiceCallback)));

            return(manager);
        }
Пример #4
0
            public TestTempPEBuildManager(IFileSystem fileSystem)
                : base(IProjectThreadingServiceFactory.Create(),
                       IUnconfiguredProjectCommonServicesFactory.Create(threadingService: IProjectThreadingServiceFactory.Create()),
                       IActiveWorkspaceProjectContextHostFactory.Create(),
                       IActiveConfiguredProjectSubscriptionServiceFactory.Create(),
                       null,
                       fileSystem,
                       IProjectFaultHandlerServiceFactory.Create(),
                       null)
            {
                BuildManager = new TestBuildManager(this);

                AppliedValue = new ProjectVersionedValue <DesignTimeInputsItem>(new DesignTimeInputsItem()
                {
                    OutputPath = "TempPE"
                }, ImmutableDictionary <NamedIdentity, IComparable> .Empty);
            }
        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        = IActiveConfiguredValueFactory.ImplementValue <IAppDesignerFolderSpecialFileProvider?>(() => IAppDesignerFolderSpecialFileProviderFactory.ImplementGetFile(appDesignerFolder));
            var project                    = UnconfiguredProjectFactory.Create(fullPath: @"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 projectFaultHandlerService = IProjectFaultHandlerServiceFactory.Create();
            var provider                   = new LaunchSettingsUnderTest(project, projectServices, fileSystem ?? new IFileSystemMock(), commonServices, null, specialFilesManager, projectFaultHandlerService);

            return(provider);
        }
        private PackageRestoreProgressTrackerInstance CreateInstance(ConfiguredProject?project = null, IDataProgressTrackerService?dataProgressTrackerService = null, IPackageRestoreDataSource?packageRestoreDataSource = null, IProjectSubscriptionService?projectSubscriptionService = null)
        {
            project ??= ConfiguredProjectFactory.Create();
            dataProgressTrackerService ??= IDataProgressTrackerServiceFactory.Create();
            packageRestoreDataSource ??= IPackageRestoreServiceFactory.Create();
            projectSubscriptionService ??= IProjectSubscriptionServiceFactory.Create();

            IProjectThreadingService    threadingService           = IProjectThreadingServiceFactory.Create();
            IProjectFaultHandlerService projectFaultHandlerService = IProjectFaultHandlerServiceFactory.Create();

            return(new PackageRestoreProgressTrackerInstance(
                       project,
                       threadingService,
                       projectFaultHandlerService,
                       dataProgressTrackerService,
                       packageRestoreDataSource,
                       projectSubscriptionService));
        }
Пример #7
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);
        }