public async void CanDeleteCreditAsync() { // Arrange _uowMock.Setup(x => x.WriteCredits.Delete(5)).Returns(() => Task.FromResult(1)); var creditWriteService = new CreditWriteService(_uowMock.Object); // Act await creditWriteService.RemoveCredit(5); // Assert _uowMock.Verify(x => x.WriteCredits.Delete(5), Times.Once); _uowMock.Verify(x => x.Save(), Times.Once); }
public async void CanUpdateCredit() { // Arrange var credit = new Credit { Id = 13 }; _uowMock.Setup(x => x.WriteCredits.Create(It.IsAny <CreditEntity>())).Returns(() => Task.FromResult(1)); _uowMock.Setup(x => x.WriteCredits.Update(It.IsAny <CreditEntity>())).Returns(() => Task.FromResult(1)); var creditWriteService = new CreditWriteService(_uowMock.Object); // Act await creditWriteService.UpsertCredit(credit); // Assert _uowMock.Verify(x => x.WriteCredits.Update(It.IsAny <CreditEntity>()), Times.Once); _uowMock.Verify(x => x.WriteCredits.Create(It.IsAny <CreditEntity>()), Times.Never); _uowMock.Verify(x => x.Save(), Times.Once); }