Exemplo n.º 1
0
 /// <summary>
 /// Validates the folder path.
 /// </summary>
 /// <param name="path">The folder path to be validated.</param>
 /// <exception cref="ArgumentException">Thrown when:
 /// <list type="bullet">
 /// <item>The folder path is empty or contains only whitespaces.</item>
 /// <item>Caller has no access rights to the folder path.</item>
 /// <item>The folder path is too long.</item>
 /// <item>The folder path contains an invalid ':' character.</item>
 /// </list></exception>
 public static void ValidateFolderPath(string path)
 {
     try
     {
         GetFullPath(path);
     }
     catch (ArgumentException exception)
     {
         string message = new DirectoryWriterErrorMessageBuilder(path)
                          .Build(exception.Message);
         throw new ArgumentException(message, exception.InnerException);
     }
 }
        public void Build_WithMessage_ReturnsDirectoryWriterErrorMessage()
        {
            // Setup
            string       folderPath    = Directory.GetCurrentDirectory();
            const string customMessage = "<Some custom message>";

            // Call
            string message = new DirectoryWriterErrorMessageBuilder(folderPath).Build(customMessage);

            // Assert
            string expectedMessage = $"Fout bij het schrijven naar bestandsmap '{folderPath}': {customMessage}";

            Assert.AreEqual(expectedMessage, message);
        }