public void Returns_specified_url_for_area_url_when_both_subdomain_is_specified_and_area_url_is_specified() { var configuration = new Configuration(); configuration.AddRoutesFromController<SubdomainWithAreaUrlController>(); var reflector = new AttributeReflector(configuration); var specs = reflector.BuildRouteSpecifications().ToList(); Assert.That(specs.Count, Is.EqualTo(1)); Assert.That(specs.Single().Subdomain, Is.EqualTo("private")); Assert.That(specs.Single().AreaUrl, Is.EqualTo("admin")); }
/// <summary> /// Yields all the routes to register in the route table. /// </summary> public IEnumerable<IAttributeRoute> BuildAllRoutes() { // Get the route specifications that describe the routes we'll build. var reflector = new AttributeReflector(_configuration); var routeSpecs = reflector.BuildRouteSpecifications().ToList(); // Update the config object with context. _configuration.MappedSubdomains = (from s in routeSpecs where s.Subdomain.HasValue() select s.Subdomain).Distinct().ToList(); return routeSpecs.SelectMany(BuildRoutes); }
/// <summary> /// Yields all the routes to register in the route table. /// </summary> public IEnumerable <IAttributeRoute> BuildAllRoutes() { // Get the route specifications that describe the routes we'll build. var reflector = new AttributeReflector(_configuration); var routeSpecs = reflector.BuildRouteSpecifications().ToList(); // Update the config object with context. _configuration.MappedSubdomains = (from s in routeSpecs where s.Subdomain.HasValue() select s.Subdomain).Distinct().ToList(); return(routeSpecs.SelectMany(BuildRoutes)); }
public void Returns_subdomain_specified_for_area_via_configuration_object() { var configuration = new Configuration(); configuration.AddRoutesFromController<SubdomainController>(); configuration.MapArea("Users").ToSubdomain("override"); var reflector = new AttributeReflector(configuration); var specs = reflector.BuildRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("override")); Assert.That(spec.AreaName, Is.EqualTo("Users")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }
public void Returns_null_area_url_when_controller_configured_with_subdomain_only_via_configuration_object() { var configuration = new Configuration(); configuration.AddRoutesFromController<SubdomainControllerWithoutSubdomainInAttribute>(); configuration.MapArea("NoSubdomain").ToSubdomain("subdomain"); var reflector = new AttributeReflector(configuration); var specs = reflector.BuildRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("subdomain")); Assert.That(spec.AreaName, Is.EqualTo("NoSubdomain")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }