Esempio n. 1
0
 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() != '/') ? "/" : "");
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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)));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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());
        }
Esempio n. 10
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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;
                    }
                }
            }
        }
Esempio n. 14
0
 public void RouteValidatorTest()
 {
     var routeValidator = new RouteValidator();
     var route = new Route();
     ValidationResults result = routeValidator.Validate(route);
 }
Esempio n. 15
0
 public void RouteValidatorTest()
 {
     var routeValidator       = new RouteValidator();
     var route                = new Route();
     ValidationResults result = routeValidator.Validate(route);
 }