Exemple #1
0
        public void ImportHouseNumberStatusFromCrab(
            CrabHouseNumberStatusId houseNumberStatusId,
            CrabHouseNumberId houseNumberId,
            CrabAddressStatus addressStatus,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            GuardRemoved(modification);

            var legacyEvent = new AddressHouseNumberStatusWasImportedFromCrab(
                houseNumberStatusId,
                houseNumberId,
                addressStatus,
                lifetime,
                timestamp,
                @operator,
                modification,
                organisation);

            ApplyStatusChangesFor(_houseNumberStatusChronicle, legacyEvent);

            ApplyAddressCompletion();

            ApplyChange(legacyEvent);
        }
 public ImportTerrainObjectFromCrab(
     VbrCaPaKey caPaKey,
     CrabTerrainObjectId terrainObjectId,
     CrabIdentifierTerrainObject identifierTerrainObject,
     CrabTerrainObjectNatureCode terrainObjectNatureCode,
     CrabCoordinate xCoordinate,
     CrabCoordinate yCoordinate,
     CrabBuildingNature buildingNature,
     CrabLifetime lifetime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     CaPaKey                 = caPaKey;
     TerrainObjectId         = terrainObjectId;
     IdentifierTerrainObject = identifierTerrainObject;
     TerrainObjectNatureCode = terrainObjectNatureCode;
     XCoordinate             = xCoordinate;
     YCoordinate             = yCoordinate;
     BuildingNature          = buildingNature;
     Lifetime                = lifetime;
     Timestamp               = timestamp;
     Operator                = @operator;
     Modification            = modification;
     Organisation            = organisation;
 }
Exemple #3
0
        public void WithStatusDeleteWhenNewerStatusIsPresent(AddressId addressId,
                                                             AddressWasRegistered addressWasRegistered,
                                                             AddressWasProposed addressWasProposed,
                                                             AddressWasOfficiallyAssigned addressWasOfficiallyAssigned,
                                                             AddressSubaddressStatusWasImportedFromCrab addressSubaddressStatusWasImportedFromCrabForProposed,
                                                             AddressBecameCurrent addressBecameCurrent,
                                                             AddressSubaddressStatusWasImportedFromCrab addressSubaddressStatusWasImportedFromCrabForCurrent,
                                                             ImportSubaddressStatusFromCrab importSubaddressStatusFromCrabDeleteProposed)
        {
            var lifetime       = new CrabLifetime(LocalDateTime.FromDateTime(DateTime.Now), null);
            var deleteProposed = importSubaddressStatusFromCrabDeleteProposed
                                 .WithStatus(CrabAddressStatus.InUse)
                                 .WithLifetime(lifetime)
                                 .WithCrabModification(CrabModification.Delete)
                                 .WithStatusId(new CrabSubaddressStatusId(addressSubaddressStatusWasImportedFromCrabForProposed.SubaddressStatusId));

            addressSubaddressStatusWasImportedFromCrabForProposed = addressSubaddressStatusWasImportedFromCrabForProposed
                                                                    .WithBeginDate(lifetime.BeginDateTime)
                                                                    .WithStatus(CrabAddressStatus.Proposed);
            addressSubaddressStatusWasImportedFromCrabForCurrent = addressSubaddressStatusWasImportedFromCrabForCurrent
                                                                   .WithBeginDate(lifetime.BeginDateTime)
                                                                   .WithStatus(CrabAddressStatus.InUse);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasProposed,
                          addressWasOfficiallyAssigned,
                          addressSubaddressStatusWasImportedFromCrabForProposed,
                          addressBecameCurrent,
                          addressSubaddressStatusWasImportedFromCrabForCurrent)
                   .When(deleteProposed)
                   .Then(addressId,
                         deleteProposed.ToLegacyEvent()));
        }
