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)); }
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)); }
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); }
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)); }
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)); }