public void TestFindAllFilesOnlyDirectorySearchOk(string relFilePath, params string[] expectedFiles)
        {
            //SETUP
            var searcher = new RelPathSearcher(B4BSetupHelper.GetActualFilePathFromVirtualPath());

            //ATTEMPT
            var foundFiles = searcher.FindAllFiles(relFilePath);

            //VERIFY
            CollectionAssert.AreEqual(expectedFiles, foundFiles);
        }
Ejemplo n.º 2
0
        public void TestBundlerForBowerFormStaticFileWithCacheBusterOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.FormStaticFileWithCacheBuster("url:js/myfile.js", "12345");

            //VERIFY
            output.ShouldEqual("url:js/myfile.js?v=12345");
        }
Ejemplo n.º 3
0
        public void CheckGetChecksumFromRelPathOk()
        {
            //SETUP
            var          func    = B4BSetupHelper.GetChecksumFromRelPath();
            const string relPath = "Scripts\\Script1.js";

            //ATTEMPT
            var path = func("~/" + relPath);

            //VERIFY
            path.ShouldEqual("fJjHT45pis5EogBORiyWYn5UIa0PBrrnusR2zVSlRL8");
        }
Ejemplo n.º 4
0
        public void TestBundlerForBowerJsNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("appLibsJs", CssOrJs.Js, false, s => "url:" + s.Substring(2));

            //VERIFY
            output.ShouldEqual("<script src='url:js/appLibsJs.min.js?v=SnW8SeyCxQMkwmWggnI6zdSJoIVYPkVYHyM4jpW3jaQ'></script>");
        }
        public void TestBundlerForBowerJsNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("appLibsJs", CssOrJs.Js, false, s => "url:" + s.Substring(2));

            //VERIFY
            output.ShouldEqual("<script src=\"url:wwwroot/js/appLibsJs.min.js\" asp-append-version=\"true\"></script>");
        }
        public void CheckGetActualFilePathFromVirtualPathFileOk()
        {
            //SETUP
            var          func    = B4BSetupHelper.GetActualFilePathFromVirtualPath();
            const string relPath = "Scripts\\Script1.js";

            //ATTEMPT
            var path = func("~/" + relPath);

            //VERIFY
            path.ShouldEqual(TestFileHelpers.GetTestFileFilePath(relPath));
        }
        public void TestBundlerForBowerCssNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("mainCss", CssOrJs.Css, false, s => "url:" + s.Substring(2));

            //VERIFY
            output.ShouldEqual("<link href=\"url:wwwroot/css/mainCss.min.css\" asp-append-version=\"true\" rel=\"stylesheet\"/>");
        }
        public void CheckGetActualFilePathFromVirtualPathDirOk()
        {
            //SETUP
            var          func    = B4BSetupHelper.GetActualFilePathFromVirtualPath();
            const string relPath = "Scripts\\";

            //ATTEMPT
            var path = func("~/" + relPath);

            //VERIFY
            path.ShouldEqual(Path.Combine(TestFileHelpers.GetTestDataFileDirectory(), relPath));
        }
Ejemplo n.º 9
0
        public void TestBundlerForBowerCssNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("mainCss", CssOrJs.Css, false, s => "url:" + s.Substring(2));

            //VERIFY
            output.ShouldEqual("<link href='url:css/mainCss.min.css?v=TdTxYoaXjmCw1qNZ3ECkVr0eMx3rj6OFikZ6GH_a_Hw' rel='stylesheet'/>");
        }
Ejemplo n.º 10
0
        public void TestBundlerForBowerCreateOk()
        {
            //SETUP

            //ATTEMPT
            using (new TimerToConsole("create BundlerForBower"))
            {
                var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                              B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());
            }

            //VERIFY
        }
        public void TestFindAllFilesBadDirSearchOk(string relFilePath, string expectedMessage)
        {
            //SETUP
            var    searcher     = new RelPathSearcher(B4BSetupHelper.GetActualFilePathFromVirtualPath());
            string errorMessage = null;

            //ATTEMPT
            var foundFiles = searcher.FindAllFiles(relFilePath, s => errorMessage = s);

            //VERIFY
            foundFiles.Count().ShouldEqual(0);
            errorMessage.ShouldEqual(expectedMessage);
        }
        public void TestBundlerForBowerFormStaticFileWithCacheBusterOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var ex = Assert.Throws <NotImplementedException>(() => b4b.FormStaticFileWithCacheBuster("js/myfile.js", "12345"));

            //VERIFY
            ex.Message.ShouldEqual("The BundlerForBower config file does not support adding a cachebuster." +
                                   "It is likely that you have local tags to do that.");
        }
Ejemplo n.º 13
0
        public void TestBundlerForBowerCssDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            using (new TimerToConsole("CalculateHtmlIncludes Debug"))
            {
                var output = b4b.CalculateHtmlIncludes("mainCss", CssOrJs.Css, true, s => "url:" + s.Substring(2));
            }

            //VERIFY
        }
        public void TestBundlerForBowerWithCdnCssDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("bootstrapCdnCss", CssOrJs.Css, true, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(1);
            lines[0].ShouldEqual("<link href='url:lib/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet'/>\r");
        }
        public void TestBundlerForBowerWithCdnCssNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("bootstrapCdnCss", CssOrJs.Css, false, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(1);
            lines[0].ShouldEqual("<link rel=\"stylesheet\" href='https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css' asp-fallback-href='url:wwwroot/css/css/bootstrap.min.css' asp-fallback-test-class=\"sr-only\" asp-fallback-test-property=\"position\" asp-fallback-test-value=\"absolute\" />\r");
        }
