Skip to content

Commit

Permalink
Reverts the last commit, moving changes back to the working director…
Browse files Browse the repository at this point in the history
…y without discarding them. This affects the following files, marking them as modified in the working directory:

- README.md: Main project documentation.
- docs/README.md: Additional documentation located in the docs directory.
- sample/CountryData.Sample.Console/Program.cs: Console application sample code demonstrating usage.
- sample/CountryData.Sample.Web.API/Controllers/CountryController.cs: Web API sample controller for country data.
- sample/CountryData.Sample.Web.API/Program.cs: Entry point for the Web API sample application.
- src/CountryData.Standard/CountryHelper.cs: Core library code for country data manipulation.
- test/CountryData.UnitTests/CountryHelperTests.cs: Unit tests for the CountryHelper class.
  • Loading branch information
Clifftech123 committed Jun 29, 2024
1 parent 3a65201 commit c3cf9d6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ The CountryData.Standard library provides a set of methods that allow you to ret
|--------|-------------|
| [`GetCountryData()`](./docs/README.md) | Returns all country data including region, short code, and country name. |
| [`GetCountryByCode(string shortCode)`](./docs/README.md) | Returns a single country's data by its short code. |
| [`GetCountryFlag(string shortCode)`](./docs/README.md) | Gets the flag of the country, represented as an emoji, by the country's short code. |
| [`GetCountryEmojiFlag(string shortCode)`](./docs/README.md) | Gets the flag of the country, represented as an emoji, by the country's short code. |
| [`GetRegionByCountryCode(string ShortCode)`](./docs/README.md) | Selects and returns a list of regions for a particular country identified by its short code. |
| [`GetCountries()`](./docs/README.md) | Gets the list of all country names. |
| [`GetPhoneCodeByCountryShortCode(string shortCode)`](./docs/README.md) | Returns a single country's phone code by its short code. |
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ This method is particularly useful for applications that need to display or anal



### GetCountryFlag (string shortCode)
### GetCountryEmojiFlag (string shortCode)

The `GetCountryFlag ()` method is designed to fetch the flag of a specific country using its ISO 3166-1 alpha-2 code. This method provides a simple and effective way to visually represent countries in your application.
The `GetCountryEmojiFlag ()` method is designed to fetch the flag of a specific country using its ISO 3166-1 alpha-2 code. This method provides a simple and effective way to visually represent countries in your application.

Here's the method signature in C#:

Expand Down
2 changes: 1 addition & 1 deletion sample/CountryData.Sample.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void GetRegionsByCountryCode(string countryCode)
/// <param name="shortCode">The country short code.</param>
static void GetCountryFlag(string shortCode)
{
var flag = _helper.GetCountryFlag(shortCode);
var flag = _helper.GetCountryEmojiFlag(shortCode);
Console.WriteLine($"Flag for {shortCode}:");
Console.WriteLine(flag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
[HttpGet("flag")]
[ProducesResponseType(typeof(string), 200)]
[ProducesResponseType(404)]
public IActionResult GetCountryFlag([FromQuery] string countryCode)
public IActionResult GetCountryEmojiFlag([FromQuery] string countryCode)
{
var flag = _helper.GetCountryFlag(countryCode);
var flag = _helper.GetCountryEmojiFlag(countryCode);
if (flag == null)
{
return NotFound();
Expand Down
12 changes: 3 additions & 9 deletions sample/CountryData.Sample.Web.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
var builder = WebApplication.CreateBuilder(args);

static void NewMethod(WebApplication app)
{
app.Run();
}

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();



// Register CountryHelper service
builder.Services.AddScoped<CountryData.Standard.CountryHelper>();

var app = builder.Build();
Expand All @@ -31,4 +24,5 @@ static void NewMethod(WebApplication app)

app.MapControllers();

NewMethod(app);
// Start the application
app.Run();
4 changes: 2 additions & 2 deletions src/CountryData.Standard/CountryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CountryHelper()
_Countries = JsonConvert.DeserializeObject<List<Country>>(json);
foreach (var country in _Countries)
{
country.CountryFlag = GetCountryFlag(country.CountryShortCode);
country.CountryFlag = GetCountryEmojiFlag(country.CountryShortCode);
}
}

Expand Down Expand Up @@ -67,7 +67,7 @@ public Country GetCountryByCode(string shortCode)
/// </summary>
/// <param name="country"></param>
/// <returns></returns>
public string GetCountryFlag (string shortCode)
public string GetCountryEmojiFlag(string shortCode)
{
return string.Concat(shortCode.ToUpper().Select(x => char.ConvertFromUtf32(x + 0x1F1A5)));
}
Expand Down
2 changes: 1 addition & 1 deletion test/CountryData.UnitTests/CountryHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void GetCountryByCode_WithCorrectCode_ShouldReturnCountry(string shortCod
public void GetCountryFlagByCode_WithCorrectCode_ShouldReturnEmojiFlag(string shortCode)
{
//Act
var countryFlag = _countryHelper.GetCountryFlag(shortCode);
var countryFlag = _countryHelper.GetCountryEmojiFlag(shortCode);

//Assert
countryFlag.Should().NotBeNull();
Expand Down

0 comments on commit c3cf9d6

Please sign in to comment.