Пример #1
0
        public void JsonSerialization_ReturnsExpected()
        {
            var routeDetail = new TestRouteDetails()
            {
                HttpMethods = new List <string>()
                {
                    "GET"
                },
                RouteTemplate = "/Home/Index",
                Consumes      = new List <string>()
                {
                    "application/json"
                },
                Produces = new List <string>()
                {
                    "application/json"
                }
            };

            var mappDescs = new List <MappingDescription>()
            {
                new MappingDescription("foobar", routeDetail)
            };

            var mappingDict = new Dictionary <string, IList <MappingDescription> >()
            {
                { "controllerTypeName", mappDescs }
            };

            var contextMappings = new ContextMappings(mappingDict);
            var result          = Serialize(contextMappings);

            Assert.Equal("{\"mappings\":{\"dispatcherServlets\":{\"controllerTypeName\":[{\"handler\":\"foobar\",\"predicate\":\"{[/Home/Index],methods=[GET],produces=[application/json],consumes=[application/json]}\"}]}}}", result);
        }
        protected internal ApplicationMappings GetApplicationMappings()
        {
            IDictionary <string, IList <MappingDescription> > desc = new Dictionary <string, IList <MappingDescription> >();

            // Use the IApiExplorer to get mappings for WebApi endpoints
            if (_apiExplorer != null)
            {
                desc = GetMappingDescriptions(_apiExplorer.ApiDescriptions);
            }

            var contextMappings = new ContextMappings(desc);

            return(new ApplicationMappings(contextMappings));
        }
Пример #3
0
        public void Constructor_SetsValues()
        {
            var mappingDict = new Dictionary <string, IList <MappingDescription> >()
            {
                { "dispatcherServlet", new List <MappingDescription>() }
            };
            var contextMappings = new ContextMappings(mappingDict);

            var appMappings = new ApplicationMappings(contextMappings);
            var ctxMappings = appMappings.ContextMappings;

            Assert.Contains("application", ctxMappings.Keys);
            Assert.Single(ctxMappings.Keys);
            Assert.Same(contextMappings, ctxMappings["application"]);
        }
Пример #4
0
        public void Constructor_SetsValues()
        {
            var mappingList = new List <MappingDescription>();
            var mappingDict = new Dictionary <string, IList <MappingDescription> >()
            {
                { "dispatcherServlet", mappingList }
            };
            var contextMappings = new ContextMappings(mappingDict);
            var smappings       = contextMappings.Mappings;

            Assert.Contains("dispatcherServlets", smappings.Keys);
            var mappings = smappings["dispatcherServlets"];

            Assert.Contains("dispatcherServlet", mappings.Keys);
            Assert.Same(mappingList, mappings["dispatcherServlet"]);
        }
Пример #5
0
        protected internal ApplicationMappings GetApplicationMappings()
        {
            IDictionary <string, IList <MappingDescription> > desc = new Dictionary <string, IList <MappingDescription> >();

            // Use the IApiExplorer to get mappings for WebApi endpoints
            if (_apiExplorer != null)
            {
                desc = GetMappingDescriptions(_apiExplorer.ApiDescriptions);
            }

            // RouteTable contains routes for everything
            var routeCollection = RouteTable.Routes;

            if (routeCollection != null)
            {
                AddRouteMappingsDescriptions(routeCollection, desc);
            }

            var contextMappings = new ContextMappings(desc);

            return(new ApplicationMappings(contextMappings));
        }