U4-7042 - bugfix the physical filesystem
This commit is contained in:
@@ -27,6 +27,8 @@ namespace Umbraco.Tests.IO
|
||||
public void TearDown()
|
||||
{
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests");
|
||||
if (Directory.Exists(path) == false) return;
|
||||
|
||||
var files = Directory.GetFiles(path);
|
||||
foreach (var f in files)
|
||||
{
|
||||
@@ -39,5 +41,31 @@ namespace Umbraco.Tests.IO
|
||||
{
|
||||
return "/Media/" + path;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetFullPathTest()
|
||||
{
|
||||
// outside of tests, one initializes the PhysicalFileSystem with eg ~/Dir
|
||||
// and then, rootPath = /path/to/Dir and rootUrl = /Dir/
|
||||
// here we initialize the PhysicalFileSystem with
|
||||
// rootPath = /path/to/FileSysTests
|
||||
// rootUrl = /Media/
|
||||
|
||||
var basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileSysTests");
|
||||
|
||||
// ensure that GetFullPath
|
||||
// - does return the proper full path
|
||||
// - does properly normalize separators
|
||||
// - does throw on invalid paths
|
||||
|
||||
var path = _fileSystem.GetFullPath("foo.tmp");
|
||||
Assert.AreEqual(Path.Combine(basePath, @"foo.tmp"), path);
|
||||
|
||||
path = _fileSystem.GetFullPath("foo/bar.tmp");
|
||||
Assert.AreEqual(Path.Combine(basePath, @"foo\bar.tmp"), path);
|
||||
|
||||
// that path is invalid as it would be outside the root directory
|
||||
Assert.Throws<FileSecurityException>(() => _fileSystem.GetFullPath("../../foo.tmp"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user