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 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 CustomVPPWithOneFileNoTransformTest() { //Setup the vpp to contain the files/directories TestVirtualPathProvider vpp = new TestVirtualPathProvider(); var file = new TestVirtualPathProvider.TestVirtualFile("/dir/file", "test"); vpp.AddFile(file); // Setup the bundle Bundle bundle = new Bundle("~/bundles/test"); bundle.Items.VirtualPathProvider = vpp; bundle.Include("~/dir/file"); // Verify the bundle repsonse BundleContext context = SetupContext(bundle, vpp); BundleResponse response = bundle.GetBundleResponse(context); Assert.AreEqual("test\r\n", response.Content); }