This repository has been archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 876
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters