Exemplo n.º 1
0
        public void Should_Fail_Buy_Creditcards_Null()
        {
            var walletRepository     = Substitute.For <IWalletRepository>();
            var creditCardRepository = Substitute.For <ICreditCardRepository>();

            var wallet = new Wallet(GetUser());

            var walletService = new WalletService(walletRepository, creditCardRepository);

            Assert.Throws <ArgumentNullException>(() => walletService.Buy(wallet));
        }
Exemplo n.º 2
0
        public void Should_Buy_Success_With_Creditcards()
        {
            var walletRepository     = Substitute.For <IWalletRepository>();
            var creditCardRepository = Substitute.For <ICreditCardRepository>();

            var user = GetUser();

            var wallet = new Wallet(user)
            {
                CreditCards = new List <CreditCard>()
            };

            wallet.AddNewCreditCart(new CreditCard(user, CreditCardType.Visa, 4539012657749922, "MARIA FERNANDES ALVES", "01/18", 3, "669", 400));
            wallet.AddNewCreditCart(new CreditCard(user, CreditCardType.AmericanExpress, 344241982621208, "MARIA FERNANDES ALVES", "05/08", 15, "949", 100));

            walletRepository.UpdateUserCreditLimit(wallet);

            var walletService = new WalletService(walletRepository, creditCardRepository);

            walletService.Buy(wallet);

            walletRepository.Received().UpdateUserCreditLimit(Arg.Any <Wallet>());
        }