public void DateTimeInputTemplateTests() { var type = "datetime"; Assert.Equal( GetExpectedInputTag(type, "Value"), DefaultEditorTemplates.DateTimeInputTemplate(MakeHtmlHelper <string>("Value"))); Assert.Equal( GetExpectedInputTag(type, "<script>alert('XSS!')</script>"), DefaultEditorTemplates.DateTimeInputTemplate(MakeHtmlHelper <string>("<script>alert('XSS!')</script>"))); var epocInLocalTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime(); var helper = MakeHtmlHelper <DateTime>(epocInLocalTime); Assert.Equal( GetExpectedInputTag(type, epocInLocalTime.ToString(CultureInfo.CurrentCulture)), DefaultEditorTemplates.DateTimeInputTemplate(helper)); helper.Html5DateRenderingMode = Html5DateRenderingMode.Rfc3339; Assert.Equal( GetExpectedInputTag(type, epocInLocalTime.ToString("yyyy-MM-ddTHH:mm:ss.fffK")), DefaultEditorTemplates.DateTimeInputTemplate(helper)); }
public void DateTimeInputTemplateTests() { Assert.Equal( @"<input class=""text-box single-line"" id=""FieldPrefix"" name=""FieldPrefix"" type=""datetime"" value=""Value"" />", DefaultEditorTemplates.DateTimeInputTemplate(MakeHtmlHelper <string>("Value"))); Assert.Equal( @"<input class=""text-box single-line"" id=""FieldPrefix"" name=""FieldPrefix"" type=""datetime"" value=""<script>alert('XSS!')</script>"" />", DefaultEditorTemplates.DateTimeInputTemplate(MakeHtmlHelper <string>("<script>alert('XSS!')</script>"))); }