Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
Add RedisBatchTests
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 29, 2015
1 parent e5ad8f5 commit 288b09d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/ServiceStack.Redis.Tests/RedisBatchTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Linq;
using NUnit.Framework;
using ServiceStack.Text;

namespace ServiceStack.Redis.Tests
{
[TestFixture]
public class RedisBatchTests
: RedisClientTestsBase
{
public class Message
{
public long Id { get; set; }
public string Key { get; set; }
public string Value { get; set; }
public string Description { get; set; }
}

[Test]
public void Store_batch_items_in_List()
{
var redisMessages = Redis.As<Message>();
const int batchSize = 500;
var nextIds = redisMessages.GetNextSequence(batchSize);

var msgBatch = batchSize.Times(i =>
new Message {
Id = nextIds - (batchSize - i) + 1,
Key = i.ToString(),
Value = Guid.NewGuid().ToString(),
Description = "Description"
});

redisMessages.Lists["listName"].AddRange(msgBatch);

var msgs = redisMessages.Lists["listName"].GetAll();
Assert.That(msgs.Count, Is.EqualTo(batchSize));

Assert.That(msgs.First().Id, Is.EqualTo(1));
Assert.That(msgs.Last().Id, Is.EqualTo(500));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<Compile Include="ConfigTests.cs" />
<Compile Include="CustomCommandTests.cs" />
<Compile Include="Issues\RedisCharacterizationTests.cs" />
<Compile Include="RedisBatchTests.cs" />
<Compile Include="RedisManagerPoolTests.cs" />
<Compile Include="DiagnosticTests.cs" />
<Compile Include="Examples\ServiceStack_Redis_UseCase.cs" />
Expand Down

0 comments on commit 288b09d

Please sign in to comment.