public void Handle_retries_and_throws_on_handled_exception_after_x_attempts(int attempts)
        {
            _retryHandlerOptionsMock.SetupGet(options => options.Timeout)
            .Returns(10);
            Assert.Throws <InvalidOperationException>(() => _sut.Handle(() => {
                _count++;
                throw new InvalidOperationException();
            }, attempts, false, typeof(InvalidOperationException)));

            Assert.AreEqual(attempts + 1, _count);
        }
        public async Task SaveTextToFile(IFile file, string content, CancellationToken cancellationToken)
        {
            try
            {
                await SavingSemaphoreSlim.WaitAsync(cancellationToken);

                await _retryHandler.Handle(async (file) =>
                {
                    await File.WriteAllTextAsync(file.FullPath, content, cancellationToken);
                }, file, _retryHandlerOptions.IOExceptionRetryAttempts, false, typeof(IOException));
            }
            finally
            {
                SavingSemaphoreSlim.Release();
            }
        }