public async Task Test_Executer()
        {
            IConfigInfo configInfo;
            var         controller = GetBucketForKey("thekey", out configInfo);

            _requestExecuter = new CouchbaseRequestExecuter(controller, configInfo, "default", _pending);

            var tcs = new TaskCompletionSource <IOperationResult <string> >();
            var cts = new CancellationTokenSource();

            var operation = new Mock <IOperation <string> >();

            operation.Setup(x => x.GetConfig()).Returns(new BucketConfig());
            operation.Setup(x => x.Write()).Throws(new Exception("bad kungfu"));
            operation.Setup(x => x.Key).Returns("thekey");
            operation.Setup(x => x.Completed).Returns(CallbackFactory.CompletedFuncWithRetryForCouchbase(
                                                          _requestExecuter, _pending, controller, tcs, cts.Token));
            operation.Setup(x => x.GetResultWithValue()).Returns(new OperationResult <string> {
                Success = true
            });

            var result = await _requestExecuter.SendWithRetryAsync(operation.Object, tcs);

            Assert.IsTrue(result.Success);
        }
        public async Task When_TransportFailure_Occurs_CheckConfigUpdate_Is_Called_For_ExecuteAsync_T()
        {
            var mockConnection = new Mock <IConnection>();

            mockConnection.Setup(x => x.IsConnected).Returns(false);

            var mockConnectionPool = new Mock <IConnectionPool>();

            mockConnectionPool.Setup(x => x.Acquire()).Returns(mockConnection.Object);
            mockConnectionPool.SetupGet(x => x.Configuration).Returns(new PoolConfiguration {
                UseEnhancedDurability = false
            });

            var service = new MultiplexingIOService(mockConnectionPool.Object);

            var mockOperation = new Mock <IOperation <string> >();

            mockOperation.Setup(x => x.Opaque).Returns(1);
            mockOperation.Setup(x => x.Exception).Returns(new TransportFailureException());

            var opqueue = new ConcurrentDictionary <uint, IOperation>();

            opqueue.TryAdd(mockOperation.Object.Opaque, mockOperation.Object);

            var mockController = new Mock <IClusterController>();

            mockController.Setup(x => x.CheckConfigUpdate(It.IsAny <string>(), It.IsAny <IPEndPoint>())).Verifiable();

            TaskCompletionSource <IOperationResult <string> > tcs = new TaskCompletionSource <IOperationResult <string> >();

            mockOperation.Setup(x => x.Completed)
            .Returns(CallbackFactory.CompletedFuncWithRetryForCouchbase <string>(null, opqueue, mockController.Object, tcs,
                                                                                 new CancellationToken()));

            await service.ExecuteAsync(mockOperation.Object);

            mockController.VerifyAll();
        }