2012-08-20 09:42:32 -01:00
|
|
|
|
using System;
|
2017-01-28 10:04:43 +01:00
|
|
|
|
using Moq;
|
2012-08-20 09:42:32 -01:00
|
|
|
|
using NUnit.Framework;
|
2017-01-28 10:04:43 +01:00
|
|
|
|
using Umbraco.Core;
|
2012-08-20 09:42:32 -01:00
|
|
|
|
using Umbraco.Core.IO;
|
2017-01-28 10:04:43 +01:00
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
|
using Umbraco.Core.Profiling;
|
2013-09-16 19:33:21 +10:00
|
|
|
|
using Umbraco.Tests.TestHelpers;
|
2012-08-20 09:42:32 -01:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.IO
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class FileSystemProviderManagerTests
|
|
|
|
|
|
{
|
2013-09-16 19:33:21 +10:00
|
|
|
|
[SetUp]
|
|
|
|
|
|
public void Setup()
|
|
|
|
|
|
{
|
|
|
|
|
|
//init the config singleton
|
|
|
|
|
|
var config = SettingsForTests.GetDefault();
|
|
|
|
|
|
SettingsForTests.ConfigureSettings(config);
|
2017-01-28 10:04:43 +01:00
|
|
|
|
|
|
|
|
|
|
// media fs wants this
|
|
|
|
|
|
ApplicationContext.Current = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
2013-09-16 19:33:21 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-08-20 09:42:32 -01:00
|
|
|
|
[Test]
|
2012-11-07 09:40:33 +05:00
|
|
|
|
public void Can_Get_Base_File_System()
|
2012-08-20 09:42:32 -01:00
|
|
|
|
{
|
2013-05-14 14:18:41 -10:00
|
|
|
|
var fs = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider(FileSystemProviderConstants.Media);
|
2012-08-20 09:42:32 -01:00
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(fs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Can_Get_Typed_File_System()
|
|
|
|
|
|
{
|
2012-11-07 09:30:40 +05:00
|
|
|
|
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
|
2012-08-20 09:42:32 -01:00
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(fs);
|
|
|
|
|
|
}
|
2012-11-07 09:40:33 +05:00
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Exception_Thrown_On_Invalid_Typed_File_System()
|
|
|
|
|
|
{
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(() => FileSystemProviderManager.Current.GetFileSystemProvider<InvalidTypedFileSystem>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Used in unit tests, for a typed file system we need to inherit from FileSystemWrapper and they MUST have a ctor
|
|
|
|
|
|
/// that only accepts a base IFileSystem object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class InvalidTypedFileSystem : FileSystemWrapper
|
|
|
|
|
|
{
|
|
|
|
|
|
public InvalidTypedFileSystem(IFileSystem wrapped, string invalidParam) : base(wrapped)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2012-08-20 09:42:32 -01:00
|
|
|
|
}
|