public void ChainTransformsTest() { Bundle bundle = new Bundle("~/ignored", new AppendTransform("H"), new AppendTransform("a"), new AppendTransform("o")); BundleContext context = new BundleContext(); List <BundleFile> files = new List <BundleFile>(); BundleResponse response = bundle.ApplyTransforms(context, "", files); Assert.AreEqual("Hao", response.Content); }
public void BundlePublicArgumentNullChecks() { Bundle bundle = new Bundle("~/whatever"); ExceptionHelper.ExpectArgumentNullException(() => bundle.EnumerateFiles(null), "context"); ExceptionHelper.ExpectArgumentNullException(() => bundle.CacheLookup(null), "context"); ExceptionHelper.ExpectArgumentNullException(() => bundle.UpdateCache(null, null), "context"); ExceptionHelper.ExpectArgumentNullException(() => bundle.UpdateCache(new BundleContext(), null), "response"); ExceptionHelper.ExpectArgumentNullException(() => bundle.GenerateBundleResponse(null), "context"); ExceptionHelper.ExpectArgumentNullException(() => bundle.GetCacheKey(null), "context"); ExceptionHelper.ExpectArgumentNullException(() => bundle.ApplyTransforms(null, "", null), "context"); }
public void EmptyTransformsListUsesNoTransformTest() { Bundle b = new Bundle("~/foo"); BundleContext context = new BundleContext(); List <BundleFile> files = new List <BundleFile>(); files.Add(new BundleFile("~/foo.js", new MyVirtualFile("foo.js"))); BundleResponse response = b.ApplyTransforms(context, null, files); Assert.AreEqual(null, response.Content); Assert.AreEqual(JsMinify.JsContentType, response.ContentType); }
private BundleResponse GetSingleFileBundleResponse(Bundle bundle, BundleContext bundleContext, string filepath) { var files = bundle.EnumerateFiles(bundleContext); var file = files.FirstOrDefault(f => f.VirtualFile.VirtualPath.TrimStart(new[] { '/' }) == filepath); if (file == null) { throw new FileNotFoundException(string.Format("File not found '{0}'", filepath)); } string contents; var virtualPathProvider = HostingEnvironment.VirtualPathProvider; var virtualFile = virtualPathProvider.GetFile(VirtualPathUtility.ToAppRelative(file.VirtualFile.VirtualPath)); using (var streamReader = new StreamReader(virtualFile.Open())) { contents = streamReader.ReadToEnd(); } return bundle.ApplyTransforms(bundleContext, contents, new List<BundleFile> { file }); }
private BundleResponse GetSingleFileBundleResponse(Bundle bundle, BundleContext bundleContext, string filepath) { var files = bundle.EnumerateFiles(bundleContext); var file = files.FirstOrDefault(f => f.VirtualFile.VirtualPath.TrimStart(new[] { '/' }) == filepath); if (file == null) { throw new FileNotFoundException(string.Format("File not found '{0}'", filepath)); } string contents; var virtualPathProvider = HostingEnvironment.VirtualPathProvider; var virtualFile = virtualPathProvider.GetFile(VirtualPathUtility.ToAppRelative(file.VirtualFile.VirtualPath)); using (var streamReader = new StreamReader(virtualFile.Open())) { contents = streamReader.ReadToEnd(); } return(bundle.ApplyTransforms(bundleContext, contents, new List <BundleFile> { file })); }