Exemple #4
0
        private void EvaluateRetirement(
            CrabLifetime crabLifetime,
            CrabModification?modification)
        {
            if (crabLifetime.EndDateTime.HasValue && _status != AddressStatus.Retired)
            {
                if (modification == CrabModification.Correction)
                {
                    ApplyStatusCorrection(AddressStatus.Retired);
                }
                else
                {
                    ApplyStatusChange(AddressStatus.Retired);
                }
            }

            if (!crabLifetime.EndDateTime.HasValue && _status == AddressStatus.Retired)
            {
                if (modification == CrabModification.Correction)
                {
                    ApplyStatusCorrection(_previousStatus);
                }
                else
                {
                    ApplyStatusChange(_previousStatus);
                }
            }

            EvaluatePositionChange();

            ApplyAddressCompletion();
        }
 public ImportStreetNameFromCrab(
     CrabStreetNameId streetNameId,
     CrabMunicipalityId municipalityId,
     NisCode nisCode,
     CrabStreetName primaryStreetName,
     CrabStreetName secondaryStreetName,
     CrabTransStreetName primaryTransStreetName,
     CrabTransStreetName secondaryTransStreetName,
     CrabLanguage?primaryLanguage,
     CrabLanguage?secondaryLanguage,
     CrabLifetime lifeTime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     StreetNameId             = streetNameId;
     MunicipalityId           = municipalityId;
     NisCode                  = nisCode;
     PrimaryStreetName        = primaryStreetName;
     SecondaryStreetName      = secondaryStreetName;
     PrimaryTransStreetName   = primaryTransStreetName;
     SecondaryTransStreetName = secondaryTransStreetName;
     PrimaryLanguage          = primaryLanguage;
     SecondaryLanguage        = secondaryLanguage;
     LifeTime                 = lifeTime;
     Timestamp                = timestamp;
     Operator                 = @operator;
     Modification             = modification;
     Organisation             = organisation;
 }
Exemple #6
0
        public void ImportSubaddressStatusFromCrab(
            CrabSubaddressStatusId subaddressStatusId,
            CrabSubaddressId subaddressId,
            CrabAddressStatus addressStatus,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            if (IsRemoved && modification != CrabModification.Delete)
            {
                return;
            }

            var legacyEvent = new AddressSubaddressStatusWasImportedFromCrab(
                subaddressStatusId,
                subaddressId,
                addressStatus,
                lifetime,
                timestamp,
                @operator,
                modification,
                organisation);

            ApplyStatusChangesFor(_subAddressStatusChronicle, legacyEvent);

            ApplyAddressCompletion();

            ApplyChange(legacyEvent);
        }
Exemple #7
0
        public void ImportSubaddressPositionFromCrab(
            CrabAddressPositionId addressPositionId,
            CrabSubaddressId subaddressId,
            WkbGeometry addressPosition,
            CrabAddressPositionOrigin addressPositionOrigin,
            CrabAddressNature addressNature,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            if (IsRemoved && modification != CrabModification.Delete)
            {
                return;
            }

            var legacyEvent = new AddressSubaddressPositionWasImportedFromCrab(
                addressPositionId,
                subaddressId,
                addressPosition,
                addressPositionOrigin,
                addressNature,
                lifetime,
                timestamp,
                @operator,
                modification,
                organisation);

            ApplyPositionChangeFor <AddressSubaddressPositionWasImportedFromCrab, int>(_crabSubaddressPositionEvents, legacyEvent);

            ApplyAddressCompletion();

            ApplyChange(legacyEvent);
        }
Exemple #8
0
        public void ImportHouseNumberPositionFromCrab(
            CrabAddressPositionId addressPositionId,
            CrabHouseNumberId houseNumberId,
            WkbGeometry addressPosition,
            CrabAddressPositionOrigin addressPositionOrigin,
            CrabAddressNature addressNature,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            GuardRemoved(modification);

            var legacyEvent = new AddressHouseNumberPositionWasImportedFromCrab(
                addressPositionId,
                houseNumberId,
                addressPosition,
                addressPositionOrigin,
                addressNature,
                lifetime,
                timestamp,
                @operator,
                modification,
                organisation);

            ApplyPositionChangeFor <AddressHouseNumberPositionWasImportedFromCrab, int>(_crabHouseNumberPositionEvents, legacyEvent);

            ApplyAddressCompletion();

            ApplyChange(legacyEvent);
        }
Exemple #9
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);
        }
        public void AppliesStatusChangedWhenStatusWasInsertedAfterAnotherWasRemoved()
        {
            //1: Given set status
            //2: => delete status from step 1
            //3: => import new status with same lifetime
            //

            var register = Arrange(Generate.StreetNameWasRegistered);

            var sut = StreetName.Factory();

            sut.Initialize(new List <object> {
                register
            });

            var crabLifetime  = new CrabLifetime(new DateTime(1830, 1, 1).ToCrabLocalDateTime(), null);
            var firstStatusId = Arrange(Generate.CrabStreetNameStatusId);

            sut = Act(sut, CrabStreetNameStatus.InUse, crabLifetime, CrabModification.Historize, firstStatusId);
            sut = Act(sut, CrabStreetNameStatus.InUse, crabLifetime, CrabModification.Delete, firstStatusId);

            sut.Should().HaveSingleChange <StreetNameStatusWasRemoved>();
            sut.Should().HaveSingleChange <StreetNameBecameIncomplete>();

            sut.ClearChanges();

            sut = Act(sut, CrabStreetNameStatus.Proposed, crabLifetime, CrabModification.Insert);

            sut.Should().HaveSingleChange <StreetNameWasProposed>();
            sut.Should().HaveSingleChange <StreetNameBecameComplete>();
            sut.Should().NotHaveAnyChange <StreetNameBecameCurrent>();
            sut.Should().NotHaveAnyChange <StreetNameWasCorrectedToCurrent>();
            sut.Should().NotHaveAnyChange <StreetNameWasCorrectedToProposed>();
        }
 public ImportMunicipalityFromCrab(
     NisCode nisCode,
     CrabLanguage?primaryLanguage,
     CrabLanguage?secondaryLanguage,
     CrabLanguage?facilityLanguage,
     WkbGeometry geometry,
     NumberOfFlags numberOfFlags,
     CrabLifetime lifetime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation,
     CrabMunicipalityId municipalityId)
 {
     NisCode           = nisCode;
     PrimaryLanguage   = primaryLanguage;
     SecondaryLanguage = secondaryLanguage;
     FacilityLanguage  = facilityLanguage;
     Geometry          = geometry;
     Lifetime          = lifetime;
     Timestamp         = timestamp;
     Operator          = @operator;
     Modification      = modification;
     Organisation      = organisation;
     NumberOfFlags     = numberOfFlags;
     MunicipalityId    = municipalityId;
 }
 public MunicipalityWasImportedFromCrab(
     CrabMunicipalityId crabMunicipalityId,
     NisCode nisCode,
     CrabLanguage?primaryLanguage,
     CrabLanguage?secondaryLanguage,
     NumberOfFlags numberOfFlags,
     CrabLifetime lifetime,
     WkbGeometry wkbGeometry,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     CrabMunicipalityId = crabMunicipalityId;
     NisCode            = nisCode;
     PrimaryLanguage    = primaryLanguage;
     SecondaryLanguage  = secondaryLanguage;
     NumberOfFlags      = numberOfFlags;
     BeginDate          = lifetime.BeginDateTime;
     EndDate            = lifetime.EndDateTime;
     WkbGeometry        = wkbGeometry?.ToString();
     Timestamp          = timestamp;
     Operator           = @operator;
     Modification       = modification;
     Organisation       = organisation;
 }
Exemple #13
0
        public PostalInformationWasImportedFromCrab(
            PostalCode postalCode,
            CrabSubCantonId subCantonId,
            CrabSubCantonCode subCantonCode,
            NisCode nisCode,
            CrabMunicipalityName municipalityName,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            PostalCode    = postalCode;
            SubCantonId   = subCantonId;
            SubCantonCode = subCantonCode;
            NisCode       = nisCode;

            BeginDate = lifetime.BeginDateTime;

            MunicipalityName         = municipalityName.Name;
            MunicipalityNameLanguage = municipalityName.Language;

            Timestamp    = timestamp;
            Operator     = @operator;
            Modification = modification;
            Organisation = organisation;
        }
