public void CallUnitOfWorksCommit_OnlyOnce() { //Arrange var mockedToDoListTaskRepository = new Mock <IEFGenericRepository <ToDoListTask> >(); var mockedUserRepository = new Mock <IEFGenericRepository <ApplicationUser> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedTask = new Mock <ToDoListTask>(); var taskService = new ToDoListTaskService(mockedToDoListTaskRepository.Object, mockedUserRepository.Object, mockedUnitOfWork.Object); //Act taskService.UpdateTask(mockedTask.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.UpdateTask(null); }); }