/// <summary> /// Redeems the specified redeemed date time. /// </summary> /// <param name="redeemedDateTime">The redeemed date time.</param> public void Redeem(DateTime redeemedDateTime) { this.CheckIfVoucherHasBeenGenerated(); this.CheckIfVoucherHasBeenIssued(); this.CheckIfVoucherAlreadyRedeemed(); VoucherFullyRedeemedEvent voucherFullyRedeemedEvent = new VoucherFullyRedeemedEvent(this.AggregateId, this.EstateId, redeemedDateTime); this.ApplyAndAppend(voucherFullyRedeemedEvent); }
public void VoucherFullyRedeemedEvent_CanBeCreated_IsCreated() { VoucherFullyRedeemedEvent voucherFullyRedeemedEvent = new VoucherFullyRedeemedEvent(TestData.VoucherId, TestData.EstateId, TestData.RedeemedDateTime); voucherFullyRedeemedEvent.ShouldNotBeNull(); voucherFullyRedeemedEvent.AggregateId.ShouldBe(TestData.VoucherId); voucherFullyRedeemedEvent.EventId.ShouldNotBe(Guid.Empty); voucherFullyRedeemedEvent.VoucherId.ShouldBe(TestData.VoucherId); voucherFullyRedeemedEvent.EstateId.ShouldBe(TestData.EstateId); voucherFullyRedeemedEvent.RedeemedDateTime.ShouldBe(TestData.RedeemedDateTime); }
public void TransactionDomainEventHandler_VoucherFullyRedeemedEvent_EventIsHandled() { VoucherFullyRedeemedEvent voucherFullyRedeemedEvent = TestData.VoucherFullyRedeemedEvent; Mock <IEstateReportingRepository> estateReportingRepository = new Mock <IEstateReportingRepository>(); TransactionDomainEventHandler eventHandler = new TransactionDomainEventHandler(estateReportingRepository.Object); Logger.Initialise(NullLogger.Instance); Should.NotThrow(async() => { await eventHandler.Handle(voucherFullyRedeemedEvent, CancellationToken.None); }); }
/// <summary> /// Plays the event. /// </summary> /// <param name="domainEvent">The domain event.</param> private void PlayEvent(VoucherFullyRedeemedEvent domainEvent) { this.RedeemedDateTime = domainEvent.RedeemedDateTime; this.IsRedeemed = true; this.Balance = 0; }
/// <summary> /// Handles the specific domain event. /// </summary> /// <param name="domainEvent">The domain event.</param> /// <param name="cancellationToken">The cancellation token.</param> private async Task HandleSpecificDomainEvent(VoucherFullyRedeemedEvent domainEvent, CancellationToken cancellationToken) { await this.EstateReportingRepository.UpdateVoucherRedemptionDetails(domainEvent, cancellationToken); }