本文整理汇总了C#中FakeConnection.SetResponse方法的典型用法代码示例。如果您正苦于以下问题:C# FakeConnection.SetResponse方法的具体用法?C# FakeConnection.SetResponse怎么用?C# FakeConnection.SetResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FakeConnection
的用法示例。
在下文中一共展示了FakeConnection.SetResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_Key_Is_Found_GetAsync_Returns_True
public async void When_Key_Is_Found_GetAsync_Returns_True()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.GET_OPAQUE_5_SUCCESS);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key1");
var result = await bucket.GetAsync<int>("key1");
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例2: When_Add_Succeeds_InsertAsync_Returns_Success
public async Task When_Add_Succeeds_InsertAsync_Returns_Success()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.ADD_SUCCESS);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key1");
var result = await bucket.InsertAsync("key1", "NA");
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例3: When_Add_Fails_InsertAsync_Returns_KEY_EXISTS
public async Task When_Add_Fails_InsertAsync_Returns_KEY_EXISTS()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.Add_FAILED_KEY_EXISTS);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key1");
var result = await bucket.InsertAsync("key1", "NA");
Assert.IsFalse(result.Success);
Assert.AreEqual(ResponseStatus.KeyExists, result.Status);
}
示例4: Test_AppendAsync
public async Task Test_AppendAsync()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.INSERT_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "Test_Append_Async";
var bucket = GetBucketForKey(key);
var result = await bucket.AppendAsync(key, "AB");
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例5: When_Key_Found_ExistAsync_Returns_True
public async Task When_Key_Found_ExistAsync_Returns_True()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.OBSERVE_KEY_DNE);
_connectionPool.AddConnection(connection);
var key = "When_Key_Found_ExistAsync_Returns_True";
var bucket = GetBucketForKey(key);
var result = await bucket.ExistsAsync(key);
Assert.IsTrue(result);
}
示例6: When_Key_Does_Not_Exist_InsertAsync_Succeeds
public async Task When_Key_Does_Not_Exist_InsertAsync_Succeeds()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.INSERT_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Does_Not_Exist_InsertAsync_Succeeds";
var bucket = GetBucketForKey(key);
var result = await bucket.InsertAsync(key, "NA");
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例7: When_Key_Found_InsertAsync_Returns_KeyExists
public async Task When_Key_Found_InsertAsync_Returns_KeyExists()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.INSERT_KEYEXISTS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Found_InsertAsync_Returns_KeyExists";
var bucket = GetBucketForKey(key);
var result = await bucket.InsertAsync(key, "NA");
Assert.IsFalse(result.Success);
Assert.AreEqual(ResponseStatus.KeyExists, result.Status);
}
示例8: When_Key_Found_ReplaceAsync_Returns_Success
public async Task When_Key_Found_ReplaceAsync_Returns_Success()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.REPLACE_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Found_ReplaceAsync_Returns_Success";
var bucket = GetBucketForKey(key);
var result = await bucket.ReplaceAsync(key, "NA");
Assert.IsTrue(result.Success);
}
示例9: When_Key_Does_Not_Exist_ReplaceAsync_Returns_KeyNotFound
public async Task When_Key_Does_Not_Exist_ReplaceAsync_Returns_KeyNotFound()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.REPLACE_KEYNOTFOUND);
_connectionPool.AddConnection(connection);
var key = "When_Key_Does_Not_Exist_ReplaceAsync_Returns_KeyNotFound";
var bucket = GetBucketForKey(key);
var result = await bucket.ReplaceAsync(key, "NA");
Assert.IsFalse(result.Success);
Assert.AreEqual(ResponseStatus.KeyNotFound, result.Status);
}
示例10: When_NMV_Found_GetAsync_Will_Retry_Until_Timeout
public async Task When_NMV_Found_GetAsync_Will_Retry_Until_Timeout()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.GET_WITH_NMV);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key1");
var result = await bucket.GetAsync<int>("key1");
Console.WriteLine(result.Message);
Assert.IsFalse(result.Success);
Assert.AreEqual(ResponseStatus.OperationTimeout, result.Status);
}
示例11: When_Key_Is_Not_Found_GetAsync_Returns_False
public async Task When_Key_Is_Not_Found_GetAsync_Returns_False()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.GET_KEY_NOT_FOUND);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key-1");
var result = await bucket.GetAsync<int>("key-1");
Assert.IsFalse(result.Success);
Assert.AreEqual(ResponseStatus.KeyNotFound, result.Status);
}
示例12: When_Key_Found_RemoveAsync_Returns_Success
public async Task When_Key_Found_RemoveAsync_Returns_Success()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.REMOVE_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Found_RemoveAsync_Returns_Success";
var bucket = GetBucketForKey(key);
var result = await bucket.RemoveAsync(key);
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例13: When_Lock_Acquired_GetWithLockReturns_Success
public async Task When_Lock_Acquired_GetWithLockReturns_Success()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.GET_WITH_LOCK_SUCCESS);
_connectionPool.AddConnection(connection);
var bucket = GetBucketForKey("key1");
#pragma warning disable 618
var result = await bucket.GetWithLockAsync<string>("key1", new TimeSpan(0, 0, 0, 2));
#pragma warning restore 618
Console.WriteLine(result.Message);
Assert.IsTrue(result.Success);
Assert.AreEqual(ResponseStatus.Success, result.Status);
}
示例14: When_Key_Found_ExistAsync_Returns_True
// [Test]
//memcached does not support observe...this impl uses observe and fails
public async void When_Key_Found_ExistAsync_Returns_True()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.UPSERT_KEYEXISTS_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Found_ExistAsync_Returns_True";
var bucket = GetBucketForKey(key);
var result = await bucket.ExistsAsync(key);
Assert.IsTrue(result);
}
示例15: When_Key_Does_Not_Exist_InsertAsync_Succeeds
public async void When_Key_Does_Not_Exist_InsertAsync_Succeeds()
{
var connection = new FakeConnection();
connection.SetResponse(ResponsePackets.INSERT_SUCCESS);
_connectionPool.AddConnection(connection);
var key = "When_Key_Does_Not_Exist_InsertAsync_Succeeds";
var bucket = GetBucketForKey(key);
var result = await bucket.InsertAsync(key, "NA");
}