Ejemplo n.º 1
0
        public void UpDown_WhenEntryThereIs()
        {
            var repositoryStub = new Mock <IRepository <BlogEntry> >();
            var blog           = new BlogEntry(new User(0, ""), DateTime.Now, new Rating(0, 0), 0, "");

            repositoryStub.Setup(stub => stub.GetEntry(0)).Returns(blog);
            var ratingService = new RatingService <BlogEntry>(repositoryStub.Object);

            ratingService.DownVote(0);

            Assert.AreEqual(-1, blog.Rating.Sum);
        }
Ejemplo n.º 2
0
        public IHttpActionResult Downvote(int id, string typeEntry)
        {
            switch (typeEntry)
            {
            case "blog":
                ratingServiceBlog.DownVote(id);
                break;

            case "comment":
                ratingServiceComment.DownVote(id);
                break;

            case "news":
                ratingServiceNews.DownVote(id);
                break;
            }
            return(Ok("I downvoted" + id));
        }