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);
        }
Exemplo n.º 2
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);
        }