Skip to content

Commit

Permalink
set the culture to be used
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Dec 24, 2020
1 parent 4fea071 commit 0b151ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions DragonFruit.Common.Data.Tests/RequestDataCompilationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Linq;
using DragonFruit.Common.Data.Parameters;
using DragonFruit.Common.Data.Utils;
using NUnit.Framework;

namespace DragonFruit.Common.Data.Tests
Expand All @@ -29,10 +30,11 @@ public void TestQueries()
[TestCase]
public void TestEnumHandling()
{
var query = new TestRequest().FullUrl.Split('?').Last().Split('&');
var request = new TestRequest();
var query = request.FullUrl.Split('?').Last().Split('&');

Assert.IsTrue(query.Contains($"enum={nameof(EnumValues.Red)}"));
Assert.IsTrue(query.Contains($"enum={nameof(EnumValues.Blue).ToLower()}"));
Assert.IsTrue(query.Contains($"enum={nameof(EnumValues.Blue).ToLower(CultureUtils.DefaultCulture)}"));
Assert.IsTrue(query.Contains($"enum={(int)EnumValues.Green}"));
}
}
Expand Down
2 changes: 1 addition & 1 deletion DragonFruit.Common.Data/Utils/ParameterUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal static IEnumerable<KeyValuePair<string, string>> GetParameter<T>(object
yield return attribute.EnumHandling.Value switch
{
EnumHandlingMode.Numeric => ((int)propertyValue).ToKeyValuePair(keyName, culture),
EnumHandlingMode.StringLower => propertyValue.ToString().ToLower().ToKeyValuePair(keyName, culture),
EnumHandlingMode.StringLower => propertyValue.ToString().ToLower(culture).ToKeyValuePair(keyName, culture),

// default includes string handling
_ => propertyValue.ToKeyValuePair(keyName, culture)
Expand Down

0 comments on commit 0b151ba

Please sign in to comment.