diff --git a/src/ServiceStack.Redis/Properties/AssemblyInfo.cs b/src/ServiceStack.Redis/Properties/AssemblyInfo.cs index b7190b12..2ff7c2f9 100644 --- a/src/ServiceStack.Redis/Properties/AssemblyInfo.cs +++ b/src/ServiceStack.Redis/Properties/AssemblyInfo.cs @@ -34,3 +34,5 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("3.9.3.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: InternalsVisibleTo("ServiceStack.Redis.Tests")] diff --git a/src/ServiceStack.Redis/RedisClient_SortedSet.cs b/src/ServiceStack.Redis/RedisClient_SortedSet.cs index f5b762ed..31f02654 100644 --- a/src/ServiceStack.Redis/RedisClient_SortedSet.cs +++ b/src/ServiceStack.Redis/RedisClient_SortedSet.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using ServiceStack.DesignPatterns.Model; using ServiceStack.Redis.Support; @@ -218,7 +219,7 @@ public List GetRangeFromSortedSetDesc(string setId, int fromRank, int to { var key = multiDataList[i].FromUtf8Bytes(); double value; - double.TryParse(multiDataList[i + 1].FromUtf8Bytes(), out value); + double.TryParse(multiDataList[i + 1].FromUtf8Bytes(), NumberStyles.Any, CultureInfo.InvariantCulture, out value); map[key] = value; } diff --git a/src/ServiceStack.Redis/RedisExtensions.cs b/src/ServiceStack.Redis/RedisExtensions.cs index fb2d45e9..6a580266 100644 --- a/src/ServiceStack.Redis/RedisExtensions.cs +++ b/src/ServiceStack.Redis/RedisExtensions.cs @@ -34,7 +34,7 @@ public static List ToRedisEndPoints(this IEnumerable host string[] hostParts; if (host.Contains("@")) { - hostParts = host.Split('@'); + hostParts = host.SplitOnLast('@'); var password = hostParts[0]; hostParts = hostParts[1].Split(':'); endpoint = GetRedisEndPoint(hostParts); diff --git a/tests/ServiceStack.Redis.Tests/RedisClientSortedSetTests.cs b/tests/ServiceStack.Redis.Tests/RedisClientSortedSetTests.cs index 3b75fb63..c2bb0f6b 100644 --- a/tests/ServiceStack.Redis.Tests/RedisClientSortedSetTests.cs +++ b/tests/ServiceStack.Redis.Tests/RedisClientSortedSetTests.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Threading; using NUnit.Framework; using ServiceStack.Common.Extensions; using ServiceStack.Text; @@ -233,6 +235,18 @@ public void Can_IncrementItemInSortedSet() Console.WriteLine(map.Dump()); } + [Test] + public void Can_WorkInSortedSetUnderDifferentCulture() + { + Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("ru-RU"); + Redis.AddItemToSortedSet(SetId, "key", 123.22); + + var map = Redis.GetAllWithScoresFromSortedSet(SetId); + + Assert.AreEqual(123.22, map["key"]); + } + + [Ignore("Not implemented yet")] [Test] public void Can_GetRangeFromSortedSetByHighestScore_from_sorted_set() diff --git a/tests/ServiceStack.Redis.Tests/RedisExtensionTests.cs b/tests/ServiceStack.Redis.Tests/RedisExtensionTests.cs new file mode 100644 index 00000000..11d88924 --- /dev/null +++ b/tests/ServiceStack.Redis.Tests/RedisExtensionTests.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; + +namespace ServiceStack.Redis.Tests +{ + [TestFixture] + public class RedisExtensionTests + { + [Test] + public void Can_Parse_Host() + { + var hosts = new[] {"pass@host.com:6123"}; + var endPoints = hosts.ToRedisEndPoints(); + + Assert.AreEqual(1, endPoints.Count); + var ep = endPoints[0]; + + Assert.AreEqual("host.com", ep.Host); + Assert.AreEqual(6123, ep.Port); + Assert.AreEqual("pass", ep.Password); + } + + [Test] + public void Host_May_Contain_AtChar() + { + var hosts = new[] {"@pa1@ss@localhost:6123"}; + var endPoints = hosts.ToRedisEndPoints(); + + Assert.AreEqual(1, endPoints.Count); + var ep = endPoints[0]; + + Assert.AreEqual("@pa1@ss", ep.Password); + Assert.AreEqual("localhost", ep.Host); + Assert.AreEqual(6123, ep.Port); + } + } +} diff --git a/tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj b/tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj index b7b6718a..f720f80c 100644 --- a/tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj +++ b/tests/ServiceStack.Redis.Tests/ServiceStack.Redis.Tests.csproj @@ -171,6 +171,7 @@ +