public void ThenAddressBecameIncompleteWhenModificationIsDelete(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            AddressWasProposed addressWasProposed,
            AddressWasOfficiallyAssigned addressWasOfficiallyAssigned,
            AddressWasPositioned addressWasPositioned,
            AddressBecameComplete addressBecameComplete,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab.WithCrabModification(CrabModification.Delete);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasProposed,
                          addressWasOfficiallyAssigned,
                          addressWasPositioned,
                          addressBecameComplete)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressStatusWasRemoved(addressId),
                         new AddressOfficialAssignmentWasRemoved(addressId),
                         new AddressBecameIncomplete(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 2
0
        public void WithStatusProposedWhenOlderLifetime(AddressId addressId,
                                                        AddressWasRegistered addressWasRegistered,
                                                        AddressWasProposed addressWasProposed,
                                                        AddressSubaddressStatusWasImportedFromCrab addressSubaddressStatusWasImportedFromCrab,
                                                        AddressWasOfficiallyAssigned addressWasOfficiallyAssigned,
                                                        ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            addressSubaddressStatusWasImportedFromCrab = addressSubaddressStatusWasImportedFromCrab
                                                         .WithStatus(CrabAddressStatus.Proposed);

            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithLifetime(new CrabLifetime(addressSubaddressStatusWasImportedFromCrab.BeginDateTime.Value.PlusDays(-1), null))
                                             .WithStatus(CrabAddressStatus.InUse);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasProposed,
                          addressWasOfficiallyAssigned,
                          addressSubaddressStatusWasImportedFromCrab
                          )
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 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()));
        }
 public static AddressSubaddressStatusWasImportedFromCrab ToLegacyEvent(this ImportSubaddressStatusFromCrab command) => new AddressSubaddressStatusWasImportedFromCrab(
     command.SubaddressStatusId,
     command.SubaddressId,
     command.AddressStatus,
     command.Lifetime,
     command.Timestamp,
     command.Operator,
     command.Modification,
     command.Organisation);
 public static ImportSubaddressStatusFromCrab WithStatusId(this ImportSubaddressStatusFromCrab command,
                                                           CrabSubaddressStatusId statusId) => new ImportSubaddressStatusFromCrab(
     statusId,
     command.SubaddressId,
     command.AddressStatus,
     command.Lifetime,
     command.Timestamp,
     command.Operator,
     command.Modification,
     command.Organisation);
