Skip to content

Commit 2da28e7

Browse files
committed
Merge branch 'hotfix/3.7.2'
2 parents c6be927 + 671e880 commit 2da28e7

10 files changed

Lines changed: 72 additions & 18 deletions

File tree

src/Patterns.Testing/Configuration/TestConfigurationSource.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using System.Xml.Linq;
2828

2929
using Patterns.Configuration;
30+
using Patterns.Text.RegularExpressions;
3031

3132
namespace Patterns.Testing.Configuration
3233
{
@@ -37,6 +38,7 @@ namespace Patterns.Testing.Configuration
3738
public class TestConfigurationSource : IConfigurationSource
3839
{
3940
private readonly XContainer _configXml;
41+
private readonly CompiledRegex _sectionNamePattern = "[^/]+$";
4042

4143
/// <summary>
4244
/// Initializes a new instance of the <see cref="TestConfigurationSource" /> class.
@@ -149,11 +151,11 @@ public IConfiguration OpenExeConfiguration(ConfigurationUserLevel userLevel)
149151
throw new NotSupportedException();
150152
}
151153

152-
private static ConfigurationSection DeserializeSection(XContainer xml, string name)
154+
private ConfigurationSection DeserializeSection(XContainer xml, string name)
153155
{
154156
XElement sectionDefinition = xml.Element("configSections")
155-
.Elements("section")
156-
.FirstOrDefault(section => section.Attribute("name").Value == name);
157+
.Descendants("section")
158+
.FirstOrDefault(section => section.Attribute("name").Value == _sectionNamePattern.Match(name).Value);
157159

158160
if (sectionDefinition == null) return null;
159161

@@ -182,7 +184,7 @@ private static ConfigurationSection DeserializeSection(XContainer xml, string na
182184
var config = new TSection();
183185
const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
184186
MethodInfo deserializer = typeof (TSection).GetMethod("DeserializeSection", flags);
185-
XElement sectionXml = xml.Element(name);
187+
var sectionXml = name.Split('/').Aggregate(xml, (current, part) => current.Element(part));
186188
if (sectionXml == null) return null;
187189

188190
try

src/Patterns/SolutionAssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
[assembly: AssemblyCulture("")]
3232
[assembly: ComVisible(false)]
3333
[assembly: NeutralResourcesLanguage("en-US")]
34-
[assembly: AssemblyVersion("3.7.1")]
34+
[assembly: AssemblyVersion("3.7.2")]

src/Patterns/SolutionAssemblyInfo.settings.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Settings.Initialize(
33
majorNumber: 3,
44
minorNumber: 7,
5-
patchNumber: 1,
5+
patchNumber: 2,
66
buildNumber: null,
77
buildLevel: BuildLevels.None
88
);

src/_specs/Features/Testing/Configuration/TestConfigSource.feature

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
I want to be able to inject my dependencies for configuration using test values
44
So that I can test my component logic using various configuration scenarios
55

6-
Scenario: GetSection (normal)
7-
Given I have a new Configuration Source using the canned config called "TestConfig1"
8-
When I ask for a Configuration Section named "settings" from the Configuration Source
9-
Then the Configuration Section I retrieved from the Configuration Source should be the expected section
6+
Scenario Outline: GetSection (normal)
7+
Given I have a new Configuration Source using the canned config called "<config>"
8+
When I ask for a Configuration Section named "<name>" from the Configuration Source
9+
Then the Configuration Section I retrieved from the Configuration Source should be the expected section
10+
Examples:
11+
| config | name |
12+
| TestConfig1 | settings |
13+
| TestConfig2 | test/settings |

src/_specs/Features/Testing/Configuration/TestConfigSource.feature.cs

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/_specs/Properties/Resources.Designer.cs

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/_specs/Properties/Resources.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
</data>
132132
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
133133
<data name="TestConfig1" type="System.Resources.ResXFileRef, System.Windows.Forms">
134-
<value>..\Resources\TestConfig1.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
134+
<value>..\Resources\TestConfig1.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;iso-8859-1</value>
135+
</data>
136+
<data name="TestConfig2" type="System.Resources.ResXFileRef, System.Windows.Forms">
137+
<value>..\Resources\TestConfig2.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
135138
</data>
136139
</root>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<section name="settings" type="Patterns.Specifications.Models.Configuration.TestConfigurationSection, _specs"/>
5+
<sectionGroup name="test">
6+
<section name="settings" type="Patterns.Specifications.Models.Configuration.TestConfigurationSection, _specs" />
7+
</sectionGroup>
8+
</configSections>
9+
<settings />
10+
<test>
11+
<settings />
12+
</test>
13+
</configuration>

src/_specs/Steps/Configuration/ConfigSourceSteps.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public void CreateSourceUsingMockedAbstraction()
6464
}
6565

6666
[Given(@"I have a new Configuration Source using the canned config called ""(.*)""")]
67-
public void CreateSourceUsingCannedConfig(string sectionName)
67+
public void CreateSourceUsingCannedConfig(string configName)
6868
{
69-
_context.ConfigSource = new TestConfigurationSource(XElement.Parse(_resources.GetString(sectionName)));
69+
_context.ConfigSource = new TestConfigurationSource(XElement.Parse(_resources.GetString(configName)));
7070
}
7171

7272
[When(@"I ask for a Configuration Section named ""(.*)"" from the Configuration Source")]

src/_specs/_specs.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@
303303
<ItemGroup>
304304
<Folder Include="Services\" />
305305
</ItemGroup>
306+
<ItemGroup>
307+
<None Include="Resources\TestConfig2.xml" />
308+
</ItemGroup>
306309
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
307310
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
308311
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

0 commit comments

Comments
 (0)