IStorageProvider FileExists() and FolderExists()

--HG--
branch : 1.x
extra : rebase_source : 89792dec51c9419263c469998810cb95d6a2c050
This commit is contained in:
piedone@pyrocenter.hu
2011-12-14 23:45:49 +01:00
parent d3bd1ebd97
commit 1350e5143f
2 changed files with 34 additions and 0 deletions

View File

@@ -57,6 +57,16 @@ namespace Orchard.Tests.Storage {
private string _folderPath;
private IStorageProvider _storageProvider;
[Test]
public void ExistsShouldBeTrueForExtistingFile() {
Assert.That(_storageProvider.FileExists("testfile.txt"), Is.True);
}
[Test]
public void ExistsShouldBeFalseForNonExtistingFile() {
Assert.That(_storageProvider.FileExists("notexisting"), Is.False);
}
[Test]
[ExpectedException(typeof(ArgumentException))]
public void GetFileThatDoesNotExistShouldThrow() {
@@ -99,6 +109,16 @@ namespace Orchard.Tests.Storage {
Assert.That(file2.GetPath(), Is.EqualTo("Subfolder1" + Path.DirectorySeparatorChar + "one.txt"));
}
[Test]
public void ExistsShouldBeTrueForExtistingFolder() {
Assert.That(_storageProvider.FolderExists("Subfolder1"), Is.True);
}
[Test]
public void ExistsShouldBeFalseForNonExtistingFolder() {
Assert.That(_storageProvider.FolderExists("notexisting"), Is.False);
}
[Test]
public void ListFoldersReturnsItemsWithShortPathAndEnvironmentSlashes() {
var folders = _storageProvider.ListFolders(@"Subfolder1");

View File

@@ -4,6 +4,13 @@ using System.IO;
namespace Orchard.FileSystems.Media {
public interface IStorageProvider : IDependency {
/// <summary>
/// Checks if the given file exists within the storage provider.
/// </summary>
/// <param name="path">The relative path within the storage provider.</param>
/// <returns>True if the file exists; False otherwise.</returns>
bool FileExists(string path);
/// <summary>
/// Retrieves the public URL for a given file within the storage provider.
/// </summary>
@@ -26,6 +33,13 @@ namespace Orchard.FileSystems.Media {
/// <returns>The list of files in the folder.</returns>
IEnumerable<IStorageFile> ListFiles(string path);
/// <summary>
/// Checks if the given folder exists within the storage provider.
/// </summary>
/// <param name="path">The relative path within the storage provider.</param>
/// <returns>True if the folder exists; False otherwise.</returns>
bool FolderExists(string path);
/// <summary>
/// Lists the folders within a storage provider's path.
/// </summary>