Started adding tests for surface controller routing. They are working but not quite correctly yet.
This commit is contained in:
11
src/Umbraco.Tests/Surface/SurfaceControllerAreaTests.cs
Normal file
11
src/Umbraco.Tests/Surface/SurfaceControllerAreaTests.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Tests.Surface
|
||||
{
|
||||
public class SurfaceControllerAreaTests
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@
|
||||
<Compile Include="DataTypeFactoryTests.cs" />
|
||||
<Compile Include="Routing\LookupByNiceUrlWithDomainsTests.cs" />
|
||||
<Compile Include="Routing\NiceUrlsProviderWithDomainsTests.cs" />
|
||||
<Compile Include="Surface\SurfaceControllerAreaTests.cs" />
|
||||
<Compile Include="TestHelpers\BaseRoutingTest.cs" />
|
||||
<Compile Include="GlobalSettingsTests.cs" />
|
||||
<Compile Include="Routing\LookupByAliasTests.cs" />
|
||||
|
||||
@@ -59,6 +59,10 @@ namespace Umbraco.Web
|
||||
//set the namespace of the controller to match
|
||||
new[] { controllerType.Namespace });
|
||||
|
||||
//TODO: FIx this!!
|
||||
//By setting the default this will always route even without specifying the surfaceId syntax in the URL,
|
||||
// we need to unit test this and ensure it is correct
|
||||
|
||||
//set defaults
|
||||
controllerPluginRoute.Defaults = new RouteValueDictionary(
|
||||
new Dictionary<string, object>
|
||||
|
||||
@@ -6,6 +6,15 @@ using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Web.Mvc
|
||||
{
|
||||
[SurfaceController("DD307F95-6D90-4593-8C97-093AC7C12573")]
|
||||
public class TestSurfaceController : SurfaceController
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Content("<html><body>hello</body></html>");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The base controller that all Presentation Add-in controllers should inherit from
|
||||
/// </summary>
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Web.Mvc
|
||||
var areaName = GlobalSettings.UmbracoMvcArea;
|
||||
|
||||
//local surface controllers do not contain the attribute
|
||||
var localSurfaceControlleres = surfaceControllers.Where(x => TypeExtensions.GetCustomAttribute<SurfaceControllerAttribute>(x.GetType(), false) == null);
|
||||
var localSurfaceControlleres = surfaceControllers.Where(x => x.GetType().GetCustomAttribute<SurfaceControllerAttribute>(false) == null);
|
||||
foreach (var s in localSurfaceControlleres)
|
||||
{
|
||||
var meta = s.GetMetadata();
|
||||
|
||||
@@ -10,9 +10,17 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
|
||||
public SurfaceControllerAttribute(Guid id)
|
||||
public SurfaceControllerAttribute(string id)
|
||||
{
|
||||
Id = id;
|
||||
Guid gid;
|
||||
if (Guid.TryParse(id, out gid))
|
||||
{
|
||||
Id = gid;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidCastException("Cannot convert the value " + id + " to a Guid");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user