示例#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 WithRemovedPostalCodeWhenSameLifetimeOfPreviouslyRemovedPostalCode(
            Fixture fixture,
            AddressId addressId,
            CrabHouseNumberMailCantonId crabHouseNumberMailCantonId,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab,
            CrabLifetime lifetime
            )
        {
            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithLifetime(lifetime);

            Assert(RegisteredAddressScenario(fixture)
                   .Given <AddressPostalCodeWasChanged>(addressId)
                   .Given <AddressHouseNumberMailCantonWasImportedFromCrab>(addressId,
                                                                            e => e.WithBeginDate(lifetime.BeginDateTime)
                                                                            .WithHouseNumberMailCantonId(crabHouseNumberMailCantonId))
                   .Given <AddressPositionWasRemoved>(addressId)
                   .Given <AddressHouseNumberMailCantonWasImportedFromCrab>(addressId,
                                                                            e => e.WithBeginDate(lifetime.BeginDateTime)
                                                                            .WithHouseNumberMailCantonId(crabHouseNumberMailCantonId)
                                                                            .WithCrabModification(CrabModification.Delete))
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         new AddressPostalCodeWasChanged(addressId, new PostalCode(importHouseNumberMailCantonFromCrab.MailCantonCode)),
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
示例#3
0
 public void ThenAddressPostalCodeWasChanged(
     Fixture fixture,
     AddressId addressId,
     ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab
     )
 {
     Assert(RegisteredAddressScenario(fixture)
            .When(importHouseNumberMailCantonFromCrab)
            .Then(addressId,
                  new AddressPostalCodeWasChanged(addressId, new PostalCode(importHouseNumberMailCantonFromCrab.MailCantonCode)),
                  importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
 }
示例#4
0
 public static AddressHouseNumberMailCantonWasImportedFromCrab ToLegacyEvent(this ImportHouseNumberMailCantonFromCrab command)
 {
     return(new AddressHouseNumberMailCantonWasImportedFromCrab(
                command.HouseNumberMailCantonId,
                command.HouseNumberId,
                command.MailCantonId,
                command.MailCantonCode,
                command.Lifetime,
                command.Timestamp,
                command.Operator,
                command.Modification,
                command.Organisation));
 }
示例#5
0
 public static ImportHouseNumberMailCantonFromCrab WithLifetime(this ImportHouseNumberMailCantonFromCrab command, CrabLifetime lifetime)
 {
     return(new ImportHouseNumberMailCantonFromCrab(
                command.HouseNumberMailCantonId,
                command.HouseNumberId,
                command.MailCantonId,
                command.MailCantonCode,
                lifetime,
                command.Timestamp,
                command.Operator,
                command.Modification,
                command.Organisation));
 }
示例#6
0
 private static void ImportHouseNumberMailCantonFromCrab(Address address, ImportHouseNumberMailCantonFromCrab message)
 {
     address.ImportHouseNumberMailCantonFromCrab(
         message.HouseNumberMailCantonId,
         message.HouseNumberId,
         message.MailCantonId,
         message.MailCantonCode,
         message.Lifetime,
         message.Timestamp,
         message.Operator,
         message.Modification,
         message.Organisation);
 }
示例#7
0
 public void ThenAddressRemovedException(
     AddressId addressId,
     AddressWasRegistered addressWasRegistered,
     AddressWasRemoved addressWasRemoved,
     ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab)
 {
     Assert(new Scenario()
            .Given(addressId,
                   addressWasRegistered,
                   addressWasRemoved)
            .When(importHouseNumberMailCantonFromCrab)
            .Throws(new AddressRemovedException($"Cannot change removed address for address id {addressId}")));
 }
示例#8
0
        public void WhenModificationIsCorrection(
            Fixture fixture,
            AddressId addressId,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab)
        {
            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithCrabModification(CrabModification.Correction);

            Assert(RegisteredAddressScenario(fixture)
                   .Given <AddressPostalCodeWasChanged>(addressId)
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         new AddressPostalCodeWasCorrected(addressId, new PostalCode(importHouseNumberMailCantonFromCrab.MailCantonCode)),
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
示例#9
0
        public void GivenCorrectedPostalCodeThenNoChangeWhenMailCantonCodeIsTheSame(
            Fixture fixture,
            AddressId addressId,
            AddressPostalCodeWasCorrected addressPostalCodeWasCorrected,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab
            )
        {
            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithCrabMailCantonCode(new CrabMailCantonCode(addressPostalCodeWasCorrected.PostalCode));

            Assert(RegisteredAddressScenario(fixture)
                   .Given(addressId, addressPostalCodeWasCorrected)
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
示例#10
0
        public void ThenAddressPostalCodeWasChangedWhenNewerLifetime(
            Fixture fixture,
            AddressId addressId,
            CrabLifetime lifetime,
            ImportHouseNumberMailCantonFromCrab importHouseNumberMailCantonFromCrab
            )
        {
            importHouseNumberMailCantonFromCrab = importHouseNumberMailCantonFromCrab
                                                  .WithLifetime(lifetime);

            Assert(RegisteredAddressScenario(fixture)
                   .Given <AddressPostalCodeWasChanged>(addressId)
                   .Given <AddressHouseNumberMailCantonWasImportedFromCrab>(addressId, e => e.WithBeginDate(lifetime.BeginDateTime.Value.PlusDays(-1)))
                   .When(importHouseNumberMailCantonFromCrab)
                   .Then(addressId,
                         new AddressPostalCodeWasChanged(addressId, new PostalCode(importHouseNumberMailCantonFromCrab.MailCantonCode)),
                         importHouseNumberMailCantonFromCrab.ToLegacyEvent()));
        }
示例#11
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()));
        }