Ejemplo n.º 1
0
        public void ShouldGetPaymentMethodsByPaymentOption()
        {
            var request = new GetPaymentMethodsRequest(new PaymentOption()
            {
                ShopName          = "My Store",
                PaymentOptionType = PaymentOptionType.PayCard
            });

            var result = new GetPaymentMethodsResult();
            var args   = new ServicePipelineArgs(request, result);

            _client.GetPaymentMethods(request.PaymentOption.ShopName).Returns(new ResponseModelOfArrayOfPaymentMethodModelQBnDdvBq()
            {
                Success = true,
                Result  = new []
                {
                    new PaymentMethodModel()
                    {
                        MethodName = "Credit Card",
                        ShopName   = "My Store",
                        SystemName = "Payments.Manual"
                    },
                    new PaymentMethodModel()
                    {
                        MethodName = "Credit Card",
                        ShopName   = "My Store",
                        SystemName = "Payments.AuthorizeNet"
                    },
                }
            });


            var xml      = new XmlDocument();
            var rootNode = xml.CreateElement("map");

            xml.AppendChild(rootNode);

            var shippingOptionValue = xml.CreateAttribute("paymentOptionValue");
            var systemName          = xml.CreateAttribute("systemName");
            var methodName          = xml.CreateAttribute("methodName");

            shippingOptionValue.Value = "1";
            systemName.Value          = "Payments.Manual";
            methodName.Value          = "Credit Card";

            rootNode.Attributes.Append(shippingOptionValue);
            rootNode.Attributes.Append(systemName);
            rootNode.Attributes.Append(methodName);

            _processor.Map(rootNode);

            shippingOptionValue.Value = "1";
            systemName.Value          = "Payments.AuthorizeNet";
            methodName.Value          = "Credit Card";

            _processor.Map(rootNode);

            _processor.Process(args);

            result.Should().NotBeNull();
            result.Success.Should().BeTrue();
            result.PaymentMethods.Should().HaveCount(2);
            result.PaymentMethods.ElementAt(0).ExternalId.Should().Be("Payments.Manual");
            result.PaymentMethods.ElementAt(0).Name.Should().Be("Credit Card");
            result.PaymentMethods.ElementAt(1).ExternalId.Should().Be("Payments.AuthorizeNet");
            result.PaymentMethods.ElementAt(1).Name.Should().Be("Credit Card");
        }