コード例 #1
0
        private static decimal Compute(string template)
        {
            var options = new Mock<IOptionsAccessor<RouteOptions>>();
            options.SetupGet(o => o.Options).Returns(new RouteOptions());

            var constraintResolver = new DefaultInlineConstraintResolver(
                Mock.Of<IServiceProvider>(),
                options.Object);

            var parsed = TemplateParser.Parse(template, constraintResolver);
            return AttributeRoutePrecedence.Compute(parsed);
        }
コード例 #2
0
        private static RouteConstraintBuilder CreateBuilder(string template)
        {
            var services = new Mock <IServiceProvider>(MockBehavior.Strict);

            var options = new Mock <IOptions <RouteOptions> >(MockBehavior.Strict);

            options
            .SetupGet(o => o.Options)
            .Returns(new RouteOptions());

            var inlineConstraintResolver = new DefaultInlineConstraintResolver(services.Object, options.Object);

            return(new RouteConstraintBuilder(inlineConstraintResolver, template));
        }
コード例 #3
0
		public void HandlesRegexConstraints(string inlineConstraint, string expected)
		{
			var routeOptions = new Mock<IOptions<RouteOptions>>();
			routeOptions.Setup(x => x.Value).Returns(new RouteOptions());
			var constraintResolver = new DefaultInlineConstraintResolver(routeOptions.Object);
			var constraint = constraintResolver.ResolveConstraint(inlineConstraint);

			var constraintsProcessor = new ConstraintsProcessor();
			var result = constraintsProcessor.ProcessConstraints(new Dictionary<string, IRouteConstraint>
			{
				{"test", constraint}
			});

			Assert.Equal(1, result.Count);
			Assert.Equal(expected, result["test"]);
		}
コード例 #4
0
        private static RouteConstraintBuilder CreateBuilder(string template)
        {
            var options = new Mock<IOptions<RouteOptions>>(MockBehavior.Strict);
            options
                .SetupGet(o => o.Value)
                .Returns(new RouteOptions());

            var inlineConstraintResolver = new DefaultInlineConstraintResolver(options.Object);
            return new RouteConstraintBuilder(inlineConstraintResolver, template);
        }