some benchmark unit tests against loading a type from an assembly this is about 100% faster. Updated the UmbracoModule to write more diagnostics for benchmark debugging. Have basically reduced the startup time to approx 50% of what it used to be based on the current benchmarks run. Previously app startup on my machine was about 5 seconds, now after the first startup it is about 2.5 seconds.
100 lines
2.0 KiB
C#
100 lines
2.0 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using NUnit.Framework;
|
|
using Umbraco.Core;
|
|
using Umbraco.Core.ObjectResolution;
|
|
using Umbraco.Tests.TestHelpers;
|
|
using umbraco.interfaces;
|
|
|
|
namespace Umbraco.Tests.Resolvers
|
|
{
|
|
[TestFixture]
|
|
public class PackageActionsResolverTests
|
|
{
|
|
[SetUp]
|
|
public void Initialize()
|
|
{
|
|
TestHelper.SetupLog4NetForTests();
|
|
|
|
//this ensures its reset
|
|
PluginManager.Current = new PluginManager(false);
|
|
|
|
//for testing, we'll specify which assemblies are scanned for the PluginTypeResolver
|
|
PluginManager.Current.AssembliesToScan = new[]
|
|
{
|
|
this.GetType().Assembly
|
|
};
|
|
|
|
PackageActionsResolver.Current = new PackageActionsResolver(
|
|
PluginManager.Current.ResolvePackageActions());
|
|
|
|
Resolution.Freeze();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
PackageActionsResolver.Reset();
|
|
Resolution.IsFrozen = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures all IPackageActions are found
|
|
/// </summary>
|
|
[Test]
|
|
public void Find_Package_Actions()
|
|
{
|
|
var actions = PackageActionsResolver.Current.PackageActions;
|
|
Assert.AreEqual(2, actions.Count());
|
|
}
|
|
|
|
#region Classes for tests
|
|
public class PackageAction1 : IPackageAction
|
|
{
|
|
public bool Execute(string packageName, XmlNode xmlData)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public string Alias()
|
|
{
|
|
return "pa1";
|
|
}
|
|
|
|
public bool Undo(string packageName, XmlNode xmlData)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public XmlNode SampleXml()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class PackageAction2 : IPackageAction
|
|
{
|
|
public bool Execute(string packageName, XmlNode xmlData)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public string Alias()
|
|
{
|
|
return "pa2";
|
|
}
|
|
|
|
public bool Undo(string packageName, XmlNode xmlData)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public XmlNode SampleXml()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |