public void CallCaptureTransaction_TransactionPresent_SuccessfulResult()
        {
            var response        = "1";
            var transactionId   = "111222";
            var responseMessage = "APPROVED";
            var mockCallResult  = $@"<message>
                                        <response>{response}</response>
                                        <responseMessage>{responseMessage}</responseMessage>
                                        <transaction>
                                            <transactionId>{transactionId}</transactionId>
                                        </transaction>
                                    </message>";

            var mockClient = new Mock <IHelcimClient>();

            mockClient
            .Setup(x => x.MakeRequest(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns((string endpint, Dictionary <string, string> values) => mockCallResult);
            var paymentService = new HelcimPaymentService("testendpoint", mockClient.Object);

            var result = paymentService.CapturePayment(new HelcimCheckTransactionRequest());

            Assert.False(result.Error);
            Assert.Equal(responseMessage, result.ResponseMessage);
            Assert.Equal(transactionId, result.Transaction.TransactionId);
        }
        public void CallCaptureTransaction_CommunicationError_ExceptionCaptured()
        {
            var message = "Exception message";

            var mockClient = new Mock <IHelcimClient>();

            mockClient
            .Setup(x => x.MakeRequest(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Throws(new Exception(message));
            var paymentService = new HelcimPaymentService("testendpoint", mockClient.Object);

            var result = paymentService.CapturePayment(new HelcimCheckTransactionRequest());

            Assert.True(result.Error);
            Assert.Equal(message, result.ResponseMessage);
            Assert.Null(result.Transaction);
        }
        public void CallCaptureTransaction_TransactionNotPresent_ErrorResult()
        {
            var response        = "0";
            var responseMessage = "Invalid Transaction ID";
            var mockCallResult  = $@"<message>
                                        <response>{response}</response>
                                        <responseMessage>{responseMessage}</responseMessage>
                                    </message>";

            var mockClient = new Mock <IHelcimClient>();

            mockClient
            .Setup(x => x.MakeRequest(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >()))
            .Returns((string endpint, Dictionary <string, string> values) => mockCallResult);
            var paymentService = new HelcimPaymentService("testendpoint", mockClient.Object);

            var result = paymentService.CapturePayment(new HelcimCheckTransactionRequest());

            Assert.True(result.Error);
            Assert.Equal(responseMessage, result.ResponseMessage);
            Assert.Null(result.Transaction);
        }