Example #1
0
        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);
        }
Example #2
0
        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);
            });
        }
Example #3
0
        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));
        }
Example #4
0
        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();
            });
        }
Example #5
0
        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));
        }
Example #6
0
 public async Task AddAsync(MeetingPayment meetingPayment)
 {
     await _paymentsContext.MeetingPayments.AddAsync(meetingPayment);
 }