本文整理汇总了C#中ScriptManager.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptManager.Add方法的具体用法?C# ScriptManager.Add怎么用?C# ScriptManager.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptManager
的用法示例。
在下文中一共展示了ScriptManager.Add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTest_1
public void AddTest_1()
{
string temp;
ScriptManager sm = new ScriptManager();
bool result = sm.Add("text", true, out temp);
Assert.IsNotNull(temp);
Assert.IsFalse(result);
}
示例2: AddTest_3
public void AddTest_3()
{
string temp;
ScriptManager sm = new ScriptManager();
bool result = sm.Add(_incorrectCode, true, out temp);
Assert.AreNotEqual(temp, "");
Assert.IsFalse(result);
}
示例3: ScriptManager_Add_Null_Throws_Exception_Test
public void ScriptManager_Add_Null_Throws_Exception_Test()
{
var cacheManager = new Mock<ICacheManager>();
var contextAccessor = new Mock<IHttpContextAccessor>();
var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);
ScriptInfo info = null;
target.Add(info);
}
示例4: AddTest_4
public void AddTest_4()
{
string temp;
ScriptManager sm = new ScriptManager();
File.WriteAllText("AddTest_4.cs", _correctCode);
bool result = sm.Add("AddTest_4.cs", true, out temp);
File.Delete("AddTest_4.cs");
Assert.AreEqual(temp, "");
Assert.IsTrue(result);
}
示例5: AddScriptSource
public static MvcHtmlString AddScriptSource(this HtmlHelper helper, Func<dynamic, HelperResult> source, string key, string area = null)
{
var scriptType = ScriptType.JavaScript;
var info = new ScriptInfo(source(null).ToHtmlString(), scriptType, key, area);
var manager = new ScriptManager();
manager.Add(info);
return MvcHtmlString.Empty;
}
示例6: AddJavaScript
public static MvcHtmlString AddJavaScript(this HtmlHelper helper, string localPath, string area = null)
{
var scriptType = ScriptType.JavaScript;
var info = new ScriptInfo(localPath, helper.ViewContext.HttpContext.Server.MapPath(localPath).Replace(@"/", @"\"), scriptType, area);
var manager = new ScriptManager();
manager.Add(info);
return MvcHtmlString.Empty;
}
示例7: ScriptManager_Add_External_StyleSheet_ScriptInfo_Test
public void ScriptManager_Add_External_StyleSheet_ScriptInfo_Test()
{
var cacheManager = new Mock<ICacheManager>();
var contextAccessor = new Mock<IHttpContextAccessor>();
var list = new Mock<IScriptFileList>();
var context = new Mock<HttpContextBase>
{
DefaultValue = DefaultValue.Mock
};
contextAccessor.Setup(c => c.Current()).Returns(context.Object);
context.SetupGet(c => c.Application["__sm__Stylesheet"]).Returns(() => list.Object);
var target = new ScriptManager(cacheManager.Object, contextAccessor.Object);
IScriptInfo info = new ScriptInfo(null, "SomeLocalPath", ScriptType.Stylesheet);
target.Add(info);
list.Verify(l => l.Add(info), Times.Once());
}
示例8: ExecuteTest
public void ExecuteTest()
{
string temp;
ScriptManager sm = new ScriptManager();
File.WriteAllText("RemoveTest_2.cs", _correctCode);
bool result = sm.Add("RemoveTest_2.cs", true, out temp);
File.Delete("RemoveTest_2.cs");
try
{
sm.Execute();
}
catch (Exception ex)
{
Assert.Fail("Expected no exception, but got: " + ex.Message);
}
}
示例9: RemoveTest_2
public void RemoveTest_2()
{
string temp;
ScriptManager sm = new ScriptManager();
File.WriteAllText("RemoveTest_2.cs", _correctCode);
bool result = sm.Add("RemoveTest_2.cs", true, out temp);
result = sm.Remove("RemoveTest_2.cs");
Assert.IsTrue(result);
File.Delete("RemoveTest_2.cs");
}