public void TestLikeItem() { var context = new Mock <IContext>(); context.Setup(c => c.Environment).Returns("LOCAL"); var db = new ReviewTable(_dbClient, context.Object); var result = db.GetReviews().ToList(); result.Should().NotBeEmpty(); var itemToFetch = result.First(); var theFetchedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id); theFetchedItem.Should().NotBeNull(); var likes = theFetchedItem.Likes; db.LikeReview(theFetchedItem.Category, theFetchedItem.Id); // TODO: return the new number of likes? // may not be updated immediatley of course, but let's see... var theLikedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id); theLikedItem.Should().NotBeNull(); theLikedItem.Likes.Should().BeGreaterThan(likes); }
public HttpResponseMessage Get(string category, Guid id) { var theCategory = ParseCategory(category); if (theCategory.IsSpecified()) { // todo: exception handling on GetReview var review = _reviewTable.GetReview(theCategory, id); return(Request.CreateResponse(HttpStatusCode.OK, review)); } return(new HttpResponseMessage(HttpStatusCode.NotFound)); }
public void TestGetItems() { var context = new Mock <IContext>(); context.Setup(c => c.Environment).Returns("LOCAL"); var db = new ReviewTable(_dbClient, context.Object); var result = db.GetReviews().ToList(); result.Should().NotBeEmpty(); var itemToFetch = result.First(); var theFetchedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id); theFetchedItem.Should().NotBeNull(); var anotherItemToFecth = db.GetReview(Category.Apps, Guid.NewGuid()); anotherItemToFecth.Should().BeNull(); }