Exemplo n.º 1
0
        public void PaymentProcessCheapGateWay(PaymentDto paymentDto, PaymentState paymentState, PaymentStateEnum state)
        {
            //arrange
            _cheapPaymentGateway.Setup(x => x.PaymentProcessCheap(paymentDto)).Returns(state);

            //act
            var paymentStateResult = _paymentGateWay.PaymentProcess(paymentDto, paymentState);

            //assert
            _cheapPaymentGateway.Verify(x => x.PaymentProcessCheap(paymentDto), Times.Once());
            Assert.AreEqual(paymentStateResult.State, state.ToString());
        }
Exemplo n.º 2
0
        public void ExpensiveProcessCheapGateWay(PaymentDto paymentDto, PaymentState paymentState, PaymentStateEnum state, int callExpensive, int callCheap, PaymentStateEnum CheapState, PaymentStateEnum Expacted)
        {
            //arrange
            _expensivePaymentGateway.Setup(x => x.PaymentProcessExpensive(paymentDto)).Returns(state);
            _cheapPaymentGateway.Setup(s => s.PaymentProcessCheap(paymentDto)).Returns(CheapState);

            //act
            var paymentStateResult = _paymentGateWay.PaymentProcess(paymentDto, paymentState);

            //assert
            _expensivePaymentGateway.Verify(x => x.PaymentProcessExpensive(paymentDto), Times.Exactly(callExpensive));
            _cheapPaymentGateway.Verify(x => x.PaymentProcessCheap(paymentDto), Times.Exactly(callCheap));
            Assert.AreEqual(paymentStateResult.State, Expacted.ToString());
        }
Exemplo n.º 3
0
        public void PaymentProcessPremium(PaymentDto paymentDto, PaymentState paymentState, PaymentStateEnum state)
        {
            //arrange
            _expensivePaymentGateway.Setup(x => x.PaymentProcessExpensive(paymentDto)).Returns(state);

            //act
            var paymentStateResult = _paymentGateWay.PaymentProcess(paymentDto, paymentState);

            //assert
            if (state == PaymentStateEnum.Failed)
            {
                _expensivePaymentGateway.Verify(x => x.PaymentProcessExpensive(paymentDto), Times.Exactly(3));
            }
            else
            {
                _expensivePaymentGateway.Verify(x => x.PaymentProcessExpensive(paymentDto), Times.Once);
            }
            Assert.AreEqual(paymentStateResult.State, state.ToString());
        }