public async Task 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 void Constructor_NullProjectTreeService_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>("projectTreeService", () =>
     {
         new SettingsFileSpecialFileProvider(null, IProjectItemProviderFactory.Create(), null, IFileSystemFactory.Create(null));
     });
 }
Exemplo n.º 3
0
        public void Constructor_NullProjectTreeService_ThrowsArgumentNullException()
        {
            var fileSystem          = IFileSystemFactory.Create();
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            Assert.Throws <ArgumentNullException>("projectTree", () =>
            {
                new AppSettingsSpecialFileProvider(null !, sourceItemsProvider, null, fileSystem, specialFilesManager);
            });
        public void Constructor_NullFileSystem_ThrowsArgumentNullException()
        {
            var projectTree         = IPhysicalProjectTreeFactory.Create();
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            Assert.Throws <ArgumentNullException>("fileSystem", () =>
            {
                new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, null, specialFilesManager);
            });
        }
        public async Task FindFile_FromRoot(string input, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);

            var provider = new AppConfigFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppConfig, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task FindFile_NodeNotInSync(string input, bool fileExistsOnDisk, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => fileExistsOnDisk);

            var provider = new SettingsFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task FindFile_FromAppDesignerFolder(string input, string expectedFilePath)
        {
            var inputTree           = ProjectTreeParser.Parse(input);
            var projectTreeProvider = new ProjectTreeProvider();
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(@"C:\Foo\Properties");

            var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task GetFile_WhenNoAppDesigner_ReturnsPathUnderProjectRoot()
        {
            var inputTree = ProjectTreeParser.Parse(@"
Root (flags: {ProjectRoot}), FilePath: ""C:\Foo\testing.csproj""
    Properties (flags: {Folder}), FilePath: ""C:\Foo\Properties""
        Settings.settings, FilePath: ""C:\Foo\Properties\Settings.settings""");

            var projectTreeProvider = new ProjectTreeProvider();
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(null); // No AppDesigner

            var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(@"C:\Foo\Settings.settings", filePath);
        }