public void PurchaseRequest_OnValidRequestWithOptions_ReturnObjects()
        {
            // arrange
            const int    purchaseAmount        = 1000;
            const string posRefId              = "test";
            const string merchantReceiptHeader = "";
            const string merchantReceiptFooter = "merchantfooter";
            const string customerReceiptHeader = "customerheader";
            const string customerReceiptFooter = "";

            var options = new TransactionOptions();

            options.SetMerchantReceiptFooter(merchantReceiptFooter);
            options.SetCustomerReceiptHeader(customerReceiptHeader);

            // act
            var request = new PurchaseRequest(purchaseAmount, posRefId);

            request.Options = options;
            var msg = request.ToMessage();

            // assert
            Assert.Equal(merchantReceiptHeader, msg.GetDataStringValue("merchant_receipt_header"));
            Assert.Equal(merchantReceiptFooter, msg.GetDataStringValue("merchant_receipt_footer"));
            Assert.Equal(customerReceiptHeader, msg.GetDataStringValue("customer_receipt_header"));
            Assert.Equal(customerReceiptFooter, msg.GetDataStringValue("customer_receipt_footer"));
        }
Beispiel #2
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"));
        }