-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add overload for AddRange accepting a list of tuples
- Loading branch information
Showing
4 changed files
with
59 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
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
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
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,40 @@ | ||
using NUnit.Framework; | ||
using RocksDb.Extensions.Tests.Utils; | ||
using Shouldly; | ||
|
||
namespace RocksDb.Extensions.Tests; | ||
|
||
public class PutRangeTests | ||
{ | ||
[Test] | ||
public void should_put_range_data_to_store() | ||
{ | ||
// Arrange | ||
using var testFixture = CreateTestFixture<int, string>(); | ||
|
||
var store = testFixture.GetStore<RocksDbGenericStore<int, string>>(); | ||
var cacheKeys = Enumerable.Range(0, 100) | ||
.Select(x => (key: x, value: x.ToString())) | ||
.ToList(); | ||
|
||
// Act | ||
store.PutRange(cacheKeys); | ||
|
||
// Assert | ||
foreach (var (key, expectedValue) in cacheKeys) | ||
{ | ||
store.HasKey(key).ShouldBeTrue(); | ||
store.TryGet(key, out var value).ShouldBeTrue(); | ||
value.ShouldBe(expectedValue); | ||
} | ||
} | ||
|
||
private static TestFixture CreateTestFixture<TKey, TValue>() | ||
{ | ||
var testFixture = TestFixture.Create(rockDb => | ||
{ | ||
_ = rockDb.AddStore<TKey, TValue, RocksDbGenericStore<TKey, TValue>>("my-store"); | ||
}); | ||
return testFixture; | ||
} | ||
} |