Exemplo n.º 1
0
        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 AddressPositionWasCorrected(
     AddressId addressId,
     AddressGeometry addressGeometry)
 {
     AddressId             = addressId;
     GeometryMethod        = addressGeometry.GeometryMethod;
     GeometrySpecification = addressGeometry.GeometrySpecification;
     ExtendedWkbGeometry   = addressGeometry.Geometry.ToString();
 }
Exemplo n.º 3
0
        private void ApplyPositionChangeFor <T, TKey>(
            List <T> events,
            T legacyEvent)
            where T : ICrabEvent, IHasCrabPosition, IHasCrabKey <TKey>
        {
            var mostQualitativeCrabPosition = GetLastMostQualitativeCrabPosition <T, TKey>(events, legacyEvent);

            if (mostQualitativeCrabPosition == null || mostQualitativeCrabPosition.Modification == CrabModification.Delete)
            {
                if (_geometry != null)
                {
                    ApplyChange(new AddressPositionWasRemoved(_addressId));
                }
            }
            else
            {
                var mostQualitativeGeometry = new AddressGeometry(
                    MapToGeometryMethod(mostQualitativeCrabPosition.AddressPositionOrigin),
                    MapToGeometrySpecification(mostQualitativeCrabPosition.AddressPositionOrigin),
                    CreateEWkb(mostQualitativeCrabPosition.AddressPosition.ToByteArray()));

                if (_geometry == mostQualitativeGeometry)
                {
                    return;
                }

                if (mostQualitativeCrabPosition.Modification != CrabModification.Correction)
                {
                    ApplyChange(new AddressWasPositioned(_addressId, mostQualitativeGeometry));
                }
                else
                {
                    ApplyChange(new AddressPositionWasCorrected(_addressId, mostQualitativeGeometry));
                }
            }
        }
Exemplo n.º 4
0
 private void When(AddressPositionWasCorrected @event)
 {
     _geometry = new AddressGeometry(@event.GeometryMethod, @event.GeometrySpecification, new ExtendedWkbGeometry(@event.ExtendedWkbGeometry));
 }
Exemplo n.º 5
0
 private void When(AddressPositionWasRemoved @event)
 {
     _geometry = null;
 }
Exemplo n.º 6
0
        public static AddressWasPositioned WithAddressGeometry(this AddressWasPositioned @event, AddressGeometry addressGeometry)
        {
            var addressWasPositioned = new AddressWasPositioned(new AddressId(@event.AddressId), addressGeometry);

            (addressWasPositioned as ISetProvenance).SetProvenance(@event.Provenance.ToProvenance());
            return(addressWasPositioned);
        }