コード例 #1
0
        public void GetByRestaurantWithNotFoundResponse()
        {
            facade.Setup(x => x.GetByRestaurantId(It.IsAny <long>())).Returns(new List <Review>());
            controller = new ReviewController(facade.Object);
            var result = controller.GetByRestaurant(0);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
コード例 #2
0
        public void GetByRestaurantTest()
        {
            controller = new ReviewController(facade.Object);
            var result           = controller.GetByRestaurant(0);
            var contentResult    = result as OkNegotiatedContentResult <List <Review> >;
            var listFromResponse = contentResult.Content;

            Assert.AreEqual(listFromResponse.First().Restaurant, review.Restaurant);
            Assert.AreEqual(listFromResponse.First().Comment, review.Comment);
            Assert.AreEqual(listFromResponse.First().RatingDateTime, review.RatingDateTime);
            Assert.AreEqual(listFromResponse.First().RestaurantId, review.RestaurantId);
            Assert.AreEqual(listFromResponse.First().ReviewId, review.ReviewId);
            Assert.AreEqual(listFromResponse.First().Score, review.Score);
            Assert.AreEqual(listFromResponse.First().User, review.User);
            Assert.AreEqual(listFromResponse.First().UserId, review.UserId);
        }