mocha - How to do function tests for TWITTER API -


i creating web app project. want allow users post there blogs onto twitter using twitter api. generate blog inside website , if share blog via twitter. no testing if twitter api works, more if works inside of website, in if syntax appropriate, , if how incorporating correct. class project.

assuming using c# / asp.net, writing class make api calls can tested independently. suggest downloading open source twitterizer dll , plugging web project, oauth implementation.

so, if posting tweet, write static method follows:

public static bool createtweet(twitterizer.oauthtokens tokens, string tweettext) {     var response = twitterizer.twitterstatus.update(tokens, text);     return response.result == twitterizer.requestresult.success; } 

and test code this:

    void test()     {         var tokens = new tw.oauthtokens             {                 _accesstoken,                 _accesstokensecret,                 _consumerkey,                 _consumersecret,             };          var testtweet = "test tweet text";         createtweet(tokens, testtweet);     } 

you need obtain tokens either via twitter's login process or have them stored if don't expect users log in.

and test code above moved appropriate piece of code-behind in asp.net application , should work!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -