Permalink
Browse files

Add unit tests for throwing DirectoryNotFoundExceptions.

  • Loading branch information...
1 parent 4400858 commit 218b53bcfbd507193001d4fff04d0b34254200e8 @kyle-fritz-zocdoc kyle-fritz-zocdoc committed with Feb 11, 2014
Showing with 29 additions and 0 deletions.
  1. +29 −0 TestHelpers.Tests/MockDirectoryTests.cs
@@ -557,6 +557,35 @@ public void MockDirectory_GetDirectories_Returns_Child_Directories()
Assert.IsTrue(directories.Contains(@"A:\folder1\folder4\"));
}
+ [Test]
+ public void MockDirectory_GetDirectories_ShouldThrowWhenPathIsNotMocked()
+ {
+ // Arrange
+ var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
+ {
+ { @"c:\a.gif", new MockFileData("Demo text content") },
+ { @"c:\b.txt", new MockFileData("Demo text content") },
+ { @"c:\c.txt", new MockFileData("Demo text content") },
+ { @"c:\a\a.txt", new MockFileData("Demo text content") },
+ { @"c:\a\b.gif", new MockFileData("Demo text content") },
+ { @"c:\a\c.txt", new MockFileData("Demo text content") },
+ { @"c:\a\a\a.txt", new MockFileData("Demo text content") },
+ { @"c:\a\a\b.txt", new MockFileData("Demo text content") },
+ { @"c:\a\a\c.gif", new MockFileData("Demo text content") },
+ });
+
+ // Act
+ try
+ {
+ var result = fileSystem.Directory.GetDirectories(@"c:\d").ToArray();
+ // Assert
+ Assert.Fail();
+ }
+ catch (DirectoryNotFoundException)
+ {
+ }
+ }
+
[Test]
public void MockDirectory_Move_ShouldMove()
{

0 comments on commit 218b53b

Please sign in to comment.