本文整理汇总了C#中HtmlHelper.VeneerScripts方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.VeneerScripts方法的具体用法?C# HtmlHelper.VeneerScripts怎么用?C# HtmlHelper.VeneerScripts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper.VeneerScripts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VeneerScripts_handles_content_types_with_no_scripts
public void VeneerScripts_handles_content_types_with_no_scripts()
{
// Arrange
var service = new Mock<IContentService>();
var content = new Content
{
RefreshDate = DateTime.Now,
Sections = new List<ContentSection>
{
new ContentSection
{
Id = "Footer", Html = "<div id='hello' />", Scripts = new List<ContentScript>()
}
}
};
service.Setup(x => x.Get(It.IsAny<ContentTypes>())).Returns(content);
var contentTypes = new List<ContentTypes> { ContentTypes.Footer };
var model = new VeneerBaseViewModel(service.Object, contentTypes);
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var htmlHelper = new HtmlHelper(viewContext, viewDataContainer.Object);
// Act
var result = htmlHelper.VeneerScripts(model).ToHtmlString();
// Assert
Assert.That(result, Is.Empty);
}
示例2: VeneerScripts_renders_script_tags_for_list_of_JS_files_in_model_for_multiple_content_types
public void VeneerScripts_renders_script_tags_for_list_of_JS_files_in_model_for_multiple_content_types()
{
// Arrange
var service = new Mock<IContentService>();
var headerContent = new Content
{
RefreshDate = DateTime.Now,
Sections = new List<ContentSection>
{
new ContentSection
{
Id = "HeaderWithMegaNav", Html = "<div id='hello' />", Scripts = new List<ContentScript>
{
new ContentScript
{
Url = new Uri("http://header-scripts.com/all.js")
}
}
}
}
};
var footerContent = new Content
{
RefreshDate = DateTime.Now,
Sections = new List<ContentSection>
{
new ContentSection
{
Id = "Footer", Html = "<div id='goodbye' />", Scripts = new List<ContentScript>
{
new ContentScript
{
Url = new Uri("http://footer-scripts.com/all.js")
}
}
}
}
};
service.Setup(x => x.Get(ContentTypes.HeaderWithMegaNav)).Returns(headerContent);
service.Setup(x => x.Get(ContentTypes.Footer)).Returns(footerContent);
var contentTypes = new List<ContentTypes> { ContentTypes.HeaderWithMegaNav, ContentTypes.Footer };
var model = new VeneerBaseViewModel(service.Object, contentTypes);
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var htmlHelper = new HtmlHelper(viewContext, viewDataContainer.Object);
// Act
var result = htmlHelper.VeneerScripts(model).ToHtmlString();
// Assert
Assert.That(result, Is.Not.Null.And.Not.Empty);
Assert.That(result, Is.StringContaining(headerContent.Sections[0].Scripts[0].Url.ToString()));
Assert.That(result, Is.StringContaining(footerContent.Sections[0].Scripts[0].Url.ToString()));
}