public void Call_SaveChangesMethod_OfTheUnitOfWork() { // Arrange var comicsDataModels = new List <ComicsDataModel>() { new ComicsDataModel() { Title = "title", isDeleted = false } }; var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepo = new Mock <IEfRepository <ComicsDataModel> >(); mockedRepo.Setup(repo => repo.All).Returns(comicsDataModels); mockedUnitOfWork.Setup(unit => unit.SaveChanges()); var comicsService = new ComicsService(mockedUnitOfWork.Object, mockedRepo.Object); // Act comicsService.RemoveComic("title"); // Arrange mockedUnitOfWork.Verify(unit => unit.SaveChanges(), Times.Once); }
public void ThrowArgumentNullException_WhenIsPassed_InvalidValue() { // Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepo = new Mock <IEfRepository <ComicsDataModel> >(); var comicsService = new ComicsService(mockedUnitOfWork.Object, mockedRepo.Object); // Act & Assert Assert.That(() => comicsService.RemoveComic(null), Throws.ArgumentNullException.With.Message.Contain("title")); }