private async Task SendMessagePoolOverAmqp( TestDeviceType type, Client.TransportType transport, int poolSize, int devicesCount, ConnectionStringAuthScope authScope = ConnectionStringAuthScope.Device) { async Task TestOperationAsync(DeviceClient deviceClient, TestDevice testDevice, TestDeviceCallbackHandler _) { Logger.Trace($"{nameof(MessageSendE2EPoolAmqpTests)}: Preparing to send message for device {testDevice.Id}"); await deviceClient.OpenAsync().ConfigureAwait(false); (Client.Message testMessage, string payload, string p1Value) = MessageSendE2ETests.ComposeD2cTestMessage(Logger); Logger.Trace($"{nameof(MessageSendE2EPoolAmqpTests)}.{testDevice.Id}: messageId='{testMessage.MessageId}' payload='{payload}' p1Value='{p1Value}'"); await deviceClient.SendEventAsync(testMessage).ConfigureAwait(false); } await PoolingOverAmqp .TestPoolAmqpAsync( _devicePrefix, transport, poolSize, devicesCount, null, TestOperationAsync, null, authScope, true, Logger) .ConfigureAwait(false); }
internal async Task SendMessageRecoveryAsync( TestDeviceType type, Client.TransportType transport, string faultType, string reason, TimeSpan delayInSec, TimeSpan durationInSec = default, TimeSpan retryDurationInMilliSec = default, string proxyAddress = null) { TimeSpan operationTimeoutInMilliSecs = retryDurationInMilliSec == TimeSpan.Zero ? FaultInjection.RecoveryTime : retryDurationInMilliSec; Func <DeviceClient, TestDevice, Task> init = (deviceClient, testDevice) => { deviceClient.OperationTimeoutInMilliseconds = (uint)retryDurationInMilliSec.TotalMilliseconds; return(Task.FromResult(0)); }; Func <DeviceClient, TestDevice, Task> testOperation = async(deviceClient, testDevice) => { (Client.Message testMessage, string payload, string p1Value) = MessageSendE2ETests.ComposeD2cTestMessage(Logger); await deviceClient.SendEventAsync(testMessage).ConfigureAwait(false); }; await FaultInjection .TestErrorInjectionAsync( _devicePrefix, type, transport, proxyAddress, faultType, reason, delayInSec, durationInSec == TimeSpan.Zero?FaultInjection.DefaultFaultDuration : durationInSec, init, testOperation, () => { return(Task.FromResult(false)); }, Logger) .ConfigureAwait(false); }