Fixed the NiceUrlProvider as it some refactor on a previous commit broke some stuff.
Fixed up some unit tests with NiceUrlProvider to ensure that the second node under the root get's the correct URL assigned. Added unit test to ensure that route caches are persisted correctly.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Tests.Routing
|
||||
{
|
||||
@@ -15,6 +17,41 @@ namespace Umbraco.Tests.Routing
|
||||
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "");
|
||||
}
|
||||
|
||||
internal override IRoutesCache GetRoutesCache()
|
||||
{
|
||||
return new DefaultRoutesCache(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This checks that when we retreive a NiceUrl for multiple items that there are no issues with cache overlap
|
||||
/// and that they are all cached correctly.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void Ensure_Cache_Is_Correct()
|
||||
{
|
||||
|
||||
var routingContext = GetRoutingContext("/test", 1111);
|
||||
ConfigurationManager.AppSettings.Set("umbracoUseDirectoryUrls", "true");
|
||||
var ids = new[]
|
||||
{
|
||||
new Tuple<int, string>(1046, "/home"),
|
||||
new Tuple<int, string>(1173, "/home/sub1"),
|
||||
new Tuple<int, string>(1174, "/home/sub1/sub2"),
|
||||
new Tuple<int, string>(1176, "/home/sub1/sub-3"),
|
||||
new Tuple<int, string>(1177, "/home/sub1/custom-sub-1"),
|
||||
new Tuple<int, string>(1178, "/home/sub1/custom-sub-2"),
|
||||
new Tuple<int, string>(1175, "/home/sub-2"),
|
||||
new Tuple<int, string>(1172, "/test-page")
|
||||
};
|
||||
foreach(var i in ids)
|
||||
{
|
||||
var result = routingContext.NiceUrlProvider.GetNiceUrl(i.Item1);
|
||||
Assert.AreEqual(i.Item2, result);
|
||||
}
|
||||
Assert.AreEqual(8, ((DefaultRoutesCache)routingContext.UmbracoContext.RoutesCache).GetCachedRoutes().Count);
|
||||
Assert.AreEqual(8, ((DefaultRoutesCache)routingContext.UmbracoContext.RoutesCache).GetCachedIds().Count);
|
||||
}
|
||||
|
||||
[TestCase(1046, "/home.aspx")]
|
||||
[TestCase(1173, "/home/sub1.aspx")]
|
||||
[TestCase(1174, "/home/sub1/sub2.aspx")]
|
||||
@@ -65,7 +102,7 @@ namespace Umbraco.Tests.Routing
|
||||
|
||||
ConfigurationManager.AppSettings.Set("umbracoHideTopLevelNodeFromPath", "true");
|
||||
|
||||
var result = routingContext.NiceUrlProvider.GetNiceUrl(nodeId);
|
||||
var result = routingContext.NiceUrlProvider.GetNiceUrl(nodeId);
|
||||
|
||||
Assert.AreEqual(niceUrlMatch, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user