本文整理汇总了C#中Cassette.Scripts.ScriptBundle.AddReference方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptBundle.AddReference方法的具体用法?C# ScriptBundle.AddReference怎么用?C# ScriptBundle.AddReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cassette.Scripts.ScriptBundle
的用法示例。
在下文中一共展示了ScriptBundle.AddReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenExternalModuleReferencedTwice_ThenContainerOnlyHasTheExternalModuleOnce
public void WhenExternalModuleReferencedTwice_ThenContainerOnlyHasTheExternalModuleOnce()
{
var urlModifier = Mock.Of<IUrlModifier>();
var externalBundle = new ExternalScriptBundle("http://external.com/api.js") { Processor = Mock.Of<IBundleProcessor<ScriptBundle>>() };
var bundle1 = new ScriptBundle("~/test1") { Processor = Mock.Of<IBundleProcessor<ScriptBundle>>() };
bundle1.Renderer = new ConstantHtmlRenderer<ScriptBundle>("", urlModifier);
bundle1.AddReference("http://external.com/api.js");
var bundle2 = new ScriptBundle("~/test2") { Processor = Mock.Of<IBundleProcessor<ScriptBundle>>() };
bundle2.Renderer = new ConstantHtmlRenderer<ScriptBundle>("", urlModifier);
bundle2.AddReference("http://external.com/api.js");
var bundles = new[] { bundle1, bundle2 };
var factory = new Mock<IBundleFactory<Bundle>>();
factory.Setup(f => f.CreateBundle("http://external.com/api.js", It.IsAny<IEnumerable<IFile>>(), It.IsAny<BundleDescriptor>()))
.Returns(externalBundle);
Settings.BundleFactories[typeof(ScriptBundle)] = factory.Object;
var builder = CreateFactory(bundles);
var container = builder.CreateBundleContainer();
container.Bundles.Count().ShouldEqual(3);
}