public async Task<bool> TryConnectWithPersistedAccessTokenAsync(AccessToken persistedAccessToken)
 {
     try
     {
         await _testRepository.Value.SearchByNameAsync("TEST");
         return true;
     }
     catch
     {
         return false;
     }
 }
        public async Task<AccessToken> GetAccessTokenAsync(RequestToken requestToken)
        {
            if (requestToken == null) throw new InvalidOperationException("Cannot get an Access token until you have the Request token.");

            var client =
                new RestClient(_apiBaseUrl)
                    {
                        Authenticator = OAuth1Authenticator.ForAccessToken(_consumerKey, _consumerSecret, requestToken.Value, requestToken.Secret)
                    };
            var request = new RestRequest(AccessTokenPath);
            var response = await client.ExecuteAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var queryString = HttpUtility.ParseQueryString(response.Content);
                var accessToken = new AccessToken(queryString["oauth_token"], queryString["oauth_token_secret"]);
                return accessToken;
            }

            throw new Exception("An error occured: Status code: " + response.StatusCode, response.ErrorException);
        }
        public async Task<AccessToken> GetAccessTokenAsync(RequestToken requestToken, string verifier)
        {
            if (requestToken == null) throw new InvalidOperationException("Cannot get the Access token without a Request token.");
            if (verifier == null) throw new InvalidOperationException("Cannot get the Access token without a verifer");

            if (string.IsNullOrWhiteSpace(verifier))
                throw new Exception("There was no oauth_verifier parameter on the callback request.");

            var client =
                new RestClient(_apiBaseUrl)
                {
                    Authenticator = OAuth1Authenticator.ForAccessToken(_consumerKey, _consumerSecret, requestToken.Value, requestToken.Secret, verifier)
                };
            var request = new RestRequest(AccessTokenPath);
            var response = await client.ExecuteAsync(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var queryString = HttpUtility.ParseQueryString(response.Content);
                var accessToken = new AccessToken(queryString["oauth_token"], queryString["oauth_token_secret"]);
                return accessToken;
            }

            throw new Exception("An error occured: Status code: " + response.StatusCode, response.ErrorException);
        }