public void CreateReviewOk()
        {
            var mock = new Mock <IReviewManagement>(MockBehavior.Strict);

            mock.Setup(m => m.Create(It.IsAny <Review>(), reserve.Id)).Returns(review);
            ReviewController reviewController = new ReviewController(mock.Object);

            var result        = reviewController.Post(reviewForRequest);
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as ReviewModelForResponse;
            var expected      = ReviewModelForResponse.ToModel(review);

            mock.VerifyAll();
            Assert.AreEqual(expected, model);
        }
Esempio n. 2
0
 public IActionResult Get(Guid id)
 {
     try
     {
         Review review = reviewManagement.GetById(id);
         return(Ok(ReviewModelForResponse.ToModel(review)));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
        public void GetReviewTestOk()
        {
            var mock = new Mock <IReviewManagement>(MockBehavior.Strict);

            mock.Setup(m => m.GetById(It.IsAny <Guid>())).Returns(review);
            ReviewController reviewController = new ReviewController(mock.Object);

            var result        = reviewController.Get(review.Id);
            var createdResult = result as OkObjectResult;
            var model         = createdResult.Value as ReviewModelForResponse;

            var expected = ReviewModelForResponse.ToModel(review);

            mock.VerifyAll();
            Assert.AreEqual(expected, model);
        }
Esempio n. 4
0
 public IActionResult Post([FromBody] ReviewModelForRequest aReviewModel)
 {
     try
     {
         Review review = reviewManagement.Create(ReviewModelForRequest.ToEntity(aReviewModel), aReviewModel.IdOfReserveAssociated);
         return(CreatedAtRoute("review", new { id = review.Id }, ReviewModelForResponse.ToModel(review)));
     }
     catch (DomainBusinessLogicException e)
     {
         return(BadRequest(e.Message));
     }
     catch (ClientBusinessLogicException e)
     {
         return(NotFound(e.Message));
     }
     catch (ServerBusinessLogicException e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
     }
 }
        public void SetUp()
        {
            image = new Picture()
            {
                Id   = Guid.NewGuid(),
                Path = "c:/MiDirectorio/Imagenes/Paisaje.png"
            };

            lodgingPicture = new LodgingPicture()
            {
                Picture   = image,
                PictureId = image.Id
            };


            lodgingTouristSpotModel = new TouristSpotModelForLodgingResponseModel()
            {
                Id   = Guid.NewGuid(),
                Name = "Punta del Este",
            };

            reviewModelForResponse = new ReviewModelForResponse()
            {
                Description           = "Muy buena",
                Id                    = Guid.NewGuid(),
                LastNameOfWhoComments = "Her",
                NameOfWhoComments     = "Agustin",
                Score                 = 3
            };

            lodgingModelForSearchResponse = new LodgingModelForResponse()
            {
                Id         = Guid.NewGuid(),
                Name       = "Hotel las cumbres",
                ImagesPath = new List <string> {
                    image.Path
                },
                Address                 = "En la punta de punta del este",
                QuantityOfStars         = 5,
                PricePerNight           = 150,
                LodgingTouristSpotModel = lodgingTouristSpotModel,
                ReviewsAverageScore     = 4.3,
                ReviewsForLodging       = new List <ReviewModelForResponse>()
                {
                    reviewModelForResponse
                }
            };

            review = new Review()
            {
                Description           = "Muy buena",
                Id                    = Guid.NewGuid(),
                LastNameOfWhoComments = "Her",
                NameOfWhoComments     = "Agustin",
                Score                 = 3
            };



            lodgingModelForResponse = new LodgingModelForResponse()
            {
                Id         = Guid.NewGuid(),
                Name       = "Hotel las cumbres",
                ImagesPath = new List <string> {
                    image.Path
                },
                Address                 = "En la punta de punta del este",
                QuantityOfStars         = 5,
                PricePerNight           = 150,
                LodgingTouristSpotModel = lodgingTouristSpotModel,
                ReviewsAverageScore     = 4.3,
                ReviewsForLodging       = new List <ReviewModelForResponse> {
                    reviewModelForResponse
                }
            };

            lodgingModelForRequest = new LodgingModelForRequest()
            {
                Id     = Guid.NewGuid(),
                Name   = "Hotel las cumbres",
                Images = new List <string> {
                    image.Path
                },
                Address         = "En la punta de punta del este",
                QuantityOfStars = 5,
                PricePerNight   = 150,
                TouristSpotId   = lodgingTouristSpotModel.Id
            };

            regionForTouristSpot = new Region()
            {
                Id   = Guid.NewGuid(),
                Name = Region.RegionName.Región_Centro_Sur,
            };

            category = new Category()
            {
                Id   = Guid.NewGuid(),
                Name = "Playa"
            };

            touristSpotAdded = new TouristSpot()
            {
                Id               = Guid.NewGuid(),
                Name             = "Punta del Este",
                Image            = image,
                Description      = "Un lugar increible",
                Region           = regionForTouristSpot,
                ListOfCategories = new List <CategoryTouristSpot>()
                {
                    new CategoryTouristSpot()
                    {
                        Category = category
                    }
                }
            };

            lodgingOfficial = new Lodging()
            {
                Id     = lodgingModelForRequest.Id,
                Name   = "Hotel las cumbres",
                Images = new List <LodgingPicture>()
                {
                    lodgingPicture
                },
                Address         = "En la punta de punta del este",
                QuantityOfStars = 5,
                PricePerNight   = 150,
                TouristSpot     = touristSpotAdded
            };

            lodgingForGet = new Lodging()
            {
                Id     = lodgingModelForSearchResponse.Id,
                Name   = "Hotel las cumbres",
                Images = new List <LodgingPicture>()
                {
                    lodgingPicture
                },
                Address             = "En la punta de punta del este",
                QuantityOfStars     = 5,
                PricePerNight       = 150,
                TouristSpot         = touristSpotAdded,
                ReviewsAverageScore = 4.3,
                Reviews             = new List <Review> {
                    review
                }
            };
        }