Ejemplo n.º 16
0
        public void TestBundlerForBowerWithCdnJsNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("WithCdn\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("standardLibsCdnJs", CssOrJs.Js, false, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(2);
            lines[0].ShouldEqual("<script src='https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js'></script><script>(window.jQuery||document.write(\"\\x3Cscript src='url:js/jquery.min.js?v=SnW8SeyCxQMkwmWggnI6zdSJoIVYPkVYHyM4jpW3jaQ'\\x3C/script>\"));</script>\r");
            lines[1].ShouldEqual("<script src='https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js'></script><script>(window.jQuery && window.jQuery.fn && window.jQuery.fn.modal||document.write(\"\\x3Cscript src='url:js/bootstrap.min.js?v=SnW8SeyCxQMkwmWggnI6zdSJoIVYPkVYHyM4jpW3jaQ'\\x3C/script>\"));</script>\r");
        }
Ejemplo n.º 17
0
        public void TestBundlerForBowerCssDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("mainCss", CssOrJs.Css, true, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(2);
            lines[0].ShouldEqual("<link href='url:Content/bootstrap.css' rel='stylesheet'/>\r");
            lines[1].ShouldEqual("<link href='url:Content/site.css' rel='stylesheet'/>\r");
        }
        public void TestBundlerForBowerWithCdnJsDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("standardLibsCndJs", CssOrJs.Js, true, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(2);
            lines[0].ShouldEqual("<script src='url:lib/jquery/dist/jquery.js'></script>\r");
            lines[1].ShouldEqual("<script src='url:lib/bootstrap/js/bootstrap.js'></script>\r");
        }
        public void TestBundlerForBowerWithCdnJsNonDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("ASPNET Core 1 Config\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), null);

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("standardLibsCndJs", CssOrJs.Js, false, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(2);
            lines[0].ShouldEqual("<script src='https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js' asp-fallback-src='url:wwwroot/js/jquery.min.js' asp-fallback-test='window.jQuery'></script>\r");
            lines[1].ShouldEqual("<script src='https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js' asp-fallback-src='url:wwwroot/js/bootstrap.min.js' asp-fallback-test='window.jQuery && window.jQuery.fn && window.jQuery.fn.modal'></script>\r");
        }
Ejemplo n.º 20
0
        public void TestBundlerForBowerJsDebugOk()
        {
            //SETUP
            var b4b = new BundlerForBower(B4BSetupHelper.GetDirRelToTestDirectory("NoConfig\\"),
                                          B4BSetupHelper.GetActualFilePathFromVirtualPath(), B4BSetupHelper.GetChecksumFromRelPath());

            //ATTEMPT
            var output = b4b.CalculateHtmlIncludes("appLibsJs", CssOrJs.Js, true, s => "url:" + s.Substring(2));

            //VERIFY
            var lines = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            lines.Length.ShouldEqual(3);
            lines[0].ShouldEqual("<script src='url:Scripts/Script1.js'></script>\r");
            lines[1].ShouldEqual("<script src='url:Scripts/Script2.js'></script>\r");
            lines[2].ShouldEqual("<script src='url:Scripts/Script3.js'></script>\r");
        }
        public void TestCheckSingleBundleIsValidBadCndBadCndCssNotSupportedOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("BadCndCssNotSupported");

            //VERIFY
            errors.Count.ShouldEqual(1);
            errors.First().ShouldEqual("This configuration of BundlerForBower does not support CDN bundles for .css files. Bad bundle is BadCndCssNotSupported.");
        }
        public void TestCheckSingleBundleIsValidBadCndContaintsSearchTestOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("BadCndContaintsSearchTest");

            //VERIFY
            errors.Count.ShouldEqual(2);
            errors.First().ShouldEqual("The following files had 'development' with search strings in the bundles called 'BadCndContaintsSearchTest':\n - lib/jquery/dist/*jquery.js");
            errors.Last().ShouldEqual("The following files had 'production' with search strings in the bundles called 'BadCndContaintsSearchTest':\n - lib/jquery/dist/*jquery.js");
        }
        public void TestCheckSingleBundleIsValidBadCndContainsMixOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("BadCndContainsMix");

            //VERIFY
            errors.Count.ShouldEqual(1);
            errors.First().ShouldEqual("The Bundle called BadCndContainsMix contained both cdn and non cdn entries, which is not supported.");
        }
        public void TestCheckSingleBundleIsValidMissingDevProdOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("BadCndMissingDev");

            //VERIFY
            errors.Count.ShouldEqual(1);
            errors.First().ShouldEqual("The CDN bundle BadCndMissingDev, array element 0, is missing a property called 'development'.");
        }
        public void TestCheckSingleBundleIsValidBadCndMissingCdnSuccessTestOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("BadCndMissingCdnSuccessTest");

            //VERIFY
            errors.Count.ShouldEqual(1);
            errors.First().ShouldEqual("In the bundle called BadCndMissingCdnSuccessTest, array element 0, the following properties were missing: cdnSuccessTest");
        }
        public void TestCheckSingleBundleIsValidBadCndCdnBadFormatOk()
        {
            //SETUP
            var checker = new CheckBundles(TestFileHelpers.GetTestDataFileDirectory(), B4BSetupHelper.GetDirRelToTestDirectory("BadBowerBundlesFormat\\"));

            //ATTEMPT
            var errors = checker.CheckSingleBundleIsValid("CdnBadFormat");

            //VERIFY
            errors.Count.ShouldEqual(2);
            errors.First().ShouldEqual("The CDN bundle CdnBadFormat, array element 0, contained an invalid type Integer");
            errors.Last().ShouldEqual("The CDN bundle CdnBadFormat, array element 1, contained an invalid type Boolean");
        }