Exemple #14
0
        public void ImportPostalInformationFromCrab(
            PostalCode postalCode,
            CrabSubCantonId subCantonId,
            CrabSubCantonCode subCantonCode,
            NisCode nisCode,
            CrabMunicipalityName municipalityName,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            ApplyChange(
                new MunicipalityWasAttached(
                    new PostalCode(subCantonCode),
                    nisCode));

            ApplyChange(
                new PostalInformationWasImportedFromCrab(
                    postalCode,
                    subCantonId,
                    subCantonCode,
                    nisCode,
                    municipalityName,
                    lifetime,
                    timestamp,
                    @operator,
                    modification,
                    organisation));
        }
        public void WhenPositionQualityIsHigher(
            Fixture fixture,
            AddressId addressId,
            CrabLifetime crabLifetime,
            AddressWasRegistered addressWasRegistered,
            AddressSubaddressPositionWasImportedFromCrab addressSubaddressPositionWasImported,
            ImportSubaddressPositionFromCrab importSubaddressPositionFromCrab)
        {
            var addressWasPositioned = new AddressWasPositioned(addressId,
                                                                new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Lot, new ExtendedWkbGeometry(addressSubaddressPositionWasImported.AddressPosition)));

            ((ISetProvenance)addressWasPositioned).SetProvenance(fixture.Create <Provenance>());

            addressSubaddressPositionWasImported = addressSubaddressPositionWasImported
                                                   .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromLot)
                                                   .WithBeginDate(crabLifetime.BeginDateTime);

            importSubaddressPositionFromCrab = importSubaddressPositionFromCrab
                                               .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromEntryOfBuilding)
                                               .WithLifetime(crabLifetime);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasPositioned,
                          addressSubaddressPositionWasImported)
                   .When(importSubaddressPositionFromCrab)
                   .Then(addressId,
                         new AddressWasPositioned(addressId,
                                                  new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Entry, GeometryHelpers.CreateEwkbFrom(importSubaddressPositionFromCrab.AddressPosition))),
                         importSubaddressPositionFromCrab.ToLegacyEvent()));
        }
Exemple #16
0
        public void ImportStatusFromCrab(
            CrabStreetNameStatusId streetNameStatusId,
            CrabStreetNameId streetNameId,
            CrabStreetNameStatus streetNameStatus,
            CrabLifetime lifeTime,
            CrabTimestamp timestamp,
            CrabOperator beginOperator,
            CrabModification?beginModification,
            CrabOrganisation?beginOrganisation)
        {
            if (IsRemoved && beginModification != CrabModification.Delete)
            {
                throw new InvalidOperationException($"Cannot change removed street name for street name id {_streetNameId}/{streetNameId}");
            }

            var legacyEvent = new StreetNameStatusWasImportedFromCrab(
                streetNameStatusId,
                streetNameId,
                streetNameStatus,
                lifeTime,
                timestamp,
                beginOperator,
                beginModification,
                beginOrganisation);

            ApplyStatusChangesFor(legacyEvent);

            ApplyCompletion();

            ApplyChange(legacyEvent);
        }
        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()));
        }
        public void ThenPositionChangeWhenOlderLifetimeAndHigherQuality(
            Fixture fixture,
            AddressId addressId,
            WkbGeometry wkbGeometry,
            CrabLifetime lifetime,
            ImportHouseNumberPositionFromCrab importHouseNumberPositionFromCrab)
        {
            var addressGeometry = new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Lot, GeometryHelpers.CreateEwkbFrom(wkbGeometry));

            importHouseNumberPositionFromCrab = importHouseNumberPositionFromCrab
                                                .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromStand)
                                                .WithLifetime(lifetime);

            Assert(RegisteredAddressScenario(fixture)
                   .Given <AddressWasPositioned>(addressId, e => e.WithAddressGeometry(addressGeometry))
                   .Given <AddressHouseNumberPositionWasImportedFromCrab>(addressId, e => e
                                                                          .WithWkbGeometry(wkbGeometry)
                                                                          .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromLot)
                                                                          .WithBeginDate(lifetime.BeginDateTime.Value.PlusDays(1)))
                   .When(importHouseNumberPositionFromCrab)
                   .Then(addressId,
                         new AddressWasPositioned(addressId,
                                                  new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Stand, GeometryHelpers.CreateEwkbFrom(importHouseNumberPositionFromCrab.AddressPosition))),
                         importHouseNumberPositionFromCrab.ToLegacyEvent()));
        }
        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()));
        }
 public StreetNameWasImportedFromCrab(
     CrabStreetNameId streetNameId,
     CrabMunicipalityId municipalityId,
     CrabStreetName primaryStreetName,
     CrabStreetName secondaryStreetName,
     CrabTransStreetName primaryTransStreetName,
     CrabTransStreetName secondaryTransStreetName,
     CrabLanguage?primaryLanguage,
     CrabLanguage?secondaryLanguage,
     CrabTimestamp timestamp,
     CrabLifetime lifetime,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     StreetNameId             = streetNameId;
     MunicipalityId           = municipalityId;
     PrimaryStreetName        = primaryStreetName?.Name;
     SecondaryStreetName      = secondaryStreetName?.Name;
     PrimaryTransStreetName   = primaryTransStreetName?.TransStreetName;
     SecondaryTransStreetName = secondaryTransStreetName?.TransStreetName;
     PrimaryLanguage          = primaryLanguage;
     SecondaryLanguage        = secondaryLanguage;
     Timestamp     = timestamp;
     BeginDateTime = lifetime.BeginDateTime;
     EndDateTime   = lifetime.EndDateTime;
     Operator      = @operator;
     Modification  = modification;
     Organisation  = organisation;
 }
