public void When_Making_Transaction_With_Credit_Card_Token_Should_Not_Throw_Exception()
        {
            //Arrange 
            UserCreditCard userCreditCard = new UserCreditCard
            {
                UserId = 1,
                AmountInCents = 1000,
                IsSavingCreditCardInToken = true,
                InstallmentCount = 1
            };

            Guid instantBuyKey = new Guid("33B92AFF-4F90-4F6A-A0FB-18FA50DBA364");

            CreditCardToken creditCardToken = new CreditCardToken
            {
                UserId = 1,
                CreditCardTokenId = instantBuyKey
            };

            var creditCardTokenRepositoryMock = new Mock<ICreditCardTokenRepository>();

            creditCardTokenRepositoryMock.Setup(x => x.GetCreditCardTokenByUserId(1)).Returns(creditCardToken);

            ICreditCardTokenService creditCardTokenService = new CreditCardTokenService(creditCardTokenRepositoryMock.Object);
            ICreditCardCompany mundipaggCompany = new MundipaggCompany(creditCardTokenService);

            //Act
            //Assert            
            mundipaggCompany.MakeTransactionWithCreditCardToken(userCreditCard);
        }
 public void AddCreditCardToken(CreditCardToken newToken)
 {
     if (UserHasCreditCardToken(newToken.UserId))
     {
         CreditCardToken deletedToken = GetCreditCardTokenByUserId(newToken.UserId);
         _creditCardTokenRepository.DeleteCreditCardToken(deletedToken);
     }
     
     _creditCardTokenRepository.AddCreditCardToken(newToken);
     _creditCardTokenRepository.Save();
 }
 public void DeleteCreditCardToken(CreditCardToken token)
 {
     _context.CreditCardsTokens.Remove(token);
 }
 public void AddCreditCardToken(CreditCardToken token)
 {
     _context.CreditCardsTokens.Add(token);
 }
        private void SaveTokenCreditCard(Guid InstantBuyKey, int userId)
        {
            CreditCardToken token = new CreditCardToken
            {
                CreditCardTokenId = InstantBuyKey,
                UserId = userId
            };

            _creditCardTokenService.AddCreditCardToken(token);
        }