public void DeleteExceptionTest() { Accommodation accommodation = new Accommodation() { Id = 3, Name = "ayi" }; var mockAccommodation = new Mock <IAccommodationRepository>(MockBehavior.Strict); mockAccommodation.Setup(p => p.GetByName(It.IsAny <string>())).Returns <Accommodation>(null); mockAccommodation.Setup(p => p.Delete(It.IsAny <Accommodation>())).Returns(accommodation); var mockTouristicSpot = new Mock <ITouristicSpotRepository>(MockBehavior.Strict); var mockReview = new Mock <IReviewRepository>(MockBehavior.Strict); var mockBooking = new Mock <IBookingRepository>(MockBehavior.Strict); var logic = new AccommodationLogic(mockAccommodation.Object, mockTouristicSpot.Object, mockReview.Object, mockBooking.Object); logic.DeleteAccommodation(accommodation); }
public void DeleteTest() { Accommodation accommodation = new Accommodation() { Id = 2, Name = "abz" }; var mockAccommodation = new Mock <IAccommodationRepository>(MockBehavior.Strict); mockAccommodation.Setup(p => p.GetByName(It.IsAny <string>())).Returns(accommodation); mockAccommodation.Setup(p => p.Delete(It.IsAny <Accommodation>())).Returns(accommodation); var mockTouristicSpot = new Mock <ITouristicSpotRepository>(MockBehavior.Strict); var mockReview = new Mock <IReviewRepository>(MockBehavior.Strict); var mockBooking = new Mock <IBookingRepository>(MockBehavior.Strict); var logic = new AccommodationLogic(mockAccommodation.Object, mockTouristicSpot.Object, mockReview.Object, mockBooking.Object); var result = logic.DeleteAccommodation(accommodation); mockAccommodation.VerifyAll(); Assert.AreEqual(result, accommodation); }