예제 #1
0
        public void testUpdateCardValidationNumOnToken()
        {
            var updateCardValidationNumOnToken = new updateCardValidationNumOnToken();
            updateCardValidationNumOnToken.orderId = "12344";
            updateCardValidationNumOnToken.litleToken = "123";

            var mockLitleResponse = new Mock<litleResponse>();
            var mockLitleXmlSerializer = new Mock<litleXmlSerializer>();

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml())
                .Returns(
                    "<updateCardValidationNumOnTokenResponse xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></updateCardValidationNumOnTokenResponse>")
                .Returns(
                    "<updateCardValidationNumOnTokenResponse xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></updateCardValidationNumOnTokenResponse>");

            var mockedLitleBatchResponse = new batchResponse();
            mockedLitleBatchResponse.setUpdateCardValidationNumOnTokenResponseReader(mockXmlReader.Object);

            mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse())
                .Returns(mockedLitleBatchResponse);
            var mockedLitleResponse = mockLitleResponse.Object;

            var mockedCommunications = mockCommunications.Object;

            mockLitleXmlSerializer.Setup(
                litleXmlSerializer =>
                    litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>()))
                .Returns(mockedLitleResponse);
            var mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;

            var mockedLitleFile = mockLitleFile.Object;

            litle.setCommunication(mockedCommunications);
            litle.setLitleXmlSerializer(mockedLitleXmlSerializer);
            litle.setLitleFile(mockedLitleFile);
            litle.setLitleTime(mockLitleTime.Object);

            var litleBatchRequest = new batchRequest(_mockCache.Object);
            litleBatchRequest.setLitleFile(mockedLitleFile);
            litleBatchRequest.setLitleTime(mockLitleTime.Object);
            litleBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken);
            litleBatchRequest.addUpdateCardValidationNumOnToken(updateCardValidationNumOnToken);
            litle.addBatch(litleBatchRequest);

            var batchFileName = litle.sendToLitle();

            var actualLitleResponse = litle.receiveFromLitle(batchFileName);
            var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse();
            var actualUpdateCardValidationNumOnTokenResponse1 =
                actualLitleBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
            var actualUpdateCardValidationNumOnTokenResponse2 =
                actualLitleBatchResponse.nextUpdateCardValidationNumOnTokenResponse();
            var nullUpdateCardValidationNumOnTokenResponse =
                actualLitleBatchResponse.nextUpdateCardValidationNumOnTokenResponse();

            Assert.AreEqual(123, actualUpdateCardValidationNumOnTokenResponse1.litleTxnId);
            Assert.AreEqual(124, actualUpdateCardValidationNumOnTokenResponse2.litleTxnId);
            Assert.IsNull(nullUpdateCardValidationNumOnTokenResponse);

            mockCommunications.Verify(
                Communications =>
                    Communications.FtpDropOff(It.IsAny<string>(), mockFileName, It.IsAny<Dictionary<string, string>>()));
            mockCommunications.Verify(
                Communications =>
                    Communications.FtpPickUp(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>(), mockFileName));
        }