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_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_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_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"));
        }