Exemple #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);
        }
Exemple #2
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 mapDesc = new MappingDescription("foobar", routeDetail);

            var result = Serialize(mapDesc);

            Assert.Equal("{\"handler\":\"foobar\",\"predicate\":\"{[/Home/Index],methods=[GET],produces=[application/json],consumes=[application/json]}\"}", result);
        }
Exemple #3
0
        public void Constructor_SetsValues()
        {
            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 mapDesc = new MappingDescription("foobar", routeDetail);

            Assert.Null(mapDesc.Details);
            Assert.Equal("foobar", mapDesc.Handler);
            Assert.Equal("{[/Home/Index],methods=[GET],produces=[application/json],consumes=[application/json]}", mapDesc.Predicate);
        }