Exemple #21
0
 public TerrainObjectWasImportedFromCrab(
     CrabTerrainObjectId terrainObjectId,
     CrabIdentifierTerrainObject identifierTerrainObject,
     CrabTerrainObjectNatureCode terrainObjectNatureCode,
     CrabCoordinate xCoordinate,
     CrabCoordinate yCoordinate,
     CrabBuildingNature buildingNature,
     CrabLifetime crabLifetime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     TerrainObjectId         = terrainObjectId;
     IdentifierTerrainObject = identifierTerrainObject;
     TerrainObjectNatureCode = terrainObjectNatureCode;
     XCoordinate             = xCoordinate;
     YCoordinate             = yCoordinate;
     BuildingNature          = buildingNature;
     Begin        = crabLifetime.BeginDateTime;
     End          = crabLifetime.EndDateTime;
     Timestamp    = timestamp;
     Operator     = @operator;
     Modification = modification;
     Organisation = organisation;
 }
        public void WhenPositionQualityIsLower(
            Fixture fixture,
            AddressId addressId,
            CrabLifetime crabLifetime,
            AddressWasRegistered addressWasRegistered,
            AddressHouseNumberPositionWasImportedFromCrab addressHouseNumberPositionWasImported,
            ImportHouseNumberPositionFromCrab importHouseNumberPositionFromCrab)
        {
            var addressWasPositioned = new AddressWasPositioned(addressId,
                                                                new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Lot, new ExtendedWkbGeometry(addressHouseNumberPositionWasImported.AddressPosition)));

            ((ISetProvenance)addressWasPositioned).SetProvenance(fixture.Create <Provenance>());

            addressHouseNumberPositionWasImported = addressHouseNumberPositionWasImported
                                                    .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromLot)
                                                    .WithBeginDate(crabLifetime.BeginDateTime);

            importHouseNumberPositionFromCrab = importHouseNumberPositionFromCrab
                                                .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.DerivedFromParcelCadastre)
                                                .WithLifetime(crabLifetime);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasPositioned,
                          addressHouseNumberPositionWasImported)
                   .When(importHouseNumberPositionFromCrab)
                   .Then(addressId,
                         importHouseNumberPositionFromCrab.ToLegacyEvent()));
        }
        protected StreetName Act(StreetName sut,
                                 CrabStreetNameId CrabStreetNameId,
                                 CrabMunicipalityId crabMunicipalityId,
                                 CrabStreetName primaryStreetName,
                                 CrabStreetName secondaryStreetName,
                                 CrabTransStreetName primaryTransStreetName,
                                 CrabTransStreetName secondaryTransStreetName,
                                 CrabLanguage?primaryLanguage,
                                 CrabLanguage?secondaryLanguage,
                                 CrabLifetime lifetime,
                                 CrabTimestamp crabTimestamp,
                                 CrabOperator beginOperator,
                                 CrabModification?modification,
                                 CrabOrganisation?beginOrganisation)
        {
            LogAct($"ImportFromCrab({CrabStreetNameId},{crabMunicipalityId},{primaryStreetName},{secondaryStreetName},{secondaryTransStreetName},{primaryTransStreetName},{primaryLanguage},{secondaryLanguage},{lifetime},{crabTimestamp},{beginOperator},{modification},{beginOrganisation})");

            sut.ImportFromCrab(CrabStreetNameId,
                               crabMunicipalityId,
                               primaryStreetName,
                               secondaryStreetName,
                               primaryTransStreetName,
                               secondaryTransStreetName,
                               primaryLanguage,
                               secondaryLanguage,
                               lifetime,
                               crabTimestamp,
                               beginOperator,
                               modification,
                               beginOrganisation);

            return(sut);
        }
