示例#1
0
        public void ShouldCreateDuplicateRouteWithDifferentMethods()
        {
            RouteManager routeManager;

            routeManager = new RouteManager(new RouteParser(), new ResponseSerializer());
            routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books/(?<Id>[^/]+)");
            routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.PUT, "/root/API/Books/(?<Id>[^/]+)");
        }
示例#2
0
        public void ShouldNotCreateDuplicateRoute()
        {
            RouteManager routeManager;

            routeManager = new RouteManager(new RouteParser(), new ResponseSerializer());
            routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books/(?<Id>[^/]+)");
            Assert.ThrowsException <DuplicateRouteException>(() => routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books/(?<Id>[^/]+)"));
        }
示例#3
0
        public void ShouldFailToBindRouteWithVariableSegmentWhenVariableCountDoesntMatch()
        {
            RouteManager routeManager;

            routeManager = new RouteManager(new RouteParser(), new ResponseSerializer());
            Assert.ThrowsException <InvalidRouteException>(() => routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books"));
            Assert.ThrowsException <InvalidRouteException>(() => routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books/(?<Id1>[^/]+)/(?<Id2>[^/]+)"));
        }
示例#4
0
        public void ShouldFailToBindRouteIfParametersAreEmpty()
        {
            RouteManager routeManager;

            routeManager = new RouteManager(new RouteParser(), new ResponseSerializer());
            Assert.ThrowsException <ArgumentNullException>(() => routeManager.BindRoute(null, MethodInfos.GetBook, RESTMethods.GET, "/root"));
            Assert.ThrowsException <ArgumentNullException>(() => routeManager.BindRoute(new BooksRouteHandler(), null, RESTMethods.GET, "/root"));
            Assert.ThrowsException <ArgumentNullException>(() => routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, null));
        }
示例#5
0
        public void ShouldBindRouteWithVariableSegment()
        {
            RouteManager routeManager;
            RouteBinding result;

            routeManager = new RouteManager(new RouteParser(), new ResponseSerializer());
            result       = routeManager.BindRoute(new BooksRouteHandler(), MethodInfos.GetBook, RESTMethods.GET, "/root/API/Books/(?<Id>[^/]+)");
            Assert.IsNotNull(result);
        }