public RouteArg(string route, bool validate = true) { route = route?.Replace('\\', '/'); if (validate && route != null) { RouteValidator.EnforceValidation(route); } this.Value = (route == null) ? null : string.Join(null, (route.First() != '/') ? "/" : "", route, (route.Last() != '/') ? "/" : ""); }
public void ValidateRoute_InvalidDistanceInputRange_ThrowsException(int distance) { var graph = new Graph <char>(); var routeModel = new RouteModel { Source = 'A', Destination = 'B', Distance = distance }; var routeValidator = new RouteValidator(); routeValidator.ValidateRoute(routeModel, graph); }
public void ValidateRoute_EqualSourceAndDestination_ThrowsException() { var graph = new Graph <char>(); var routeModel = new RouteModel { Source = 'A', Destination = 'A', Distance = 5 }; var routeValidator = new RouteValidator(); routeValidator.ValidateRoute(routeModel, graph); }
public void ValidateRoute_InvalidSourceInput_ThrowsException() { var graph = new Graph <char>(); var routeModel = new RouteModel { Source = '7', Destination = 'B', Distance = 5 }; var routeValidator = new RouteValidator(); routeValidator.ValidateRoute(routeModel, graph); }
public async Task <ActionResult> Update(int id, [FromBody] RouteRequestDto dto) { var validator = new RouteValidator(); var result = await validator.ValidateAsync(dto); if (!result.IsValid) { return(BadRequest(result.Errors)); } return(Ok(await _service.Update(id, dto))); }
public Simulation() { var routeValidator = new RouteValidator(); var routeFactory = Route.Factory(routeValidator); var routePlanner = new RoutePlanner(routeFactory); var transportManager = new TransportManager(); _deliveryManager = new DeliveryManager(routePlanner, transportManager); }
public void Setup() { _sitecore = new Mock<ISitecoreContext>(); _sitecore.Setup(x => x.IsDatabaseNull()).Returns(false); _sitecore.Setup(x => x.IsDatabaseCore()).Returns(false); _sitecore.Setup(x => x.IsCurrentFilePathNull()).Returns(false); _sitecore.Setup(x => x.IsValidPage()).Returns(true); _sitecore.Setup(x => x.IsItem()).Returns(false); _routeValidator = new RouteValidator(_sitecore.Object); }
public void Setup() { _sitecore = new Mock <ISitecoreContext>(); _sitecore.Setup(x => x.IsDatabaseNull()).Returns(false); _sitecore.Setup(x => x.IsDatabaseCore()).Returns(false); _sitecore.Setup(x => x.IsCurrentFilePathNull()).Returns(false); _sitecore.Setup(x => x.IsValidPage()).Returns(true); _sitecore.Setup(x => x.IsItem()).Returns(false); _routeValidator = new RouteValidator(_sitecore.Object); }
public void ValidateRoute_RepeatedRoute_ThrowsException() { var graphBuilder = new DirectedGraphBuilder <char>(); var routeModel = new RouteModel { Source = 'A', Destination = 'B', Distance = 5 }; graphBuilder.AddEdge(routeModel.Source, routeModel.Destination, routeModel.Distance); var routeValidator = new RouteValidator(); routeValidator.ValidateRoute(routeModel, graphBuilder.GetGraph()); }
private IBaseTestBuilderWithCaughtException RedirectTo <TController>(LambdaExpression actionCall) where TController : ApiController { var redirectToRouteResult = this.GetRedirectResult <RedirectToRouteResult>(RouteName); RouteValidator.Validate <TController>( redirectToRouteResult.Request, redirectToRouteResult.RouteName, redirectToRouteResult.RouteValues, actionCall, this.ThrowNewRedirectResultAssertionException); return(this); }
private void _MVC(WebContext context) { var(controller, action) = default((String, String)); var path = context.Request.path; if (String.Compare(path, "/") == 0) { (controller, action) = ParserRoute.GetDefaultMVC(_routeMVC); } else if (RouteValidator.IsValid(_routeMVC, path)) { (controller, action) = ParserRoute.GetMVC(_routeMVC, path); } ControllerInvoker.Invoke(controller, action, context); }
private IAndCreatedTestBuilder AtRoute <TController>(LambdaExpression actionCall) where TController : ApiController { RuntimeBinderValidator.ValidateBinding(() => { var createdAtRouteResult = this.GetActionResultAsDynamic(); RouteValidator.Validate <TController>( createdAtRouteResult.Request, createdAtRouteResult.RouteName, createdAtRouteResult.RouteValues, actionCall, new Action <string, string, string>(this.ThrowNewCreatedResultAssertionException)); }); return(this); }
private async Task ValidateRouteAsync(IEnumerable <TKey> ids, QueryString queryString, bool forceValidation = false) { if (forceValidation || queryString.ValidateRoute) { var result = await RouteValidator.ValidateRouteAsync(GetType(), ids.Select(p => p as object)); if (result != null) { switch (result.ErrorType) { case RecordErrorType.RecordNotExist: if (result.EntityType != typeof(TEntity)) { AddRecordNotFoundError(result); } break; case RecordErrorType.RecordRelationNotValid: AddRecordNotBelongToParentError(result); break; } } } }
public void RouteValidatorTest() { var routeValidator = new RouteValidator(); var route = new Route(); ValidationResults result = routeValidator.Validate(route); }