Exemple #24
0
        public void ImportFromCrab(
            CrabStreetNameId streetNameId,
            CrabMunicipalityId municipalityId,
            CrabStreetName primaryStreetName,
            CrabStreetName secondaryStreetName,
            CrabTransStreetName primaryTransStreetName,
            CrabTransStreetName secondaryTransStreetName,
            CrabLanguage?primaryLanguage,
            CrabLanguage?secondaryLanguage,
            CrabLifetime lifeTime,
            CrabTimestamp timestamp,
            CrabOperator beginOperator,
            CrabModification?beginModification,
            CrabOrganisation?beginOrganisation)
        {
            if (IsRemoved)
            {
                throw new InvalidOperationException($"Cannot change removed street name for street name id {_streetNameId}/{streetNameId}");
            }

            if (beginModification == CrabModification.Delete)
            {
                ApplyChange(new StreetNameWasRemoved(_streetNameId));
            }
            else
            {
                ApplyRetiredOrUnretire(lifeTime, beginModification);

                if (beginModification != CrabModification.Correction)
                {
                    ApplyNameChanges(primaryStreetName, secondaryStreetName);
                    ApplyLanguageChanges(primaryLanguage?.ToLanguage(), secondaryLanguage?.ToLanguage());
                }
                else
                {
                    ApplyNameCorrections(primaryStreetName, secondaryStreetName);
                    ApplyLanguageCorrections(primaryLanguage?.ToLanguage(), secondaryLanguage?.ToLanguage());
                }
            }

            AssignPersistentLocalId(new PersistentLocalId(streetNameId), new PersistentLocalIdAssignmentDate(timestamp));

            ApplyChange(new StreetNameWasImportedFromCrab(
                            streetNameId,
                            municipalityId,
                            primaryStreetName,
                            secondaryStreetName,
                            primaryTransStreetName,
                            secondaryTransStreetName,
                            primaryLanguage,
                            secondaryLanguage,
                            timestamp,
                            lifeTime,
                            beginOperator,
                            beginModification,
                            beginOrganisation));
        }
