public void TwoInstances_SameIdInput_AreEqual()
 {
     const int identityId = 13251235;
     var sut1 = new ShoppingCart { Id = identityId };
     var sut2 = new ShoppingCart { Id = identityId };
     Assert.AreEqual(sut1, sut2);
 }
 public PaymentGatewayResultDTO ApprovePayment(ShoppingCart shoppingCart)
 {
     // happy path
     return new PaymentGatewayResultDTO
                {
                    ApprovedTotal = shoppingCart.Total
                };
 }
 public void ToStringMethod_IdInput_ReturnsConcatPropertyDescription()
 {
     var sut = new ShoppingCart
                   {
                       Id = 12351235,
                       Account = new Account
                                     {
                                         Id = 1235,
                                         CreditCardInfo = new CreditCardInfo
                                                              {
                                                                  Id = 1235123
                                                              }
                                     },
                       Total = 35.27M
                   };
     const string expected = "[type:ShoppingCart] Id=12351235 Properties:Account=[type:Account] Id=1235 Properties:CreditCardInfo=[type:CreditCardInfo] Id=1235123 Properties:none||Total=35.27|";
     Assert.AreEqual(expected, sut.ToString());
 }
        public void GetPaymentApprovalAndGenerateTransactionMethod_AccountPassedToConstructor_GeneratesApprovalAndTransaction()
        {
            // declare constants
            const decimal totalAmount = 35.27M;
            const int accountId = 12354;
            var shoppingCart = new ShoppingCart
                                   {
                                       Id = 12531515,
                                       Total = totalAmount,
                                       Account = new Account
                                                     {
                                                         Id = accountId,
                                                         CreditCardInfo = new CreditCardInfo()
                                                     }
                                   };

            var paymentGatewayResultDto = new PaymentGatewayResultDTO
                                              {
                                                  ApprovedTotal = totalAmount
                                            };

            var transaction = new Transaction
                                  {
                                      GrossAmount = totalAmount
                                  };

            // set expectations
            Expect.Call(_accountRepository.GetCurrentShoppingCart(accountId)).Return(shoppingCart);
            Expect.Call(_paymentGateway.ApprovePayment(shoppingCart)).Return(paymentGatewayResultDto);
            _transactionsRepository.Save(transaction);

            _mockRepository.ReplayAll();

            var sut = new ProcessTransactionService(_accountRepository, _transactionsRepository, _paymentGateway);
            sut.GetPaymentApprovalAndGenerateTransaction(accountId);

            _mockRepository.VerifyAll();

            Assert.AreEqual(shoppingCart.Total, paymentGatewayResultDto.ApprovedTotal);
            Assert.AreEqual(paymentGatewayResultDto.ApprovedTotal, transaction.GrossAmount);
        }