/// <summary> /// Creates the <see cref="HtmlToJavaScriptOutput"/> so we can cache it. /// </summary> /// <param name="context">The <see cref="HttpContext"/>.</param> /// <param name="htmlFile"></param> /// <returns></returns> private HtmlToJavaScriptOutput CreateOutput(HttpContext context, string htmlFile) { // get the file var file = new FileInfo(htmlFile); // create the date and strip the milliseconds var fileLastModified = new DateTime(file.LastWriteTime.Year, file.LastWriteTime.Month, file.LastWriteTime.Day, file.LastWriteTime.Hour, file.LastWriteTime.Minute, file.LastWriteTime.Second, DateTimeKind.Local); // load the html var html = File.ReadAllText(file.FullName); // create the converter var converter = new HtmlConverter(Options); // convert the html to javascript var javaScript = converter.ToJavaScript(file.Name.ToLower(), html); // create the output return new HtmlToJavaScriptOutput() { LastModified = fileLastModified, JavaScript = javaScript, }; }
public void ToJavaScriptTest(HtmlConverter converter, string expected, string inputName, string inputHtml) { var actual = converter.ToJavaScript(inputName, inputHtml); //Console.WriteLine("@\"{0}\"", actual.Replace("\"", "\"\"")); Assert.AreEqual(expected, actual); }