Пример #1
0
 public void GivenPatternIsJsAndExcludeVsdocJs_ThenIsMatchVsdocJsFileReturnsFalse()
 {
     var fileSearch = new FileSearch
     {
         Pattern = "*.js",
         Exclude = new Regex("-vsdoc.js")
     };
     fileSearch.IsMatch("test-vsdoc.js").ShouldBeFalse();
 }
Пример #2
0
        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");
        }
Пример #3
0
        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");
        }
Пример #4
0
        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" });
        }
Пример #5
0
 public void GivenPatternIsJsAndCoffee_ThenIsMatchCoffeeFilenameReturnsTrue()
 {
     var fileSearch = new FileSearch { Pattern = "*.js;*.coffee" };
     fileSearch.IsMatch("~/test.coffee").ShouldBeTrue();
 }
Пример #6
0
 public void GivenPatternIsAsterisk_ThenIsMatchReturnsTrue()
 {
     var fileSearch = new FileSearch { Pattern = "*" };
     fileSearch.IsMatch("~/test.js").ShouldBeTrue();
 }
Пример #7
0
        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);
        }
Пример #8
0
        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");
        }
Пример #9
0
        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();
        }
Пример #10
0
        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);
        }
Пример #11
0
        public void GivenHtmAndHtmlFilePattern_WhenFindFiles_ThenHtmlFileFoundOnlyOnce()
        {
            CreateFile("test.html");

            var search = new FileSearch { Pattern = "*.htm;*.html" };

            var files = search.FindFiles(directory);
            files.Count().ShouldEqual(1);
        }
Пример #12
0
        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");
        }
Пример #13
0
        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");
        }
Пример #14
0
        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);
        }
Пример #15
0
 public void GivenPatternIsJs_ThenIsMatchDifferentlyCasedJsFilenameReturnsTrue()
 {
     var fileSearch = new FileSearch { Pattern = "*.js" };
     fileSearch.IsMatch("~/TEST.JS").ShouldBeTrue();
 }
Пример #16
0
 public void GivenPatternIsJs_ThenIsMatchJsFilenameReturnsTrue()
 {
     var fileSearch = new FileSearch { Pattern = "*.js" };
     fileSearch.IsMatch("~/test.js").ShouldBeTrue();
 }
Пример #17
0
        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");
        }