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

Commit aa66480

Browse files
committed
Create output directory if it doesn't exist
1 parent bcd42e8 commit aa66480

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/dotnet-ad-core/Validation/WritableFileAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected override ValidationResult IsValid(object value, ValidationContext cont
2020

2121
try
2222
{
23+
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
2324
File.WriteAllText(fullPath, "q");
2425
return ValidationResult.Success;
2526
}

tests/dotnet-wad-to-csv-tests/Validation/WritableFileAttributeTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ public void GivenNonWritableFilePath_WhenGetValidationResult_ThenErrorMessage()
5050
}
5151

5252
[Fact]
53-
public void GivenWritableFilePath_WhenGetValidationResult_ThenNoErrorMessage()
53+
public void GivenWritableFilePathInNewDirectory_WhenGetValidationResult_ThenNoErrorMessage()
5454
{
5555
// Arrange
5656

57-
var writableFilePath = Path.GetTempFileName();
57+
var writableFilePath = Path.Combine(
58+
Path.GetTempPath(),
59+
"wad-to-csv-tests",
60+
Guid.NewGuid().ToString(),
61+
Path.GetRandomFileName());
5862

5963
SetTarget(writableFilePath);
6064

0 commit comments

Comments
 (0)