diff --git a/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs b/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
index 1ea84731c..929538161 100644
--- a/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
+++ b/src/Orchard.Tests/Environment/Extensions/ExtensionFoldersTests.cs
@@ -1,7 +1,12 @@
-using System.IO;
+using System;
+using System.Collections.Generic;
+using System.IO;
using System.Linq;
using NUnit.Framework;
+using Orchard.Caching;
using Orchard.Environment.Extensions.Folders;
+using Orchard.FileSystems.WebSite;
+using Orchard.Tests.Stubs;
using Yaml.Grammar;
namespace Orchard.Tests.Environment.Extensions {
@@ -58,14 +63,10 @@ namespace Orchard.Tests.Environment.Extensions {
[Test]
public void ModuleTxtShouldBeParsedAndReturnedAsYamlDocument() {
- var folders = new ModuleFolders(new[] { _tempFolderName },null,null);
- var sample1 = folders.ParseManifest("Sample1");
- var mapping = (Mapping)sample1.YamlDocument.Root;
- var entities = mapping.Entities
- .Where(x => x.Key is Scalar)
- .ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
- Assert.That(entities.Keys, Has.Some.EqualTo("name"));
- Assert.That(entities.Keys, Has.Some.EqualTo("author"));
+ var folders = new ModuleFolders(new[] { _tempFolderName }, new StubCacheManager(), new StubWebSiteFolder());
+ var sample1 = folders.AvailableExtensions().Single(d => d.Name == "Sample1");
+ Assert.That(sample1.Name, Is.Not.Empty);
+ Assert.That(sample1.Author, Is.EqualTo("Bertrand Le Roy"));
}
- }
+ }
}
\ No newline at end of file
diff --git a/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt b/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
index 44bbc569e..dab08c839 100644
--- a/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
+++ b/src/Orchard.Tests/Environment/Extensions/FoldersData/Sample3/Module.txt
@@ -1 +1 @@
-This is another test.txt
+name: This is another test.txt
diff --git a/src/Orchard.Tests/Orchard.Framework.Tests.csproj b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
index f36cac6bf..8d74a9917 100644
--- a/src/Orchard.Tests/Orchard.Framework.Tests.csproj
+++ b/src/Orchard.Tests/Orchard.Framework.Tests.csproj
@@ -179,6 +179,8 @@
+
+
diff --git a/src/Orchard.Tests/Stubs/StubCacheManager.cs b/src/Orchard.Tests/Stubs/StubCacheManager.cs
new file mode 100644
index 000000000..fd28e5083
--- /dev/null
+++ b/src/Orchard.Tests/Stubs/StubCacheManager.cs
@@ -0,0 +1,15 @@
+using System;
+using Orchard.Caching;
+
+namespace Orchard.Tests.Stubs {
+ public class StubCacheManager : ICacheManager {
+ public TResult Get(TKey key, Func, TResult> acquire) {
+ var cache = new Cache();
+ return cache.Get(key, acquire);
+ }
+
+ public ICache GetCache() {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Tests/Stubs/StubClock.cs b/src/Orchard.Tests/Stubs/StubClock.cs
index 55a247d47..e5c60bb5a 100644
--- a/src/Orchard.Tests/Stubs/StubClock.cs
+++ b/src/Orchard.Tests/Stubs/StubClock.cs
@@ -16,6 +16,5 @@ namespace Orchard.Tests.Stubs {
public DateTime FutureMoment(TimeSpan span) {
return UtcNow.Add(span);
}
-
}
}
diff --git a/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs b/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs
new file mode 100644
index 000000000..82e0446ee
--- /dev/null
+++ b/src/Orchard.Tests/Stubs/StubWebSiteFolder.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Orchard.Caching;
+using Orchard.FileSystems.WebSite;
+
+namespace Orchard.Tests.Stubs {
+ public class StubWebSiteFolder : IWebSiteFolder {
+ public IEnumerable ListDirectories(string path) {
+ if (!Directory.Exists(path))
+ return Enumerable.Empty();
+
+ return Directory.GetDirectories(path);
+ }
+
+ public string ReadFile(string path) {
+ if (!File.Exists(path))
+ return null;
+
+ return File.ReadAllText(path);
+ }
+
+ public IVolatileToken WhenPathChanges(string path) {
+ return new WebSiteFolder.Token(path);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard/Environment/Extensions/Folders/ExtensionFolders.cs b/src/Orchard/Environment/Extensions/Folders/ExtensionFolders.cs
index cac09fef5..3f2203a19 100644
--- a/src/Orchard/Environment/Extensions/Folders/ExtensionFolders.cs
+++ b/src/Orchard/Environment/Extensions/Folders/ExtensionFolders.cs
@@ -88,14 +88,14 @@ namespace Orchard.Environment.Extensions.Folders {
}
}
- public ParseResult ParseManifest(string name) {
+ public ParseResult ParseManifest(string manifestText) {
bool success;
- var yamlStream = new YamlParser().ParseYamlStream(new TextInput(name), out success);
+ var yamlStream = new YamlParser().ParseYamlStream(new TextInput(manifestText), out success);
if (yamlStream == null || !success) {
return null;
}
return new ParseResult {
- Name = name,
+ Name = manifestText,
YamlDocument = yamlStream.Documents.Single()
};
}
@@ -125,14 +125,14 @@ namespace Orchard.Environment.Extensions.Folders {
}
private static IEnumerable GetFeaturesForExtension(Mapping features, ExtensionDescriptor extensionDescriptor) {
- List featureDescriptors = new List();
+ var featureDescriptors = new List();
if (features != null) {
foreach (var entity in features.Entities) {
- FeatureDescriptor featureDescriptor = new FeatureDescriptor {
+ var featureDescriptor = new FeatureDescriptor {
Extension = extensionDescriptor,
Name = entity.Key.ToString(),
};
- Mapping featureMapping = (Mapping)entity.Value;
+ var featureMapping = (Mapping)entity.Value;
foreach (var featureEntity in featureMapping.Entities) {
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
featureDescriptor.Description = featureEntity.Value.ToString();