Exemplo n.º 1
0
        public void FromRoute_NotFound(string routeToAdd, string routeToCheck)
        {
            var pipeline = new AssetPipeline();

            pipeline.AddBundle(routeToAdd, "text/css", "file.css");

            Assert.False(pipeline.TryGetAssetFromRoute(routeToCheck, out var a1), routeToCheck);
        }
Exemplo n.º 2
0
        public void FromRoute_MixedSlashes_Success(string routeToAdd, string routeToCheck)
        {
            var pipeline = new AssetPipeline();

            pipeline.AddBundle(routeToAdd, "text/css", "file.css");

            Assert.True(pipeline.TryGetAssetFromRoute(routeToCheck, out var a1), routeToCheck);
        }
Exemplo n.º 3
0
        public void AddBundleWithGlobRoute_Throws()
        {
            var    pipeline = new AssetPipeline();
            string route    = "/*.css";
            var    ex       = Assert.Throws <ArgumentException>(() => pipeline.AddBundle(route, "text/css", new[] { "source.css" }));

            Assert.Equal("route", ex.ParamName);
            Assert.Equal(0, pipeline.Assets.Count);
        }
Exemplo n.º 4
0
        public void AddBundle_Success(string inputRoute, string normalizedRoute)
        {
            var asset    = new Asset(inputRoute, "text/css", new[] { "file.css" });
            var pipeline = new AssetPipeline();

            pipeline.AddBundle(asset);

            Assert.Equal(normalizedRoute, pipeline.Assets.First().Route);
        }
Exemplo n.º 5
0
        public void AddZeroSourceFilesToBundle_Fail()
        {
            var env = new HostingEnvironment {
                EnvironmentName = "Development"
            };
            IAsset asset    = new Asset("/file.css", "text/css", new string[0]);
            var    pipeline = new AssetPipeline();

            Assert.Throws <ArgumentException>(() => pipeline.AddBundle(asset));
        }
Exemplo n.º 6
0
        public void AddSingeAsset_Success()
        {
            var env = new HostingEnvironment {
                EnvironmentName = "Development"
            };
            var asset    = new Asset("/route", "text/css", new[] { "file.css" });
            var pipeline = new AssetPipeline();

            pipeline.AddBundle(asset);

            Assert.Equal(1, pipeline.Assets.Count);
        }
Exemplo n.º 7
0
        public void AddTwoAsset_Succes()
        {
            var env = new HostingEnvironment {
                EnvironmentName = "Development"
            };
            var asset1   = new Asset("/route1", "text/css", new[] { "file.css" });
            var asset2   = new Asset("/route2", "text/css", new[] { "file.css" });
            var pipeline = new AssetPipeline();

            pipeline.AddBundle(new[] { asset1, asset2 });

            Assert.Equal(2, pipeline.Assets.Count);
        }
Exemplo n.º 8
0
        public void AddTwoSameRoutes_Throws()
        {
            var env = new HostingEnvironment {
                EnvironmentName = "Development"
            };
            var asset1   = new Asset("/route", "text/css", new[] { "file.css" });
            var asset2   = new Asset("/route", "text/css", new[] { "file.css" });
            var pipeline = new AssetPipeline();

            var ex = Assert.Throws <ArgumentException>(() => pipeline.AddBundle(new[] { asset1, asset2 }));

            Assert.Equal("route", ex.ParamName);
            Assert.Equal(1, pipeline.Assets.Count);
        }
Exemplo n.º 9
0
        public void AddConcatinate_Assets_Success()
        {
            var env = new HostingEnvironment {
                EnvironmentName = "Development"
            };
            var asset1   = new Asset("/file1", "text/css", new[] { "file.css" });
            var asset2   = new Asset("/file2", "text/css", new[] { "file.css" });
            var pipeline = new AssetPipeline();
            var assets   = pipeline.AddBundle(new[] { asset1, asset2 });

            assets = assets.Concatenate();

            Assert.Equal(2, assets.Count());

            foreach (var asset in assets)
            {
                Assert.Equal(1, asset.Processors.Count);
                Assert.True(asset.Processors.First() is Concatenator);
            }
        }