Exemplo n.º 1
0
        public virtual async Task <TestResourceOperationOrResponseOfT> GetLroAsync(WaitUntil waitUntil, bool exceptionOnWait = false, CancellationToken cancellationToken = default)
        {
            using var scope = _diagnostic.CreateScope("TestResource.GetLro");
            scope.Start();

            try
            {
                var lro = new TestResourceOperationOrResponseOfT(new TestResource(), exceptionOnWait);
                if (waitUntil == WaitUntil.Completed)
                {
                    await lro.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(lro);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <TestResourceOperationOrResponseOfT> StartLroWrapperAsync(bool waitForCompletion, CancellationToken cancellationToken = default)
        {
            using var scope = _diagnostic.CreateScope("TestResource.StartLroWrapper");
            scope.Start();

            try
            {
                var lro = new TestResourceOperationOrResponseOfT(new TestResource());
                if (waitForCompletion)
                {
                    await lro.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(lro);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 3
0
        public async virtual Task <TestResourceOperationOrResponseOfT> StartLongLroAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default)
        {
            using var scope = _diagnostic.CreateScope("TestResource.StartLongLro");
            scope.Start();

            try
            {
                await Task.Delay(1);

                var lro = new TestResourceOperationOrResponseOfT(new TestResource(), delaySteps: 10);
                if (waitUntil == WaitUntil.Completed)
                {
                    await lro.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(lro);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }