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