Пример #1
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");
        }
Пример #2
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");
        }
Пример #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 GivenBundleDescriptorFile_WhenFindFiles_ThenAssetIsNotCreatedForTheDescriptorFile()
        {
            var search = new FileSearch();
            CreateDirectory("test");
            CreateFile("test", "bundle.txt");
            CreateFile("test", "module.txt"); // Legacy support - module.txt synonymous to bundle.txt

            var files = search.FindFiles(directory.GetDirectory("test"));

            files.ShouldBeEmpty();
        }
Пример #5
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" });
        }
Пример #6
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);
        }
Пример #7
0
        public void GivenFilePatternForJSandCoffeeScriptUsingCommaSeparator_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");
        }
Пример #8
0
        public void Configure(BundleCollection bundles, CassetteSettings settings)
        {
            // TODO: Configure your bundles here...
            // Please read http://getcassette.net/documentation/configuration

            var cssSearch = new FileSearch
            {
                Pattern = "*.css",
                SearchOption = SearchOption.TopDirectoryOnly
            };

            var jsSearch = new FileSearch
            {
                Pattern = "*.js",
                SearchOption = SearchOption.TopDirectoryOnly
            };

            // This default configuration treats each file as a separate 'bundle'.
            // In production the content will be minified, but the files are not combined.
            // So you probably want to tweak these defaults!
            bundles.Add<StylesheetBundle>("Public/CSS", cssSearch);

            bundles.Add<ScriptBundle>("Public/JavaScript/External", jsSearch);
            bundles.Add<ScriptBundle>("Public/JavaScript", jsSearch);

            //jasmine tests, yes they're in this main project for a reason, so tests can run in the same context as the web app
            //helps wih a few XSS issues in particular for file upload tests
            bundles.Add<ScriptBundle>("Private/Specs/try1");

            // To combine files, try something like this instead:
            //   bundles.Add<StylesheetBundle>("Content");
            // In production mode, all of ~/Content will be combined into a single bundle.

            // If you want a bundle per folder, try this:
            //   bundles.AddPerSubDirectory<ScriptBundle>("Scripts");
            // Each immediate sub-directory of ~/Scripts will be combined into its own bundle.
            // This is useful when there are lots of scripts for different areas of the website.

            // *** TOP TIP: Delete all ".min.js" files now ***
            // Cassette minifies scripts for you. So those files are never used.
        }
Пример #9
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);
        }
Пример #10
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");
        }
Пример #11
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");
        }
Пример #12
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);
        }
Пример #13
0