Ejemplo n.º 1
0
        public void SettingsAreMergedRightToLeft()
        {
            var left = new SparkSettings();
            var right = new SparkSettings();

            right.NullBehaviour = NullBehaviour.Strict;
            right.PageBaseType = "test";
            right.Prefix = "test";
            right.StatementMarker = "T";
            right.AutomaticEncoding = true;
            right.AddResourceMapping("test", "test");
            right.AddAssembly("test");
            right.AddNamespace("test");
            right.AddViewFolder(typeof (int), new Dictionary<string, string>());

            Merger.Merge(left, right);

            left.NullBehaviour.ShouldEqual(right.NullBehaviour);
            left.NullBehaviour.ShouldEqual(right.PageBaseType);
            left.NullBehaviour.ShouldEqual(right.Prefix);
            left.NullBehaviour.ShouldEqual(right.StatementMarker);
            left.NullBehaviour.ShouldEqual(right.AutomaticEncoding);
            left.ResourceMappings.ShouldEqual(right.ResourceMappings);
            left.UseAssemblies.ShouldEqual(right.UseAssemblies);
            left.UseNamespaces.ShouldEqual(right.UseNamespaces);
        }
        public void WhenResourceMappingWithNoStopAttributeThenNextMatchOrDefaultMatchWillBeProcessedWithItOutput()
        {
            var settings = new SparkSettings()
                           .AddResourceMapping("/js", "~/content/js", false);

            var manager = new DefaultResourcePathManager(settings);

            var path = manager.GetResourcePath("/my/webapp", "/js/jquery.1.2.6.js");

            Assert.AreEqual("/my/webapp/content/js/jquery.1.2.6.js", path);

            settings.AddResourceMapping("/ftpmirror", "/ftp/mymyrror.com", false);
            settings.AddResourceMapping("/ftp/", "ftp://");

            var path2 = manager.GetResourcePath("/my/webapp", "/ftpmirror/1.zip");

            Assert.AreEqual("ftp://mymyrror.com/1.zip", path2);
        }
        public void WhenResourceMappingWithNoStopAttributeThenNextMatchOrDefaultMatchWillBeProcessedWithItOutput()
        {
            var settings = new SparkSettings()
                .AddResourceMapping("/js", "~/content/js", false);

            var manager = new DefaultResourcePathManager(settings);

            var path = manager.GetResourcePath("/my/webapp", "/js/jquery.1.2.6.js");
            Assert.AreEqual("/my/webapp/content/js/jquery.1.2.6.js", path);

            settings.AddResourceMapping("/ftpmirror", "/ftp/mymyrror.com", false);
            settings.AddResourceMapping("/ftp/", "ftp://");

            var path2 = manager.GetResourcePath("/my/webapp", "/ftpmirror/1.zip");
            Assert.AreEqual("ftp://mymyrror.com/1.zip", path2);
        }