Пример #1
0
        public void ThenNoPostalCodeChangeWhenOlderLifetime(
            Fixture fixture,
            AddressId addressId,
            CrabLifetime lifetime,
            string mailCantonCode,
            Provenance provenance,
            AddressHouseNumberMailCantonWasImportedFromCrab addressHouseNumberMailCantonWasImportedFromCrab,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab)
        {
            addressHouseNumberMailCantonWasImportedFromCrab = addressHouseNumberMailCantonWasImportedFromCrab
                                                              .WithBeginDate(lifetime.BeginDateTime.Value.PlusDays(1))
                                                              .WithPostalCode(mailCantonCode);

            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithLifetime(lifetime);

            var addressPostalCodeWasChanged = new AddressPostalCodeWasChanged(addressId, new PostalCode(mailCantonCode));

            ((ISetProvenance)addressPostalCodeWasChanged).SetProvenance(provenance);

            Assert(RegisteredAddressScenario(fixture)
                   .Given(addressId,
                          addressPostalCodeWasChanged,
                          addressHouseNumberMailCantonWasImportedFromCrab)
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
Пример #2
0
        public void ImportHouseNumberMailCantonFromCrab(
            CrabHouseNumberMailCantonId houseNumberMailCantonId,
            CrabHouseNumberId houseNumberId,
            CrabMailCantonId mailCantonId,
            CrabMailCantonCode mailCantonCode,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            if (!IsSubaddress)
            {
                GuardRemoved(modification);
            }

            var legacyEvent = new AddressHouseNumberMailCantonWasImportedFromCrab(
                houseNumberMailCantonId,
                houseNumberId,
                mailCantonId,
                mailCantonCode,
                lifetime,
                timestamp,
                @operator,
                modification,
                organisation);

            if (!(IsSubaddress && IsRemoved) && !(_coupledHouseNumberId != null && _coupledHouseNumberId != houseNumberId))
            {
                ApplyPostalCodeChangeFor(legacyEvent);
            }

            ApplyChange(legacyEvent);
        }
Пример #3
0
 public static ImportHouseNumberMailCantonFromCrab ToCommand(this AddressHouseNumberMailCantonWasImportedFromCrab @event)
 {
     return(new ImportHouseNumberMailCantonFromCrab(
                new CrabHouseNumberMailCantonId(@event.HouseNumberMailCantonId),
                new CrabHouseNumberId(@event.HouseNumberId),
                new CrabMailCantonId(@event.MailCantonId),
                new CrabMailCantonCode(@event.MailCantonCode),
                new CrabLifetime(@event.BeginDateTime, @event.EndDateTime),
                new CrabTimestamp(@event.Timestamp),
                new CrabOperator(@event.Operator),
                @event.Modification,
                @event.Organisation));
 }
Пример #4
0
 public static AddressHouseNumberMailCantonWasImportedFromCrab WithBeginDate(this AddressHouseNumberMailCantonWasImportedFromCrab @event, LocalDateTime?beginDate)
 {
     return(new AddressHouseNumberMailCantonWasImportedFromCrab(
                new CrabHouseNumberMailCantonId(@event.HouseNumberMailCantonId),
                new CrabHouseNumberId(@event.HouseNumberId),
                new CrabMailCantonId(@event.MailCantonId),
                new CrabMailCantonCode(@event.MailCantonCode),
                new CrabLifetime(beginDate, @event.EndDateTime),
                new CrabTimestamp(@event.Timestamp),
                new CrabOperator(@event.Operator),
                @event.Modification,
                @event.Organisation));
 }
Пример #5
0
        private void ApplyPostalCodeChangeFor(
            AddressHouseNumberMailCantonWasImportedFromCrab legacyEvent,
            CrabModification?modification = null)
        {
            var crabMailCanton = _mailCantonChronicle.MostCurrent(legacyEvent);
            var newPostalCode  = crabMailCanton == null ? null : new PostalCode(crabMailCanton.MailCantonCode);

            if (_postalCode != newPostalCode && crabMailCanton != null)
            {
                if ((modification ?? crabMailCanton.Modification) != CrabModification.Correction)
                {
                    ApplyChange(new AddressPostalCodeWasChanged(_addressId, newPostalCode));
                }
                else
                {
                    ApplyChange(new AddressPostalCodeWasCorrected(_addressId, newPostalCode));
                }
            }
            else if (crabMailCanton == null && _postalCode != null)
            {
                ApplyChange(new AddressPostalCodeWasRemoved(_addressId));
            }
        }
Пример #6
0
        public void ThenAddressPostalCodeWasRemovedWhenModificationIsDelete(
            Fixture fixture,
            AddressId addressId,
            AddressPostalCodeWasChanged addressPostalCodeWasChanged,
            AddressHouseNumberMailCantonWasImportedFromCrab addressHouseNumberMailCantonWasImportedFromCrab,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab
            )
        {
            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithCrabModification(CrabModification.Delete)
                                                  .WithCrabMailCantonCode(new CrabMailCantonCode(addressPostalCodeWasChanged.PostalCode));

            addressHouseNumberMailCantonWasImportedFromCrab = addressHouseNumberMailCantonWasImportedFromCrab
                                                              .WithCrabModification(CrabModification.Insert)
                                                              .WithHouseNumberMailCantonId(importHouseNumberMailCantonFromCrab.HouseNumberMailCantonId)
                                                              .WithPostalCode(addressPostalCodeWasChanged.PostalCode);

            Assert(RegisteredAddressScenario(fixture)
                   .Given(addressId, addressPostalCodeWasChanged, addressHouseNumberMailCantonWasImportedFromCrab)
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         new AddressPostalCodeWasRemoved(addressId),
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
Пример #7
0
 private void When(AddressHouseNumberMailCantonWasImportedFromCrab @event)
 {
     _mailCantonChronicle.Add(@event);
     _lastHouseNumberMailCantonEventsForSubaddress[new CrabHouseNumberId(@event.HouseNumberId)] = @event;
     WhenCrabEventApplied();
 }
Пример #8
0
 public static AddressHouseNumberMailCantonWasImportedFromCrab WithBeginDate(this AddressHouseNumberMailCantonWasImportedFromCrab @event, DateTimeOffset?beginDate)
 {
     return(@event.WithBeginDate(beginDate.HasValue ? LocalDateTime.FromDateTime(beginDate.Value.LocalDateTime) : new LocalDateTime?()));
 }