Skip to content

Commit

Permalink
Use directory.exists for checking source directory for adapters. (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
codito committed Sep 30, 2016
1 parent 8c734bb commit 573df88
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public bool Exists(string path)
return File.Exists(path);
}

/// <inheritdoc/>
public bool DirectoryExists(string path)
{
return Directory.Exists(path);
}

/// <inheritdoc/>
public Stream GetStream(string filePath, FileMode mode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ public interface IFileHelper
/// Exists utility to check if file exists
/// </summary>
/// <param name="path"> The path of file. </param>
/// <returns> True if file exists <see cref="bool"/>. </returns>
/// <returns>True if file exists <see cref="bool"/>.</returns>
bool Exists(string path);

/// <summary>
/// Exists utility to check if directory exists
/// </summary>
/// <param name="path"> The path of file. </param>
/// <returns>True if directory exists <see cref="bool"/>.</returns>
bool DirectoryExists(string path);

/// <summary>
/// Gets a stream for the file.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public IEnumerable<string> GetTestPlatformExtensions(IEnumerable<string> sources
{
var sourceDirectory = Path.GetDirectoryName(sources.Single());

if (!string.IsNullOrEmpty(sourceDirectory) && this.fileHelper.Exists(sourceDirectory))
if (!string.IsNullOrEmpty(sourceDirectory) && this.fileHelper.DirectoryExists(sourceDirectory))
{
return this.fileHelper.EnumerateFiles(sourceDirectory, "*.TestAdapter.dll", SearchOption.TopDirectoryOnly);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void GetTestHostProcessStartInfoShouldIncludeCurrentDirectoryAsWorkingDir
[TestMethod]
public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryDoesNotExist()
{
this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(false);
this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny<string>())).Returns(false);
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" });

Assert.AreEqual(0, extensions.Count());
Expand All @@ -287,7 +287,7 @@ public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryDoesNo
[TestMethod]
public void GetTestPlatformExtensionsShouldReturnLibariesFromSourceDirectory()
{
this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny<string>(), It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(new[] { "foo.TestAdapter.dll" });
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(new[] { $".{Path.DirectorySeparatorChar}foo.dll" });

Expand All @@ -298,7 +298,7 @@ public void GetTestPlatformExtensionsShouldReturnLibariesFromSourceDirectory()
public void GetTestPlatformExtensionsShouldReturnEmptySetIfSourceDirectoryIsEmpty()
{
// Parent directory is empty since the input source is file "test.dll"
this.mockFileHelper.Setup(fh => fh.Exists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.DirectoryExists(It.IsAny<string>())).Returns(true);
this.mockFileHelper.Setup(fh => fh.EnumerateFiles(It.IsAny<string>(), It.IsAny<string>(), SearchOption.TopDirectoryOnly)).Returns(new[] { "foo.dll" });
var extensions = this.dotnetHostManager.GetTestPlatformExtensions(this.testSource);

Expand Down

0 comments on commit 573df88

Please sign in to comment.