public void Invoke_EmptyGuid_DeleteNorSaveAreCalled() { var mockedUserTokenRepository = new Mock <IUserTokenRepository>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var action = new DeleteUserTokenById(mockedUserTokenRepository.Object, mockedUnitOfWork.Object); // action var actionResult = action.Invoke(new Guid()); // assert Assert.False(actionResult); mockedUserTokenRepository.Verify(r => r.GetById(It.IsAny <Guid>()), Times.Never); mockedUserTokenRepository.Verify(r => r.Delete(It.IsAny <DataAccess.Models.UserToken>()), Times.Never); mockedUnitOfWork.Verify(r => r.Save(), Times.Never); }
public void Invoke_ValidData_DeleteAndSaveAreCalled() { // prepare var guid = Guid.NewGuid(); var userTokenFromDb = new DataAccess.Models.UserToken { Id = guid }; var mockedUserTokenRepository = new Mock <IUserTokenRepository>(); mockedUserTokenRepository.Setup(r => r.GetById(guid)).Returns(userTokenFromDb); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var action = new DeleteUserTokenById(mockedUserTokenRepository.Object, mockedUnitOfWork.Object); // action var actionResult = action.Invoke(guid); // assert Assert.True(actionResult); mockedUserTokenRepository.Verify(r => r.Delete(It.IsAny <DataAccess.Models.UserToken>()), Times.Once()); mockedUnitOfWork.Verify(r => r.Save(), Times.Once()); }