/// <summary> /// Adds the address. /// </summary> /// <param name="addressId">The address identifier.</param> /// <param name="addressLine1">The address line1.</param> /// <param name="addressLine2">The address line2.</param> /// <param name="addressLine3">The address line3.</param> /// <param name="addressLine4">The address line4.</param> /// <param name="town">The town.</param> /// <param name="region">The region.</param> /// <param name="postalCode">The postal code.</param> /// <param name="country">The country.</param> public void AddAddress(Guid addressId, String addressLine1, String addressLine2, String addressLine3, String addressLine4, String town, String region, String postalCode, String country) { this.EnsureMerchantHasBeenCreated(); AddressAddedEvent addressAddedEvent = new AddressAddedEvent(this.AggregateId, this.EstateId, addressId, addressLine1, addressLine2, addressLine3, addressLine4, town, region, postalCode, country); this.ApplyAndAppend(addressAddedEvent); }
public void MerchantDomainEventHandler_AddressAddedEvent_EventIsHandled() { AddressAddedEvent addressAddedEvent = TestData.AddressAddedEvent; Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>(); MerchantDomainEventHandler eventHandler = new MerchantDomainEventHandler(estateReportingRepository.Object); Logger.Initialise(NullLogger.Instance); Should.NotThrow(async() => { await eventHandler.Handle(addressAddedEvent, CancellationToken.None); }); }
/// <summary> /// Plays the event. /// </summary> /// <param name="addressAddedEvent">The address added event.</param> private void PlayEvent(AddressAddedEvent addressAddedEvent) { Address address = Address.Create(addressAddedEvent.AddressId, addressAddedEvent.AddressLine1, addressAddedEvent.AddressLine2, addressAddedEvent.AddressLine3, addressAddedEvent.AddressLine4, addressAddedEvent.Town, addressAddedEvent.Region, addressAddedEvent.PostalCode, addressAddedEvent.Country); this.Addresses.Add(address); }
public void AddressAddedEvent_CanBeCreated_IsCreated() { AddressAddedEvent addressAddedEvent = new AddressAddedEvent(TestData.MerchantId, TestData.EstateId, TestData.MerchantAddressId, TestData.MerchantAddressLine1, TestData.MerchantAddressLine2, TestData.MerchantAddressLine3, TestData.MerchantAddressLine4, TestData.MerchantTown, TestData.MerchantRegion, TestData.MerchantPostalCode, TestData.MerchantCountry); addressAddedEvent.ShouldNotBeNull(); addressAddedEvent.AggregateId.ShouldBe(TestData.MerchantId); addressAddedEvent.EventId.ShouldNotBe(Guid.Empty); addressAddedEvent.EstateId.ShouldBe(TestData.EstateId); addressAddedEvent.MerchantId.ShouldBe(TestData.MerchantId); addressAddedEvent.AddressId.ShouldBe(TestData.MerchantAddressId); addressAddedEvent.AddressLine1.ShouldBe(TestData.MerchantAddressLine1); addressAddedEvent.AddressLine2.ShouldBe(TestData.MerchantAddressLine2); addressAddedEvent.AddressLine3.ShouldBe(TestData.MerchantAddressLine3); addressAddedEvent.AddressLine4.ShouldBe(TestData.MerchantAddressLine4); addressAddedEvent.Town.ShouldBe(TestData.MerchantTown); addressAddedEvent.Region.ShouldBe(TestData.MerchantRegion); addressAddedEvent.PostalCode.ShouldBe(TestData.MerchantPostalCode); addressAddedEvent.Country.ShouldBe(TestData.MerchantCountry); }
/// <summary> /// Handles the specific domain event. /// </summary> /// <param name="domainEvent">The domain event.</param> /// <param name="cancellationToken">The cancellation token.</param> private async Task HandleSpecificDomainEvent(AddressAddedEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.AddMerchantAddress(domainEvent, cancellationToken); }
void IEmit <AddressAddedEvent> .Apply(AddressAddedEvent aggregateEvent) { // save address into field for later usage // .. }