public async Task <Card> Update(CardModel cardModel) { var cardToUpdate = await _cardRepository.CardById(cardModel.Id); if (cardToUpdate != null) { CardMapper.UpdateTrapCardWith(cardToUpdate, cardModel); return(await _cardRepository.Update(cardToUpdate)); } return(null); }
public async Task Given_A_Card_Id_Should_Invoke_CardById_Method_Once() { // Arrange const long cardId = 4322; _cardRepository.CardById(Arg.Any <long>()).Returns(new Card()); // Act await _sut.CardById(cardId); // Assert await _cardRepository.Received(1).CardById(Arg.Is(cardId)); }
public async Task Given_A_CardModel_Should_Execute_Update_Method_Once() { // Arrange const int expected = 1; var cardModel = new CardModel(); _cardRepository.CardById(Arg.Any <long>()).Returns(new Card()); // Act await _sut.Update(cardModel); // Assert await _cardRepository.Received(expected).Update(Arg.Any <Card>()); }
public Task <Card> CardById(long cardId) { return(_cardRepository.CardById(cardId)); }