Esempio n. 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>[^/]+)");
        }
Esempio n. 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>[^/]+)"));
        }
Esempio n. 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>[^/]+)"));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }