Skip to content

Commit

Permalink
Merge pull request ServiceStack#66 from desunit/master
Browse files Browse the repository at this point in the history
Fixed issues #63, #24. Added more tests.
  • Loading branch information
mythz committed Aug 4, 2012
2 parents 5eacc50 + 36e0cd2 commit 3fa372b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ServiceStack.Redis/Properties/AssemblyInfo.cs
Expand Up @@ -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")]
3 changes: 2 additions & 1 deletion src/ServiceStack.Redis/RedisClient_SortedSet.cs
Expand Up @@ -12,6 +12,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using ServiceStack.DesignPatterns.Model;
using ServiceStack.Redis.Support;
Expand Down Expand Up @@ -218,7 +219,7 @@ public List<string> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ServiceStack.Redis/RedisExtensions.cs
Expand Up @@ -34,7 +34,7 @@ public static List<RedisEndPoint> ToRedisEndPoints(this IEnumerable<string> host
string[] hostParts;
if (host.Contains("@"))
{
hostParts = host.Split('@');
hostParts = host.SplitOnLast('@');
var password = hostParts[0];
hostParts = hostParts[1].Split(':');
endpoint = GetRedisEndPoint(hostParts);
Expand Down
14 changes: 14 additions & 0 deletions 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;
Expand Down Expand Up @@ -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()
Expand Down
40 changes: 40 additions & 0 deletions 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);
}
}
}
Expand Up @@ -171,6 +171,7 @@
<Compile Include="AlchemyClientTestsBase.cs" />
<Compile Include="AlchemyNativeClientTests.cs" />
<Compile Include="Benchmarks\RedisMqHostPoolBenchmarks.cs" />
<Compile Include="RedisExtensionTests.cs" />
<Compile Include="RedisMqServerSpinServerTests.cs" />
<Compile Include="RedisMqServerSleepServerTests.cs" />
<Compile Include="RedisMqServerTests.cs" />
Expand Down

0 comments on commit 3fa372b

Please sign in to comment.