public void Build_should_return_route_with_Id_in_url_pattern()
        {
            var type = typeof(GetHandler<MockViewModel, MockEntity>);
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, type.GetMethod("Retrieve", new[] { typeof(Get<MockViewModel>) }));

            var route = policy.Build(action);

            CollectionAssert.Contains(route.Input.RouteParameters.Select(rp => rp.Name), "Id");
        }
        public void Build_should_return_route_with_Get_using_view_model_as_generic_input_type()
        {
            var type = typeof(GetHandler<MockViewModel, MockEntity>);
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, type.GetMethod("Retrieve", new[] { typeof(Get<MockViewModel>) }));

            var route = policy.Build(action);

            Assert.AreEqual(typeof(Get<MockViewModel>), route.Input.InputType);
        }
        public void Build_should_return_route_with_edit_text_in_url_pattern_when_handler_input_type_is_Edit()
        {
            var type = typeof(GetHandler<MockViewModel, MockEntity>);
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, type.GetMethod("Retrieve", new[] { typeof(Edit<MockViewModel>) }));

            var route = policy.Build(action);

            Assert.That(route.Pattern, Is.StringEnding("edit"));
        }
        public void Build_should_return_route_constrained_to_GET_verb()
        {
            var type = typeof(GetHandler<MockViewModel, MockEntity>);
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, type.GetMethod("Retrieve", new[] { typeof(Get<MockViewModel>) }));

            var route = policy.Build(action);

            Assert.AreEqual(1, route.AllowedHttpMethods.Count);
            CollectionAssert.Contains(route.AllowedHttpMethods, "GET");
        }
        public void Build_should_return_route_with_view_model_name_as_url_without_ViewModel()
        {
            var type = typeof(GetHandler<MockViewModel, MockEntity>);
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, type.GetMethod("Retrieve", new[] { typeof(Get<MockViewModel>) }));

            var route = policy.Build(action);

            Assert.IsTrue(route.Pattern.StartsWith("mock"));
        }
        public void Matches_should_reurn_false_for_NON_GetHandler_action_call_handlers(Type type)
        {
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(type, null);

            Assert.IsFalse(policy.Matches(action, null));
        }
        public void Matches_should_return_true_for_GetHandler_action_call_handlers()
        {
            var policy = new GetHandlerUrlPolicy();
            var action = new ActionCall(typeof(GetHandler<MockViewModel, MockEntity>), null);

            Assert.IsTrue(policy.Matches(action, null));
        }