public void DebugPreferredWithOptimizationsDisabledTest()
        {
            //Setup the vpp to contain the files/directories
            TestVirtualPathProvider vpp = new TestVirtualPathProvider();
            var directory = new TestVirtualPathProvider.TestVirtualDirectory("/");
            var files     = new TestVirtualPathProvider.TestVirtualFile[] {
                new TestVirtualPathProvider.TestVirtualFile("/jquery.js", "jquery"),
                new TestVirtualPathProvider.TestVirtualFile("/jquery.debug.js", "jquery.debug")
            };

            foreach (var file in files)
            {
                directory.DirectoryFiles.Add(file);
                vpp.AddFile(file);
            }
            vpp.AddDirectory(directory);

            // Setup the bundle
            ScriptBundle bundle = new ScriptBundle("~/bundles/test");

            bundle.Items.VirtualPathProvider = vpp;
            bundle.Include("~/jquery.js");

            // Verify the bundle repsonse
            BundleContext context = BundleTest.SetupContext(bundle, vpp);

            context.EnableOptimizations = false;
            BundleResponse response = bundle.GetBundleResponse(context);

            Assert.AreEqual(@"jquery.debug", response.Content);
        }
        public void MinJsPreferredWithOptimizationsEnabledTest()
        {
            //Setup the vpp to contain the files/directories
            TestVirtualPathProvider vpp = new TestVirtualPathProvider();
            var directory     = new TestVirtualPathProvider.TestVirtualDirectory("/");
            var jqueryFile    = new TestVirtualPathProvider.TestVirtualFile("/jquery.js", "jquery");
            var jqueryMinFile = new TestVirtualPathProvider.TestVirtualFile("/jquery.min.js", "jquery.min");

            directory.DirectoryFiles.Add(jqueryFile);
            directory.DirectoryFiles.Add(jqueryMinFile);
            vpp.AddDirectory(directory);
            vpp.AddFile(jqueryFile);
            vpp.AddFile(jqueryMinFile);

            // Setup the bundle
            ScriptBundle bundle = new ScriptBundle("~/bundles/test");

            bundle.Items.VirtualPathProvider = vpp;
            bundle.Include("~/jquery.js");

            // Verify the bundle repsonse
            BundleContext context = BundleTest.SetupContext(bundle, vpp);

            context.EnableOptimizations = true;
            BundleResponse response = bundle.GetBundleResponse(context);

            Assert.AreEqual(@"jquery.min", response.Content);
        }
        public void StyleBundleCustomVPPIncludeVersionSelectsTest()
        {
            //Setup the vpp to contain the files/directories
            TestVirtualPathProvider vpp = new TestVirtualPathProvider();
            var directory = new TestVirtualPathProvider.TestVirtualDirectory("/dir/");

            directory.DirectoryFiles.Add(new TestVirtualPathProvider.TestVirtualFile("/dir/style1.0.css", "correct"));
            directory.DirectoryFiles.Add(new TestVirtualPathProvider.TestVirtualFile("/dir/style.css", "wrong"));
            vpp.AddDirectory(directory);

            // Setup the bundle
            ScriptBundle bundle = new ScriptBundle("~/bundles/test");

            bundle.Items.VirtualPathProvider = vpp;
            bundle.Include("~/dir/style{version}.css");

            // Verify the bundle repsonse
            BundleContext  context  = SetupContext(bundle, vpp);
            BundleResponse response = bundle.GetBundleResponse(context);

            Assert.AreEqual(@"correct", response.Content);
        }
        public void ScriptBundleCustomVPPIncludeAllJsTest()
        {
            //Setup the vpp to contain the files/directories
            TestVirtualPathProvider vpp = new TestVirtualPathProvider();
            var directory = new TestVirtualPathProvider.TestVirtualDirectory("/dir/");

            directory.DirectoryFiles.Add(new TestVirtualPathProvider.TestVirtualFile("/dir/1.js", "alert('1')"));
            directory.DirectoryFiles.Add(new TestVirtualPathProvider.TestVirtualFile("/dir/2.js", "alert('2')"));
            vpp.AddDirectory(directory);

            // Setup the bundle
            ScriptBundle bundle = new ScriptBundle("~/bundles/test");

            bundle.Items.VirtualPathProvider = vpp;
            bundle.Include("~/dir/*.js");

            // Verify the bundle repsonse
            BundleContext  context  = SetupContext(bundle, vpp);
            BundleResponse response = bundle.GetBundleResponse(context);

            Assert.AreEqual(@"alert(""1"");alert(""2"")", response.Content);
        }