Example #1
0
        public ScriptBundleManifestBuilder_Tests()
        {
            bundle = new ScriptBundle("~/path")
            {
                PageLocation = "body",
                Hash         = new byte[] { 1, 2, 3 },
                Processor    = new ScriptPipeline()
            };
            asset = new StubAsset
            {
                CreateStream = () => new MemoryStream(bundleContent),
                References   =
                {
                    new AssetReference("~/path/asset/file", asset, 0, AssetReferenceType.RawFilename)
                }
            };
            bundle.Assets.Add(asset);
            bundle.AddReference("~/reference/path");
            bundle.Process(new CassetteSettings(""));
            var urlModifier = Mock.Of <IUrlModifier>();

            bundle.Renderer = new ConstantHtmlRenderer <ScriptBundle>("", urlModifier);

            manifest = builder.BuildManifest(bundle);
        }
Example #2
0
        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);
        }
        public ScriptBundleManifestBuilder_Tests()
        {
            bundle = new ScriptBundle("~/path") { PageLocation = "body", Hash = new byte[] { 1, 2, 3 } };
            asset = StubAsset();
            bundle.Assets.Add(asset);
            bundle.AddReference("~/reference/path");
            bundle.Process(new CassetteSettings(""));

            manifest = builder.BuildManifest(bundle);
        }
Example #4
0
        public void GivenBundleAReferencesBundleB_WhenAddReferenceToBundleA_ThenGetBundlesReturnsBoth()
        {
            var bundleA = new ScriptBundle("~/a");
            var bundleB = new ScriptBundle("~/b");

            bundleA.AddReference("~/b");
            AddBundles(bundleA, bundleB);

            builder.Reference("a");

            builder.GetBundles(null).ShouldEqual(new[] { bundleB, bundleA });
        }
        public ScriptBundleManifestBuilder_Tests()
        {
            bundle = new ScriptBundle("~/path")
            {
                PageLocation = "body",
                Hash = new byte[] { 1, 2, 3 },
                Processor = new ScriptPipeline()
            };
            asset = new StubAsset
            {
                CreateStream = () => new MemoryStream(bundleContent),
                References =
                    {
                        new AssetReference("~/path/asset/file", asset, 0, AssetReferenceType.RawFilename)
                    }
            };
            bundle.Assets.Add(asset);
            bundle.AddReference("~/reference/path");
            bundle.Process(new CassetteSettings(""));
            var urlModifier = Mock.Of<IUrlModifier>();
            bundle.Renderer = new ConstantHtmlRenderer<ScriptBundle>("", urlModifier);

            manifest = builder.BuildManifest(bundle);
        }