2012-08-20 09:42:32 -01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2012-11-07 09:40:33 +05:00
|
|
|
|
using System.IO;
|
2012-08-20 09:42:32 -01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
using Umbraco.Core.IO;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.IO
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class FileSystemProviderManagerTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[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>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
|
|
|
|
|
|
/// <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)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
2012-08-20 09:42:32 -01:00
|
|
|
|
}
|