Esempio n. 1
0
        public async Task ReturnBReviewDTO_IfParamsAreValid()
        {
            //Arrange
            var mockIDateTimeProvider = new Mock <IDateTimeProvider>();
            var mockIBarReviewMapper  = new Mock <IBarReviewMapper>();

            mockIBarReviewMapper
            .Setup(r => r.MapToBarReviewDTO(It.IsAny <BarsUsersReviews>()))
            .Returns <BarsUsersReviews>(r => new BarReviewDTO {
                BarId = r.BarId, AuthorId = r.UserId, Comment = r.Comment
            });

            var options = Utils.GetOptions(nameof(ReturnBReviewDTO_IfParamsAreValid));

            Utils.GetInMemoryDataBase(options);

            //Act & Assert
            using (var assertContext = new CocktailMagicianContext(options))
            {
                var sut = new BarReviewService(mockIDateTimeProvider.Object, assertContext, mockIBarReviewMapper.Object);

                var result = await sut.GetBarReviewAsync(2, 2);

                Assert.AreEqual(2, result.BarId);
                Assert.AreEqual(2, result.AuthorId);
            }
        }
Esempio n. 2
0
        public async Task ReturnNull_IfNoBarReview()
        {
            //Arrange
            var mockIDateTimeProvider = new Mock <IDateTimeProvider>();
            var mockIBarReviewMapper  = new Mock <IBarReviewMapper>();

            var options = Utils.GetOptions(nameof(ReturnNull_IfNoBarReview));

            Utils.GetInMemoryDataBase(options);

            //Act & Assert
            using (var assertContext = new CocktailMagicianContext(options))
            {
                var sut = new BarReviewService(mockIDateTimeProvider.Object, assertContext, mockIBarReviewMapper.Object);

                var result = await sut.GetBarReviewAsync(1, 1);

                Assert.IsNull(result);
            }
        }