Ejemplo n.º 1
0
        public static void RouteNotMatched <TValues>(
            this Assert assert,
            RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> routeInfo,
            UrlPathDetails url)
        {
            var routeWasMatched = false;
            var route           = routeInfo.ToRoute(extractedValue => routeWasMatched = true);

            route.ExecuteCallbackIfUrlMatches(url);
            assert.NotOk(routeWasMatched);
        }
        public static IMatchRoutes ToRoute <TValues>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> source, Action <TValues> ifMatched)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (ifMatched == null)
            {
                throw new ArgumentNullException("ifMatched");
            }

            return(source.ToRoute(ifMatched: (values, queryString) => ifMatched(values)));
        }
Ejemplo n.º 3
0
        public static void RouteMatched <TValues>(
            this Assert assert,
            RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> routeInfo,
            UrlPathDetails url,
            TValues expectedValue,
            ResultComparer <TValues> comparer)
        {
            var routeMatched = false;
            var route        = routeInfo.ToRoute(extractedValue => routeMatched = comparer(extractedValue, expectedValue));

            route.ExecuteCallbackIfUrlMatches(url);
            assert.Ok(routeMatched);
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <TValuesExpanded> Int <TValues, TValuesExpanded>(
            this RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> source,
            Func <TValues, int, TValuesExpanded> valueExtender)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (valueExtender == null)
            {
                throw new ArgumentNullException("valueExtender");
            }

            return(source.Variable(valueExtender, ParseInt));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <TValuesExpanded> String <TValues, TValuesExpanded>(
            this RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> source,
            Func <TValues, NonBlankTrimmedString, TValuesExpanded> valueExtender)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (valueExtender == null)
            {
                throw new ArgumentNullException("valueExtender");
            }

            return(source.Variable(valueExtender, parser: segment => Optional.For(segment)));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, T2, T3, T4, T5, T6, NonBlankTrimmedString> > String <T1, T2, T3, T4, T5, T6>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, T2, T3, T4, T5, T6> > source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.String(TupleExtensions.Extend));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, NonBlankTrimmedString> > String <T1>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <T1> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.String((matchSoFar, segment) => Tuple.Create(matchSoFar, segment)));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, T2, T3, T4, T5, T6, int> > Int <T1, T2, T3, T4, T5, T6>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, T2, T3, T4, T5, T6> > source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.Int(TupleExtensions.Extend));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <Tuple <T1, int> > Int <T1>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <T1> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            return(source.Int((matchSoFar, intValue) => Tuple.Create(matchSoFar, intValue)));
        }
        public static RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> Fixed <TValues>(this RouteBuilder.IBuildRoutesWithVariablesToMatch <TValues> source, string segment)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (string.IsNullOrWhiteSpace(segment))
            {
                throw new ArgumentException("Null/blank/whitespace-only segment specified");
            }

            return(source.Fixed(new NonBlankTrimmedString(segment)));
        }