public void Setup() { fs = Substitute.For<IFileDataSource>(); ds = Substitute.For<IDirectoryDataSource>(); o = Substitute.For<IOutputController>(); fv = Substitute.For<IFileValidator>(); ds.EnumerateDirectories(Arg.Any<string>()).Returns(new List<string>() { @"C:\test\directory1", @"C:\test\directory1\directory2", @"C:\test\directory1\MySolution.directory2", @"C:\test\directory1\MySolution.directory3" }); ds.GetFiles(Arg.Any<string>(),Arg.Any<string>(),Arg.Any<SearchOption>()).Returns(new string[] { @"C:\test\directory1\test.txt", @"C:\test\directory1\directory2\test2.txt", @"C:\test\directory1\directory2\test2.dll", @"C:\test\directory1\directory2\MySolution.test2.dll", @"C:\test\directory1\directory2\MySolution.test2.txt", @"C:\test\directory1\directory2\MySolution.test3.html", @"C:\test\directory1\directory2\MySolution.test4.csproj", @"C:\test\directory1\directory2\MySolution.test5.sln" }); fv.IsValidFile(Arg.Is<string>(x => new[] { ".txt", ".csproj", ".sln", ".html" }.Contains(x))).Returns(true); }
private bool SetFilePriority(bool up) { List <IFileDataSource> selectedFiles = this.GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileDataSource item = selectedFiles.First <IFileDataSource>(); if (!item.IsUrl) { List <IFileDataSource> files = this.Files.ToList <IFileDataSource>(); this.SetFilePriorities(files); if (up && (item.FileOrder > 0)) { item.FileOrder--; } if (!up && (item.FileOrder < files.Count)) { item.FileOrder++; } files.Remove(item); files.Insert(item.FileOrder, item); this.SetFilePriorities(files); foreach (IFileDataSource source2 in files) { this.DataSourceAdapter.UpdateFile(source2); } return(true); } } return(false); }
public FileDataSourceViewModel(IFileDataSource dataSource, IActionCenter actionCenter, IApplicationSettings applicationSettings) : base(dataSource, actionCenter, applicationSettings) { _actionCenter = actionCenter ?? throw new ArgumentNullException(nameof(actionCenter)); _dataSource = dataSource; _fileName = Path.GetFileName(dataSource.FullFileName); _canBeRemoved = true; Update(); UpdateFolder(); AddFileMenuItems(new [] { new CommandMenuViewModel(new DelegateCommand2(OpenInExplorer)) { Header = "Open Containing Folder", ToolTip = "Opens Folder the current Data Source is contained in" } }); UpdateDisplayNoTimestampCount(); PropertyChanged += OnPropertyChanged; }
public RenameHelper(string startingPath, string newSolutionVal, IDirectoryDataSource dirProvider, IFileDataSource fileProv, IOutputController outputControl) { startPath = startingPath; newSolutionValue = newSolutionVal; magicWord = Config.MAGIC_WORD; directoryProvider = dirProvider; fileProvider = fileProv; outputController = outputControl; }
public void InsertFile(IFileDataSource ds) { List <DbParameter> list; string[] exclude = new string[] { "FileID" }; string sql = this.InsertStatement("Files", ds, exclude, out list); this.DataAccess.ExecuteNonQuery(sql, list); }
public RenameHelper(string startingPath, string newSolutionVal) { startPath = startingPath; newSolutionValue = newSolutionVal; magicWord = Config.MAGIC_WORD; directoryProvider = new DirectoryDataSource(); fileProvider = new FileDataSource(); outputController = new OutputController(); }
public FindReplaceHelper(string startingPath, string newSolutionValue) { startPath = startingPath; newSolutionName = newSolutionValue; magicWord = Config.MAGIC_WORD; directoryProvider = new DirectoryDataSource(); fileProvider = new FileDataSource(); outputController=new OutputController(); _fileValidator = new FileValidator(); }
public FindReplaceHelper(string startingPath, string newSolutionValue, IDirectoryDataSource dirDataSource, IFileDataSource fileDataSource, IOutputController outputControl,IFileValidator fileValidator) { startPath = startingPath; newSolutionName = newSolutionValue; magicWord = Config.MAGIC_WORD; directoryProvider = dirDataSource; fileProvider = fileDataSource; outputController = outputControl; _fileValidator = fileValidator; }
public void UpdateFile(IFileDataSource ds) { string sql = "update Files set \r\n SourcePortID = @SourcePortID, Description = @Description, FileOrder = @FileOrder\r\n where FileID = @FileID"; List <DbParameter> parameters = new List <DbParameter> { this.DataAccess.DbAdapter.CreateParameter("SourcePortID", ds.SourcePortID), this.DataAccess.DbAdapter.CreateParameter("Description", ds.Description), this.DataAccess.DbAdapter.CreateParameter("FileID", ds.FileID), this.DataAccess.DbAdapter.CreateParameter("FileOrder", ds.FileOrder) }; this.DataAccess.ExecuteNonQuery(sql, parameters); }
public void Initialize(IDataSourceAdapter adapter, IFileDataSource file) { this.DataSourceAdapter = adapter; this.cmbSourcePort.DisplayMember = "Name"; this.cmbSourcePort.ValueMember = "SourcePortID"; this.cmbSourcePort.DataSource = adapter.GetSourcePorts(); if (file != null) { this.cmbSourcePort.SelectedValue = file.SourcePortID; this.txtDescription.Text = file.Description; } }
public void View() { List <IFileDataSource> selectedFiles = this.GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileDataSource source = selectedFiles.First <IFileDataSource>(); if (source.IsUrl) { Process.Start(source.FileName); } else if (File.Exists(Path.Combine(this.DataDirectory.GetFullPath(), source.FileName))) { Process.Start(Path.Combine(this.DataDirectory.GetFullPath(), source.FileName)); } } }
public void Setup() { fs = Substitute.For<IFileDataSource>(); ds= Substitute.For<IDirectoryDataSource>(); o = Substitute.For<IOutputController>(); ds.EnumerateDirectories(Arg.Any<string>()).Returns(new List<string>() { @"C:\test\directory1", @"C:\test\directory1\directory2", @"C:\test\directory1\MySolution.directory2", @"C:\test\directory1\MySolution.directory3" }); ds.EnumerateFiles(Arg.Any<string>()).Returns(new List<string>() { @"C:\test\directory1\test.txt", @"C:\test\directory1\directory2\test2.txt", @"C:\test\directory1\directory2\test2.dll", @"C:\test\directory1\directory2\MySolution.test2.dll", @"C:\test\directory1\directory2\MySolution.test2.txt", @"C:\test\directory1\directory2\MySolution.test3.html", @"C:\test\directory1\directory2\MySolution.test4.csproj", @"C:\test\directory1\directory2\MySolution.test5.sln" }); ds.GetFiles(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<SearchOption>()).Returns(new string[] { @"C:\test\directory1\test.txt", @"C:\test\directory1\directory2\test2.txt", @"C:\test\directory1\directory2\test2.dll", @"C:\test\directory1\directory2\MySolution.test2.dll", @"C:\test\directory1\directory2\MySolution.test2.txt", @"C:\test\directory1\directory2\MySolution.test3.html", @"C:\test\directory1\directory2\MySolution.test4.csproj", @"C:\test\directory1\directory2\MySolution.test5.sln" }); fs.When(x => x.Move(Arg.Any<string>(), Arg.Any<string>())).Do(x => fileMoveCounter++); ds.When(x => x.Move(Arg.Any<string>(), Arg.Any<string>())).Do(x => folderMoveCounter++); }
public bool SetFileOrderFirst() { List <IFileDataSource> selectedFiles = this.GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileDataSource item = selectedFiles.First <IFileDataSource>(); if (!item.IsUrl) { List <IFileDataSource> files = this.Files.ToList <IFileDataSource>(); files.Remove(item); files.Insert(0, item); this.SetFilePriorities(files); foreach (IFileDataSource source2 in files) { this.DataSourceAdapter.UpdateFile(source2); } return(true); } } return(false); }
public bool Edit() { List <IFileDataSource> selectedFiles = this.GetSelectedFiles(); if (selectedFiles.Count > 0) { IFileDataSource file = selectedFiles.First <IFileDataSource>(); FileDetailsEditForm form = new FileDetailsEditForm(); form.Initialize(this.DataSourceAdapter, file); form.StartPosition = FormStartPosition.CenterParent; if (((form.ShowDialog(this) == DialogResult.OK) && (form.SourcePort != null)) && !file.IsUrl) { file.SourcePortID = form.SourcePort.SourcePortID; file.Description = form.Description; this.DataSourceAdapter.UpdateFile(file); return(true); } if (form.SourcePort == null) { MessageBox.Show(this, "A source port must be selected.", "Error", MessageBoxButtons.OK); } } return(false); }
public void DeleteFile(IFileDataSource ds) { this.DataAccess.ExecuteNonQuery($"delete from Files where FileID = {ds.FileID}"); }
public void UpdateFile(IFileDataSource ds) { throw new NotImplementedException(); }
public void InsertFile(IFileDataSource ds) { throw new NotImplementedException(); }
public Import(IFileDataSource source) { _source = source; _dataStorage = new DataStorage(); _destination = new Destination(); }
private FileDataSourceViewModel CreateFileViewModel(IFileDataSource dataSource) { return(new FileDataSourceViewModel(dataSource, _actionCenter.Object, _applicationSettings.Object)); }