Ejemplo n.º 1
0
        public RequestPaymentCommandHandlerTests()
        {
            _merchantRepository = Substitute.For <IMerchantRepository>();
            _paymentrepository  = Substitute.For <IPaymentRepository>();
            _acquiringBank      = Substitute.For <IAcquiringBank>();
            _logger             = Substitute.For <ILogger <RequestPaymentCommandHandler> >();

            _handler = new RequestPaymentCommandHandler(_logger, _merchantRepository, _paymentrepository, _acquiringBank);
        }
Ejemplo n.º 2
0
        public async Task GetPaymentDbReturnsAPaymentWithStatusPending()
        {
            //Arange
            var requestPayment     = this.FakeValidRequestPayment();
            var requestPaymentCode = Guid.NewGuid();
            var bankResponse       = this.FakeBankResponsePayment(requestPaymentCode, PaymentStatusTypes.Pending);

            // Act
            var command = new RequestPaymentCommand(requestPayment);

            this.paymentGatewayRepostiory.Setup(x => x.AddPaymentAsync(command.RequestPayment)).Returns(Task.FromResult(Guid.NewGuid()));
            this.paymentBankRepostiory.Setup(x => x.RequestPaymentAsync(command.RequestPayment)).Returns(Task.FromResult(bankResponse));

            var handler = new RequestPaymentCommandHandler(this.paymentBankRepostiory.Object, this.paymentGatewayRepostiory.Object);
            var result  = await handler.Handle(command, CancellationToken.None);

            // Assert
            Assert.Equal(PaymentStatusTypes.Pending, result.PaymentStatus);
            Assert.NotNull(result);
        }