コード例 #1
0
        public void testEcheckRedeposit()
        {
            EcheckRedeposit echeckredeposit = new EcheckRedeposit();
            echeckredeposit.LitleTxnId = 123456;

            var mockLitleResponse = new Mock<LitleResponse>();
            var mockLitleXmlSerializer = new Mock<LitleXmlSerializer>();

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

            BatchResponse mockedLitleBatchResponse = new BatchResponse();
            mockedLitleBatchResponse.SetEcheckRedepositResponseReader(mockXmlReader.Object);

            mockLitleResponse.Setup(litleResponse => litleResponse.NextBatchResponse()).Returns(mockedLitleBatchResponse);
            LitleResponse mockedLitleResponse = mockLitleResponse.Object;

            Communications mockedCommunications = mockCommunications.Object;

            mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse);
            LitleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;

            LitleFile mockedLitleFile = mockLitleFile.Object;

            litle.SetCommunication(mockedCommunications);
            litle.SetLitleXmlSerializer(mockedLitleXmlSerializer);
            litle.SetLitleFile(mockedLitleFile);
            litle.SetLitleTime(mockLitleTime.Object);

            BatchRequest litleBatchRequest = new BatchRequest();
            litleBatchRequest.SetLitleFile(mockedLitleFile);
            litleBatchRequest.SetLitleTime(mockLitleTime.Object);
            litleBatchRequest.AddEcheckRedeposit(echeckredeposit);
            litleBatchRequest.AddEcheckRedeposit(echeckredeposit);
            litle.AddBatch(litleBatchRequest);

            string batchFileName = litle.SendToLitle();

            LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName);
            BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse();
            EcheckRedepositResponse actualEcheckRedepositResponse1 = actualLitleBatchResponse.NextEcheckRedepositResponse();
            EcheckRedepositResponse actualEcheckRedepositResponse2 = actualLitleBatchResponse.NextEcheckRedepositResponse();
            EcheckRedepositResponse nullEcheckRedepositResponse = actualLitleBatchResponse.NextEcheckRedepositResponse();

            Assert.AreEqual(123, actualEcheckRedepositResponse1.LitleTxnId);
            Assert.AreEqual(124, actualEcheckRedepositResponse2.LitleTxnId);
            Assert.IsNull(nullEcheckRedepositResponse);

            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));
        }