public void GivenPatternIsJsAndExcludeVsdocJs_ThenIsMatchVsdocJsFileReturnsFalse() { var fileSearch = new FileSearch { Pattern = "*.js", Exclude = new Regex("-vsdoc.js") }; fileSearch.IsMatch("test-vsdoc.js").ShouldBeFalse(); }
public void GivenDebugAndRegularFiles_WhenFindFiles_ThenOnlyDebugFileIsIncluded() { CreateFile("jquery.debug.js"); CreateFile("jquery.js"); var search = new FileSearch { Pattern = "*.js" }; var files = search.FindFiles(directory); files.Single().FullPath.ShouldEqual("~/jquery.debug.js"); }
public void GivenMinAndNonMinFilesExist_WhenFindFiles_ThenMinFileIgnored() { CreateFile("jquery.js"); CreateFile("jquery.min.js"); var search = new FileSearch { Pattern = "*.js" }; var files = search.FindFiles(directory); files.Single().FullPath.ShouldEqual("~/jquery.js"); }
public void GivenMinAndNonMinScripts_WhenFindFiles_ThenOnlyIncludeNonMinScripts() { CreateFile("jquery.js"); CreateFile("jquery.min.js"); CreateFile("jquery-ui.js"); CreateFile("jquery-ui.min.js"); var search = new FileSearch { Pattern = "*.js" }; var files = search.FindFiles(directory).ToArray(); var names = new HashSet<string>(files.Select(f => f.FullPath)); names.SetEquals(new[] { "~/jquery.js", "~/jquery-ui.js" }); }
public void GivenPatternIsJsAndCoffee_ThenIsMatchCoffeeFilenameReturnsTrue() { var fileSearch = new FileSearch { Pattern = "*.js;*.coffee" }; fileSearch.IsMatch("~/test.coffee").ShouldBeTrue(); }
public void GivenPatternIsAsterisk_ThenIsMatchReturnsTrue() { var fileSearch = new FileSearch { Pattern = "*" }; fileSearch.IsMatch("~/test.js").ShouldBeTrue(); }
public void SetDefaultFileSearchCausesConfigureToRegisterAFileSearchForTheBundleType() { var customFileSearch = new FileSearch(); config.SetDefaultFileSearch<ScriptBundle>(customFileSearch); var container = new TinyIoCContainer(); config.Configure(container); var actualFileSearch = container.Resolve<IFileSearch>(HostBase.FileSearchComponentName(typeof(ScriptBundle))); actualFileSearch.ShouldBeSameAs(customFileSearch); }
public void GivenMinCssAndNonMinCss_WhenFindFiles_ThenOnlyNonMinCssIncluded() { CreateFile("test.min.css"); CreateFile("test.css"); var search = new FileSearch { Pattern = "*.css" }; var files = search.FindFiles(directory); files.Single().FullPath.ShouldEqual("~/test.css"); }
public void GivenBundleDescriptorFile_WhenFindFiles_ThenAssetIsNotCreatedForTheDescriptorFile() { var search = new FileSearch(); CreateDirectory("test"); CreateFile("test", "bundle.txt"); CreateFile("test", "scriptbundle.txt"); CreateFile("test", "stylesheetbundle.txt"); CreateFile("test", "htmltemplatebundle.txt"); var files = search.FindFiles(directory.GetDirectory("test")); files.ShouldBeEmpty(); }
public void GivenSimpleFilePatternAndSomeFiles_WhenFindFiles_ThenAssetCreatedForEachMatchingFile() { var search = new FileSearch { Pattern = "*.js" }; CreateDirectory("test"); CreateFile("test", "asset1.js"); CreateFile("test", "asset2.js"); CreateFile("test", "other.txt"); // this file should be ignored var files = search.FindFiles(directory.GetDirectory("test")) .OrderBy(f => f.FullPath).ToArray(); files[0].FullPath.ShouldEqual("~/test/asset1.js"); files[1].FullPath.ShouldEqual("~/test/asset2.js"); files.Length.ShouldEqual(2); }
public void GivenHtmAndHtmlFilePattern_WhenFindFiles_ThenHtmlFileFoundOnlyOnce() { CreateFile("test.html"); var search = new FileSearch { Pattern = "*.htm;*.html" }; var files = search.FindFiles(directory); files.Count().ShouldEqual(1); }
public void GivenFilePatternIsNotSet_WhenFindFiles_ThenMatchAllFiles() { var search = new FileSearch(); CreateDirectory("test"); CreateFile("test", "asset1.js"); CreateFile("test", "asset2.txt"); var files = search.FindFiles(directory.GetDirectory("test")) .OrderBy(f => f.FullPath).ToArray(); files[0].FullPath.ShouldEqual("~/test/asset1.js"); files[1].FullPath.ShouldEqual("~/test/asset2.txt"); }
public void GivenFilePatternForJSandCoffeeScript_WhenFindFiles_ThenBothTypesOfAssetAreCreated() { var search = new FileSearch { Pattern = "*.js;*.coffee" }; CreateDirectory("test"); CreateFile("test", "asset1.js"); CreateFile("test", "asset2.coffee"); var files = search.FindFiles(directory.GetDirectory("test")) .OrderBy(f => f.FullPath).ToArray(); files[0].FullPath.ShouldEqual("~/test/asset1.js"); files[1].FullPath.ShouldEqual("~/test/asset2.coffee"); }
public void GivenExclude_WhenFindFiles_ThenAssetsNotCreatedForFilesMatchingExclude() { var search = new FileSearch() { Exclude = new Regex("-vsdoc\\.js$"), }; CreateDirectory("test"); CreateFile("test", "asset.js"); CreateFile("test", "asset-vsdoc.js"); var files = search.FindFiles(directory.GetDirectory("test")); files.Count().ShouldEqual(1); }
public void GivenPatternIsJs_ThenIsMatchDifferentlyCasedJsFilenameReturnsTrue() { var fileSearch = new FileSearch { Pattern = "*.js" }; fileSearch.IsMatch("~/TEST.JS").ShouldBeTrue(); }
public void GivenPatternIsJs_ThenIsMatchJsFilenameReturnsTrue() { var fileSearch = new FileSearch { Pattern = "*.js" }; fileSearch.IsMatch("~/test.js").ShouldBeTrue(); }
public void GivenOnlyMinFile_WhenFindFiles_ThenMinFileIsIncluded() { CreateFile("jquery.min.js"); var search = new FileSearch { Pattern = "*.js" }; var files = search.FindFiles(directory); files.Single().FullPath.ShouldEqual("~/jquery.min.js"); }