예제 #1
0
        public void WithExpressionAsDateTimeReturnsCorrectly()
        {
            var viewModel = new TimeViewModel( new DateTime( 2000, 1, 1, 13, 1, 1 ) );

            HtmlHelper<TimeViewModel> htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.TimeFor( x => x.Time );

            string expectedResult = string.Format( "<input id=\"Time\" name=\"Time\" type=\"time\" value=\"{0}\" />", viewModel.Time.ToString( "HH:mm" ) );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
예제 #2
0
        public void WithExpressionAndTimeFormatReturnsCorrectly()
        {
            var viewModel = new TimeViewModel( "13:01:01" );
            TimeFormat timeFormat = TimeFormat.Second;

            HtmlHelper<TimeViewModel> htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.TimeFor( x => x.TimeAsString, timeFormat );

            string expectedResult = string.Format( "<input id=\"TimeAsString\" name=\"TimeAsString\" step=\"1\" type=\"time\" value=\"{0}\" />", viewModel.TimeAsString );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
예제 #3
0
        public void WithExpressionAndAttributeExpressionReturnsCorrectly()
        {
            var viewModel = new TimeViewModel( "13:01" );
            string attributeName = "attributeName";
            string attributeValue = "attributeValue";

            HtmlHelper<TimeViewModel> htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.TimeFor( x => x.TimeAsString, x => x.Attribute( attributeName, attributeValue ) );

            string expectedResult = string.Format( "<input {0}=\"{1}\" id=\"TimeAsString\" name=\"TimeAsString\" type=\"time\" value=\"{2}\" />", attributeName, attributeValue, viewModel.TimeAsString );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }
예제 #4
0
        public void WithExpressionTimeFormatAndHtmlAttributesObjectReturnsCorrectly()
        {
            var viewModel = new TimeViewModel( "13:01:01" );
            TimeFormat timeFormat = TimeFormat.Second;
            string attributeValue = "attributeValue";

            object htmlAttributes = new
            {
                AttributeName = attributeValue
            };

            HtmlHelper<TimeViewModel> htmlHelper = HtmlHelperGenerator.CreateHtmlHelper( viewModel );

            var result = htmlHelper.TimeFor( x => x.TimeAsString, timeFormat, htmlAttributes );

            string expectedResult = string.Format( "<input AttributeName=\"{0}\" id=\"TimeAsString\" name=\"TimeAsString\" step=\"1\" type=\"time\" value=\"{1}\" />", attributeValue, viewModel.TimeAsString );
            Assert.AreEqual( expectedResult, result.ToHtmlString() );
        }