Skip to content

Commit 99abf27

Browse files
committed
Unit test
1 parent 08a4f42 commit 99abf27

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

FakeApiTest/ConfigIOTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using FakeApi;
@@ -63,6 +64,21 @@ public void ShouldMergeApisConfigFiles()
6364

6465
//Assert
6566
Assert.AreEqual(4, config.Apis.Count());
67+
}
68+
69+
[TestMethod]
70+
public void MergeApis_ShouldThrowExceptionWhenDirectoryNotFound()
71+
{
72+
//Arrange
73+
var config = new Config();
74+
config.ApisDirectories = new List<string> { "fakeDirectories" };
75+
76+
//Assert
77+
var ex = Assert.ThrowsException<DirectoryNotFoundException>(() =>
78+
{
79+
ConfigIO.MergeApis(config, "configSource");
80+
});
81+
Assert.AreEqual("Directory fakeDirectories not found", ex.Message);
6682
}
6783
}
6884
}

Src/FakeApi/ConfigIO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static void MergeApis(Config config, string configSource)
7272
{
7373
if (!Directory.Exists(directory))
7474
{
75-
throw new DirectoryNotFoundException(directory);
75+
throw new DirectoryNotFoundException($"Directory {directory} not found");
7676
}
7777

7878
foreach (var file in Directory.GetFiles(directory).Except(new List<string> { configSource }))

0 commit comments

Comments
 (0)