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"); }
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); }
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); }
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); }
public async void 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); }
public async void 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); }
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); }
public async void When_Key_Not_Found_ExistAsync_Returns_False() { var connection = new FakeConnection(); connection.SetResponse(ResponsePackets.OBSERVE_KEYEXISTS); _connectionPool.AddConnection(connection); var key = "When_Key_Not_Found_ExistAsync_Returns_False"; var bucket = GetBucketForKey(key); var result = await bucket.ExistsAsync(key); Assert.IsFalse(result); }
public async void 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); }
public async void 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); }
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); }
public async void 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); }
public async void 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); }
public async void 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); }
public async void 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); }
public async void When_Key_Does_Exist_UpsertAsync_Succeeds() { var connection = new FakeConnection(); connection.SetResponse(ResponsePackets.UPSERT_KEYEXISTS_SUCCESS); _connectionPool.AddConnection(connection); var key = "When_Key_Does_Exist_UpsertAsync_Succeeds"; var bucket = GetBucketForKey(key); var result = await bucket.UpsertAsync(key, "NA"); Assert.IsTrue(result.Success); Assert.AreEqual(ResponseStatus.Success, result.Status); }
public async void When_Lock_Acquired_GetWithLockReturns_Success() { var connection = new FakeConnection(); connection.SetResponse(ResponsePackets.GET_WITH_LOCK_SUCCESS); _connectionPool.AddConnection(connection); var bucket = GetBucketForKey("key1"); var result = await bucket.GetWithLockAsync <string>("key1", new TimeSpan(0, 0, 0, 2)); Console.WriteLine(result.Message); Assert.IsTrue(result.Success); Assert.AreEqual(ResponseStatus.Success, result.Status); }
// [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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public async Task When_Key_Not_Found_ExistAsync_Returns_False() { var connection = new FakeConnection(); connection.SetResponse(ResponsePackets.UPSERT_NOKEY_SUCCESS); _connectionPool.AddConnection(connection); var key = "When_Key_Not_Found_ExistAsync_Returns_False"; var bucket = GetBucketForKey(key); var result = await bucket.ExistsAsync(key); Assert.IsFalse(result); }