public Task <Guid> Handle(CreatePriceListItemCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = PriceListItem.Create(
                command.CountryCode,
                SubscriptionPeriod.Of(command.SubscriptionPeriodCode),
                PriceListItemCategory.Of(command.CategoryCode),
                MoneyValue.Of(command.PriceValue, command.PriceCurrency));

            _aggregateStore.AppendChanges(priceListItem);

            return(Task.FromResult(priceListItem.Id));
        }
Exemplo n.º 2
0
        public void CreatePriceListItem_IsSuccessful()
        {
            // Act
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Assert
            var priceListItemCreated = AssertPublishedDomainEvent <PriceListItemCreatedDomainEvent>(priceListItem);

            Assert.That(priceListItemCreated.PriceListItemId, Is.EqualTo(priceListItem.Id));
        }
Exemplo n.º 3
0
        public void ActivatePriceListItem_WhenItemIsActive_ThenActivationIgnored()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Act
            priceListItem.Activate();

            // Assert
            AssertDomainEventNotPublished <PriceListItemActivatedDomainEvent>(priceListItem);
        }
Exemplo n.º 4
0
        public void DeactivatePriceListItem_WhenItemNotActive_ThenDeactivationIgnored()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            priceListItem.Deactivate();

            // Act
            priceListItem.Deactivate();

            // Assert
            var priceListItemActivatedEvents = AssertPublishedDomainEvents <PriceListItemDeactivatedDomainEvent>(priceListItem);

            Assert.That(priceListItemActivatedEvents.Count, Is.EqualTo(1));
        }
Exemplo n.º 5
0
        public void ChangePriceListItem_IsSuccessful()
        {
            // Arrange
            var priceListItem = PriceListItem.Create(
                "BRA",
                SubscriptionPeriod.Month,
                PriceListItemCategory.New,
                MoneyValue.Of(50, "BRL"));

            // Act
            priceListItem.ChangeAttributes(
                "ARG",
                SubscriptionPeriod.HalfYear,
                PriceListItemCategory.Renewal,
                MoneyValue.Of(25, "ARS"));

            // Assert
            var priceListItemAttributesChangedEvent = AssertPublishedDomainEvent <PriceListItemAttributesChangedDomainEvent>(priceListItem);

            Assert.That(priceListItemAttributesChangedEvent.PriceListItemId, Is.EqualTo(priceListItem.Id));
        }