Beispiel #1
0
        public void Renew(
            SubscriptionRenewalPaymentSnapshot subscriptionRenewalPayment)
        {
            var expirationDate = SubscriptionDateExpirationCalculator.CalculateForRenewal(
                _expirationDate, subscriptionRenewalPayment.SubscriptionPeriod);

            SubscriptionRenewedDomainEvent subscriptionRenewedDomainEvent = new SubscriptionRenewedDomainEvent(
                this.Id,
                expirationDate,
                subscriptionRenewalPayment.PayerId.Value,
                subscriptionRenewalPayment.SubscriptionPeriod.Code,
                SubscriptionStatus.Active.Code);

            this.Apply(subscriptionRenewedDomainEvent);
            this.AddDomainEvent(subscriptionRenewedDomainEvent);
        }
        public void RenewSubscription_IsSuccessful()
        {
            // Arrange
            var subscriptionPaymentSnapshot = new SubscriptionPaymentSnapshot(
                new SubscriptionPaymentId(Guid.NewGuid()),
                new PayerId(Guid.NewGuid()),
                SubscriptionPeriod.Month,
                "PL");

            var subscription = Subscription.Create(subscriptionPaymentSnapshot);

            var subscriptionRenewalPaymentSnapshot = new SubscriptionRenewalPaymentSnapshot(
                new SubscriptionRenewalPaymentId(Guid.NewGuid()),
                new PayerId(Guid.NewGuid()),
                SubscriptionPeriod.Month,
                "PL");

            // Act
            subscription.Renew(subscriptionRenewalPaymentSnapshot);

            // Assert
            AssertPublishedDomainEvent <SubscriptionRenewedDomainEvent>(subscription);
        }