예제 #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();
     }
 }