コード例 #1
0
        public void InputTag_should_render_input_validation_class_if_ModelState_Error()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState          state  = new System.Web.Mvc.ModelState();
            state.Value = result;

            dateTimePicker.Name = "dateTimePicker1";
            dateTimePicker.ViewContext.ViewData.ModelState.Add("dateTimePicker1", state);
            dateTimePicker.ViewContext.ViewData.ModelState.AddModelError("dateTimePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("class").ShouldContain("input-validation-error");
        }
コード例 #2
0
        public void Input_value_method_should_set_attempedValue_if_GetValue_returns_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState          state  = new System.Web.Mvc.ModelState();
            state.Value = result;

            datePicker.Name = "DatePicker1";
            datePicker.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            datePicker.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("value").ShouldEqual("s");
        }
コード例 #3
0
        public void InputTag_should_render_input_validation_class_if_ModelState_Error()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState state = new System.Web.Mvc.ModelState();
            state.Value = result;

            datePicker.Name = "DatePicker1";
            datePicker.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            datePicker.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("class").ShouldContain("input-validation-error");
        }
コード例 #4
0
        public void Input_if_GetValue_returns_null_set_DatePicker_Value_to_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState          state  = new System.Web.Mvc.ModelState();
            state.Value = result;

            datePicker.Name  = "DatePicker1";
            datePicker.Value = DateTime.Now;
            datePicker.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            datePicker.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            datePicker.Value.ShouldBeNull();
        }
コード例 #5
0
        public void Input_value_method_should_render_ModelStateValue_even_Model_value_is_set()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("30", "30", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState          state  = new System.Web.Mvc.ModelState();
            state.Value = result;

            input.Value = 10;
            input.Name  = "DatePicker1";
            input.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            input.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("value").ShouldEqual("30");
        }
コード例 #6
0
        public void Input_if_GetValue_returns_null_set_DatePicker_Value_to_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState          state  = new System.Web.Mvc.ModelState();
            state.Value = result;

            AutoComplete.Name  = "AutoComplete1";
            AutoComplete.Value = "test";
            AutoComplete.ViewContext.ViewData.ModelState.Add("AutoComplete1", state);
            AutoComplete.ViewContext.ViewData.ModelState.AddModelError("AutoComplete1", "error");

            IHtmlNode tag = renderer.Build();

            tag.Attribute("value").ShouldEqual("s");
        }
コード例 #7
0
        public void Input_value_method_should_set_attempedValue_if_GetValue_returns_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState state = new System.Web.Mvc.ModelState();
            state.Value = result;

            timePicker.Name = "DatePicker1";
            timePicker.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            timePicker.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("value").ShouldEqual("s");
        }
コード例 #8
0
        public void Input_if_GetValue_returns_null_set_DatePicker_Value_to_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState state = new System.Web.Mvc.ModelState();
            state.Value = result;

            AutoComplete.Name = "AutoComplete1";
            AutoComplete.Value = "test";
            AutoComplete.ViewContext.ViewData.ModelState.Add("AutoComplete1", state);
            AutoComplete.ViewContext.ViewData.ModelState.AddModelError("AutoComplete1", "error");

            IHtmlNode tag = renderer.Build();
            tag.Attribute("value").ShouldEqual("s");
        }
コード例 #9
0
        public void Input_if_GetValue_returns_null_set_DatePicker_Value_to_null()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("s", "s", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState state = new System.Web.Mvc.ModelState();
            state.Value = result;

            datePicker.Name = "DatePicker1";
            datePicker.Value = DateTime.Now;
            datePicker.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            datePicker.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            datePicker.Value.ShouldBeNull();
        }
コード例 #10
0
        public void Input_value_method_should_render_ModelStateValue_even_Model_value_is_set()
        {
            System.Web.Mvc.ValueProviderResult result = new System.Web.Mvc.ValueProviderResult("30", "30", System.Threading.Thread.CurrentThread.CurrentCulture);
            System.Web.Mvc.ModelState state = new System.Web.Mvc.ModelState();
            state.Value = result;

            input.Value = 10;
            input.Name = "DatePicker1";
            input.ViewContext.ViewData.ModelState.Add("DatePicker1", state);
            input.ViewContext.ViewData.ModelState.AddModelError("DatePicker1", new Exception());

            IHtmlNode tag = renderer.InputTag();

            tag.Attribute("value").ShouldEqual("30");
        }