public void find_policies_for_an_asset_file_should_return_all_matching_transforms_for_that_mimetype_but_excluding_the_globals() { var assetFile = new AssetFile("script.tr1.coffee.js"); assetFile.MimeType.ShouldEqual(MimeType.Javascript); theLibrary.FindPoliciesFor(assetFile).ShouldHaveTheSameElementsAs(js2, js1); }
public void find_policies_for_an_asset_file_should_return_all_matching_transforms_for_that_mimetype_but_excluding_the_globals_2() { var assetFile = new AssetFile("main.less.css"); assetFile.MimeType.ShouldEqual(MimeType.Css); theLibrary.FindPoliciesFor(assetFile).ShouldHaveTheSameElementsAs(less, css1); }
public void SetUp() { _theFileGraph = new AssetFileGraph(); _theFile = new AssetFile("a.js"); _thePath = new AssetPath("pak1", "a.js", AssetFolder.scripts); _theFileGraph.AddFile(_thePath, _theFile); }
public void find_policies_for_an_asset_file_does_NOT_include_any_globals() { var assetFile = new AssetFile("script.coffee.js"); assetFile.MimeType.ShouldEqual(MimeType.Javascript); theLibrary.FindPoliciesFor(assetFile).ShouldNotContain(globalJS); }
public void only_group_by_the_same_folder() { var files = new AssetFile[]{ new AssetFile("a.css"), new AssetFile("b.css"), new AssetFile("f1/c.css"), new AssetFile("f1/d.css"), new AssetFile("e.css"), new AssetFile("f2/f.css"), new AssetFile("f2/g.css") }; var plan = new AssetTagPlan(MimeType.Css, files); var policy = new CombineAllStylesheets(); var combos = policy.DetermineCombinations(plan); combos.Count().ShouldEqual(3); combos.ElementAt(0).Files.Select(x => x.Name).ShouldHaveTheSameElementsAs("a.css", "b.css"); combos.ElementAt(1).Files.Select(x => x.Name).ShouldHaveTheSameElementsAs("f1/c.css", "f1/d.css"); combos.ElementAt(1).ShouldBeOfType<StyleFileCombination>().Name.ShouldStartWith("f1/"); combos.ElementAt(2).Files.Select(x => x.Name).ShouldHaveTheSameElementsAs("f2/f.css", "f2/g.css"); combos.ElementAt(2).ShouldBeOfType<StyleFileCombination>().Name.ShouldStartWith("f2/"); }
public Specification(AssetFile file) { _fullname = new Lazy<string>(() => Parent.FullName + "/" + _libraryName); File = file; string fileContentFolder = file.ContentFolder(); if (fileContentFolder == null || fileContentFolder == "specs") { _contentFolder = null; } else { var list = fileContentFolder.Split('/').ToList(); list.Remove("specs"); _contentFolder = list.Join("/"); } _libraryName = file.LibraryName(); var libraryParts = _libraryName.Split('.').ToList(); var index = libraryParts.IndexOf("spec"); if (index > -1) { _subject = libraryParts.Take(index).Join("."); } else { _subject = libraryParts.Where(x => !_ignoredExtensions.Contains("." + x)).Join("."); } }
public void files_are_just_the_one_file() { var file = new AssetFile("something.js"); var source = new FileRead(file); source.Files.Single().ShouldBeTheSameAs(file); }
public void no_inner_content_sources() { var file = new AssetFile("something.js"); var source = new FileRead(file); source.InnerSources.Any().ShouldBeFalse(); }
public void Changed(AssetFile file) { _logger.InfoMessage(() => new AssetFileChangeDetected{ Name = file.Name, Fullpath = file.FullPath }); _cache.Changed(file); }
public void AddFile(AssetPath path, AssetFile file) { if (!path.Folder.HasValue) { throw new ArgumentException("AssetPath must have an AssetType to be used here"); } _files[path.Folder.Value].Add(file); }
public static IContentSource InitialSourceForAssetFile(AssetFile file) { if (file.FullPath.IsNotEmpty()) { return new FileRead(file); } throw new ArgumentOutOfRangeException("Don't know how to determine a content source for an AssetFile without a FullPath (yet)"); }
public void CreateAssetFile(string filename) { var name = filename.PathRelativeTo(_specificDirectory).Replace(Path.DirectorySeparatorChar, '/'); var path = new AssetPath(_directory.PackageName, name, _assetFolder); var file = new AssetFile(name){ FullPath = filename.ToFullPath() }; _registration.AddFile(path, file); }
public void determine_mimetype_positive() { var scriptFile = new AssetFile("script.js"); var cssFile = new AssetFile("main.css"); scriptFile.MimeType.ShouldEqual(MimeType.Javascript); cssFile.MimeType.ShouldEqual(MimeType.Css); }
public void InitialSourceForAssetFile_needs_to_throw_out_of_range_exception_if_there_is_no_full_path_for_the_asset_for_now() { var assetFile = new AssetFile("something.js"); assetFile.FullPath.IsEmpty(); Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() => { ContentPlan.InitialSourceForAssetFile(assetFile); }); }
public void determine_asset_url_simple() { var file = new AssetFile("jquery.forms.js") { Folder = AssetFolder.scripts }; UrlRegistry.DetermineRelativeAssetUrl(file) .ShouldEqual("_content/scripts/jquery.forms.js"); }
public void determine_asset_url_simple() { var file = new AssetFile("jquery.forms.js") { Folder = AssetFolder.scripts }; AssetContentHandler.DetermineAssetUrl(file) .ShouldEqual("http://myapp.com/_content/scripts/jquery.forms.js"); }
public void determine_asset_url_complex() { var file = new AssetFile("shared/jquery.forms.js") { Folder = AssetFolder.scripts }; AssetUrls.DetermineRelativeAssetUrl(file) .ShouldEqual("_content/scripts/shared/jquery.forms.js"); }
public IEnumerable<ITransformerPolicy> FindPoliciesFor(AssetFile file) { var mimeType = file.MimeType; var policies = _policies .Where(x => x.MimeType == mimeType && x.ActionType != ActionType.Global && x.AppliesTo(file)) .ToList(); policies.Sort(new TransformerComparer(file)); return policies; }
public void applies_to_negative_on_all() { var policy = new TransformerPolicy(ActionType.Transformation, MimeType.Javascript, typeof(StubTransformer)); policy.AddExtension(".coffee"); var file = new AssetFile("script.js"); policy.AppliesTo(file).ShouldBeFalse(); }
public void adding_a_file_by_path_sets_the_folder_on_the_file() { // This is important for later var theFile = new AssetFile("a.js"); var thePath = new AssetPath("pak1", "a.js", AssetFolder.styles); _theFileGraph.AddFile(thePath, theFile); theFile.Folder.ShouldEqual(thePath.Folder); }
public void constructor_sets_up_the_default_content_sources_for_each_file() { var files = new AssetFile[]{ new AssetFile("something.js"){FullPath = "something.js"}, new AssetFile("something2.js"){FullPath = "something2.js"}, new AssetFile("something3.js"){FullPath = "something3.js"}, new AssetFile("something4.js"){FullPath = "something4.js"}, }; var plan = new ContentPlan("a plan", files); plan.GetAllSources().ShouldHaveTheSameElementsAs(files.Select(x => new FileRead(x))); }
public void read_content() { var context = MockRepository.GenerateMock<IContentPipeline>(); var file = new AssetFile("something.js"){ FullPath = "some/path" }; var theContents = "some contents"; context.Stub(x => x.ReadContentsFrom(file.FullPath)).Return(theContents); var source = new FileRead(file); source.GetContent(context).ShouldEqual(theContents); }
public void find_for_file_initially() { var files = new AssetFile[]{ new AssetFile("something.js"){FullPath = "something.js"}, new AssetFile("something2.js"){FullPath = "something2.js"}, new AssetFile("something3.js"){FullPath = "something3.js"}, new AssetFile("something4.js"){FullPath = "something4.js"}, }; var plan = new ContentPlan("a plan", files); files.Each(f => { plan.FindForFile(f).ShouldBeOfType<FileRead>().Files.Single().ShouldBeTheSameAs(f); }); }
public void SetUp() { file1 = new AssetFile("1"); file2 = new AssetFile("2"); file3 = new AssetFile("3"); file4 = new AssetFile("4"); file5 = new AssetFile("5"); file6 = new AssetFile("6"); theOutputCache = MockRepository.GenerateMock<IOutputCache>(); headersCache = MockRepository.GenerateMock<IHeadersCache>(); theCache = new AssetContentCache(headersCache, theOutputCache); theGraph = BehaviorGraph.BuildFrom(new FubuRegistry()); }
public void figure_out_mime_type_after_ctor() { var jsFile = new AssetFile("something.js"){ FullPath = "something.js" }; new ContentPlan("something", new AssetFile[]{ jsFile }).MimeType.ShouldEqual(MimeType.Javascript); var cssFile = new AssetFile("something.css"){ FullPath = "something.css" }; new ContentPlan("something", new AssetFile[]{ cssFile }).MimeType.ShouldEqual(MimeType.Css); }
private IEnumerable<AssetFile> writeBinary(AssetPath asset, Action<IEnumerable<AssetFile>> writeHeaders) { var file = _fileGraph.Find(asset); if (file == null) { return Enumerable.Empty<AssetFile>(); } var files = new AssetFile[] { file }; writeHeaders(files); _writer.WriteFile(file.MimeType, file.FullPath, null); return files; }
public void apply_to_an_asset_tag_plan_simple_condition_of_all_files() { var files = new AssetFile[]{ new AssetFile("a.js"), new AssetFile("b.js"), new AssetFile("c.js"), new AssetFile("d.js") }; var plan = new AssetTagPlan(MimeType.Javascript, files); var policy = new CombineAllScriptFiles(); var combo = policy.DetermineCombinations(plan).Single(); combo.Files.ShouldHaveTheSameElementsAs(files); }
//key=type/name private void LoadAsset(string line) { if (line.Trim().IsEmpty()) return; var parts = line.Split('='); var key = parts.First(); var stringPath = parts.Last(); var @override = stringPath.EndsWith("!override"); if (@override) { stringPath = stringPath.Replace("!override", ""); } var path = new AssetPath(stringPath); var file = new AssetFile(path.Name){ Override = @override }; _files[key] = file; _callback(path, file); }
public bool Equals(AssetFile other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other.Folder.Equals(Folder) && Equals(other.Name, Name) && Equals(other.FullPath, FullPath); }
public void SetUp() { file1 = new AssetFile("1"); file2 = new AssetFile("2"); file3 = new AssetFile("3"); file4 = new AssetFile("4"); file5 = new AssetFile("5"); file6 = new AssetFile("6"); theCache = new AssetContentCache(); theGraph = new FubuRegistry().BuildGraph(); }
public AssetPath AssetPathOf(AssetFile file) { var package = _allPackages.First(x => x.AllFiles().Contains(file)); return(new AssetPath(package.PackageName, file.Name, file.Folder)); }