/* * Verify */ /// <summary> /// Verifies whether the data entered by the user is valid. /// </summary> /// <returns><see langword="true"/> if the entered data is valid; otherwise, <see langword="false"/>.</returns> public bool Verify() { if (!NuGenArgument.IsValidDirectoryName(this.directorySelector.Path)) { MessageBox.Show( string.Format(Properties.Resources.Argument_InvalidDirectory, new string(Path.GetInvalidPathChars())), Properties.Resources.Message_Alert, MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); return(false); } if (!NuGenArgument.IsValidFilename(this.filenameTextBox.Text)) { MessageBox.Show( string.Format(Properties.Resources.Argument_InvalidFilename, new string(Path.GetInvalidFileNameChars())), Properties.Resources.Message_Alert, MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); this.filenameTextBox.SelectionStart = 0; this.filenameTextBox.SelectAll(); return(false); } return(true); }
public void IsValidFilenameTest() { string validFilename = "filename"; Assert.IsTrue(NuGenArgument.IsValidFilename(validFilename)); string invalidFilename = string.Concat(validFilename, new string(Path.GetInvalidFileNameChars()[0], 1)); Assert.IsFalse(NuGenArgument.IsValidFilename(invalidFilename)); }
public void IsValidFilenameEmptyStringTest() { Assert.IsFalse(NuGenArgument.IsValidFilename(null)); Assert.IsFalse(NuGenArgument.IsValidFilename("")); }