Ejemplo n.º 1
0
        public HttpResponseMessage Get(string category)
        {
            var theCategory = ParseCategory(category);

            if (theCategory.IsSpecified())
            {
                var reviews = _reviewTable.GetReviewsByCategory(theCategory);
                return(Request.CreateResponse(HttpStatusCode.OK, reviews));
            }
            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
        public void TestGetItemsByCategory()
        {
            var context = new Mock <IContext>();

            context.Setup(c => c.Environment).Returns("LOCAL");

            var db = new ReviewTable(_dbClient, context.Object);

            var result = db.GetReviewsByCategory(Category.Books).ToList();

            result.Should().NotBeEmpty();

            var itemToFetch = result.FirstOrDefault(i => i.Category.Equals(Category.Books));

            var theFetchedItem = db.GetReview(itemToFetch.Category, itemToFetch.Id);

            theFetchedItem.Should().NotBeNull();

            var anotherItemToFecth = db.GetReview(Category.Apps, itemToFetch.Id);

            anotherItemToFecth.Should().BeNull();
        }