本文整理汇总了C#中ScriptManager.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptManager.Generate方法的具体用法?C# ScriptManager.Generate怎么用?C# ScriptManager.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptManager
的用法示例。
在下文中一共展示了ScriptManager.Generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScriptManager_Generate_Sets_Correct_ContentType_For_JavaScript
public void ScriptManager_Generate_Sets_Correct_ContentType_For_JavaScript()
{
var cacheManager = new Mock<ICacheManager>();
var contextAccessor = new Mock<IHttpContextAccessor>();
var info = new Mock<IScriptGenerationInfo>();
info.SetupGet(i => i.Type).Returns(ScriptType.JavaScript);
var list = new Mock<IScriptFileList>();
var items = new Dictionary<string, object>();
items.Add("__sm__JavaScript", list.Object);
var context = new Mock<HttpContextBase>
{
DefaultValue = DefaultValue.Mock
};
contextAccessor.Setup(c => c.Current()).Returns(context.Object);
context.SetupGet(c => c.Items).Returns(items);
var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);
IScriptOutput actual;
actual = target.Generate(info.Object);
var expected = @"application/javascript";
Assert.AreEqual(expected, actual.ContentType);
}
示例2: ScriptManager_Generate_Sets_Correct_ContentType_For_Stylesheet
public void ScriptManager_Generate_Sets_Correct_ContentType_For_Stylesheet()
{
string area = "foo";
List<IScriptInfo> scripts = new List<IScriptInfo>();
var cacheManager = new Mock<ICacheManager>();
var contextAccessor = new Mock<IHttpContextAccessor>();
var info = new Mock<IScriptGenerationInfo>();
info.SetupGet(i => i.Type).Returns(ScriptType.Stylesheet);
info.SetupGet(i => i.Area).Returns(area);
var list = new Mock<IScriptFileList>();
list.Setup(l => l.ScriptsForArea(area)).Returns(scripts);
var items = new Dictionary<string, object>();
items.Add("__sm__Stylesheet", list.Object);
var context = new Mock<HttpContextBase>
{
DefaultValue = DefaultValue.Mock
};
contextAccessor.Setup(c => c.Current()).Returns(context.Object);
context.SetupGet(c => c.Items).Returns(items);
var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);
IScriptOutput actual;
actual = target.Generate(info.Object);
var expected = @"text/css";
Assert.AreEqual(expected, actual.ContentType);
}
示例3: ScriptManager_Generate_With_Null_ScriptInfo_Throws_Exception_Test
public void ScriptManager_Generate_With_Null_ScriptInfo_Throws_Exception_Test()
{
var cacheManager = new Mock<ICacheManager>();
var contextAccessor = new Mock<IHttpContextAccessor>();
var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);
IScriptGenerationInfo info = null;
IScriptOutput actual;
actual = target.Generate(info);
}