Пример #1
0
        public void TestRetrieveByCardNumber(string cardNumber, string expirationDate,
                                             int expectedId, int expectedNCases, bool expectedNull)
        {
            var expectedXmlResponse     = GenerateXmlResponse(expectedId, expectedNCases);
            var expectedResponseContent = new ResponseContent(
                "text/xml", ChargebackUtils.StringToBytes(expectedXmlResponse));
            var    commMock                 = new Mock <Communication>();
            var    cardExpirationdate       = ChargebackUtils.ParseDate(expirationDate);
            var    stringCardExpirationdate = cardExpirationdate.ToString("MMyy");
            string expectedQuery            =
                string.Format("/chargebacks/?cardNumber={0}&expirationDate={1}", cardNumber, stringCardExpirationdate);

            commMock.Setup(c => c.Get(expectedQuery))
            .Returns(expectedResponseContent);
            var request
                = new ChargebackRetrievalRequest(commMock.Object);
            var response
                = request.RetrieveByCardNumber(cardNumber, cardExpirationdate.Month, cardExpirationdate.Year);

            Assert.AreEqual(expectedId, response.transactionId);
            var nullCase = response.chargebackCase == null;

            Assert.AreEqual(expectedNull, nullCase);
            if (!nullCase)
            {
                Assert.AreEqual(expectedNCases, response.chargebackCase.Length);
            }
        }
        public void TestRetrieveByCardNumber()
        {
            var retrievalResponse =
                _retrievalRequest.RetrieveByCardNumber(2222222222222222222.ToString(), 2, 1998);

            Assert.NotNull(retrievalResponse);
            Assert.NotNull(retrievalResponse.transactionId);
            Assert.NotNull(retrievalResponse.chargebackCase);
        }