Ejemplo n.º 6
0
 private static void ImportSubaddressStatusFromCrab(Address address, ImportSubaddressStatusFromCrab message)
 {
     address.ImportSubaddressStatusFromCrab(
         message.SubaddressStatusId,
         message.SubaddressId,
         message.AddressStatus,
         message.Lifetime,
         message.Timestamp,
         message.Operator,
         message.Modification,
         message.Organisation);
 }
 public void ThenAddressRemovedException(
     AddressId addressId,
     AddressWasRegistered addressWasRegistered,
     AddressWasRemoved addressWasRemoved,
     ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
 {
     Assert(new Scenario()
            .Given(addressId,
                   addressWasRegistered,
                   addressWasRemoved
                   )
            .When(importSubaddressStatusFromCrab)
            .Throws(new AddressRemovedException($"Cannot change removed address for address id {addressId}")));
 }
 public void ThenAddressRemovedException(
     AddressId addressId,
     AddressWasRegistered addressWasRegistered,
     AddressWasRemoved addressWasRemoved,
     ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
 {
     Assert(new Scenario()
            .Given(addressId,
                   addressWasRegistered,
                   addressWasRemoved
                   )
            .When(importSubaddressStatusFromCrab)
            .ThenNone()); //Changed due to in some edge cases modify events occur after delete and deletes of those properties occurred too
 }
Ejemplo n.º 9
0
        public void WithStatusProposedWhenModificationIsDelete(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithCrabModification(CrabModification.Delete)
                                             .WithStatus(CrabAddressStatus.Proposed);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 10
0
        public void ThenNoStatusChangeButOfficiallyAssigned(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            AddressWasRetired addressWasRetired,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab.WithStatus(CrabAddressStatus.InUse);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasRetired)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressWasOfficiallyAssigned(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 11
0
        public void GivenWasCorrectedToNotOffiallyAssignedWhenStatusIsUnoffical(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            AddressWasCorrectedToNotOfficiallyAssigned addressWasCorrectedToNotOfficiallyAssigned,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithStatus(CrabAddressStatus.Unofficial);

            Assert(new Scenario()
                   .Given(addressId, addressWasRegistered)
                   .Given(addressId, addressWasCorrectedToNotOfficiallyAssigned)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressBecameCurrent(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 12
0
        public void WhenStatusIsInUse(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithStatus(CrabAddressStatus.InUse);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressBecameCurrent(addressId),
                         new AddressWasOfficiallyAssigned(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 13
0
        public void GivenWasCorrectedToOfficiallyAssignedWhenStatusIsProposed(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            AddressWasCorrectedToOfficiallyAssigned addressWasCorrectedToOfficiallyAssigned,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithStatus(CrabAddressStatus.Proposed);

            Assert(new Scenario()
                   .Given(addressId, addressWasRegistered)
                   .Given(addressId, addressWasCorrectedToOfficiallyAssigned)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressWasProposed(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
        public void ThenAddressWasCorrectedToCurrentIfStatusIsOutOfUseAndCorrection(
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithStatus(CrabAddressStatus.OutOfUse)
                                             .WithCrabModification(CrabModification.Correction);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressWasCorrectedToCurrent(addressId),
                         new AddressWasCorrectedToOfficiallyAssigned(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
        public void ThenAddressBecameComplete(
            Fixture fixture,
            AddressId addressId,
            AddressWasRegistered addressWasRegistered,
            AddressWasPositioned addressWasPositioned,
            ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab.WithStatus(CrabAddressStatus.Proposed);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasPositioned)
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressWasProposed(addressId),
                         new AddressWasOfficiallyAssigned(addressId),
                         new AddressBecameComplete(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 16
0
        public void WithStatusCurrentWhenModificationIsDelete(AddressId addressId,
                                                              AddressWasRegistered addressWasRegistered,
                                                              AddressBecameCurrent addressBecameCurrent,
                                                              AddressWasOfficiallyAssigned addressWasOfficiallyAssigned,
                                                              ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab)
        {
            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithCrabModification(CrabModification.Delete);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressBecameCurrent,
                          addressWasOfficiallyAssigned
                          )
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressStatusWasRemoved(addressId),
                         new AddressOfficialAssignmentWasRemoved(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }
Ejemplo n.º 17
0
        public void WithRemovedStatusWhenStatusInUseAndSameLifetimeOfPreviouslyRemovedStatus(AddressId addressId,
                                                                                             AddressWasRegistered addressWasRegistered,
                                                                                             AddressWasProposed addressWasProposed,
                                                                                             AddressWasOfficiallyAssigned addressWasOfficiallyAssigned,
                                                                                             AddressSubaddressStatusWasImportedFromCrab addressSubaddressStatusWasImportedFromCrab,
                                                                                             AddressStatusWasRemoved addressStatusWasRemoved,
                                                                                             AddressSubaddressStatusWasImportedFromCrab addressSubaddressStatusWasImportedFromCrabDelete,
                                                                                             ImportSubaddressStatusFromCrab importSubaddressStatusFromCrab,
                                                                                             CrabLifetime lifetime)
        {
            var statusId = new CrabSubaddressStatusId(1);

            addressSubaddressStatusWasImportedFromCrab = addressSubaddressStatusWasImportedFromCrab
                                                         .WithSubaddressStatusId(statusId)
                                                         .WithStatus(CrabAddressStatus.Proposed)
                                                         .WithBeginDate(lifetime.BeginDateTime);
            addressSubaddressStatusWasImportedFromCrabDelete = addressSubaddressStatusWasImportedFromCrabDelete
                                                               .WithSubaddressStatusId(statusId)
                                                               .WithStatus(CrabAddressStatus.Proposed)
                                                               .WithCrabModification(CrabModification.Delete)
                                                               .WithBeginDate(lifetime.BeginDateTime);

            importSubaddressStatusFromCrab = importSubaddressStatusFromCrab
                                             .WithLifetime(lifetime)
                                             .WithStatus(CrabAddressStatus.InUse);

            Assert(new Scenario()
                   .Given(addressId,
                          addressWasRegistered,
                          addressWasProposed,
                          addressWasOfficiallyAssigned,
                          addressSubaddressStatusWasImportedFromCrab,
                          addressStatusWasRemoved,
                          addressSubaddressStatusWasImportedFromCrabDelete
                          )
                   .When(importSubaddressStatusFromCrab)
                   .Then(addressId,
                         new AddressBecameCurrent(addressId),
                         importSubaddressStatusFromCrab.ToLegacyEvent()));
        }