示例#1
0
 public async Task<OAuthToken> Login(string username, string password)
 {
     OAuthToken token;
     using (var xauth = new XAuth())
     {
         token = await xauth.XAuthAccessTokenRequest(username, password, Credentials.GetInstance(), BaseUrl + "access_token/");
     }
     return token;
 }
示例#2
0
 public async Task TestLogin()
 {
     OAuthToken token;
     using (var xauth = new XAuth())
     {
         token = await xauth.XAuthAccessTokenRequest("test", "test", Credentials.GetInstance(), "https://mobilevikings.com:443/api/2.0/oauth/access_token/");
     }
     Assert.AreNotEqual(string.Empty, token.TokenKey);
     Assert.AreNotEqual(string.Empty, token.TokenSecret);
 }
示例#3
0
 public async Task TestGetSimDetails()
 {
     OAuthToken token;
     using (var xauth = new XAuth())
     {
         token = await xauth.XAuthAccessTokenRequest("test", "test", Credentials.GetInstance(), "https://mobilevikings.com:443/api/2.0/oauth/access_token/");
     }
     string response;
     using (var oauth = new OAuth())
     {
         var parameters = new List<QueryParameter> { new QueryParameter("alias", "1") };
         response = await oauth.OAuthRequest(Credentials.GetInstance(), token, "https://mobilevikings.com:443/api/2.0/oauth/msisdn_list.json", parameters);
     }
     Assert.AreNotEqual(string.Empty, response);
 }
示例#4
0
 public async Task TestExceptionInvalidEndpoint()
 {
     try
     {
         OAuthToken token;
         using (var xauth = new XAuth())
         {
             token =
                 await
                     xauth.XAuthAccessTokenRequest("test", "test", Credentials.GetInstance(),
                         "https://mobilevikings.com:443/api/2.0/oauth/access_/");
         }
         Assert.Fail();
     }
     catch (OAuthException e)
     {
         Assert.AreEqual(e.Code, 404);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
示例#5
0
 public async Task TestExceptionInvalidPassword()
 {
     try
     {
         OAuthToken token;
         using (var xauth = new XAuth())
         {
             token =
                 await
                     xauth.XAuthAccessTokenRequest("test", "noneshallpass", Credentials.GetInstance(),
                         "https://mobilevikings.com:443/api/2.0/oauth/access_token/");
         }
         Assert.Fail();
     }
     catch (OAuthException e)
     {
         //Seriously though, a 500 upon providing a wrong password?!
         Assert.AreEqual(e.Code, 500);
     }
     catch (Exception)
     {
         Assert.Fail();
     }
 }