Adds some more error checking to PhysicalFileSystem ctor. Fixing issues with Script/Style repo tests.
This commit is contained in:
@@ -18,7 +18,11 @@ namespace Umbraco.Core.IO
|
||||
|
||||
public PhysicalFileSystem(string virtualRoot)
|
||||
{
|
||||
RootPath = IOHelper.MapPath(virtualRoot);
|
||||
if (virtualRoot == null) throw new ArgumentNullException("virtualRoot");
|
||||
if (!virtualRoot.StartsWith("~/"))
|
||||
throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'");
|
||||
|
||||
RootPath = IOHelper.MapPath(virtualRoot);
|
||||
_rootUrl = IOHelper.ResolveUrl(virtualRoot);
|
||||
}
|
||||
|
||||
@@ -30,6 +34,9 @@ namespace Umbraco.Core.IO
|
||||
if (string.IsNullOrEmpty(rootUrl))
|
||||
throw new ArgumentException("The argument 'rootUrl' cannot be null or empty.");
|
||||
|
||||
if (rootPath.StartsWith("~/"))
|
||||
throw new ArgumentException("The rootPath argument cannot be a virtual path and cannot start with '~/'");
|
||||
|
||||
RootPath = rootPath;
|
||||
_rootUrl = rootUrl;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// </summary>
|
||||
internal class ScriptRepository : FileRepository<string, Script>, IScriptRepository
|
||||
{
|
||||
public ScriptRepository(IUnitOfWork work, IFileSystem fileSystem)
|
||||
internal ScriptRepository(IUnitOfWork work, IFileSystem fileSystem)
|
||||
: base(work, fileSystem)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// </summary>
|
||||
internal class StylesheetRepository : FileRepository<string, Stylesheet>, IStylesheetRepository
|
||||
{
|
||||
public StylesheetRepository(IUnitOfWork work, IFileSystem fileSystem)
|
||||
internal StylesheetRepository(IUnitOfWork work, IFileSystem fileSystem)
|
||||
: base(work, fileSystem)
|
||||
{
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
[SetUp]
|
||||
public void Initialize()
|
||||
{
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Scripts, "/scripts");
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
|
||||
var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");");
|
||||
_fileSystem.AddFile("test-script.js", stream);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
_fileSystem = null;
|
||||
//Delete all files
|
||||
var fs = new PhysicalFileSystem(SystemDirectories.Scripts, "/scripts");
|
||||
var fs = new PhysicalFileSystem(SystemDirectories.Scripts);
|
||||
var files = fs.GetFiles("", "*.js");
|
||||
foreach (var file in files)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
[SetUp]
|
||||
public void Initialize()
|
||||
{
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Css, "/css");
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Css);
|
||||
var stream = CreateStream("body {background:#EE7600; color:#FFF;}");
|
||||
_fileSystem.AddFile("styles.css", stream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user