public async Task ReportOperationExceptionAsync_PropagatesCalls()
        {
            IServiceRemotingClient client = new Mock <IServiceRemotingClient>().Object;
            ExceptionInformation   exceptionInformation = new ExceptionInformation(new FileNotFoundException());
            OperationRetrySettings retrySettings        = new OperationRetrySettings();
            CancellationToken      cancellationToken    = CancellationToken.None;

            Expression <Func <IServiceRemotingClientFactory, Task <OperationRetryControl> > > expression = f =>
                                                                                                           f.ReportOperationExceptionAsync(
                client,
                exceptionInformation,
                retrySettings,
                cancellationToken);

            OperationRetryControl expectedResult             = new OperationRetryControl();
            Mock <IServiceRemotingClientFactory> factoryMock = new Mock <IServiceRemotingClientFactory>();

            factoryMock.Setup(expression).Returns(Task.FromResult(expectedResult));
            OmexServiceRemotingClientFactory wrapper = new OmexServiceRemotingClientFactory(factoryMock.Object);

            OperationRetryControl actualResult = await wrapper.ReportOperationExceptionAsync(
                client,
                exceptionInformation,
                retrySettings,
                cancellationToken).ConfigureAwait(false);

            factoryMock.Verify(expression, Times.Once);

            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #2
0
 /// <summary>
 /// Registers an <see cref="OperationRetryControl"/> to return from <see cref="ReportOperationExceptionAsync"/>.
 /// </summary>
 /// <param name="client"></param>
 /// <param name="control"></param>
 public void RegisterOperationRetryControl(IServiceRemotingClient client, OperationRetryControl control)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     _operationRetryControls[client] = control;
 }