Exemple #1
0
        public void GetReviewByNotExistIdTestFailed()
        {
            var reviewMock = new Mock <IReviewRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Get(It.IsAny <Guid>())).Throws(new ClientException());

            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object);
            Review           reviewResult = reviewLogic.GetById(review.Id);
        }
Exemple #2
0
        public void GetReviewByIdTestOk()
        {
            var reviewMock = new Mock <IReviewRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(review);

            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object);
            Review           reviewResult = reviewLogic.GetById(review.Id);

            reviewMock.VerifyAll();
            Assert.IsTrue(review.Equals(reviewResult));
        }
Exemple #3
0
        public void CreateReviewInternalErrorWhenAddReviewFailedTest()
        {
            var reviewMock  = new Mock <IReviewRepository>(MockBehavior.Strict);
            var reserveMock = new Mock <IRepository <Reserve> >(MockBehavior.Strict);
            var lodgingMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Add(It.IsAny <Review>())).Throws(new ServerException());
            reserveMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(reserve);
            reviewMock.Setup(m => m.GetReviewByReserveId(It.IsAny <Guid>())).Returns(value: null);
            reviewMock.Setup(m => m.GetAverageReviewScoreByLodging(It.IsAny <Guid>())).Returns(4.0);
            lodgingMock.Setup(m => m.Update(lodging));

            IReserveManagement reserveLogic = new ReserveManagement(reserveMock.Object);
            ILodgingManagement lodgingLogic = new LodgingManagement(lodgingMock.Object);


            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object, reserveLogic, lodgingLogic);
            Review           reviewResult = reviewLogic.Create(review, reserve.Id);
        }
Exemple #4
0
        public void CreateReviewThatAlredyExistForThisCodeReserveFailedTest()
        {
            var reviewMock  = new Mock <IReviewRepository>(MockBehavior.Strict);
            var reserveMock = new Mock <IRepository <Reserve> >(MockBehavior.Strict);
            var lodgingMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Add(It.IsAny <Review>()));
            reserveMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(reserve);
            reviewMock.Setup(m => m.GetReviewByReserveId(It.IsAny <Guid>())).Returns(review);
            reviewMock.Setup(m => m.GetAverageReviewScoreByLodging(It.IsAny <Guid>())).Returns(4.0);
            lodgingMock.Setup(m => m.Update(lodging));

            IReserveManagement reserveLogic = new ReserveManagement(reserveMock.Object);
            ILodgingManagement lodgingLogic = new LodgingManagement(lodgingMock.Object);


            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object, reserveLogic, lodgingLogic);
            Review           reviewResult = reviewLogic.Create(review, reserve.Id);
        }
Exemple #5
0
        public void CreateReviewWithNumberOfStarsGreaterThanFiveFailedTest()
        {
            review.Score = 7;

            var reviewMock  = new Mock <IReviewRepository>(MockBehavior.Strict);
            var reserveMock = new Mock <IRepository <Reserve> >(MockBehavior.Strict);
            var lodgingMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Add(It.IsAny <Review>()));
            reserveMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(reserve);
            reviewMock.Setup(m => m.GetReviewByReserveId(It.IsAny <Guid>())).Returns(value: null);
            reviewMock.Setup(m => m.GetAverageReviewScoreByLodging(It.IsAny <Guid>())).Returns(4.0);
            lodgingMock.Setup(m => m.Update(lodging));

            IReserveManagement reserveLogic = new ReserveManagement(reserveMock.Object);
            ILodgingManagement lodgingLogic = new LodgingManagement(lodgingMock.Object);


            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object, reserveLogic, lodgingLogic);
            Review           reviewResult = reviewLogic.Create(review, reserve.Id);
        }
Exemple #6
0
        public void CreateReviewTestOk()
        {
            var reviewMock  = new Mock <IReviewRepository>(MockBehavior.Strict);
            var reserveMock = new Mock <IRepository <Reserve> >(MockBehavior.Strict);
            var lodgingMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            reviewMock.Setup(m => m.Add(It.IsAny <Review>()));
            reserveMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(reserve);
            reviewMock.Setup(m => m.GetReviewByReserveId(It.IsAny <Guid>())).Returns(value: null);
            reviewMock.Setup(m => m.GetAverageReviewScoreByLodging(It.IsAny <Guid>())).Returns(4.0);
            lodgingMock.Setup(m => m.Update(lodging));

            IReserveManagement reserveLogic = new ReserveManagement(reserveMock.Object);
            ILodgingManagement lodgingLogic = new LodgingManagement(lodgingMock.Object);


            ReviewManagement reviewLogic  = new ReviewManagement(reviewMock.Object, reserveLogic, lodgingLogic);
            Review           reviewResult = reviewLogic.Create(review, reserve.Id);

            reviewMock.VerifyAll();
            Assert.IsTrue(review.Equals(reviewResult));
        }