コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            });
        }