public virtual litleResponse DeserializeObjectFromFile(string filePath)
 {
     litleResponse i;
     try
     {
         i = new litleResponse(filePath);
     }
     catch (XmlException e)
     {
         throw new LitleOnlineException("Error in recieving response from Litle!", e);
     }
     return i;
 }
 public virtual litleResponse DeserializeObjectFromString(string value)
 {
     litleResponse i;
     try
     {
         var bytes = Encoding.UTF8.GetBytes(value);
         using (var memoryStream = new MemoryStream(bytes))
         {
             i = new litleResponse(memoryStream);
         }
     }
     catch (XmlException e)
     {
         throw new LitleOnlineException("Error in recieving response from Litle!", e);
     }
     return i;
 }
Example #3
0
        public void testRFRRequest()
        {
            RFRRequest rfrRequest = new RFRRequest();
            rfrRequest.litleSessionId = 123456789;

            var mockBatchXmlReader = new Mock<XmlReader>();
            mockBatchXmlReader.Setup(XmlReader => XmlReader.ReadState).Returns(ReadState.Closed);

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadState).Returns(ReadState.Interactive).Returns(ReadState.Closed);
            mockXmlReader.Setup(XmlReader => XmlReader.ReadOuterXml()).Returns("<RFRResponse response=\"1\" message=\"The account update file is not ready yet. Please try again later.\" xmlns='http://www.litle.com/schema'> </RFRResponse>");

            litleResponse mockedLitleResponse = new litleResponse();
            mockedLitleResponse.setRfrResponseReader(mockXmlReader.Object);
            mockedLitleResponse.setBatchResponseReader(mockBatchXmlReader.Object);

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

            litleFile mockedLitleFile = mockLitleFile.Object;
            litleTime mockedLitleTime = mockLitleTime.Object;
            Communications mockedCommunications = mockCommunications.Object;

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

            rfrRequest.setLitleFile(mockedLitleFile);
            rfrRequest.setLitleTime(mockedLitleTime);

            litle.addRFRRequest(rfrRequest);

            string batchFileName = litle.sendToLitle();

            litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName);
            batchResponse nullLitleBatchResponse = actualLitleResponse.nextBatchResponse();
            RFRResponse actualRFRResponse = actualLitleResponse.nextRFRResponse();
            RFRResponse nullRFRResponse = actualLitleResponse.nextRFRResponse();

            Assert.IsNotNull(actualRFRResponse);
            Assert.AreEqual("1", actualRFRResponse.response);
            Assert.AreEqual("The account update file is not ready yet. Please try again later.", actualRFRResponse.message);
            Assert.IsNull(nullLitleBatchResponse);
            Assert.IsNull(nullRFRResponse);

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