Commit b591974b authored by Marc Gravell's avatar Marc Gravell

Merge pull request #94 from mwikstrom/master

Key space isolation tests
parents 63e3fdb9 b0301847
using System;
using Moq;
using NUnit.Framework;
using StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public sealed class BatchWrapperTests
{
private Mock<IBatch> mock;
private BatchWrapper wrapper;
[TestFixtureSetUp]
public void Initialize()
{
mock = new Mock<IBatch>();
wrapper = new BatchWrapper(mock.Object, "prefix:");
}
[Test]
public void Execute()
{
wrapper.Execute();
mock.Verify(_ => _.Execute(), Times.Once());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
using Moq;
using NUnit.Framework;
using StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public sealed class DatabaseWrapperTests
{
private Mock<IDatabase> mock;
private DatabaseWrapper wrapper;
[TestFixtureSetUp]
public void Initialize()
{
mock = new Mock<IDatabase>();
wrapper = new DatabaseWrapper(mock.Object, "prefix:");
}
[Test]
public void CreateBatch()
{
object asyncState = new object();
IBatch innerBatch = new Mock<IBatch>().Object;
mock.Setup(_ => _.CreateBatch(asyncState)).Returns(innerBatch);
IBatch wrappedBatch = wrapper.CreateBatch(asyncState);
mock.Verify(_ => _.CreateBatch(asyncState));
Assert.IsInstanceOf<BatchWrapper>(wrappedBatch);
Assert.AreSame(innerBatch, ((BatchWrapper)wrappedBatch).Inner);
}
[Test]
public void CreateTransaction()
{
object asyncState = new object();
ITransaction innerTransaction = new Mock<ITransaction>().Object;
mock.Setup(_ => _.CreateTransaction(asyncState)).Returns(innerTransaction);
ITransaction wrappedTransaction = wrapper.CreateTransaction(asyncState);
mock.Verify(_ => _.CreateTransaction(asyncState));
Assert.IsInstanceOf<TransactionWrapper>(wrappedTransaction);
Assert.AreSame(innerTransaction, ((TransactionWrapper)wrappedTransaction).Inner);
}
[Test]
public void DebugObject()
{
wrapper.DebugObject("key", CommandFlags.HighPriority);
mock.Verify(_ => _.DebugObject("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void get_Database()
{
mock.SetupGet(_ => _.Database).Returns(123);
Assert.AreEqual(123, wrapper.Database);
}
[Test]
public void HashDecrement_1()
{
wrapper.HashDecrement("key", "hashField", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDecrement("prefix:key", "hashField", 123, CommandFlags.HighPriority));
}
[Test]
public void HashDecrement_2()
{
wrapper.HashDecrement("key", "hashField", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDecrement("prefix:key", "hashField", 1.23, CommandFlags.HighPriority));
}
[Test]
public void HashDelete_1()
{
wrapper.HashDelete("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashDelete("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashDelete_2()
{
RedisValue[] hashFields = new RedisValue[0];
wrapper.HashDelete("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDelete("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashExists()
{
wrapper.HashExists("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashExists("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashGet_1()
{
wrapper.HashGet("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashGet("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashGet_2()
{
RedisValue[] hashFields = new RedisValue[0];
wrapper.HashGet("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashGet("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashGetAll()
{
wrapper.HashGetAll("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashGetAll("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashIncrement_1()
{
wrapper.HashIncrement("key", "hashField", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.HashIncrement("prefix:key", "hashField", 123, CommandFlags.HighPriority));
}
[Test]
public void HashIncrement_2()
{
wrapper.HashIncrement("key", "hashField", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.HashIncrement("prefix:key", "hashField", 1.23, CommandFlags.HighPriority));
}
[Test]
public void HashKeys()
{
wrapper.HashKeys("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashKeys("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashLength()
{
wrapper.HashLength("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashLength("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashScan()
{
wrapper.HashScan("key", "pattern", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.HashScan("prefix:key", "pattern", 123, CommandFlags.HighPriority));
}
[Test]
public void HashSet_1()
{
HashEntry[] hashFields = new HashEntry[0];
wrapper.HashSet("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashSet("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashSet_2()
{
wrapper.HashSet("key", "hashField", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.HashSet("prefix:key", "hashField", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void HashValues()
{
wrapper.HashValues("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashValues("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogAdd_1()
{
wrapper.HyperLogLogAdd("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogAdd("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogAdd_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.HyperLogLogAdd("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogAdd("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogLength()
{
wrapper.HyperLogLogLength("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogLength("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogMerge_1()
{
wrapper.HyperLogLogMerge("destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogMerge("prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogMerge_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.HyperLogLogMerge("destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogMerge("prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void IdentifyEndpoint()
{
wrapper.IdentifyEndpoint("key", CommandFlags.HighPriority);
mock.Verify(_ => _.IdentifyEndpoint("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyDelete_1()
{
wrapper.KeyDelete("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDelete("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyDelete_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.KeyDelete(keys, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDelete(It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void KeyDump()
{
wrapper.KeyDump("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDump("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyExists()
{
wrapper.KeyExists("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExists("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyExpire_1()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.KeyExpire("key", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExpire("prefix:key", expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyExpire_2()
{
DateTime expiry = DateTime.Now;
wrapper.KeyExpire("key", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExpire("prefix:key", expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyMigrate()
{
EndPoint toServer = new IPEndPoint(IPAddress.Loopback, 123);
wrapper.KeyMigrate("key", toServer, 123, 456, MigrateOptions.Copy, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyMigrate("prefix:key", toServer, 123, 456, MigrateOptions.Copy, CommandFlags.HighPriority));
}
[Test]
public void KeyMove()
{
wrapper.KeyMove("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyMove("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void KeyPersist()
{
wrapper.KeyPersist("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyPersist("prefix:key", CommandFlags.HighPriority));
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void KeyRandom()
{
wrapper.KeyRandom();
}
[Test]
public void KeyRename()
{
wrapper.KeyRename("key", "newKey", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyRename("prefix:key", "prefix:newKey", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void KeyRestore()
{
Byte[] value = new Byte[0];
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.KeyRestore("key", value, expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyRestore("prefix:key", value, expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyTimeToLive()
{
wrapper.KeyTimeToLive("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyTimeToLive("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyType()
{
wrapper.KeyType("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyType("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListGetByIndex()
{
wrapper.ListGetByIndex("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.ListGetByIndex("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void ListInsertAfter()
{
wrapper.ListInsertAfter("key", "pivot", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListInsertAfter("prefix:key", "pivot", "value", CommandFlags.HighPriority));
}
[Test]
public void ListInsertBefore()
{
wrapper.ListInsertBefore("key", "pivot", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListInsertBefore("prefix:key", "pivot", "value", CommandFlags.HighPriority));
}
[Test]
public void ListLeftPop()
{
wrapper.ListLeftPop("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPop("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListLeftPush_1()
{
wrapper.ListLeftPush("key", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPush("prefix:key", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void ListLeftPush_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.ListLeftPush("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPush("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void ListLength()
{
wrapper.ListLength("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListLength("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListRange()
{
wrapper.ListRange("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRange("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void ListRemove()
{
wrapper.ListRemove("key", "value", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRemove("prefix:key", "value", 123, CommandFlags.HighPriority));
}
[Test]
public void ListRightPop()
{
wrapper.ListRightPop("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPop("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListRightPopLeftPush()
{
wrapper.ListRightPopLeftPush("source", "destination", CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPopLeftPush("prefix:source", "prefix:destination", CommandFlags.HighPriority));
}
[Test]
public void ListRightPush_1()
{
wrapper.ListRightPush("key", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPush("prefix:key", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void ListRightPush_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.ListRightPush("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPush("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void ListSetByIndex()
{
wrapper.ListSetByIndex("key", 123, "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListSetByIndex("prefix:key", 123, "value", CommandFlags.HighPriority));
}
[Test]
public void ListTrim()
{
wrapper.ListTrim("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.ListTrim("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void LockExtend()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.LockExtend("key", "value", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.LockExtend("prefix:key", "value", expiry, CommandFlags.HighPriority));
}
[Test]
public void LockQuery()
{
wrapper.LockQuery("key", CommandFlags.HighPriority);
mock.Verify(_ => _.LockQuery("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void LockRelease()
{
wrapper.LockRelease("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.LockRelease("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void LockTake()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.LockTake("key", "value", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.LockTake("prefix:key", "value", expiry, CommandFlags.HighPriority));
}
[Test]
public void Publish()
{
wrapper.Publish("channel", "message", CommandFlags.HighPriority);
mock.Verify(_ => _.Publish("prefix:channel", "message", CommandFlags.HighPriority));
}
[Test]
public void ScriptEvaluate_1()
{
byte[] hash = new byte[0];
RedisValue[] values = new RedisValue[0];
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.ScriptEvaluate(hash, keys, values, CommandFlags.HighPriority);
mock.Verify(_ => _.ScriptEvaluate(hash, It.Is(valid), values, CommandFlags.HighPriority));
}
[Test]
public void ScriptEvaluate_2()
{
RedisValue[] values = new RedisValue[0];
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.ScriptEvaluate("script", keys, values, CommandFlags.HighPriority);
mock.Verify(_ => _.ScriptEvaluate("script", It.Is(valid), values, CommandFlags.HighPriority));
}
[Test]
public void SetAdd_1()
{
wrapper.SetAdd("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetAdd("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetAdd_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.SetAdd("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SetAdd("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SetCombine_1()
{
wrapper.SetCombine(SetOperation.Intersect, "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombine(SetOperation.Intersect, "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void SetCombine_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombine(SetOperation.Intersect, keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombine(SetOperation.Intersect, It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SetCombineAndStore_1()
{
wrapper.SetCombineAndStore(SetOperation.Intersect, "destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStore(SetOperation.Intersect, "prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void SetCombineAndStore_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombineAndStore(SetOperation.Intersect, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStore(SetOperation.Intersect, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SetContains()
{
wrapper.SetContains("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetContains("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetLength()
{
wrapper.SetLength("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetLength("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetMembers()
{
wrapper.SetMembers("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetMembers("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetMove()
{
wrapper.SetMove("source", "destination", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetMove("prefix:source", "prefix:destination", "value", CommandFlags.HighPriority));
}
[Test]
public void SetPop()
{
wrapper.SetPop("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetPop("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetRandomMember()
{
wrapper.SetRandomMember("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetRandomMember("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetRandomMembers()
{
wrapper.SetRandomMembers("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.SetRandomMembers("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void SetRemove_1()
{
wrapper.SetRemove("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetRemove("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetRemove_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.SetRemove("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SetRemove("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SetScan()
{
wrapper.SetScan("key", "pattern", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.SetScan("prefix:key", "pattern", 123, CommandFlags.HighPriority));
}
[Test]
public void Sort()
{
RedisValue[] get = new RedisValue[] { "a", "#" };
Expression<Func<RedisValue[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "#";
wrapper.Sort("key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", get, CommandFlags.HighPriority);
wrapper.Sort("key", 123, 456, Order.Descending, SortType.Alphabetic, "by", get, CommandFlags.HighPriority);
mock.Verify(_ => _.Sort("prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", It.Is(valid), CommandFlags.HighPriority));
mock.Verify(_ => _.Sort("prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "prefix:by", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortAndStore()
{
RedisValue[] get = new RedisValue[] { "a", "#" };
Expression<Func<RedisValue[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "#";
wrapper.SortAndStore("destination", "key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", get, CommandFlags.HighPriority);
wrapper.SortAndStore("destination", "key", 123, 456, Order.Descending, SortType.Alphabetic, "by", get, CommandFlags.HighPriority);
mock.Verify(_ => _.SortAndStore("prefix:destination", "prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", It.Is(valid), CommandFlags.HighPriority));
mock.Verify(_ => _.SortAndStore("prefix:destination", "prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "prefix:by", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortedSetAdd_1()
{
wrapper.SortedSetAdd("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetAdd("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetAdd_2()
{
SortedSetEntry[] values = new SortedSetEntry[0];
wrapper.SortedSetAdd("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetAdd("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SortedSetCombineAndStore_1()
{
wrapper.SortedSetCombineAndStore(SetOperation.Intersect, "destination", "first", "second", Aggregate.Max, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetCombineAndStore(SetOperation.Intersect, "prefix:destination", "prefix:first", "prefix:second", Aggregate.Max, CommandFlags.HighPriority));
}
[Test]
public void SortedSetCombineAndStore_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombineAndStore(SetOperation.Intersect, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStore(SetOperation.Intersect, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortedSetDecrement()
{
wrapper.SortedSetDecrement("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetDecrement("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetIncrement()
{
wrapper.SortedSetIncrement("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetIncrement("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetLength()
{
wrapper.SortedSetLength("key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetLength("prefix:key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetLengthByValue()
{
wrapper.SortedSetLengthByValue("key", "min", "max", Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetLengthByValue("prefix:key", "min", "max", Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByRank()
{
wrapper.SortedSetRangeByRank("key", 123, 456, Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByRank("prefix:key", 123, 456, Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByRankWithScores()
{
wrapper.SortedSetRangeByRankWithScores("key", 123, 456, Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByRankWithScores("prefix:key", 123, 456, Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByScore()
{
wrapper.SortedSetRangeByScore("key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByScore("prefix:key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByScoreWithScores()
{
wrapper.SortedSetRangeByScoreWithScores("key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByScoreWithScores("prefix:key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByValue()
{
wrapper.SortedSetRangeByValue("key", "min", "max", Exclude.Start, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByValue("prefix:key", "min", "max", Exclude.Start, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRank()
{
wrapper.SortedSetRank("key", "member", Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRank("prefix:key", "member", Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemove_1()
{
wrapper.SortedSetRemove("key", "member", CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemove("prefix:key", "member", CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemove_2()
{
RedisValue[] members = new RedisValue[0];
wrapper.SortedSetRemove("key", members, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemove("prefix:key", members, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByRank()
{
wrapper.SortedSetRemoveRangeByRank("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByRank("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByScore()
{
wrapper.SortedSetRemoveRangeByScore("key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByScore("prefix:key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByValue()
{
wrapper.SortedSetRemoveRangeByValue("key", "min", "max", Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByValue("prefix:key", "min", "max", Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetScan()
{
wrapper.SortedSetScan("key", "pattern", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetScan("prefix:key", "pattern", 123, CommandFlags.HighPriority));
}
[Test]
public void SortedSetScore()
{
wrapper.SortedSetScore("key", "member", CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetScore("prefix:key", "member", CommandFlags.HighPriority));
}
[Test]
public void StringAppend()
{
wrapper.StringAppend("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringAppend("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void StringBitCount()
{
wrapper.StringBitCount("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitCount("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringBitOperation_1()
{
wrapper.StringBitOperation(Bitwise.Xor, "destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitOperation(Bitwise.Xor, "prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void StringBitOperation_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.StringBitOperation(Bitwise.Xor, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitOperation(Bitwise.Xor, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void StringBitPosition()
{
wrapper.StringBitPosition("key", true, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitPosition("prefix:key", true, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringDecrement_1()
{
wrapper.StringDecrement("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringDecrement("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringDecrement_2()
{
wrapper.StringDecrement("key", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.StringDecrement("prefix:key", 1.23, CommandFlags.HighPriority));
}
[Test]
public void StringGet_1()
{
wrapper.StringGet("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGet("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringGet_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.StringGet(keys, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGet(It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void StringGetBit()
{
wrapper.StringGetBit("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetBit("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringGetRange()
{
wrapper.StringGetRange("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetRange("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringGetSet()
{
wrapper.StringGetSet("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetSet("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void StringGetWithExpiry()
{
wrapper.StringGetWithExpiry("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetWithExpiry("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringIncrement_1()
{
wrapper.StringIncrement("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringIncrement("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringIncrement_2()
{
wrapper.StringIncrement("key", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.StringIncrement("prefix:key", 1.23, CommandFlags.HighPriority));
}
[Test]
public void StringLength()
{
wrapper.StringLength("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringLength("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringSet_1()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.StringSet("key", "value", expiry, When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSet("prefix:key", "value", expiry, When.Exists, CommandFlags.HighPriority));
}
[Test]
public void StringSet_2()
{
KeyValuePair<RedisKey, RedisValue>[] values = new KeyValuePair<RedisKey, RedisValue>[] { new KeyValuePair<RedisKey, RedisValue>("a", "x"), new KeyValuePair<RedisKey, RedisValue>("b", "y") };
Expression<Func<KeyValuePair<RedisKey, RedisValue>[], bool>> valid = _ => _.Length == 2 && _[0].Key == "prefix:a" && _[0].Value == "x" && _[1].Key == "prefix:b" && _[1].Value == "y";
wrapper.StringSet(values, When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSet(It.Is(valid), When.Exists, CommandFlags.HighPriority));
}
[Test]
public void StringSetBit()
{
wrapper.StringSetBit("key", 123, true, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetBit("prefix:key", 123, true, CommandFlags.HighPriority));
}
[Test]
public void StringSetRange()
{
wrapper.StringSetRange("key", 123, "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetRange("prefix:key", 123, "value", CommandFlags.HighPriority));
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{19C00111-1328-4089-8565-94920B5B47F2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StackExchange.Redis.Tests</RootNamespace>
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Verbose|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Verbose\</OutputPath>
<DefineConstants>TRACE;DEBUG;VERBOSE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Log Output|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Log Output\</OutputPath>
<DefineConstants>TRACE;DEBUG;LOGOUTPUT</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="BookSleeve">
<HintPath>..\packages\BookSleeve.1.3.41\lib\BookSleeve.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\StackExchange.Redis\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="AsyncTests.cs" />
<Compile Include="BasicOps.cs" />
<Compile Include="Bits.cs" />
<Compile Include="Cluster.cs" />
<Compile Include="Commands.cs" />
<Compile Include="ConnectFailTimeout.cs" />
<Compile Include="ConnectionShutdown.cs" />
<Compile Include="Databases.cs" />
<Compile Include="DefaultPorts.cs" />
<Compile Include="Expiry.cs" />
<Compile Include="Config.cs" />
<Compile Include="FloatingPoint.cs" />
<Compile Include="Issues\BGSAVEResponse.cs" />
<Compile Include="Issues\Issue25.cs" />
<Compile Include="Issues\Issue6.cs" />
<Compile Include="Issues\SO22786599.cs" />
<Compile Include="Issues\SO23949477.cs" />
<Compile Include="Issues\SO24807536.cs" />
<Compile Include="Issues\SO25567566.cs" />
<Compile Include="Keys.cs" />
<Compile Include="KeysAndValues.cs" />
<Compile Include="Lex.cs" />
<Compile Include="Lists.cs" />
<Compile Include="Locking.cs" />
<Compile Include="Migrate.cs" />
<Compile Include="MultiAdd.cs" />
<Compile Include="MultiMaster.cs" />
<Compile Include="Naming.cs" />
<Compile Include="PreserveOrder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PubSub.cs" />
<Compile Include="PubSubCommand.cs" />
<Compile Include="RealWorld.cs" />
<Compile Include="Scans.cs" />
<Compile Include="Scripting.cs" />
<Compile Include="Secure.cs" />
<Compile Include="Sentinel.cs" />
<Compile Include="Sets.cs" />
<Compile Include="Issues\SO25113323.cs" />
<Compile Include="SSDB.cs" />
<Compile Include="SSL.cs" />
<Compile Include="TaskTests.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestInfoReplicationChecks.cs" />
<Compile Include="Transactions.cs" />
<Compile Include="VPNTest.cs" />
<Compile Include="WithKeyPrefixTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj">
<Project>{7cec07f2-8c03-4c42-b048-738b215824c1}</Project>
<Name>StackExchange.Redis</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{19C00111-1328-4089-8565-94920B5B47F2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StackExchange.Redis.Tests</RootNamespace>
<AssemblyName>StackExchange.Redis.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Verbose|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Verbose\</OutputPath>
<DefineConstants>TRACE;DEBUG;VERBOSE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Log Output|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Log Output\</OutputPath>
<DefineConstants>TRACE;DEBUG;LOGOUTPUT</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="BookSleeve">
<HintPath>..\packages\BookSleeve.1.3.41\lib\BookSleeve.dll</HintPath>
</Reference>
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\StackExchange.Redis\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="AsyncTests.cs" />
<Compile Include="BasicOps.cs" />
<Compile Include="WrapperBaseTests.cs" />
<Compile Include="TransactionWrapperTests.cs" />
<Compile Include="Bits.cs" />
<Compile Include="Cluster.cs" />
<Compile Include="Commands.cs" />
<Compile Include="ConnectFailTimeout.cs" />
<Compile Include="ConnectionShutdown.cs" />
<Compile Include="Databases.cs" />
<Compile Include="BatchWrapperTests.cs" />
<Compile Include="DatabaseWrapperTests.cs" />
<Compile Include="DefaultPorts.cs" />
<Compile Include="Expiry.cs" />
<Compile Include="Config.cs" />
<Compile Include="FloatingPoint.cs" />
<Compile Include="Issues\BGSAVEResponse.cs" />
<Compile Include="Issues\Issue25.cs" />
<Compile Include="Issues\Issue6.cs" />
<Compile Include="Issues\SO22786599.cs" />
<Compile Include="Issues\SO23949477.cs" />
<Compile Include="Issues\SO24807536.cs" />
<Compile Include="Issues\SO25567566.cs" />
<Compile Include="Keys.cs" />
<Compile Include="KeysAndValues.cs" />
<Compile Include="Lex.cs" />
<Compile Include="Lists.cs" />
<Compile Include="Locking.cs" />
<Compile Include="Migrate.cs" />
<Compile Include="MultiAdd.cs" />
<Compile Include="MultiMaster.cs" />
<Compile Include="Naming.cs" />
<Compile Include="PreserveOrder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PubSub.cs" />
<Compile Include="PubSubCommand.cs" />
<Compile Include="RealWorld.cs" />
<Compile Include="Scans.cs" />
<Compile Include="Scripting.cs" />
<Compile Include="Secure.cs" />
<Compile Include="Sentinel.cs" />
<Compile Include="Sets.cs" />
<Compile Include="Issues\SO25113323.cs" />
<Compile Include="SSDB.cs" />
<Compile Include="SSL.cs" />
<Compile Include="TaskTests.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestInfoReplicationChecks.cs" />
<Compile Include="Transactions.cs" />
<Compile Include="VPNTest.cs" />
<Compile Include="WithKeyPrefixTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj">
<Project>{7cec07f2-8c03-4c42-b048-738b215824c1}</Project>
<Name>StackExchange.Redis</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
\ No newline at end of file
using System;
using Moq;
using NUnit.Framework;
using StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public sealed class TransactionWrapperTests
{
private Mock<ITransaction> mock;
private TransactionWrapper wrapper;
[TestFixtureSetUp]
public void Initialize()
{
mock = new Mock<ITransaction>();
wrapper = new TransactionWrapper(mock.Object, "prefix:");
}
[Test]
public void AddCondition_HashEqual()
{
wrapper.AddCondition(Condition.HashEqual("key", "field", "value"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key > field == value" == value.ToString())));
}
[Test]
public void AddCondition_HashNotEqual()
{
wrapper.AddCondition(Condition.HashNotEqual("key", "field", "value"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key > field != value" == value.ToString())));
}
[Test]
public void AddCondition_HashExists()
{
wrapper.AddCondition(Condition.HashExists("key", "field"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key > field exists" == value.ToString())));
}
[Test]
public void AddCondition_HashNotExists()
{
wrapper.AddCondition(Condition.HashNotExists("key", "field"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key > field does not exists" == value.ToString())));
}
[Test]
public void AddCondition_KeyExists()
{
wrapper.AddCondition(Condition.KeyExists("key"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key exists" == value.ToString())));
}
[Test]
public void AddCondition_KeyNotExists()
{
wrapper.AddCondition(Condition.KeyNotExists("key"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key does not exists" == value.ToString())));
}
[Test]
public void AddCondition_StringEqual()
{
wrapper.AddCondition(Condition.StringEqual("key", "value"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key == value" == value.ToString())));
}
[Test]
public void AddCondition_StringNotEqual()
{
wrapper.AddCondition(Condition.StringNotEqual("key", "value"));
mock.Verify(_ => _.AddCondition(It.Is<Condition>(value => "prefix:key != value" == value.ToString())));
}
[Test]
public void ExecuteAsync()
{
wrapper.ExecuteAsync(CommandFlags.HighPriority);
mock.Verify(_ => _.ExecuteAsync(CommandFlags.HighPriority), Times.Once());
}
[Test]
public void Execute()
{
wrapper.Execute(CommandFlags.HighPriority);
mock.Verify(_ => _.Execute(CommandFlags.HighPriority), Times.Once());
}
}
}
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
using Moq;
using NUnit.Framework;
using StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public sealed class WrapperBaseTests
{
private Mock<IDatabaseAsync> mock;
private WrapperBase<IDatabaseAsync> wrapper;
[TestFixtureSetUp]
public void Initialize()
{
mock = new Mock<IDatabaseAsync>();
wrapper = new WrapperBase<IDatabaseAsync>(mock.Object, "prefix:");
}
[Test]
public void DebugObjectAsync()
{
wrapper.DebugObjectAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.DebugObjectAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashDecrementAsync_1()
{
wrapper.HashDecrementAsync("key", "hashField", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDecrementAsync("prefix:key", "hashField", 123, CommandFlags.HighPriority));
}
[Test]
public void HashDecrementAsync_2()
{
wrapper.HashDecrementAsync("key", "hashField", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDecrementAsync("prefix:key", "hashField", 1.23, CommandFlags.HighPriority));
}
[Test]
public void HashDeleteAsync_1()
{
wrapper.HashDeleteAsync("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashDeleteAsync("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashDeleteAsync_2()
{
RedisValue[] hashFields = new RedisValue[0];
wrapper.HashDeleteAsync("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashDeleteAsync("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashExistsAsync()
{
wrapper.HashExistsAsync("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashExistsAsync("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashGetAllAsync()
{
wrapper.HashGetAllAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashGetAllAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashGetAsync_1()
{
wrapper.HashGetAsync("key", "hashField", CommandFlags.HighPriority);
mock.Verify(_ => _.HashGetAsync("prefix:key", "hashField", CommandFlags.HighPriority));
}
[Test]
public void HashGetAsync_2()
{
RedisValue[] hashFields = new RedisValue[0];
wrapper.HashGetAsync("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashGetAsync("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashIncrementAsync_1()
{
wrapper.HashIncrementAsync("key", "hashField", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.HashIncrementAsync("prefix:key", "hashField", 123, CommandFlags.HighPriority));
}
[Test]
public void HashIncrementAsync_2()
{
wrapper.HashIncrementAsync("key", "hashField", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.HashIncrementAsync("prefix:key", "hashField", 1.23, CommandFlags.HighPriority));
}
[Test]
public void HashKeysAsync()
{
wrapper.HashKeysAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashKeysAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashLengthAsync()
{
wrapper.HashLengthAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashLengthAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HashSetAsync_1()
{
HashEntry[] hashFields = new HashEntry[0];
wrapper.HashSetAsync("key", hashFields, CommandFlags.HighPriority);
mock.Verify(_ => _.HashSetAsync("prefix:key", hashFields, CommandFlags.HighPriority));
}
[Test]
public void HashSetAsync_2()
{
wrapper.HashSetAsync("key", "hashField", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.HashSetAsync("prefix:key", "hashField", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void HashValuesAsync()
{
wrapper.HashValuesAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HashValuesAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogAddAsync_1()
{
wrapper.HyperLogLogAddAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogAddAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogAddAsync_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.HyperLogLogAddAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogAddAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogLengthAsync()
{
wrapper.HyperLogLogLengthAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogLengthAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogMergeAsync_1()
{
wrapper.HyperLogLogMergeAsync("destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogMergeAsync("prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void HyperLogLogMergeAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.HyperLogLogMergeAsync("destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.HyperLogLogMergeAsync("prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void IdentifyEndpointAsync()
{
wrapper.IdentifyEndpointAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.IdentifyEndpointAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void IsConnected()
{
wrapper.IsConnected("key", CommandFlags.HighPriority);
mock.Verify(_ => _.IsConnected("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyDeleteAsync_1()
{
wrapper.KeyDeleteAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDeleteAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyDeleteAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.KeyDeleteAsync(keys, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDeleteAsync(It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void KeyDumpAsync()
{
wrapper.KeyDumpAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyDumpAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyExistsAsync()
{
wrapper.KeyExistsAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExistsAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyExpireAsync_1()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.KeyExpireAsync("key", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExpireAsync("prefix:key", expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyExpireAsync_2()
{
DateTime expiry = DateTime.Now;
wrapper.KeyExpireAsync("key", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyExpireAsync("prefix:key", expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyMigrateAsync()
{
EndPoint toServer = new IPEndPoint(IPAddress.Loopback, 123);
wrapper.KeyMigrateAsync("key", toServer, 123, 456, MigrateOptions.Copy, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyMigrateAsync("prefix:key", toServer, 123, 456, MigrateOptions.Copy, CommandFlags.HighPriority));
}
[Test]
public void KeyMoveAsync()
{
wrapper.KeyMoveAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyMoveAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void KeyPersistAsync()
{
wrapper.KeyPersistAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyPersistAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
public void KeyRandomAsync()
{
wrapper.KeyRandomAsync();
}
[Test]
public void KeyRenameAsync()
{
wrapper.KeyRenameAsync("key", "newKey", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyRenameAsync("prefix:key", "prefix:newKey", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void KeyRestoreAsync()
{
Byte[] value = new Byte[0];
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.KeyRestoreAsync("key", value, expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.KeyRestoreAsync("prefix:key", value, expiry, CommandFlags.HighPriority));
}
[Test]
public void KeyTimeToLiveAsync()
{
wrapper.KeyTimeToLiveAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyTimeToLiveAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void KeyTypeAsync()
{
wrapper.KeyTypeAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.KeyTypeAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListGetByIndexAsync()
{
wrapper.ListGetByIndexAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.ListGetByIndexAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void ListInsertAfterAsync()
{
wrapper.ListInsertAfterAsync("key", "pivot", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListInsertAfterAsync("prefix:key", "pivot", "value", CommandFlags.HighPriority));
}
[Test]
public void ListInsertBeforeAsync()
{
wrapper.ListInsertBeforeAsync("key", "pivot", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListInsertBeforeAsync("prefix:key", "pivot", "value", CommandFlags.HighPriority));
}
[Test]
public void ListLeftPopAsync()
{
wrapper.ListLeftPopAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPopAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListLeftPushAsync_1()
{
wrapper.ListLeftPushAsync("key", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPushAsync("prefix:key", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void ListLeftPushAsync_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.ListLeftPushAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.ListLeftPushAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void ListLengthAsync()
{
wrapper.ListLengthAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListLengthAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListRangeAsync()
{
wrapper.ListRangeAsync("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRangeAsync("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void ListRemoveAsync()
{
wrapper.ListRemoveAsync("key", "value", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRemoveAsync("prefix:key", "value", 123, CommandFlags.HighPriority));
}
[Test]
public void ListRightPopAsync()
{
wrapper.ListRightPopAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPopAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void ListRightPopLeftPushAsync()
{
wrapper.ListRightPopLeftPushAsync("source", "destination", CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPopLeftPushAsync("prefix:source", "prefix:destination", CommandFlags.HighPriority));
}
[Test]
public void ListRightPushAsync_1()
{
wrapper.ListRightPushAsync("key", "value", When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPushAsync("prefix:key", "value", When.Exists, CommandFlags.HighPriority));
}
[Test]
public void ListRightPushAsync_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.ListRightPushAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.ListRightPushAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void ListSetByIndexAsync()
{
wrapper.ListSetByIndexAsync("key", 123, "value", CommandFlags.HighPriority);
mock.Verify(_ => _.ListSetByIndexAsync("prefix:key", 123, "value", CommandFlags.HighPriority));
}
[Test]
public void ListTrimAsync()
{
wrapper.ListTrimAsync("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.ListTrimAsync("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void LockExtendAsync()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.LockExtendAsync("key", "value", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.LockExtendAsync("prefix:key", "value", expiry, CommandFlags.HighPriority));
}
[Test]
public void LockQueryAsync()
{
wrapper.LockQueryAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.LockQueryAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void LockReleaseAsync()
{
wrapper.LockReleaseAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.LockReleaseAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void LockTakeAsync()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.LockTakeAsync("key", "value", expiry, CommandFlags.HighPriority);
mock.Verify(_ => _.LockTakeAsync("prefix:key", "value", expiry, CommandFlags.HighPriority));
}
[Test]
public void PublishAsync()
{
wrapper.PublishAsync("channel", "message", CommandFlags.HighPriority);
mock.Verify(_ => _.PublishAsync("prefix:channel", "message", CommandFlags.HighPriority));
}
[Test]
public void ScriptEvaluateAsync_1()
{
byte[] hash = new byte[0];
RedisValue[] values = new RedisValue[0];
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.ScriptEvaluateAsync(hash, keys, values, CommandFlags.HighPriority);
mock.Verify(_ => _.ScriptEvaluateAsync(hash, It.Is(valid), values, CommandFlags.HighPriority));
}
[Test]
public void ScriptEvaluateAsync_2()
{
RedisValue[] values = new RedisValue[0];
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.ScriptEvaluateAsync("script", keys, values, CommandFlags.HighPriority);
mock.Verify(_ => _.ScriptEvaluateAsync("script", It.Is(valid), values, CommandFlags.HighPriority));
}
[Test]
public void SetAddAsync_1()
{
wrapper.SetAddAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetAddAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetAddAsync_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.SetAddAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SetAddAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SetCombineAndStoreAsync_1()
{
wrapper.SetCombineAndStoreAsync(SetOperation.Intersect, "destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStoreAsync(SetOperation.Intersect, "prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void SetCombineAndStoreAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombineAndStoreAsync(SetOperation.Intersect, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStoreAsync(SetOperation.Intersect, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SetCombineAsync_1()
{
wrapper.SetCombineAsync(SetOperation.Intersect, "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAsync(SetOperation.Intersect, "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void SetCombineAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombineAsync(SetOperation.Intersect, keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAsync(SetOperation.Intersect, It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SetContainsAsync()
{
wrapper.SetContainsAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetContainsAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetLengthAsync()
{
wrapper.SetLengthAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetLengthAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetMembersAsync()
{
wrapper.SetMembersAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetMembersAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetMoveAsync()
{
wrapper.SetMoveAsync("source", "destination", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetMoveAsync("prefix:source", "prefix:destination", "value", CommandFlags.HighPriority));
}
[Test]
public void SetPopAsync()
{
wrapper.SetPopAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetPopAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetRandomMemberAsync()
{
wrapper.SetRandomMemberAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.SetRandomMemberAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void SetRandomMembersAsync()
{
wrapper.SetRandomMembersAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.SetRandomMembersAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void SetRemoveAsync_1()
{
wrapper.SetRemoveAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.SetRemoveAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void SetRemoveAsync_2()
{
RedisValue[] values = new RedisValue[0];
wrapper.SetRemoveAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SetRemoveAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SortAndStoreAsync()
{
RedisValue[] get = new RedisValue[] { "a", "#" };
Expression<Func<RedisValue[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "#";
wrapper.SortAndStoreAsync("destination", "key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", get, CommandFlags.HighPriority);
wrapper.SortAndStoreAsync("destination", "key", 123, 456, Order.Descending, SortType.Alphabetic, "by", get, CommandFlags.HighPriority);
mock.Verify(_ => _.SortAndStoreAsync("prefix:destination", "prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", It.Is(valid), CommandFlags.HighPriority));
mock.Verify(_ => _.SortAndStoreAsync("prefix:destination", "prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "prefix:by", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortAsync()
{
RedisValue[] get = new RedisValue[] { "a", "#" };
Expression<Func<RedisValue[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "#";
wrapper.SortAsync("key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", get, CommandFlags.HighPriority);
wrapper.SortAsync("key", 123, 456, Order.Descending, SortType.Alphabetic, "by", get, CommandFlags.HighPriority);
mock.Verify(_ => _.SortAsync("prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "nosort", It.Is(valid), CommandFlags.HighPriority));
mock.Verify(_ => _.SortAsync("prefix:key", 123, 456, Order.Descending, SortType.Alphabetic, "prefix:by", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortedSetAddAsync_1()
{
wrapper.SortedSetAddAsync("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetAddAsync("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetAddAsync_2()
{
SortedSetEntry[] values = new SortedSetEntry[0];
wrapper.SortedSetAddAsync("key", values, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetAddAsync("prefix:key", values, CommandFlags.HighPriority));
}
[Test]
public void SortedSetCombineAndStoreAsync_1()
{
wrapper.SortedSetCombineAndStoreAsync(SetOperation.Intersect, "destination", "first", "second", Aggregate.Max, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetCombineAndStoreAsync(SetOperation.Intersect, "prefix:destination", "prefix:first", "prefix:second", Aggregate.Max, CommandFlags.HighPriority));
}
[Test]
public void SortedSetCombineAndStoreAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.SetCombineAndStoreAsync(SetOperation.Intersect, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.SetCombineAndStoreAsync(SetOperation.Intersect, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void SortedSetDecrementAsync()
{
wrapper.SortedSetDecrementAsync("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetDecrementAsync("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetIncrementAsync()
{
wrapper.SortedSetIncrementAsync("key", "member", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetIncrementAsync("prefix:key", "member", 1.23, CommandFlags.HighPriority));
}
[Test]
public void SortedSetLengthAsync()
{
wrapper.SortedSetLengthAsync("key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetLengthAsync("prefix:key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetLengthByValueAsync()
{
wrapper.SortedSetLengthByValueAsync("key", "min", "max", Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetLengthByValueAsync("prefix:key", "min", "max", Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByRankAsync()
{
wrapper.SortedSetRangeByRankAsync("key", 123, 456, Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByRankAsync("prefix:key", 123, 456, Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByRankWithScoresAsync()
{
wrapper.SortedSetRangeByRankWithScoresAsync("key", 123, 456, Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByRankWithScoresAsync("prefix:key", 123, 456, Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByScoreAsync()
{
wrapper.SortedSetRangeByScoreAsync("key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByScoreAsync("prefix:key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByScoreWithScoresAsync()
{
wrapper.SortedSetRangeByScoreWithScoresAsync("key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByScoreWithScoresAsync("prefix:key", 1.23, 1.23, Exclude.Start, Order.Descending, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRangeByValueAsync()
{
wrapper.SortedSetRangeByValueAsync("key", "min", "max", Exclude.Start, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRangeByValueAsync("prefix:key", "min", "max", Exclude.Start, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRankAsync()
{
wrapper.SortedSetRankAsync("key", "member", Order.Descending, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRankAsync("prefix:key", "member", Order.Descending, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveAsync_1()
{
wrapper.SortedSetRemoveAsync("key", "member", CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveAsync("prefix:key", "member", CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveAsync_2()
{
RedisValue[] members = new RedisValue[0];
wrapper.SortedSetRemoveAsync("key", members, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveAsync("prefix:key", members, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByRankAsync()
{
wrapper.SortedSetRemoveRangeByRankAsync("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByRankAsync("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByScoreAsync()
{
wrapper.SortedSetRemoveRangeByScoreAsync("key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByScoreAsync("prefix:key", 1.23, 1.23, Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetRemoveRangeByValueAsync()
{
wrapper.SortedSetRemoveRangeByValueAsync("key", "min", "max", Exclude.Start, CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetRemoveRangeByValueAsync("prefix:key", "min", "max", Exclude.Start, CommandFlags.HighPriority));
}
[Test]
public void SortedSetScoreAsync()
{
wrapper.SortedSetScoreAsync("key", "member", CommandFlags.HighPriority);
mock.Verify(_ => _.SortedSetScoreAsync("prefix:key", "member", CommandFlags.HighPriority));
}
[Test]
public void StringAppendAsync()
{
wrapper.StringAppendAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringAppendAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void StringBitCountAsync()
{
wrapper.StringBitCountAsync("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitCountAsync("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringBitOperationAsync_1()
{
wrapper.StringBitOperationAsync(Bitwise.Xor, "destination", "first", "second", CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitOperationAsync(Bitwise.Xor, "prefix:destination", "prefix:first", "prefix:second", CommandFlags.HighPriority));
}
[Test]
public void StringBitOperationAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.StringBitOperationAsync(Bitwise.Xor, "destination", keys, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitOperationAsync(Bitwise.Xor, "prefix:destination", It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void StringBitPositionAsync()
{
wrapper.StringBitPositionAsync("key", true, 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringBitPositionAsync("prefix:key", true, 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringDecrementAsync_1()
{
wrapper.StringDecrementAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringDecrementAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringDecrementAsync_2()
{
wrapper.StringDecrementAsync("key", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.StringDecrementAsync("prefix:key", 1.23, CommandFlags.HighPriority));
}
[Test]
public void StringGetAsync_1()
{
wrapper.StringGetAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringGetAsync_2()
{
RedisKey[] keys = new RedisKey[] { "a", "b" };
Expression<Func<RedisKey[], bool>> valid = _ => _.Length == 2 && _[0] == "prefix:a" && _[1] == "prefix:b";
wrapper.StringGetAsync(keys, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetAsync(It.Is(valid), CommandFlags.HighPriority));
}
[Test]
public void StringGetBitAsync()
{
wrapper.StringGetBitAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetBitAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringGetRangeAsync()
{
wrapper.StringGetRangeAsync("key", 123, 456, CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetRangeAsync("prefix:key", 123, 456, CommandFlags.HighPriority));
}
[Test]
public void StringGetSetAsync()
{
wrapper.StringGetSetAsync("key", "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetSetAsync("prefix:key", "value", CommandFlags.HighPriority));
}
[Test]
public void StringGetWithExpiryAsync()
{
wrapper.StringGetWithExpiryAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringGetWithExpiryAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringIncrementAsync_1()
{
wrapper.StringIncrementAsync("key", 123, CommandFlags.HighPriority);
mock.Verify(_ => _.StringIncrementAsync("prefix:key", 123, CommandFlags.HighPriority));
}
[Test]
public void StringIncrementAsync_2()
{
wrapper.StringIncrementAsync("key", 1.23, CommandFlags.HighPriority);
mock.Verify(_ => _.StringIncrementAsync("prefix:key", 1.23, CommandFlags.HighPriority));
}
[Test]
public void StringLengthAsync()
{
wrapper.StringLengthAsync("key", CommandFlags.HighPriority);
mock.Verify(_ => _.StringLengthAsync("prefix:key", CommandFlags.HighPriority));
}
[Test]
public void StringSetAsync_1()
{
TimeSpan expiry = TimeSpan.FromSeconds(123);
wrapper.StringSetAsync("key", "value", expiry, When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetAsync("prefix:key", "value", expiry, When.Exists, CommandFlags.HighPriority));
}
[Test]
public void StringSetAsync_2()
{
KeyValuePair<RedisKey, RedisValue>[] values = new KeyValuePair<RedisKey, RedisValue>[] { new KeyValuePair<RedisKey, RedisValue>("a", "x"), new KeyValuePair<RedisKey, RedisValue>("b", "y") };
Expression<Func<KeyValuePair<RedisKey, RedisValue>[], bool>> valid = _ => _.Length == 2 && _[0].Key == "prefix:a" && _[0].Value == "x" && _[1].Key == "prefix:b" && _[1].Value == "y";
wrapper.StringSetAsync(values, When.Exists, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetAsync(It.Is(valid), When.Exists, CommandFlags.HighPriority));
}
[Test]
public void StringSetBitAsync()
{
wrapper.StringSetBitAsync("key", 123, true, CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetBitAsync("prefix:key", 123, true, CommandFlags.HighPriority));
}
[Test]
public void StringSetRangeAsync()
{
wrapper.StringSetRangeAsync("key", 123, "value", CommandFlags.HighPriority);
mock.Verify(_ => _.StringSetRangeAsync("prefix:key", 123, "value", CommandFlags.HighPriority));
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BookSleeve" version="1.3.41" targetFramework="net45" />
<package id="NUnit" version="2.6.3" targetFramework="net45" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BookSleeve" version="1.3.41" targetFramework="net45" />
<package id="Moq" version="4.2.1409.1722" targetFramework="net45" />
<package id="NUnit" version="2.6.3" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -37,4 +37,6 @@
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly:CLSCompliant(true)]
\ No newline at end of file
[assembly:CLSCompliant(true)]
[assembly:InternalsVisibleTo("StackExchange.Redis.Tests")]
\ No newline at end of file
......@@ -6,12 +6,12 @@
namespace StackExchange.Redis.StackExchange.Redis.KeyspaceIsolation
{
internal abstract class WrapperBase<TInner> : IDatabaseAsync where TInner : IDatabaseAsync
internal class WrapperBase<TInner> : IDatabaseAsync where TInner : IDatabaseAsync
{
private readonly TInner _inner;
private readonly RedisKey _prefix;
protected WrapperBase(TInner inner, RedisKey prefix)
internal WrapperBase(TInner inner, RedisKey prefix)
{
_inner = inner;
_prefix = prefix;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment