public void CorrectMapping_ToBarReviewDTO()
        {
            //Arrange
            var sut = new BarReviewMapper();

            var options = Utils.GetOptions(nameof(CorrectReturnInstanceType_ToBarReviewDTO));
            var bar     = new Bar {
                Id = 1, Name = "Lorka"
            };
            var user = new User {
                Id = 2, UserName = "******"
            };
            var review = new BarsUsersReviews
            {
                BarId   = 1,
                Bar     = bar,
                UserId  = 2,
                User    = user,
                Comment = "Top!",
                Rating  = 4
            };

            //Act
            var result = sut.MapToBarReviewDTO(review);

            //Assert
            Assert.AreEqual(review.BarId, result.BarId);
            Assert.AreEqual(review.UserId, result.AuthorId);
            Assert.AreEqual(review.Bar.Name, result.BarName);
            Assert.AreEqual(review.User.UserName, result.Author);
            Assert.AreEqual(review.Comment, result.Comment);
            Assert.AreEqual(review.Rating, result.Rating);
        }
        public void CorrectReturnInstanceType_ToBarReviewDTO()
        {
            //Arrange
            var sut = new BarReviewMapper();

            var bar = new Bar {
                Id = 1, Name = "Lorka"
            };
            var user = new User {
                Id = 2, UserName = "******"
            };
            var review = new BarsUsersReviews
            {
                BarId   = 1,
                Bar     = bar,
                UserId  = 2,
                User    = user,
                Comment = "Top!",
                Rating  = 4
            };

            //Act
            var result = sut.MapToBarReviewDTO(review);

            //Assert
            Assert.IsInstanceOfType(result, typeof(BarReviewDTO));
        }
Beispiel #3
0
        public BarsUsersReviews MapToBarReview(BarReviewDTO reviewDTO)
        {
            BarsUsersReviews review = new BarsUsersReviews
            {
                Rating  = reviewDTO.Rating,
                Comment = reviewDTO.Comment,
                BarId   = reviewDTO.BarId,
                UserId  = reviewDTO.AuthorId
            };

            return(review);
        }
Beispiel #4
0
        public BarReviewDTO MapToBarReviewDTO(BarsUsersReviews review)
        {
            BarReviewDTO reviewDTO = new BarReviewDTO
            {
                Rating   = review.Rating,
                Comment  = review.Comment,
                BarId    = review.BarId,
                AuthorId = review.UserId,
                BarName  = review.Bar.Name,
                Author   = review.User.UserName
            };

            return(reviewDTO);
        }