public void when_initiating_payment_then_adds_new_payment()
        {
            ThirdPartyProcessorPayment payment = null;
            var orderId      = Guid.NewGuid();
            var paymentId    = Guid.NewGuid();
            var conferenceId = Guid.NewGuid();

            this.contextMock
            .Setup(x => x.Save(It.IsAny <ThirdPartyProcessorPayment>()))
            .Callback <ThirdPartyProcessorPayment>(p => payment = p);

            this.handler.Handle(
                new InitiateThirdPartyProcessorPayment
            {
                PaymentId       = paymentId,
                PaymentSourceId = orderId,
                ConferenceId    = conferenceId,
                Items           =
                {
                    new InitiateThirdPartyProcessorPayment.PaymentItem {
                        Description = "payment", Amount = 100
                    }
                }
            });

            Assert.NotNull(payment);
            Assert.Equal(1, payment.Items.Count);
            Assert.Equal("payment", payment.Items.ElementAt(0).Description);
            Assert.Equal(100, payment.Items.ElementAt(0).Amount);
        }
        public given_initiated_payment()
        {
            this.contextMock = new Mock <IDataContext <ThirdPartyProcessorPayment> >();
            this.payment     = new ThirdPartyProcessorPayment(Guid.NewGuid(), Guid.NewGuid(), "payment", 100, new ThidPartyProcessorPaymentItem[0]);
            this.handler     = new ThirdPartyProcessorPaymentCommandHandler(() => this.contextMock.Object);

            contextMock.Setup(x => x.Find(payment.Id)).Returns(payment);
        }
        public given_initiated_payment()
        {
            this.contextMock = new Mock<IDataContext<ThirdPartyProcessorPayment>>();
            this.payment = new ThirdPartyProcessorPayment(Guid.NewGuid(), Guid.NewGuid(), "payment", 100, new ThidPartyProcessorPaymentItem[0]);
            this.handler = new ThirdPartyProcessorPaymentCommandHandler(() => this.contextMock.Object);

            contextMock.Setup(x => x.Find(payment.Id)).Returns(payment);
        }
 public ThirdPartyProcessorPaymentDetails(Guid id, ThirdPartyProcessorPayment.States state, Guid paymentSourceId, string description, decimal totalAmount)
 {
     this.Id = id;
     this.State = state;
     this.PaymentSourceId = paymentSourceId;
     this.Description = description;
     this.TotalAmount = totalAmount;
 }
        protected given_initated_payment(IPersistenceProvider sutProvider)
        {
            this.sutProvider = sutProvider;

            this.sut = new ThirdPartyProcessorPayment(PaymentId, SourceId, "payment", 300, new[] { new ThidPartyProcessorPaymentItem("item1", 100), new ThidPartyProcessorPaymentItem("item2", 200) });

            this.sut = this.sutProvider.PersistReload(this.sut);
        }
        protected given_initated_payment(IPersistenceProvider sutProvider)
        {
            this.sutProvider = sutProvider;

            sut = new ThirdPartyProcessorPayment(PaymentId, SourceId, "payment", 300, new[] { new ThidPartyProcessorPaymentItem("item1", 100), new ThidPartyProcessorPaymentItem("item2", 200) });

            sut = this.sutProvider.PersistReload(sut);
        }
        public async Task Consume(ConsumeContext <InitiateThirdPartyProcessorPayment> consumeContext)
        {
            await using var repository = this.contextFactory();
            var items   = consumeContext.Message.Items.Select(t => new ThidPartyProcessorPaymentItem(t.Description, t.Amount)).ToList();
            var payment = new ThirdPartyProcessorPayment(consumeContext.Message.PaymentId, consumeContext.Message.PaymentSourceId, consumeContext.Message.Description
                                                         , consumeContext.Message.TotalAmount, items);

            await repository.Save(payment);
        }
        public void Handle(InitiateThirdPartyProcessorPayment command)
        {
            using (var repository = this._contextFactory()) {
                var items   = command.Items.Select(t => new ThirdPartyProcessorPaymentItem(t.Description, t.Amount));
                var payment = new ThirdPartyProcessorPayment(command.PaymentId, command.PaymentSourceId,
                                                             command.Description, command.TotalAmount, items);

                repository.Save(payment);
            }
        }
示例#9
0
 public void Setup()
 {
     _sut = new ThirdPartyProcessorPayment(PaymentId, SourceId, "payment", 300,
                                           new[] { new ThirdPartyProcessorPaymentItem("item1", 100), new ThirdPartyProcessorPaymentItem("item2", 200) });
 }
 private void InitiatePayment()
 {
     this.sut = new ThirdPartyProcessorPayment(PaymentId, SourceId, "payment", 300, new[] { new ThidPartyProcessorPaymentItem("item1", 100), new ThidPartyProcessorPaymentItem("item2", 200) });
 }
 private void InitiatePayment()
 {
     sut = new ThirdPartyProcessorPayment(PaymentId, SourceId, "payment", 300, new[] { new ThidPartyProcessorPaymentItem("item1", 100), new ThidPartyProcessorPaymentItem("item2", 200) });
 }