Example #1
0
        public void AddTransactionTo(CreditCard creditCard, Payment payment, DateTimeOffset now)
        {
            if (!Active)
            {
                throw new InvalidOperationException("Subscription not active");
            }
            var transaction = Transaction.CreatePayment(payment);

            creditCard.AddTransaction(transaction, now);
            var fee = _paymentFeeStrategy.CalculateFee(payment);

            if (fee != Money.Zero(payment.Value.CurrencyCode))
            {
                creditCard.AddTransaction(Transaction.CreateFee(fee, transaction.Id, now), now);
            }
        }
Example #2
0
        public void When_CreditCard_AddTransaction_Applies_CreditCardTransactionAdded()
        {
            var id    = CreditCardId.NewId();
            var subId = CreditCardSubscriptionId.NewId();

            var transaction =
                Transaction.CreatePayment(new Payment(PaymentId.NewId(), Money.CreateAUD(200), DateTimeOffset.Now));

            var sut = new CreditCard(id, subId, DateTimeOffset.Now);

            var actual = sut.GetUncommittedChanges();

            sut.AddTransaction(transaction, DateTimeOffset.Now);

            Assert.True(actual.OfType <CreditCardTransactionAdded>().Any(x =>
                                                                         x.Transaction.Id == transaction.Id &&
                                                                         x.Transaction.Value == transaction.Value &&
                                                                         x.AggregateId == id));
        }