2012-07-27 12:23:22 +06:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Umbraco.Core;
|
2012-07-31 02:34:57 +06:00
|
|
|
using Umbraco.Tests.TestHelpers;
|
2012-07-27 12:23:22 +06:00
|
|
|
using umbraco.BusinessLogic;
|
|
|
|
|
using umbraco.cms.businesslogic.media;
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class MediaFactoryTests
|
|
|
|
|
{
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
2012-07-31 02:34:57 +06:00
|
|
|
TestHelper.SetupLog4NetForTests();
|
|
|
|
|
|
|
|
|
|
//this ensures its reset
|
2012-08-01 22:06:15 +06:00
|
|
|
PluginManager.Current = new PluginManager();
|
2012-07-31 02:34:57 +06:00
|
|
|
|
2012-07-27 12:23:22 +06:00
|
|
|
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
|
2012-08-01 22:06:15 +06:00
|
|
|
PluginManager.Current.AssembliesToScan = new[]
|
2012-07-27 12:23:22 +06:00
|
|
|
{
|
|
|
|
|
this.GetType().Assembly
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ensures that the media factory finds the correct number of IMediaFactory
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test]
|
|
|
|
|
public void Find_Media_Factories()
|
|
|
|
|
{
|
|
|
|
|
var factories = MediaFactory.Factories;
|
|
|
|
|
Assert.AreEqual(2, factories.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Classes for tests
|
|
|
|
|
public class MediaFactory1 : IMediaFactory
|
|
|
|
|
{
|
|
|
|
|
public List<string> Extensions
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Priority
|
|
|
|
|
{
|
|
|
|
|
get { return 1; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanHandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user, bool replaceExisting)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MediaFactory2 : IMediaFactory
|
|
|
|
|
{
|
|
|
|
|
public List<string> Extensions
|
|
|
|
|
{
|
|
|
|
|
get { throw new NotImplementedException(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Priority
|
|
|
|
|
{
|
|
|
|
|
get { return 2; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanHandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Media HandleMedia(int parentNodeId, PostedMediaFile postedFile, User user, bool replaceExisting)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|