Last active
December 11, 2015 01:09
-
-
Save jharmn/4521814 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Binding] | |
| public class RestTestSteps | |
| { | |
| private string url; | |
| private string content; | |
| private WebClient wc = new WebClient(); | |
| JObject response; | |
| HttpStatusCode httpStatus; | |
| [Given(@"I access the resource url ""(.*)""")] | |
| public void GivenIAccessTheResourceUrl(string resourceUrl) | |
| { | |
| this.url = "https://api.twitter.com" + resourceUrl; | |
| } | |
| [When(@"I retrieve the results")] | |
| public void WhenRetrieveTheResults() | |
| { | |
| try | |
| { | |
| this.content = wc.DownloadString(url); | |
| this.httpStatus = HttpStatusCode.OK; | |
| } | |
| catch (WebException we) | |
| { | |
| this.httpStatus = ((HttpWebResponse)we.Response).StatusCode; | |
| } | |
| if (this.httpStatus.Equals(HttpStatusCode.OK)) | |
| { | |
| Assert.IsNotNullOrEmpty(this.content); | |
| this.response = (JObject)JToken.Parse(this.content); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment