public void TestMergeWithAuthenticationContext() { var sut = new EmptyAuthenticationContext(); sut.MergeWith(_authenticationContext); Assert.Equal(_authenticationContext.ConsumerKey, sut.ConsumerKey); Assert.Equal(_authenticationContext.ConsumerKeySecret, sut.ConsumerKeySecret); Assert.Equal(_authenticationContext.AccessToken, sut.AccessToken); Assert.Equal(_authenticationContext.AccessTokenSecret, sut.AccessTokenSecret); }
private IAuthenticationContext BuildAuthenticationContext(IDictionary<string, string> dictionary) { IAuthenticationContext result = new EmptyAuthenticationContext(); string accessToken = dictionary[ACCESS_TOKEN_NAME]; result.AccessToken = accessToken; string accessTokenSecret = dictionary[ACCESS_TOKEN_SECRET_NAME]; result.AccessTokenSecret = accessTokenSecret; return result; }
private IAuthenticationContext BuildAuthenticationContext(IDictionary <string, string> dictionary) { IAuthenticationContext result = new EmptyAuthenticationContext(); string accessToken = dictionary[ACCESS_TOKEN_NAME]; result.AccessToken = accessToken; string accessTokenSecret = dictionary[ACCESS_TOKEN_SECRET_NAME]; result.AccessTokenSecret = accessTokenSecret; return(result); }
public void TestMergeWithDictionary() { var sut = new EmptyAuthenticationContext(); IDictionary<string, string> dictoinary = new Dictionary<string, string> { { "oauth_token", "oauth_token_value" }, { "oauth_token_secret", "oauth_token_secret_value" } }; sut.MergeWith(dictoinary); Assert.Equal("oauth_token_value", sut.AccessToken); Assert.Equal("oauth_token_secret_value", sut.AccessTokenSecret); }
private static IAuthenticationContext GetRequestTokens(IAuthenticationContext authenticationContext) { HttpWebRequest request = GetRequestTokenRequest(authenticationContext); using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) using (Stream dataStream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(dataStream)) { //Read the content. string responseFromServer = reader.ReadToEnd(); string[] tokens = responseFromServer.Split(new[] { "&" }, StringSplitOptions.RemoveEmptyEntries); Dictionary<string, string> dictionary = tokens.ToDictionary(s => s.Split('=')[0], s => s.Split('=')[1]); var emptyContext = new EmptyAuthenticationContext(); emptyContext.MergeWith(dictionary); return emptyContext; } }