cairey/Let-Me-Rate-NancyFX
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A restful API for a rating service built on top of Nancy and Simple.Data. How many times have you recreated ratings for an applicaion? Every response is JSON format. See the tests for how to use https://github.com/cairey/Let-Me-Rate/tree/master/source/LetMeRate.Web.Acceptance.Specs/Steps An example: Step 1 - Create an account to get an Account Key _response = Browser.Post("/Account/Create", with => { with.HttpRequest(); with.FormValue("EmailAddress", "example@example.com"); with.FormValue("Password", "Pa55word"); with.FormValue("RateOutOf", "100"); }); Step 2 - Validate the Account Key _response = Browser.Post(string.Format("/Account/Validate"), with => { with.HttpRequest(); with.FormValue("ValidationKey", (string)validationKey); }); Step 3 - Anything now requires a token key to make requests. Below gets a temp token (token last once per request) Step 4 - We can start adding ratings! [When(@"adding a rating for my account")] public void WhenAddingARatingForMyAccount() { var accountKey = FeatureContext.Current["AccountKey"]; var response = Browser.Post(string.Format("/{0}/Authorisation", accountKey), with => { with.HttpRequest(); with.FormValue("IPAddress", "192.168.129.189"); }); var responseString = response.GetBodyAsString(); var jss = new JavaScriptSerializer(); var result = jss.Deserialize<Dictionary<string, object>>(responseString); var tokenKey = result["TokenKey"]; uniqueKey = 1; _response = Browser.Post(string.Format("/{0}/Ratings", tokenKey), with => { with.HttpRequest(); with.FormValue("Rating", "10"); with.FormValue("UniqueKey", uniqueKey.ToString()); with.FormValue("CustomParams", "{ \"RelatedContent\": \"1234\" }"); }); }
About
Need a rating service? Using Nancy and Simple.Data
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published