public async Task <Unit> Handle(CreateMeetingPaymentCommand request, CancellationToken cancellationToken) { var meetingPayment = MeetingPayment.CreatePaymentForMeeting( request.PayerId, request.MeetingId, MoneyValue.Of(request.Value, request.Currency)); await _meetingPaymentRepository.AddAsync(meetingPayment); return(Unit.Value); }
public void MeetingPayment_WhenFeeIsNotGreaterThanZero_CannotBeCreated() { var payerId = new PayerId(Guid.NewGuid()); var meetingId = new MeetingId(Guid.NewGuid()); var fee = new MoneyValue(0, "EUR"); AssertBrokenRule <MeetingPaymentFeeMustBeGreaterThanZeroRule>(() => { MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee); }); }
public void MeetingPayment_WhenFeeIsGreaterThanZero_IsCreated() { var payerId = new PayerId(Guid.NewGuid()); var meetingId = new MeetingId(Guid.NewGuid()); var fee = new MoneyValue(100, "EUR"); var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee); var meetingCreated = GetPublishedDomainEvent <MeetingPaymentCreatedDomainEvent>(meetingPayment); Assert.That(meetingCreated.PayerId, Is.EqualTo(payerId)); Assert.That(meetingCreated.MeetingId, Is.EqualTo(meetingId)); Assert.That(meetingCreated.Fee, Is.EqualTo(fee)); }
public void MarkPaymentAsPayed_WhenIsPayedAlready_CannotBePayedTwice() { var payerId = new PayerId(Guid.NewGuid()); var meetingId = new MeetingId(Guid.NewGuid()); var fee = new MoneyValue(100, "EUR"); var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee); meetingPayment.MarkIsPayed(); AssertBrokenRule <MeetingPaymentCannotBePayedTwiceRule>(() => { meetingPayment.MarkIsPayed(); }); }
public void MarkPaymentAsPayed_WhenIsNotPayed_IsPayed() { var payerId = new PayerId(Guid.NewGuid()); var meetingId = new MeetingId(Guid.NewGuid()); var fee = new MoneyValue(100, "EUR"); var paymentDate = DateTime.UtcNow; SystemClock.Set(paymentDate); var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee); meetingPayment.MarkIsPayed(); var meetingPayed = GetPublishedDomainEvent <MeetingPayedDomainEvent>(meetingPayment); Assert.That(meetingPayed.MeetingId, Is.EqualTo(meetingId)); Assert.That(meetingPayed.PayerId, Is.EqualTo(payerId)); Assert.That(meetingPayed.PaymentDate, Is.EqualTo(paymentDate)); }
public async Task AddAsync(MeetingPayment meetingPayment) { await _paymentsContext.MeetingPayments.AddAsync(meetingPayment); }