Skip to content

Commit

Permalink
little change
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Oct 30, 2023
1 parent d6541c2 commit 425de55
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,24 @@ public void TestThatReturnsNullIfNoWayOfGettingTheFile()
}

[Test]
public void TestThatReturnsNullIfDirectoryBasedSearchFailsWithUnexpectedError()
public void TestThatDoesNotFailWhenSearchForOneOfDirectoriesFails()
{
// arrange
t_environmentOperations
.Setup(e => e.GetFolderPath(Environment.SpecialFolder.UserProfile))
.Throws(() => new Exception("No home directory"));
MockHomeDirectoryFails();

// act
var filePath = t_finder.FindConfigFilePath(null);

// assert
Assert.IsNull(filePath);
}

[Test]
public void TestThatDoesNotFailWhenOneOfDirectoriesNotDefined()
{
// arrange
MockHomeDirectoryReturnsNull();

// act
var filePath = t_finder.FindConfigFilePath(null);

Expand All @@ -148,6 +159,20 @@ private static void MockHomeDirectory()
.Returns(HomeDirectory);
}

private static void MockHomeDirectoryFails()
{
t_environmentOperations
.Setup(e => e.GetFolderPath(Environment.SpecialFolder.UserProfile))
.Throws(() => new Exception("No home directory"));
}

private static void MockHomeDirectoryReturnsNull()
{
t_environmentOperations
.Setup(e => e.GetFolderPath(Environment.SpecialFolder.UserProfile))
.Returns((string) null);
}

private static void MockFileFromEnvironmentalVariable()
{
t_environmentOperations
Expand Down

0 comments on commit 425de55

Please sign in to comment.