From c6e6b29905d1d831986c15142347f03d6c6de4dd Mon Sep 17 00:00:00 2001 From: Mathias Beaulieu-Duncan Date: Wed, 8 Oct 2025 11:35:23 -0400 Subject: [PATCH] refactor Country to CountryCode to better reflect the value it contain --- .../Abstractions/IAddress.cs | 2 +- Svrnty.GeoManagement.Abstractions/Models/Address.cs | 4 ++-- .../ServiceCollectionExtensions.cs | 12 ++++++------ .../Mapping/GoogleAddressMapper.cs | 2 +- Svrnty.GeoManagement.Tests/GoogleProviderTests.cs | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Svrnty.GeoManagement.Abstractions/Abstractions/IAddress.cs b/Svrnty.GeoManagement.Abstractions/Abstractions/IAddress.cs index c65e3dd..47c74a4 100644 --- a/Svrnty.GeoManagement.Abstractions/Abstractions/IAddress.cs +++ b/Svrnty.GeoManagement.Abstractions/Abstractions/IAddress.cs @@ -7,5 +7,5 @@ public interface IAddress public string City { get; set; } public string Subdivision { get; set; } public string PostalCode { get; set; } - public string Country { get; set; } + public string CountryCode { get; set; } } \ No newline at end of file diff --git a/Svrnty.GeoManagement.Abstractions/Models/Address.cs b/Svrnty.GeoManagement.Abstractions/Models/Address.cs index c941487..acbbe44 100644 --- a/Svrnty.GeoManagement.Abstractions/Models/Address.cs +++ b/Svrnty.GeoManagement.Abstractions/Models/Address.cs @@ -11,7 +11,7 @@ public record Address(bool Normalized = false) : IAddress public required string City { get; set; } public required string Subdivision { get; set; } public required string PostalCode { get; set; } - public required string Country { get; set; } + public required string CountryCode { get; set; } public GeoPoint? Location { get; set; } public string? Note { get; set; } public bool IsNormalized() => Normalized; @@ -25,7 +25,7 @@ public record Address(bool Normalized = false) : IAddress City = address.City, Subdivision = address.Subdivision, PostalCode = address.PostalCode, - Country = address.Country, + CountryCode = address.CountryCode, Location = location, Note = note, }; diff --git a/Svrnty.GeoManagement.Abstractions/ServiceCollectionExtensions.cs b/Svrnty.GeoManagement.Abstractions/ServiceCollectionExtensions.cs index 18066b8..e5c5dbb 100644 --- a/Svrnty.GeoManagement.Abstractions/ServiceCollectionExtensions.cs +++ b/Svrnty.GeoManagement.Abstractions/ServiceCollectionExtensions.cs @@ -11,7 +11,7 @@ public static class ServiceCollectionExtensions toAddress.Line2 = address.Line2; toAddress.City = address.City; toAddress.PostalCode = address.PostalCode; - toAddress.Country = address.Country; + toAddress.CountryCode = address.CountryCode; toAddress.Subdivision = address.Subdivision; } @@ -21,7 +21,7 @@ public static class ServiceCollectionExtensions address.Line2 = fromAddress.Line2; address.City = fromAddress.City; address.PostalCode = fromAddress.PostalCode; - address.Country = fromAddress.Country; + address.CountryCode = fromAddress.CountryCode; address.Subdivision = fromAddress.Subdivision; } @@ -40,10 +40,10 @@ public static class ServiceCollectionExtensions { if (string.IsNullOrWhiteSpace(address.Line2)) { - return $"{address.Line1}, {address.City}, {address.Subdivision} {address.PostalCode}, {address.Country}"; + return $"{address.Line1}, {address.City}, {address.Subdivision} {address.PostalCode}, {address.CountryCode}"; } - return $"{address.Line2}, {address.Line1}, {address.City}, {address.Subdivision} {address.PostalCode}, {address.Country}"; + return $"{address.Line2}, {address.Line1}, {address.City}, {address.Subdivision} {address.PostalCode}, {address.CountryCode}"; } private static string FormatCompactOneLine(IAddress address) @@ -60,9 +60,9 @@ public static class ServiceCollectionExtensions { if (string.IsNullOrWhiteSpace(address.Line2)) { - return $"{address.Line1}\n{address.City}, {address.Subdivision} {address.PostalCode}\n{address.Country}"; + return $"{address.Line1}\n{address.City}, {address.Subdivision} {address.PostalCode}\n{address.CountryCode}"; } - return $"{address.Line2}, {address.Line1}\n{address.City}, {address.Subdivision} {address.PostalCode}\n{address.Country}"; + return $"{address.Line2}, {address.Line1}\n{address.City}, {address.Subdivision} {address.PostalCode}\n{address.CountryCode}"; } } \ No newline at end of file diff --git a/Svrnty.GeoManagement.Google/Mapping/GoogleAddressMapper.cs b/Svrnty.GeoManagement.Google/Mapping/GoogleAddressMapper.cs index e1aa902..8ae2d84 100644 --- a/Svrnty.GeoManagement.Google/Mapping/GoogleAddressMapper.cs +++ b/Svrnty.GeoManagement.Google/Mapping/GoogleAddressMapper.cs @@ -36,7 +36,7 @@ internal static class GoogleAddressMapper City = city, Subdivision = subdivision, PostalCode = postalCode, - Country = country, + CountryCode = country, Location = location, Note = null }; diff --git a/Svrnty.GeoManagement.Tests/GoogleProviderTests.cs b/Svrnty.GeoManagement.Tests/GoogleProviderTests.cs index 1981126..2e52e3d 100644 --- a/Svrnty.GeoManagement.Tests/GoogleProviderTests.cs +++ b/Svrnty.GeoManagement.Tests/GoogleProviderTests.cs @@ -61,7 +61,7 @@ public class GoogleProviderTests : IDisposable City = _testData.ValidAddress.City, Subdivision = _testData.ValidAddress.Subdivision, PostalCode = _testData.ValidAddress.PostalCode, - Country = _testData.ValidAddress.Country, + CountryCode = _testData.ValidAddress.Country, Location = null, Note = null }; @@ -90,7 +90,7 @@ public class GoogleProviderTests : IDisposable Assert.NotNull(result); Assert.NotNull(result.Line1); Assert.NotNull(result.City); - Assert.NotNull(result.Country); + Assert.NotNull(result.CountryCode); Assert.True(result.IsNormalized()); Assert.NotNull(result.Location); } @@ -106,7 +106,7 @@ public class GoogleProviderTests : IDisposable City = _testData.NormalizeTestAddress.City, Subdivision = _testData.NormalizeTestAddress.Subdivision, PostalCode = _testData.NormalizeTestAddress.PostalCode, - Country = _testData.NormalizeTestAddress.Country, + CountryCode = _testData.NormalizeTestAddress.Country, Location = null, Note = null }; @@ -150,7 +150,7 @@ public class GoogleProviderTests : IDisposable City = _testData.InvalidAddress.City, Subdivision = _testData.InvalidAddress.Subdivision, PostalCode = _testData.InvalidAddress.PostalCode, - Country = _testData.InvalidAddress.Country, + CountryCode = _testData.InvalidAddress.Country, Location = null, Note = null };