Beispiel #1
0
        public void GetPaymentEntryShouldCallDataAccessOnce()
        {
            MockPaymentsDataAccess.Setup(x => x.GetPaymentEntry(It.IsAny <Guid>()))
            .ReturnsAsync(new GetPaymentEntryResult()
            {
                Success = true, PaymentEntry = Fakes.FakePaymentData.FakePaymentEntryData()
            });

            var res = this.PaymentsRepository.GetPaymentEntry(Guid.NewGuid());

            Assert.IsTrue(res.IsCompletedSuccessfully);
            Assert.IsTrue(res.Result.Success);

            MockPaymentsDataAccess.Verify(x => x.GetPaymentEntry(It.IsAny <Guid>()), Times.Exactly(1));
        }
Beispiel #2
0
        public void ProcessPaymentShouldBeAFailWhenDAtaAccessCallFails()
        {
            MockBankRepository.Setup(x => x.RequestPayment(It.IsAny <MockBankPaymentRequest>()))
            .Returns(new MockBankResponse()
            {
                HttpStatus = System.Net.HttpStatusCode.OK,
                Identifier = "Dummy",
                Status     = COPaymentGateWay.Core.Enum.PaymentStatus.Authorized
            });

            MockPaymentsDataAccess.Setup(x => x.AddPayment(It.IsAny <PaymentEntry>()))
            .ReturnsAsync(new BaseResult()
            {
                Success = false
            });

            var res = this.PaymentsRepository.ProcessPayment(Fakes.FakePaymentData.FakePaymentEntryData());

            Assert.IsTrue(res.IsCompletedSuccessfully);
            Assert.IsFalse(res.Result.Success);

            MockBankRepository.Verify(x => x.RequestPayment(It.IsAny <MockBankPaymentRequest>()), Times.Once);
            MockPaymentsDataAccess.Verify(x => x.AddPayment(It.IsAny <PaymentEntry>()), Times.Exactly(2));
        }