public void CallUnitOfWorkCommit_OnlyOnce() { //Arrange var mockedToDoListTaskRepository = new Mock <IEFGenericRepository <ToDoListTask> >(); var mockedUserRepository = new Mock <IEFGenericRepository <ApplicationUser> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedToDoTask = new Mock <ToDoListTask>(); var taskService = new ToDoListTaskService(mockedToDoListTaskRepository.Object, mockedUserRepository.Object, mockedUnitOfWork.Object); //Act taskService.DeleteTask(mockedToDoTask.Object); //Assert mockedUnitOfWork.Verify(r => r.Commit(), Times.Once); }
public void Throw_WhenTaskIsNull() { //Arrange var mockedToDoListTaskRepository = new Mock <IEFGenericRepository <ToDoListTask> >(); var mockedUserRepository = new Mock <IEFGenericRepository <ApplicationUser> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var taskService = new ToDoListTaskService(mockedToDoListTaskRepository.Object, mockedUserRepository.Object, mockedUnitOfWork.Object); //Act & Assert Assert.Throws <ArgumentNullException>(() => { taskService.DeleteTask(null); }); }