Skip to content

Instantly share code, notes, and snippets.

@jharmn
Last active December 11, 2015 01:09
Show Gist options
  • Select an option

  • Save jharmn/4521814 to your computer and use it in GitHub Desktop.

Select an option

Save jharmn/4521814 to your computer and use it in GitHub Desktop.
[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