コード例 #1
0
        public void DateTimePicker()
        {
            var hh = new FakeHtmlHelper<Foo>();
            hh.ViewData.Model = new Foo
            {
                CreatedAt = new DateTime(2011, 8, 15, 12, 30, 15)
            };

            var html = hh.WDateTimePicker("abc", "123", new { bla = "blabla" });
            Assert.AreEqual("<input bla=\"blabla\" class=\"wdatetimepicker\" id=\"abc\" name=\"abc\" type=\"text\" value=\"123\" />", html.ToHtmlString());

            html = hh.WDateTimePicker("abc");
            Assert.AreEqual("<input class=\"wdatetimepicker\" id=\"abc\" name=\"abc\" type=\"text\" value=\"\" />", html.ToHtmlString());

            html = hh.WDateTimePickerFor(m=>m.CreatedAt, new { @class = "testClass1 testClass2" });
            Assert.IsTrue(html.ToHtmlString() == "<input class=\"testClass1 testClass2 wdatetimepicker\" id=\"CreatedAt\" name=\"CreatedAt\" type=\"text\" value=\"15/08/2011 12:30:15\" />" ||
                          html.ToHtmlString() == "<input class=\"testClass1 testClass2 wdatetimepicker\" id=\"CreatedAt\" name=\"CreatedAt\" type=\"text\" value=\"8/15/2011 12:30:15 PM\" />");

            html = hh.WDateTimePickerFor(m => m.CreatedAt);
            Assert.IsTrue(html.ToHtmlString() == "<input class=\"wdatetimepicker\" id=\"CreatedAt\" name=\"CreatedAt\" type=\"text\" value=\"15/08/2011 12:30:15\" />" ||
                          html.ToHtmlString() == "<input class=\"wdatetimepicker\" id=\"CreatedAt\" name=\"CreatedAt\" type=\"text\" value=\"8/15/2011 12:30:15 PM\" />");
        }