public void AddDefinitionIfFound_AddsDefinitionWithVerSupportIfFileFound()
        {
            // Arrange
            var map = new ScriptResourceMapping();
            var sd = new ScriptResourceDefinition
            {
                Path = "~/Scripts/",
                DebugPath = "~/Scripts/",
                CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-{0}.min.js",
                CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-{0}.js",
                CdnSupportsSecureConnection = true
            };
            var vpp = Substitute.For<VirtualPathProvider>();
            var vd = Substitute.For<VirtualDirectory>("~/Scripts/");
            var file = Substitute.For<VirtualFile>("jquery-1.6.2.js");
            file.Name.Returns("jquery-1.6.2.js");
            vd.Files.Returns(new List<VirtualFile> { file });
            vpp.GetDirectory("~/Scripts/").Returns(vd);
            ScriptResourceMappingExtensions.VirtualPathProvider = vpp;

            // Act
            map.AddDefinitionIfFound("jquery", typeof(Page).Assembly, sd,
                @"^jquery-" + ScriptResourceMappingExtensions.VerRegexPattern + @"(?:\.min){0,1}\.js$");

            // Assert
            Assert.IsNotNull(map.GetDefinition("jquery", typeof(Page).Assembly));
        }
示例#2
0
 private static void RegisterScripts(ScriptResourceMapping scriptResourceMapping)
 {
     scriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
     {
         Path = "~/Scripts/jquery-2.0.3.min.js",
         DebugPath = "~/Scripts/jquery-2.0.3.js",
         CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js",
         CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.js",
         CdnSupportsSecureConnection = true,
         LoadSuccessExpression = "window.jQuery"
     });
 }
        public void AddDefinitionIfFound_AddsDefinitionWithNoVerSupportIfFileFound()
        {
            // Arrange
            var map = new ScriptResourceMapping();
            var sd = new ScriptResourceDefinition
            {
                Path = "~/Scripts/"
            };
            var vpp = Substitute.For<VirtualPathProvider>();
            var vd = Substitute.For<VirtualDirectory>("~/Scripts/");
            var file = Substitute.For<VirtualFile>("foo.js");
            file.Name.Returns("foo.js");
            vd.Files.Returns(new List<VirtualFile> { file });
            vpp.GetDirectory("~/Scripts/").Returns(vd);
            ScriptResourceMappingExtensions.VirtualPathProvider = vpp;

            // Act
            map.AddDefinitionIfFound("foo", typeof(Page).Assembly, sd, @"^foo.js$");

            // Assert
            Assert.IsNotNull(map.GetDefinition("foo", typeof(Page).Assembly));
        }
示例#4
0
        public static void RegisterScripts(ScriptResourceMapping mapping)
        {
            // Map jquery definition to the Google CDN
            mapping.AddDefinition("jquery", new ScriptResourceDefinition
            {
                Path = "~/Scripts/jquery-1.7.2.min.js",
                DebugPath = "~/Scripts/jquery-1.7.2.js",
                CdnPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js",
                CdnDebugPath = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js",
                CdnSupportsSecureConnection = true,
                LoadSuccessExpression = "window.jQuery"
            });

            // Map jquery ui definition to the Google CDN
            mapping.AddDefinition("jquery.ui.combined", new ScriptResourceDefinition
            {
                Path = "~/Scripts/jquery-ui-1.8.20.min.js",
                DebugPath = "~/Scripts/jquery-ui-1.8.20.js",
                CdnPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.20/jquery-ui.min.js",
                CdnDebugPath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.20/jquery-ui.js",
                CdnSupportsSecureConnection = true,
                LoadSuccessExpression = "window.jQuery && window.jQuery.ui && window.jQuery.ui.version === '1.8.20'"
            });
        }