public void when_string_property_and_null_then_theres_no_default()
 {
     var model = new ModelHandlerInput() {Text = null };
     var data = new RouteValueDictionary();
     Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Text"), model, data);
     data.ContainsKey("text").Should().BeFalse();   
 }
        public void when_nullable_property_with_value_then_use_that_value()
        {
            var model = new ModelHandlerInput() { Optional = 45};
            var data = new RouteValueDictionary();
            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Optional"), model, data);

            data["optional"].Should().Be(45); 
        }
        public void when_nullable_property_and_null_value_then_its_optional()
        {
            var model = new ModelHandlerInput() { Optional = null };
            var data = new RouteValueDictionary();
            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Optional"), model, data);

            data["optional"].Should().Be(UrlParameter.Optional);
        }
        public void when_type_is_valueType_and_has_non_default_value_then_use_that_value()
        {
            var model = new ModelHandlerInput() { Page = 234 };
            var data = new RouteValueDictionary();
            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Page"), model, data);

            data["page"].Should().Be(234);
        }
        public void when_type_is_valueType_and_has_default_value_then_theres_no_default()
        {
            var model = new ModelHandlerInput() { Page = 0 };
            var data = new RouteValueDictionary();
            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Page"), model, data);

            data.ContainsKey("page").Should().BeFalse();            
        }
        public void when_string_property_with_empty_value_then_its_optional()
        {
            var model = new ModelHandlerInput() { Text = "" };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Text"), model, data);

            data["text"].Should().Be(UrlParameter.Optional);
        }
        public void when_string_property_and_non_empty_then_use_value()
        {
            var model = new ModelHandlerInput() { Text = "test" };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof (ModelHandlerInput).GetProperty("Text"), model, data);
            
            data["text"].Should().Be("test");
        }
Exemple #8
0
        public void when_string_property_and_null_then_theres_no_default()
        {
            var model = new ModelHandlerInput()
            {
                Text = null
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Text"), model, data);
            data.ContainsKey("text").Should().BeFalse();
        }
Exemple #9
0
        public void when_string_property_with_empty_value_then_its_optional()
        {
            var model = new ModelHandlerInput()
            {
                Text = ""
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Text"), model, data);

            data["text"].Should().Be(UrlParameter.Optional);
        }
Exemple #10
0
        public void when_string_property_and_non_empty_then_use_value()
        {
            var model = new ModelHandlerInput()
            {
                Text = "test"
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Text"), model, data);

            data["text"].Should().Be("test");
        }
Exemple #11
0
        public void when_nullable_property_with_value_then_use_that_value()
        {
            var model = new ModelHandlerInput()
            {
                Optional = 45
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Optional"), model, data);

            data["optional"].Should().Be(45);
        }
Exemple #12
0
        public void when_nullable_property_and_null_value_then_its_optional()
        {
            var model = new ModelHandlerInput()
            {
                Optional = null
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Optional"), model, data);

            data["optional"].Should().Be(UrlParameter.Optional);
        }
Exemple #13
0
        public void when_type_is_valueType_and_has_non_default_value_then_use_that_value()
        {
            var model = new ModelHandlerInput()
            {
                Page = 234
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Page"), model, data);

            data["page"].Should().Be(234);
        }
Exemple #14
0
        public void when_type_is_valueType_and_has_default_value_then_theres_no_default()
        {
            var model = new ModelHandlerInput()
            {
                Page = 0
            };
            var data = new RouteValueDictionary();

            Extensions.SetDefaultValue(typeof(ModelHandlerInput).GetProperty("Page"), model, data);

            data.ContainsKey("page").Should().BeFalse();
        }
Exemple #15
0
        public ActionResult Post(ModelHandlerInput data)
        {

            return Content("");
        }
Exemple #16
0
 public ActionResult Post(ModelHandlerInput data)
 {
     return(Content(""));
 }