diff --git a/src/IbanNet/Registry/IbanRegistry.cs b/src/IbanNet/Registry/IbanRegistry.cs index a5d50f3..7bfd6e3 100644 --- a/src/IbanNet/Registry/IbanRegistry.cs +++ b/src/IbanNet/Registry/IbanRegistry.cs @@ -36,7 +36,10 @@ public IbanRegistry() } /// - public IEnumerator GetEnumerator() => Dictionary.Values.GetEnumerator(); + public IEnumerator GetEnumerator() + { + return Dictionary.Values.OrderBy(c => c.TwoLetterISORegionName).GetEnumerator(); + } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/test/IbanNet.Tests/Registry/IbanRegistryTests.cs b/test/IbanNet.Tests/Registry/IbanRegistryTests.cs index 2670ec5..4e6e077 100644 --- a/test/IbanNet.Tests/Registry/IbanRegistryTests.cs +++ b/test/IbanNet.Tests/Registry/IbanRegistryTests.cs @@ -167,4 +167,16 @@ public void Given_that_registry_has_been_hydrated_when_adding_another_provider_t // Assert sut.Providers.Should().HaveCount(1); } + + [Fact] + public void Registry_should_be_ordered_by_country_code() + { + var reg = new IbanRegistry { Providers = { new SwiftRegistryProvider() } }; + + // Act + var countryCodes = reg.Select(c => c.TwoLetterISORegionName).ToList(); + + // Assert + countryCodes.Should().BeInAscendingOrder(); + } }