public void Test_AddTour() { Tour tour = (Tour)_tourList[0]; _tourDalMock.Setup(s => s.AddTour(tour)); _tourService.AddTour(tour); _tourDalMock.Verify(s => s.AddTour(tour), Times.Once); }
public void AddTour_ValidTour_ReturnTrue() { // Arrange var mock = new Mock <IUnitOfWork>(); mock.Setup(unitOfWork => unitOfWork.TourRepository.AddAsync(It.IsAny <TourEntity>())).Verifiable(); mock.Setup(unitOfWork => unitOfWork.Commit()).Verifiable(); var tourService = new TourService(mock.Object); TourDto tour = new TourDto() { Name = "TourId", Price = 5 }; // Act var result = tourService.AddTour(tour); // Assert mock.Verify(moq => moq.Commit(), Times.Once); Assert.True(result); }