Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Create output directory if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielweyer committed Jun 30, 2018
1 parent bcd42e8 commit aa66480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/dotnet-ad-core/Validation/WritableFileAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected override ValidationResult IsValid(object value, ValidationContext cont

try
{
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
File.WriteAllText(fullPath, "q");
return ValidationResult.Success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ public void GivenNonWritableFilePath_WhenGetValidationResult_ThenErrorMessage()
}

[Fact]
public void GivenWritableFilePath_WhenGetValidationResult_ThenNoErrorMessage()
public void GivenWritableFilePathInNewDirectory_WhenGetValidationResult_ThenNoErrorMessage()
{
// Arrange

var writableFilePath = Path.GetTempFileName();
var writableFilePath = Path.Combine(
Path.GetTempPath(),
"wad-to-csv-tests",
Guid.NewGuid().ToString(),
Path.GetRandomFileName());

SetTarget(writableFilePath);

Expand Down

0 comments on commit aa66480

Please sign in to comment.