using System; using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.IO; 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); // media fs wants this ApplicationContext.Current = new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of(), Mock.Of())); } [Test] public void Can_Get_Base_File_System() { var fs = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider(FileSystemProviderConstants.Media); Assert.NotNull(fs); } [Test] public void Can_Get_Typed_File_System() { var fs = FileSystemProviderManager.Current.GetFileSystemProvider(); Assert.NotNull(fs); } [Test] public void Exception_Thrown_On_Invalid_Typed_File_System() { Assert.Throws(() => FileSystemProviderManager.Current.GetFileSystemProvider()); } /// /// 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 /// internal class InvalidTypedFileSystem : FileSystemWrapper { public InvalidTypedFileSystem(IFileSystem wrapped, string invalidParam) : base(wrapped) { } } } }