public void BackOfficeRouting_Ensure_Default_Editor_Url_Structures() { //Arrange var context = new FakeHttpContextFactory("~/empty", new RouteData()); var contentEditor = new ContentEditorController(new FakeBackOfficeRequestContext()); var contentControllerName = RebelController.GetControllerName(contentEditor.GetType()); var contentControllerId = RebelController.GetControllerId<EditorAttribute>(contentEditor.GetType()); var dataTypeEditor = new DataTypeEditorController(new FakeBackOfficeRequestContext()); var dataTypeControllerName = RebelController.GetControllerName(dataTypeEditor.GetType()); var dataTypeControllerId = RebelController.GetControllerId<EditorAttribute>(dataTypeEditor.GetType()); var docTypeEditor = new DocumentTypeEditorController(new FakeBackOfficeRequestContext()); var docTypeControllerName = RebelController.GetControllerName(docTypeEditor.GetType()); var docTypeControllerId = RebelController.GetControllerId<EditorAttribute>(docTypeEditor.GetType()); const string customAction = "Index"; const string defaultAction = "Dashboard"; const int id = -1; const string area = "Rebel"; //Act //ensure the area is passed in because we're matchin a URL in an area, otherwise it will not work var contentEditorDefaultUrl = UrlHelper.GenerateUrl(null, defaultAction, contentControllerName, new RouteValueDictionary(new { area, id = UrlParameter.Optional, editorId = contentControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); var dataTypeEditorDefaultUrl = UrlHelper.GenerateUrl(null, defaultAction, dataTypeControllerName, new RouteValueDictionary(new { area, id = UrlParameter.Optional, editorId = dataTypeControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); var docTypeEditorDefaultUrl = UrlHelper.GenerateUrl(null, defaultAction, docTypeControllerName, new RouteValueDictionary(new { area, id = UrlParameter.Optional, editorId = docTypeControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); var contentEditorCustomUrl = UrlHelper.GenerateUrl(null, customAction, contentControllerName, new RouteValueDictionary(new { area, id, editorId = contentControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); var dataTypeEditorCustomUrl = UrlHelper.GenerateUrl(null, customAction, dataTypeControllerName, new RouteValueDictionary(new { area, id, editorId = dataTypeControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); var docTypeEditorCustomUrl = UrlHelper.GenerateUrl(null, customAction, docTypeControllerName, new RouteValueDictionary(new { area, id, editorId = docTypeControllerId.ToString("N") }), RouteTable.Routes, context.RequestContext, true); //Assert Assert.AreEqual(string.Format("/Rebel/Editors/{0}", contentControllerName), contentEditorDefaultUrl); Assert.AreEqual(string.Format("/Rebel/Editors/{0}", dataTypeControllerName), dataTypeEditorDefaultUrl); Assert.AreEqual(string.Format("/Rebel/Editors/{0}", docTypeControllerName), docTypeEditorDefaultUrl); Assert.AreEqual(string.Format("/Rebel/Editors/{0}/{1}/{2}", contentControllerName, customAction, id), contentEditorCustomUrl); Assert.AreEqual(string.Format("/Rebel/Editors/{0}/{1}/{2}", dataTypeControllerName, customAction, id), dataTypeEditorCustomUrl); Assert.AreEqual(string.Format("/Rebel/Editors/{0}/{1}/{2}", docTypeControllerName, customAction, id), docTypeEditorCustomUrl); }