From 425de55d6fc731206f92a3d7c4946f24a22e34d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Nozderko Date: Mon, 30 Oct 2023 14:21:14 +0100 Subject: [PATCH] little change --- .../EasyLoggingConfigFinderTest.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs b/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs index 1f26a4f00..b60b794bc 100644 --- a/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs @@ -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); @@ -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