Exemple #25
0
        public void ImportTerrainObjectFromCrab(
            CrabTerrainObjectId terrainObjectId,
            CrabIdentifierTerrainObject identifierTerrainObject,
            CrabTerrainObjectNatureCode terrainObjectNatureCode,
            CrabCoordinate xCoordinate,
            CrabCoordinate yCoordinate,
            CrabBuildingNature buildingNature,
            CrabLifetime lifetime,
            CrabTimestamp timestamp,
            CrabOperator @operator,
            CrabModification?modification,
            CrabOrganisation?organisation)
        {
            if (modification == CrabModification.Delete)
            {
                ApplyChange(new ParcelWasRemoved(_parcelId));
            }
            else
            {
                if (lifetime.EndDateTime.HasValue && !IsRetired)
                {
                    if (modification == CrabModification.Correction)
                    {
                        ApplyChange(new ParcelWasCorrectedToRetired(_parcelId));
                    }
                    else
                    {
                        ApplyChange(new ParcelWasRetired(_parcelId));
                    }
                }
                else if (!lifetime.EndDateTime.HasValue && !IsRealized)
                {
                    if (modification == CrabModification.Correction)
                    {
                        ApplyChange(new ParcelWasCorrectedToRealized(_parcelId));
                    }
                    else
                    {
                        ApplyChange(new ParcelWasRealized(_parcelId));
                    }
                }
            }

            ApplyChange(new TerrainObjectWasImportedFromCrab(
                            terrainObjectId,
                            identifierTerrainObject,
                            terrainObjectNatureCode,
                            xCoordinate,
                            yCoordinate,
                            buildingNature,
                            lifetime,
                            timestamp,
                            @operator,
                            modification,
                            organisation));
        }
 public static ImportSubaddressStatusFromCrab WithLifetime(this ImportSubaddressStatusFromCrab command,
                                                           CrabLifetime lifetime) => new ImportSubaddressStatusFromCrab(
     command.SubaddressStatusId,
     command.SubaddressId,
     command.AddressStatus,
     lifetime,
     command.Timestamp,
     command.Operator,
     command.Modification,
     command.Organisation);
        protected StreetName Act(StreetName sut, CrabStreetNameStatus status, CrabLifetime lifetime, CrabModification?modification, CrabStreetNameStatusId statusId = null)
        {
            LogAct($"ImportStatusFromCrab({status}, {lifetime}, {modification})");

            sut.ImportStatusFromCrab(statusId ?? Arrange(Generate.CrabStreetNameStatusId),
                                     Arrange(Generate.CrabStreetNameId),
                                     status,
                                     lifetime,
                                     Arrange(Generate.CrabTimestamp),
                                     Arrange(Generate.CrabOperator),
                                     modification,
                                     Arrange(Generate.CrabOrganisationNullable)
                                     );

            return(sut);
        }
        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()));
        }
        public void When2PositionsAreCurrentAndLowestGetsHistorized(
            Fixture fixture,
            AddressId addressId,
            CrabLifetime crabLifetime,
            AddressWasRegistered addressWasRegistered,
            AddressHouseNumberPositionWasImportedFromCrab addressHouseNumberPositionWasImportedHigh,
            AddressHouseNumberPositionWasImportedFromCrab addressHouseNumberPositionWasImportedLow,
            ImportHouseNumberPositionFromCrab importHouseNumberPositionFromCrab)
        {
            var addressWasPositioned = new AddressWasPositioned(addressId,
                                                                new AddressGeometry(GeometryMethod.DerivedFromObject, GeometrySpecification.Parcel, new ExtendedWkbGeometry(addressHouseNumberPositionWasImportedHigh.AddressPosition)));

            ((ISetProvenance)addressWasPositioned).SetProvenance(fixture.Create <Provenance>());
            var addressWasPositioned2 = new AddressWasPositioned(addressId,
                                                                 new AddressGeometry(GeometryMethod.AppointedByAdministrator, GeometrySpecification.Lot,
                                                                                     new ExtendedWkbGeometry(addressHouseNumberPositionWasImportedHigh.AddressPosition)));

            ((ISetProvenance)addressWasPositioned2).SetProvenance(fixture.Create <Provenance>());

            addressHouseNumberPositionWasImportedLow = addressHouseNumberPositionWasImportedLow
                                                       .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.DerivedFromParcelCadastre)
                                                       .WithBeginDate(crabLifetime.BeginDateTime);

            addressHouseNumberPositionWasImportedHigh = addressHouseNumberPositionWasImportedHigh
                                                        .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.ManualIndicationFromLot)
                                                        .WithBeginDate(crabLifetime.BeginDateTime);

            importHouseNumberPositionFromCrab = importHouseNumberPositionFromCrab
                                                .WithPositionId(new CrabAddressPositionId(addressHouseNumberPositionWasImportedLow.AddressPositionId))
                                                .WithCrabAddressPositionOrigin(CrabAddressPositionOrigin.DerivedFromParcelCadastre)
                                                .WithLifetime(new CrabLifetime(crabLifetime.BeginDateTime, LocalDateTime.FromDateTime(DateTime.Now)));

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasPositioned,
                          addressHouseNumberPositionWasImportedLow,
                          addressWasPositioned2,
                          addressHouseNumberPositionWasImportedHigh)
                   .When(importHouseNumberPositionFromCrab)
                   .Then(addressId,
                         importHouseNumberPositionFromCrab.ToLegacyEvent()));
        }
 public ImportStreetNameStatusFromCrab(
     CrabStreetNameStatusId streetNameStatusId,
     CrabStreetNameId streetNameId,
     CrabStreetNameStatus streetNameStatus,
     CrabLifetime lifeTime,
     CrabTimestamp timestamp,
     CrabOperator @operator,
     CrabModification?modification,
     CrabOrganisation?organisation)
 {
     StreetNameStatusId = streetNameStatusId;
     StreetNameId       = streetNameId;
     StreetNameStatus   = streetNameStatus;
     LifeTime           = lifeTime;
     Timestamp          = timestamp;
     Operator           = @operator;
     Modification       = modification;
     Organisation       = organisation;
 }