public void CallUnitOfWorkCommit_OnlyOnce() { //Arrange var mockedUserRepository = new Mock <IEFGenericRepository <ApplicationUser> >(); var mockedToDoListModelRepository = new Mock <IEFGenericRepository <ToDoListModel> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedToDoList = new Mock <ToDoListModel>(); var toDoListModelService = new ToDoList.Services.ToDoListModelService(mockedToDoListModelRepository.Object, mockedUserRepository.Object, mockedUnitOfWork.Object); //Act toDoListModelService.DeleteToDoList(mockedToDoList.Object); //Assert mockedUnitOfWork.Verify(r => r.Commit(), Times.Once); }
public void Throw_WhenToDoListIsNull() { //Arrange var mockedUserRepository = new Mock <IEFGenericRepository <ApplicationUser> >(); var mockedToDoListModelRepository = new Mock <IEFGenericRepository <ToDoListModel> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var toDoListModelService = new ToDoList.Services.ToDoListModelService(mockedToDoListModelRepository.Object, mockedUserRepository.Object, mockedUnitOfWork.Object); //Act & Assert Assert.Throws <ArgumentNullException>(() => { toDoListModelService.DeleteToDoList(null); }); }