public void DeleteAsync_ShouldThrowArgumentNullException() { mockRepo.Setup(x => x.Get(It.IsAny <Expression <Func <MemberFee, bool> > >())).ReturnsAsync(() => null); MemberFeeService memberFeeService = new MemberFeeService(mockUnitOfWork.Object); int id = 4; Func <Task> act = async() => await memberFeeService.DeleteAsync(id); act.Should().Throw <ArgumentNullException>(); }
public void DeleteAsync_ShouldDeleteOneFee() { mockUnitOfWork.Setup(x => x.SaveChangesAsync()).Verifiable(); mockRepo.Setup(x => x.Get(It.IsAny <Expression <Func <MemberFee, bool> > >())) .ReturnsAsync((Expression <Func <MemberFee, bool> > expression) => fakeMemberFees .AsQueryable() .Where(expression) .FirstOrDefault()); mockRepo.Setup(x => x.Remove(It.IsAny <MemberFee>())).Verifiable(); MemberFeeService memberFeeService = new MemberFeeService(mockUnitOfWork.Object); var result = memberFeeService.DeleteAsync(1); mockRepo.Verify(x => x.Remove(It.IsAny <MemberFee>()), Times.Once()); mockUnitOfWork.Verify(x => x.SaveChangesAsync(), Times.Once()); }