Skip to content

Commit

Permalink
Revert breaking change, expose dictionary via internal interface. Bre…
Browse files Browse the repository at this point in the history
…aking change will be postponed until v4.
  • Loading branch information
skwasjer committed Jul 24, 2019
1 parent 5364406 commit 8593bae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/IbanNet/IbanValidator.cs
Expand Up @@ -58,7 +58,13 @@ public IbanValidator(Lazy<IReadOnlyCollection<CountryInfo>> registry)
/// <summary>
/// Gets the supported countries.
/// </summary>
public IReadOnlyDictionary<string, CountryInfo> SupportedCountries
// TODO: v4, change to dictionary for faster lookup.
public IEnumerable<CountryInfo> SupportedCountries => ((ICountryValidationSupport)this).SupportedCountries.Values;

/// <summary>
/// Gets the supported countries.
/// </summary>
IReadOnlyDictionary<string, CountryInfo> ICountryValidationSupport.SupportedCountries
{
get
{
Expand Down
10 changes: 9 additions & 1 deletion test/IbanNet.Tests/IbanValidatorTests.cs
Expand Up @@ -181,10 +181,18 @@ public void When_validating_good_iban_should_validate(string countryCode, string
actual.Should().BeEquivalentTo(expectedResult);
}

[Test]
public void When_getting_supported_countries_should_match_default_registry()
{
_validator.SupportedCountries
.Should()
.BeEquivalentTo(new IbanRegistry());
}

[Test]
public void When_casting_readonly_countries_dictionary_should_not_be_able_to_add()
{
var countries = (IDictionary<string, CountryInfo>)_validator.SupportedCountries;
var countries = (IDictionary<string, CountryInfo>)((ICountryValidationSupport)_validator).SupportedCountries;

// Act
Action act = () => countries.Add("key", new CountryInfo());
Expand Down

0 comments on commit 8593bae

Please sign in to comment.