当前位置: 首页>>代码示例>>C#>>正文


C# TestableBundle.AddReference方法代码示例

本文整理汇总了C#中TestableBundle.AddReference方法的典型用法代码示例。如果您正苦于以下问题:C# TestableBundle.AddReference方法的具体用法?C# TestableBundle.AddReference怎么用?C# TestableBundle.AddReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestableBundle的用法示例。


在下文中一共展示了TestableBundle.AddReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GivenAssetWithUrlReferenceAndSameBundleLevelUrlReference_WhenCreate_ThenExternalBundleInContainer

        public void GivenAssetWithUrlReferenceAndSameBundleLevelUrlReference_WhenCreate_ThenExternalBundleInContainer()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.References)
                 .Returns(new[] { new AssetReference("http://test.com/", asset.Object, -1, AssetReferenceType.Url) });
            asset.Setup(a => a.OpenStream()).Returns(Stream.Null);

            var externalBundle = new TestableBundle("http://test.com/");
            var factory = new Mock<IBundleFactory<Bundle>>();
            factory.Setup(f => f.CreateBundle("http://test.com/", It.IsAny<IEnumerable<IFile>>(), It.IsAny<BundleDescriptor>()))
                   .Returns(externalBundle);
            Settings.BundleFactories[typeof(TestableBundle)] = factory.Object;
            var containerFactory = CreateFactory();

            var bundle = new TestableBundle("~/test");
            bundle.AddReference("http://test.com/");
            bundle.Assets.Add(asset.Object);
            var container = containerFactory.Create(new[] { bundle });

            container.FindBundlesContainingPath("http://test.com/").First().ShouldBeSameAs(externalBundle);
        }
开发者ID:ChrisMH,项目名称:cassette,代码行数:21,代码来源:BundleContainerFactoryTestSuite.cs

示例2: GivenBundleWithAdHocUrlReference_WhenCreate_ThenExternalBundleIsCreatedAndProcessed

        public void GivenBundleWithAdHocUrlReference_WhenCreate_ThenExternalBundleIsCreatedAndProcessed()
        {
            var externalBundle = new TestableBundle("http://test.com/");
            var factory = new Mock<IBundleFactory<Bundle>>();
            factory.Setup(f => f.CreateBundle("http://test.com/", It.IsAny<IEnumerable<IFile>>(), It.IsAny<BundleDescriptor>()))
                   .Returns(externalBundle);
            var factories = new Dictionary<Type, IBundleFactory<Bundle>>();
            factories[typeof(TestableBundle)] = factory.Object;
            var containerFactory = CreateFactory(factories);

            var bundle = new TestableBundle("~/test");
            bundle.AddReference("http://test.com/");
            var settings = CreateSettings();

            containerFactory.Create(new[] { bundle }, settings);

            externalBundle.WasProcessed.ShouldBeTrue();
        }
开发者ID:JamesTryand,项目名称:cassette,代码行数:18,代码来源:BundleContainerFactoryTestSuite.cs

示例3: WhenExternalModuleReferencedTwice_ThenContainerOnlyHasTheExternalModuleOnce

        public void WhenExternalModuleReferencedTwice_ThenContainerOnlyHasTheExternalModuleOnce()
        {
            var externalBundle = new TestableBundle("http://external.com/api.js");
            var bundle1 = new TestableBundle("~/test1");
            bundle1.AddReference("http://external.com/api.js");
            var bundle2 = new TestableBundle("~/test2");
            bundle2.AddReference("http://external.com/api.js");
            var bundles = new[] { bundle1, bundle2 };

            var factories = new Dictionary<Type, IBundleFactory<Bundle>>();
            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);
            factories[typeof(TestableBundle)] = factory.Object;

            var builder = CreateFactory(factories);
            var container = builder.Create(bundles, CreateSettings());

            container.Bundles.Count().ShouldEqual(3);
        }
开发者ID:JamesTryand,项目名称:cassette,代码行数:20,代码来源:BundleContainerFactoryTestSuite.cs

示例4: WhenCreateWithBundleHavingExternalReference_ThenAnExternalBundleIsAlsoAddedToContainer

        public void WhenCreateWithBundleHavingExternalReference_ThenAnExternalBundleIsAlsoAddedToContainer()
        {
            var externalBundle = new TestableBundle("http://external.com/api.js");
            var bundle = new TestableBundle("~/test");
            bundle.AddReference("http://external.com/api.js");

            var factories = new Dictionary<Type, IBundleFactory<Bundle>>();
            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);
            factories[typeof(TestableBundle)] = factory.Object;

            var builder = CreateFactory(factories);
            var container = builder.Create(new[] { bundle }, CreateSettings());

            container.FindBundlesContainingPath("http://external.com/api.js").First().ShouldBeSameAs(externalBundle);
        }
开发者ID:JamesTryand,项目名称:cassette,代码行数:17,代码来源:BundleContainerFactoryTestSuite.cs

示例5: GivenBundleWithReference_WhenSaveContainer_ThenXmlHasReferenceElement

        public void GivenBundleWithReference_WhenSaveContainer_ThenXmlHasReferenceElement()
        {
            using (var cacheDir = new TempDirectory())
            {
                var settings = new CassetteSettings
                {
                    SourceDirectory = Mock.Of<IDirectory>(),
                    CacheDirectory = new FileSystemDirectory(cacheDir)
                };
                var cache = new BundleCache("VERSION", settings);
                var bundle = new TestableBundle("~/test");
                bundle.AddReference("~/other");

                cache.SaveBundleContainer(new BundleContainer(new[] { bundle, new TestableBundle("~/other")  }));

                var xml = File.ReadAllText(Path.Combine(cacheDir, "container.xml"));
                xml.ShouldContain("<Reference Path=\"~/other\"");
            }
        }
开发者ID:prasanths,项目名称:cassette,代码行数:19,代码来源:BundleCache.cs


注:本文中的TestableBundle.AddReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。