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); }
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)); }
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); }
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); }
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); }
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)); }