Files
Umbraco-CMS/src/Umbraco.Tests/IO/FileSystemProviderManagerTests.cs

61 lines
1.8 KiB
C#
Raw Normal View History

using System;
2017-01-28 10:04:43 +01:00
using Moq;
using NUnit.Framework;
2017-01-28 10:04:43 +01:00
using Umbraco.Core;
using Umbraco.Core.IO;
2017-01-28 10:04:43 +01:00
using Umbraco.Core.Logging;
using Umbraco.Core.Profiling;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.IO
{
[TestFixture]
public class FileSystemProviderManagerTests
{
[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>()));
}
[Test]
public void Can_Get_Base_File_System()
{
2013-05-14 14:18:41 -10:00
var fs = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider(FileSystemProviderConstants.Media);
Assert.NotNull(fs);
}
[Test]
public void Can_Get_Typed_File_System()
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
Assert.NotNull(fs);
}
[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)
{
}
}
}
}