public async Task CreateFile_NotInSync(string input, string expected, bool fileExistsOnDisk, string expectedFilePath) { var inputTree = ProjectTreeParser.Parse(input); var expectedTree = ProjectTreeParser.Parse(expected); var projectTreeProvider = new ProjectTreeProvider(); var projectTree = IPhysicalProjectTreeFactory.Create(provider: projectTreeProvider, currentTree: inputTree); var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree); var fileSystem = IFileSystemFactory.Create(path => fileExistsOnDisk, path => { // Verify that file is created on disk. Assert.False(fileExistsOnDisk); Assert.Equal(expectedFilePath, path); return(null); }); var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(@"C:\Foo\Properties"); var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager); var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist); Assert.Equal(expectedFilePath, filePath); AssertAreEquivalent(expectedTree, inputTree); }
public async Task FindFile_FromAppDesignerFolder(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 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 FindFile_NodeNotInSync(string input, bool fileExistsOnDisk, string expectedFilePath) { var inputTree = ProjectTreeParser.Parse(input); var projectTree = IPhysicalProjectTreeFactory.Create(currentTree: inputTree); var sourceItemsProvider = IProjectItemProviderFactory.Create(); var fileSystem = IFileSystemFactory.Create(path => fileExistsOnDisk); var specialFilesManager = ISpecialFilesManagerFactory.Create(); 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); }
public async Task CreateFile_InAppDesignerFolder(string input, string expected, string expectedFilePath) { var inputTree = ProjectTreeParser.Parse(input); var expectedTree = ProjectTreeParser.Parse(expected); var projectTreeService = IProjectTreeServiceFactory.Create(inputTree); var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree); var fileSystem = IFileSystemFactory.Create(path => false, path => { // Verify that file is created on disk. Assert.Equal(expectedFilePath, path); return(null); }); var provider = new SettingsFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem); var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist); Assert.Equal(expectedFilePath, filePath); AssertAreEquivalent(expectedTree, inputTree); }
public async Task CreateFile_CallTemplateProvider(string input, string expected, string expectedFilePath) { var inputTree = ProjectTreeParser.Parse(input); var expectedTree = ProjectTreeParser.Parse(expected); var projectTreeService = IProjectTreeServiceFactory.Create(inputTree); var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree); var fileSystem = IFileSystemFactory.Create(path => false, path => { // Verify that file is created on disk. Assert.False(true, "File system create shouldn't have been called directly."); return(null); }); var templateProvider = new Lazy <ICreateFileFromTemplateService>(() => ICreateFileFromTemplateServiceFactory.Create()); var provider = new SettingsFileSpecialFileProvider(projectTreeService, sourceItemsProvider, templateProvider, fileSystem); var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist); Assert.Equal(expectedFilePath, filePath); AssertAreEquivalent(expectedTree, inputTree); }