public void SetPath_WhenProvidedWithPathSuffixedWithASlash_ThrowsArgumentException() { const string routePath = "Google/"; var attribute = new UrlRouteAttribute(); attribute.Path = routePath; // Exception }
public void SetPath_WhenProvidedWithAValidOneWordPath_SetsCorrectly() { const string routePath = "Google"; var attribute = new UrlRouteAttribute(); attribute.Path = routePath; Assert.AreEqual(routePath, attribute.Path); }
public void SetPath_WhenProvidedWithAValidMultiWordPath_SetsCorrectly() { const string routePath = "Search/Api/Google/Redirect"; var attribute = new UrlRouteAttribute(); attribute.Path = routePath; Assert.AreEqual(routePath, attribute.Path); }
void findRoutes(string siteKey, Dictionary <string, Type> types) { UrlMappingConfig config = UrlMappingConfig.Instance; IUrlMappingProvider provider = ServiceLocator.Instance.Resolve <IUrlMappingProvider>(); foreach (var controller in types) { foreach (MethodInfo m in controller.Value.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance)) { object[] objs = m.GetCustomAttributes(typeof(UrlRouteAttribute), true); if (objs.Length == 0) { continue; } UrlRouteAttribute attr = objs[0] as UrlRouteAttribute; UrlMappingItem item = UrlMapping.Utility.CreateTemplatedMappingItem(string.Empty, attr.Template, UrlMapping.Utility.GetHref(attr.Href), config.IncomingQueryStringBehavior); item.UrlTemplate = attr.Template; item.Index = -1; item.SubIndex = -1; item.SubsubIndex = -1; item.Title = attr.Title; item.Id = controller.Key; item.Action = m.Name; provider.AddMapping(siteKey, item); } } }