From 92ef22bd587b85f03ea01f79ebc545b1f2ba6480 Mon Sep 17 00:00:00 2001 From: Dave Reed Date: Mon, 31 Jan 2011 12:47:10 -0800 Subject: [PATCH] #17217: Exception thrown if a theme includes a static resource with the same name as a static resource in its BaseTheme (and varies by case) --HG-- branch : dev --- .../StylesheetBindingStrategyTests.cs | 16 ++++++++++++++-- .../StylesheetBindingStrategy.cs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Tests/DisplayManagement/Descriptors/StylesheetBindingStrategyTests.cs b/src/Orchard.Tests/DisplayManagement/Descriptors/StylesheetBindingStrategyTests.cs index fa10824a2..03bcfe58b 100644 --- a/src/Orchard.Tests/DisplayManagement/Descriptors/StylesheetBindingStrategyTests.cs +++ b/src/Orchard.Tests/DisplayManagement/Descriptors/StylesheetBindingStrategyTests.cs @@ -25,7 +25,7 @@ namespace Orchard.Tests.DisplayManagement.Descriptors { protected override void Register(Autofac.ContainerBuilder builder) { _descriptor = new ShellDescriptor { }; _testViewEngine = new TestViewEngine(); - _testVirtualPathProvider = new TestVirtualPathProvider(); + _testVirtualPathProvider = new TestVirtualPathProvider { TestViewEngine = _testViewEngine }; builder.Register(ctx => _descriptor); builder.RegisterType().As(); @@ -44,6 +44,8 @@ namespace Orchard.Tests.DisplayManagement.Descriptors { } public class TestVirtualPathProvider : IVirtualPathProvider { + public TestViewEngine TestViewEngine { get; set; } + public string Combine(params string[] paths) { throw new NotImplementedException(); } @@ -89,7 +91,7 @@ namespace Orchard.Tests.DisplayManagement.Descriptors { } public IEnumerable ListFiles(string path) { - return new List {"~/Modules/Alpha/Styles/AlphaStyle.css"}; + return TestViewEngine.Keys.Select(o => o.ToString()); } public IEnumerable ListDirectories(string path) { @@ -129,6 +131,7 @@ namespace Orchard.Tests.DisplayManagement.Descriptors { AddEnabledFeature("Alpha"); _testViewEngine.Add("~/Modules/Alpha/Styles/AlphaShape.css", null); + _testViewEngine.Add("~/Modules/Alpha/Styles/alpha-shape.css", null); var strategy = _container.Resolve(); IList alterationBuilders = new List(); @@ -137,6 +140,15 @@ namespace Orchard.Tests.DisplayManagement.Descriptors { var alterations = alterationBuilders.Select(alterationBuilder=>alterationBuilder.Build()); Assert.That(alterations.Any(alteration => alteration.ShapeType == "Style")); + + var descriptor = new ShapeDescriptor { ShapeType = "Style" }; + alterations.Aggregate(descriptor, (d, alteration) => { + alteration.Alter(d); + return d; + }); + + var keys = descriptor.Bindings.Select(b => b.Key); + Assert.That(keys.Count() == keys.Select(k => k.ToLowerInvariant()).Distinct().Count(), "Descriptors should never vary by case only."); } } diff --git a/src/Orchard/DisplayManagement/Descriptors/ResourceBindingStrategy/StylesheetBindingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ResourceBindingStrategy/StylesheetBindingStrategy.cs index 910364b13..7ed76f709 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ResourceBindingStrategy/StylesheetBindingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ResourceBindingStrategy/StylesheetBindingStrategy.cs @@ -27,7 +27,7 @@ namespace Orchard.DisplayManagement.Descriptors.ResourceBindingStrategy { private static string SafeName(string name) { if (string.IsNullOrWhiteSpace(name)) return String.Empty; - return _safeName.Replace(name, String.Empty); + return _safeName.Replace(name, String.Empty).ToLowerInvariant(); } public static string GetAlternateShapeNameFromFileName(string fileName) {