public void CopyFunctionOutputFormatTest() { //Function Requirements: //Accepts 2 Parameters<string, int> //Returns string in correct format w/ necessary seperator ; string pattern = @"^.+\.glsl(?>;.*\.glsl)*$"; Assert.IsTrue(Regex.IsMatch(CopyMaker.Output(Shader.shaders.GetValueOrDefault(ShaderEnum.AutoDownscale), 3), pattern)); }
private void buttonCopy_Click(object sender, EventArgs e) { int copies = Convert.ToInt32(comboBoxCopies.SelectedItem); //Check if Copy Directory exists if (Directory.Exists(Shader.GetShaderCopyRootDirectory())) { DialogResult result = MessageBox.Show("All files in the following directory will be deleted:\n\t" + Shader.GetShaderCopyRootDirectory() + "\n Do you wish to continue?", "Overwrite confirmation!", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { //Clear all the files of the directory String[] filePaths = Directory.GetFiles(Shader.GetShaderCopyRootDirectory()); foreach (string file in filePaths) { File.Delete(file); } //Each File gets a new filename and is copied to the destination path foreach (var shader in Shader.shaders) { for (int i = 1; i <= copies; i++) { String sourceFile = Path.Combine(Shader.GetShaderRootDirectory(), shader.Value); //CopyMaker.Output add the number(i) to the filename and returns the string String destFile = Path.Combine(Shader.GetShaderCopyRootDirectory(), CopyMaker.Output(shader.Value, i)); if (!File.Exists(destFile)) { try { File.Copy(sourceFile, destFile); } catch (IOException ex) { break; } } } } MessageBox.Show("Copy Completed"); Properties.Settings.Default.NumberOfCopies = Convert.ToInt32(comboBoxCopies.SelectedItem.ToString()); Properties.Settings.Default.Save(); }//end second if else { MessageBox.Show("Copy was aborted"); } }//end first if else { //Missing Directory is created Directory.CreateDirectory(Shader.GetShaderCopyRootDirectory()); MessageBox.Show("Directory " + Shader.GetShaderCopyRootDirectory() + " created!"); } }