Ejemplo n.º 1
0
 public OAuthTwitterWrapper()
 {
     string oAuthConsumerKey = ConfigurationManager.AppSettings["oAuthConsumerKey"];
     string oAuthConsumerSecret = ConfigurationManager.AppSettings["oAuthConsumerSecret"];
     string oAuthUrl = ConfigurationManager.AppSettings["oAuthUrl"];
     AuthenticateSettings = new AuthenticateSettings { OAuthConsumerKey = oAuthConsumerKey, OAuthConsumerSecret = oAuthConsumerSecret, OAuthUrl = oAuthUrl };
     string screenname = ConfigurationManager.AppSettings["screenname"];
     string include_rts = ConfigurationManager.AppSettings["include_rts"];
     string exclude_replies = ConfigurationManager.AppSettings["exclude_replies"];
     int count = Convert.ToInt16(ConfigurationManager.AppSettings["count"]);
     string timelineFormat = ConfigurationManager.AppSettings["timelineFormat"];         
     TimeLineSettings = new TimeLineSettings
     {
         ScreenName = screenname,
         IncludeRts = include_rts,
         ExcludeReplies = exclude_replies,
         Count = count,
         TimelineFormat = timelineFormat
     };
     string searchFormat = ConfigurationManager.AppSettings["searchFormat"];
     string searchQuery = ConfigurationManager.AppSettings["searchQuery"];
     SearchSettings = new SearchSettings
     {
         SearchFormat = searchFormat,
         SearchQuery = searchQuery
     };
Ejemplo n.º 2
0
        public void AuthenticateConsumerNullParameter()
        {
            //Arrange
            AuthenticateSettings obAuthSettings = null;

            //Act
            IAuthenticate obAuthenticate = new Authenticate();
            AuthResponse  obAuthRespose  = obAuthenticate.AuthenticateConsumer(obAuthSettings);

            //Assert
            // When null parameter is passed, the expected output is null Authentication Response.
            Assert.AreEqual(obAuthRespose, null);
        }
Ejemplo n.º 3
0
        public void AuthenticateConsumerEmptyOAuthConsumerSecret()
        {
            //Arrange
            AuthenticateSettings obAuthSettings = new AuthenticateSettings();

            obAuthSettings.OAuthConsumerSecret = string.Empty;

            //Act
            IAuthenticate obAuthenticate = new Authenticate();
            AuthResponse  obAuthRespose  = obAuthenticate.AuthenticateConsumer(obAuthSettings);

            //Assert
            // When Consumer Secret is empty, the expected output is null Authentication Response.
            Assert.AreEqual(obAuthRespose, null);
        }
Ejemplo n.º 4
0
        public void AuthenticateConsumerNullOAuthConsumerKey()
        {
            //Arrange
            AuthenticateSettings obAuthSettings = new AuthenticateSettings();

            obAuthSettings.OAuthConsumerKey = null;

            //Act
            IAuthenticate obAuthenticate = new Authenticate();
            AuthResponse  obAuthRespose  = obAuthenticate.AuthenticateConsumer(obAuthSettings);

            //Assert
            // When Consumer key is null, the expected output is null Authentication Response.
            Assert.AreEqual(obAuthRespose, null);
        }
Ejemplo n.º 5
0
        public void AuthenticateConsumerWithValidParameter()
        {
            //Arrange
            //**This Key needs to be replaced in case if it has expired for any reason
            AuthenticateSettings obAuthSettings = new AuthenticateSettings();

            obAuthSettings.OAuthConsumerKey    = "yEkVQqHKfqeLDiPBnGk6xtOHJ";
            obAuthSettings.OAuthConsumerSecret = "ASrjZGIQCFsBewxYYlnkKM45FHkniu0Uk8saKhZ0kloXO6d2Fy";
            obAuthSettings.OAuthUrl            = "https://api.twitter.com/oauth2/token";
            //Act
            IAuthenticate obAuthenticate = new Authenticate();
            AuthResponse  obAuthRespose  = obAuthenticate.AuthenticateConsumer(obAuthSettings);

            //Assert
            // When all valid parameter is passed, response is expected with access token
            Assert.IsTrue(obAuthRespose.TokenType != null && obAuthRespose.AccessToken != null);
        }
Ejemplo n.º 6
0
        public void AuthenticateConsumerWithInValidAuthCredential()
        {
            //Arrange
            //**This Key needs to be replaced in case if it has expired for any reason
            AuthenticateSettings obAuthSettings = new AuthenticateSettings();

            obAuthSettings.OAuthConsumerKey    = "DummyKey";
            obAuthSettings.OAuthConsumerSecret = "DummySecret";
            obAuthSettings.OAuthUrl            = "https://api.twitter.com/oauth2/token";
            //Act
            IAuthenticate obAuthenticate = new Authenticate();
            AuthResponse  obAuthRespose  = obAuthenticate.AuthenticateConsumer(obAuthSettings);

            //Assert
            // When all valid parameter is passed, response is expected with access token
            //Exception is ecxpected
        }