本文整理汇总了C#中HtmlHelper.EnableQUnitTesting方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.EnableQUnitTesting方法的具体用法?C# HtmlHelper.EnableQUnitTesting怎么用?C# HtmlHelper.EnableQUnitTesting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper.EnableQUnitTesting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnableQUnitEmptyIfNotTestMode
public void EnableQUnitEmptyIfNotTestMode()
{
var httpContext = MockRepository.GenerateStub<HttpContextBase>();
var viewContext = MockRepository.GenerateStub<ViewContext>();
viewContext.HttpContext = httpContext;
viewContext.RequestContext = new RequestContext( httpContext, new RouteData() );
var html = new HtmlHelper( viewContext, new ViewPage() );
Assert.AreEqual( "", html.EnableQUnitTesting() );
}
示例2: EnableQUnitIfTestMode
public void EnableQUnitIfTestMode()
{
var httpContext = MockRepository.GenerateStub<HttpContextBase>();
var viewContext = MockRepository.GenerateStub<ViewContext>();
var httpRequest = MockRepository.GenerateStub<HttpRequestBase>();
httpContext.Stub(c => c.Request).Return(httpRequest).Repeat.Any();
httpRequest.Stub(c => c.ApplicationPath).Return("http://localhost/CometGateway.Server.TelnetDemo");
viewContext.HttpContext = httpContext;
viewContext.RequestContext = new RequestContext( httpContext, new RouteData() );
var viewData = new ViewDataDictionary() {{TestModeConstants.ENABLE_TEST_MODE, true}};
viewContext.ViewData = viewData;
var view = new WebFormView("~/Views/Main/Index.aspx");
viewContext.View = view;
var html = new HtmlHelper( viewContext, new ViewPage() );
html.ViewDataContainer.ViewData = viewData;
const string expectedSnippet =
@"
<link href=""http://localhost/CometGateway.Server.TelnetDemo/Content/QUnit.css"" rel=""stylesheet"" type=""text/css""></link>
<script src=""http://localhost/CometGateway.Server.TelnetDemo/Scripts/qunit.js"" type=""text/javascript""></script>
<script src=""http://localhost/CometGateway.Server.TelnetDemo/Scripts/Views/Main/IndexTest.js"" type=""text/javascript""></script>
<div id='testResults'>
<h1 id='qunit-header'></h1>
<h2 id='qunit-banner'></h2>
<h2 id='qunit-userAgent'></h2>
<ol id='qunit-tests'></ol>
<div id='qunit-fixture'></div>
</div>
<script type='text/javascript'>var testmode = true;</script>
<script type='text/javascript'>
$('body').contents().hide();
$('#testResults').show();
</script>";
TestUtilities.AssertStringsMatch( expectedSnippet, html.EnableQUnitTesting());
}