コード例 #1
0
        public void testEcheckPreNoteCredit()
        {
            EcheckPreNoteCredit echeckPreNoteCredit = new EcheckPreNoteCredit();
            echeckPreNoteCredit.OrderId = "12345";
            echeckPreNoteCredit.OrderSource = OrderSourceType.Ecommerce;
            EcheckType echeck = new EcheckType();
            echeck.AccType = EcheckAccountTypeEnum.CorpSavings;
            echeck.AccNum = "12345657890";
            echeck.RoutingNum = "123456789";
            echeck.CheckNum = "123455";
            echeckPreNoteCredit.Echeck = echeck;
            Contact contact = new Contact();
            contact.Name = "Bob";
            contact.City = "lowell";
            contact.State = "MA";
            contact.Email = "litle.com";
            echeckPreNoteCredit.BillToAddress = contact;

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

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

            BatchResponse mockedLitleBatchResponse = new BatchResponse();
            mockedLitleBatchResponse.SetEcheckPreNoteCreditResponseReader(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.AddEcheckPreNoteCredit(echeckPreNoteCredit);
            litleBatchRequest.AddEcheckPreNoteCredit(echeckPreNoteCredit);
            litle.AddBatch(litleBatchRequest);

            string batchFileName = litle.SendToLitle();

            LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName);
            BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse();
            EcheckPreNoteCreditResponse actualEcheckPreNoteCreditResponse1 = actualLitleBatchResponse.NextEcheckPreNoteCreditResponse();
            EcheckPreNoteCreditResponse actualEcheckPreNoteCreditResponse2 = actualLitleBatchResponse.NextEcheckPreNoteCreditResponse();
            EcheckPreNoteCreditResponse nullEcheckPreNoteCreditsResponse = actualLitleBatchResponse.NextEcheckPreNoteCreditResponse();

            Assert.AreEqual(123, actualEcheckPreNoteCreditResponse1.LitleTxnId);
            Assert.AreEqual(124, actualEcheckPreNoteCreditResponse2.LitleTxnId);
            Assert.IsNull(nullEcheckPreNoteCreditsResponse);

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