public void BuildRoute_ActionNotAllowed_OnActionRoute(string template)
        {
            // Arrange
            var actions = GetActions();

            var expectedMessage =
                "A direct route for an action method cannot use the parameter 'action'. " +
                "Specify a literal path in place of this parameter to create a route to the action.";

            var builder = new MockDirectRouteBuilder(actions, targetIsAction: true);
            builder.Template = template;

            // Act & Assert
            Assert.Throws<InvalidOperationException>(() => builder.Build(), expectedMessage);
            Assert.Equal(1, builder.TimesValidateParametersCalled);
        }
        public void BuildRoute_ValidatesAllowedParameters()
        {
            // Arrange
            var actions = GetActions();
            var builder = new MockDirectRouteBuilder(actions, targetIsAction: true);
            builder.Template = "{a}/{b}";

            // Act
            RouteEntry entry = builder.Build();

            // Assert
            Assert.NotNull(entry);
            Assert.Equal(1, builder.TimesValidateParametersCalled);
        }
        public void BuildRoute_ControllerParameterNotAllowed(string template, bool targetIsAction)
        {
            // Arrange
            var actions = GetActions();

            var expectedMessage =
                "A direct route cannot use the parameter 'controller'. " +
                "Specify a literal path in place of this parameter to create a route to a controller.";

            var builder = new MockDirectRouteBuilder(actions, targetIsAction);
            builder.Template = template;

            // Act & Assert
            Assert.Throws<InvalidOperationException>(() => builder.Build(), expectedMessage);
            Assert.Equal(1, builder.TimesValidateParametersCalled);
        }