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);
        }
Beispiel #2
0
        public async Task GetActiveConfiguredProjectAsync_WhenNoActiveConfiguration_ReturnsNull()
        {
            var activeConfiguredProjectProvider = IActiveConfiguredProjectProviderFactory.ImplementActiveProjectConfiguration(() => null);
            var services = IUnconfiguredProjectServicesFactory.Create(activeConfiguredProjectProvider: activeConfiguredProjectProvider);

            var provider = CreateInstance(services: services);

            var result = await provider.GetActiveConfiguredProjectsAsync();

            Assert.Null(result);
        }
Beispiel #3
0
        private ActiveConfiguredProjectsProvider CreateInstance(string activeConfiguration, string configurations, params string[] dimensionNames)
        {
            var activeConfig                    = ProjectConfigurationFactory.Create(activeConfiguration);
            var configs                         = ProjectConfigurationFactory.CreateMany(configurations.Split(';'));
            var configurationsService           = IProjectConfigurationsServiceFactory.ImplementGetKnownProjectConfigurationsAsync(configs.ToImmutableHashSet());
            var activeConfiguredProjectProvider = IActiveConfiguredProjectProviderFactory.ImplementActiveProjectConfiguration(() => activeConfig);
            var services                        = IUnconfiguredProjectServicesFactory.Create(activeConfiguredProjectProvider: activeConfiguredProjectProvider, projectConfigurationsService: configurationsService);
            var project                         = UnconfiguredProjectFactory.ImplementLoadConfiguredProjectAsync((projectConfiguration) => {
                return(Task.FromResult(ConfiguredProjectFactory.ImplementProjectConfiguration(projectConfiguration)));
            });

            var dimensionProviders = dimensionNames.Select(name => IActiveConfiguredProjectsDimensionProviderFactory.ImplementDimensionName(name));

            return(CreateInstance(services: services, project: project, dimensionProviders: dimensionProviders));
        }
Beispiel #4
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);
        }