public async Task <int> RemoveTransactionAsync(int id) { var transaction = _context.GetTransactions().SingleOrDefault(t => t.ID == id); if (transaction != null) { _context.DeleteTransaction(transaction); } return(await _context.SaveChangesAsync()); }
public void DeleteTransaction_calls_EfCore_Remove() { // Arrange var mockTransactionSet = new Mock <DbSet <Transaction> >(); _mockContext.SetupGet(m => m.Transactions).Returns(mockTransactionSet.Object); var testTransaction = new Transaction(); // Act _testRepo.DeleteTransaction(testTransaction); // Assert mockTransactionSet.Verify(m => m.Remove(testTransaction), Times.Once()); }