コード例 #1
0
        // todo: Refactor into multiple unit tests
        public void CashoutOnlyRequest_OnValidRequestWithTransactionsOptions_ReturnObjects()
        {
            // arrange
            const string posRefId      = "123";
            const int    amountCents   = 1000;
            const string receiptHeader = "Receipt Header";
            const string receiptFooter = "Receipt Footer";

            var config = new SpiConfig
            {
                PrintMerchantCopy             = true,
                PromptForCustomerCopyOnEftpos = false,
                SignatureFlowOnEftpos         = true
            };

            var options = new TransactionOptions();

            options.SetCustomerReceiptHeader(receiptHeader); // todo: any method in arrange should be unit tested
            options.SetCustomerReceiptFooter(receiptFooter);
            options.SetMerchantReceiptHeader(receiptHeader);
            options.SetMerchantReceiptFooter(receiptFooter);

            // act
            var request = new CashoutOnlyRequest(amountCents, posRefId)
            {
                SurchargeAmount = 100,
                Config          = config,
                Options         = options
            };
            var msg = request.ToMessage();

            // assert
            Assert.Equal(posRefId, request.PosRefId);
            Assert.Equal(amountCents, request.CashoutAmount);
            Assert.Equal(config.PrintMerchantCopy, msg.GetDataBoolValue("print_merchant_copy", false));
            Assert.Equal(config.PromptForCustomerCopyOnEftpos, msg.GetDataBoolValue("prompt_for_customer_copy", false));
            Assert.Equal(config.SignatureFlowOnEftpos, msg.GetDataBoolValue("print_for_signature_required_transactions", false));
            Assert.Equal(receiptHeader, msg.GetDataStringValue("customer_receipt_header"));
            Assert.Equal(receiptFooter, msg.GetDataStringValue("customer_receipt_footer"));
            Assert.Equal(receiptHeader, msg.GetDataStringValue("merchant_receipt_header"));
            Assert.Equal(receiptFooter, msg.GetDataStringValue("merchant_receipt_footer"));
        }
コード例 #2
0
        public void SettleRequest_OnValidRequestWithConfig_ReturnObjects()
        {
            // arrange
            const string posRefId = "test";

            var config = new SpiConfig();

            config.PrintMerchantCopy             = true;
            config.PromptForCustomerCopyOnEftpos = true;
            config.SignatureFlowOnEftpos         = true;

            // act
            var request = new SettleRequest(posRefId);

            request.Config = config;
            var msg = request.ToMessage();

            // assert
            Assert.True(msg.GetDataBoolValue("print_merchant_copy", false));
            Assert.False(msg.GetDataBoolValue("prompt_for_customer_copy", false));
            Assert.False(msg.GetDataBoolValue("print_for_signature_required_transactions", false));
        }
コード例 #3
0
        public void RefundRequest_OnValidRequestWithConfig_ReturnObjects()
        {
            // arrange
            const int    refundAmount             = 1000;
            const string posRefId                 = "test";
            const bool   suppressMerchantPassword = true;

            var config = new SpiConfig();

            config.PrintMerchantCopy             = true;
            config.PromptForCustomerCopyOnEftpos = false;
            config.SignatureFlowOnEftpos         = true;

            // act
            var request = new RefundRequest(refundAmount, posRefId, suppressMerchantPassword);

            request.Config = config;
            var msg = request.ToMessage();

            // assert
            Assert.Equal(config.PrintMerchantCopy, msg.GetDataBoolValue("print_merchant_copy", false));
            Assert.Equal(config.PromptForCustomerCopyOnEftpos, msg.GetDataBoolValue("prompt_for_customer_copy", false));
            Assert.Equal(config.SignatureFlowOnEftpos, msg.GetDataBoolValue("print_for_signature_required_transactions", false));
        }