Ejemplo n.º 1
0
        public void Returns_specified_url_for_area_url_when_both_subdomain_is_specified_and_area_url_is_specified()
        {
            var configuration = new AttributeRoutingConfiguration();

            configuration.AddRoutesFromController <SubdomainWithAreaUrlController>();

            var reflector = new RouteReflector(configuration);
            var specs     = reflector.GenerateRouteSpecifications().ToList();

            Assert.That(specs.Count, Is.EqualTo(1));
            Assert.That(specs.Single().Subdomain, Is.EqualTo("private"));
            Assert.That(specs.Single().AreaUrl, Is.EqualTo("admin"));
        }
Ejemplo n.º 2
0
        public void Returns_null_for_area_url_when_subdomain_is_specified_and_area_url_is_not_specified()
        {
            var configuration = new AttributeRoutingConfiguration();

            configuration.AddRoutesFromController <SubdomainController>();

            var reflector = new RouteReflector(configuration);
            var specs     = reflector.BuildRouteSpecifications().ToList();

            Assert.That(specs.Count, Is.EqualTo(1));
            Assert.That(specs.Single().Subdomain, Is.EqualTo("users"));
            Assert.That(specs.Single().AreaUrl, Is.Null);
        }
Ejemplo n.º 3
0
        public void Returns_subdomain_specified_for_area_via_configuration_object()
        {
            var configuration = new AttributeRoutingConfiguration();

            configuration.AddRoutesFromController <SubdomainController>();
            configuration.MapArea("Users").ToSubdomain("override");

            var reflector = new RouteReflector(configuration);
            var specs     = reflector.GenerateRouteSpecifications().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 AttributeRoutingConfiguration();

            configuration.AddRoutesFromController <SubdomainControllerWithoutSubdomainInAttribute>();
            configuration.MapArea("NoSubdomain").ToSubdomain("subdomain");

            var reflector = new RouteReflector(configuration);
            var specs     = reflector.GenerateRouteSpecifications().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));
        }
Ejemplo n.º 5
0
        public void WriteToStream(Stream stream)
        {
            var tsWriter = new TypeScriptWriter(stream, _options);

            var webApiWriter = new RouteReflector(_options);

            foreach (var additionalTypes in _types)
            {
                webApiWriter.AddAdditionalTypes(additionalTypes);
            }

            foreach (var assembly in _assemblies ?? Array.Empty <Assembly>())
            {
                webApiWriter.AddAssembly(assembly, _controllerFilter);
            }
            foreach (var controller in _controllers?.Where(_controllerFilter) ?? Array.Empty <Type>())
            {
                webApiWriter.AddController(controller);
            }

            webApiWriter.WriteTo(tsWriter);
        }