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 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>");
        }
Пример #3
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");
        }
Пример #4
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'/>");
        }
Пример #5
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 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.");
        }
Пример #7
0
        public void TestBundlerForBowerCreateOk()
        {
            //SETUP

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

            //VERIFY
        }
Пример #8
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 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");
        }
        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 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");
        }
Пример #13
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");
        }
Пример #14
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");
        }
Пример #15
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");
        }
 private static BundlerForBower GetBundlerForBowerCached(HtmlHelper helper)
 {
     return(_bundler ??
            (_bundler = new BundlerForBower(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(),
                                            HostingEnvironment.MapPath, GetChecksumFromRelPath)));
 }