Ejemplo n.º 1
0
        public async Task WhenProjectUnloading_DoesNotLoadConfiguredProject()
        {
            var tasksService = IUnconfiguredProjectTasksServiceFactory.CreateWithUnloadedProject<ConfiguredProject>();

            int callCount = 0;
            UnconfiguredProject project = UnconfiguredProjectFactory.ImplementLoadConfiguredProjectAsync(configuration =>
            {

                callCount++;
                return Task.FromResult<ConfiguredProject>(null);
            });

            var loader = CreateInstance(project, tasksService, out ProjectValueDataSource<IConfigurationGroup<ProjectConfiguration>> source);
            await loader.InitializeAsync();

            var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|AnyCPU");

            // Change the active configurations
            await source.SendAndCompleteAsync(configurationGroups, loader.TargetBlock);

            // Should not be listening
            Assert.Equal(0, callCount);
        }
        public async Task AppManifestSpecialFileProvider_Test(string input, string appManifestPropertyValue, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeProvider = IProjectTreeProviderFactory.Create(@"C:\Foo\Properties", (root, path) =>
            {
                root.TryFindImmediateChild(Path.GetFileName(path), out var node);
                return(node);
            });
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            var properties = ProjectPropertiesFactory.Create(UnconfiguredProjectFactory.Create(), new PropertyPageData {
                Category     = ConfigurationGeneralBrowseObject.SchemaName,
                PropertyName = ConfigurationGeneralBrowseObject.ApplicationManifestProperty,
                Value        = appManifestPropertyValue
            });
            var provider = new AppManifestSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager, properties);
            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task Dispose_WhenInitialized_DisposesSubscription()
        {
            var configuredProject = ConfiguredProjectFactory.Create();

            int callCount = 0;
            UnconfiguredProject project = UnconfiguredProjectFactory.ImplementLoadConfiguredProjectAsync(configuration =>
            {
                callCount++;
                return(Task.FromResult(configuredProject));
            });

            var loader = CreateInstance(project, out ProjectValueDataSource <IConfigurationGroup <ProjectConfiguration> > source);
            await loader.InitializeAsync();

            loader.Dispose();

            var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|AnyCPU");

            // Change the active configurations
            await source.SendAndCompleteAsync(configurationGroups, loader.TargetBlock);

            // Should not be listening
            Assert.Equal(0, callCount);
        }
        public async Task InitializeAsync_CanNotInitializeTwice()
        {
            var configuredProject = ConfiguredProjectFactory.Create();

            var results = new List <string>();
            var project = UnconfiguredProjectFactory.ImplementLoadConfiguredProjectAsync(configuration =>
            {
                results.Add(configuration.Name);
                return(Task.FromResult(configuredProject));
            });

            var loader = CreateInstance(project, out var source);

            await loader.InitializeAsync();

            await loader.InitializeAsync();

            var configurationGroups = IConfigurationGroupFactory.CreateFromConfigurationNames("Debug|AnyCPU");

            // Change the active configurations
            await source.SendAndCompleteAsync(configurationGroups, loader.TargetBlock);

            Assert.Equal(new string[] { "Debug|AnyCPU" }, results);
        }
        public static ConfiguredProject Create(IProjectCapabilitiesScope?capabilities = null, ProjectConfiguration?projectConfiguration = null, ConfiguredProjectServices?services = null, UnconfiguredProject?unconfiguredProject = null)
        {
            var mock = new Mock <ConfiguredProject>();

            mock.Setup(c => c.Capabilities).Returns(capabilities !);
            mock.Setup(c => c.ProjectConfiguration).Returns(projectConfiguration !);
            mock.Setup(c => c.Services).Returns(services !);
            mock.SetupGet(c => c.UnconfiguredProject).Returns(unconfiguredProject ! ?? UnconfiguredProjectFactory.Create());
            return(mock.Object);
        }
 public static ProjectProperties CreateEmpty()
 {
     return(Create(UnconfiguredProjectFactory.Create()));
 }
 public static ProjectProperties Create(params PropertyPageData[] data)
 {
     return(Create(UnconfiguredProjectFactory.Create(), data));
 }