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 WithBeginDate(this AddressSubaddressStatusWasImportedFromCrab @event, DateTimeOffset?beginDate) { return(@event.WithBeginDate(beginDate.HasValue ? LocalDateTime.FromDateTime(beginDate.Value.LocalDateTime) : new LocalDateTime?())); }