public void testAccountUpdate()
        {
            AccountUpdate accountUpdate = new AccountUpdate();
            accountUpdate.ReportGroup = "Planets";
            accountUpdate.OrderId = "12344";
            CardType card = new CardType();
            card.Type = MethodOfPaymentTypeEnum.VI;
            card.Number = "4100000000000002";
            card.ExpDate = "1210";
            accountUpdate.Card = card;

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

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml())
                .Returns("<accountUpdateResponse reportGroup=\"Merch01ReportGrp\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId><orderId>MERCH01-0002</orderId><response>000</response><responseTime>2010-04-11T15:44:26</responseTime><message>Approved</message></accountUpdateResponse>")
                .Returns("<accountUpdateResponse reportGroup=\"Merch01ReportGrp\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId><orderId>MERCH01-0002</orderId><response>000</response><responseTime>2010-04-11T15:44:26</responseTime><message>Approved</message></accountUpdateResponse>");

            BatchResponse mockLitleBatchResponse = new BatchResponse();
            mockLitleBatchResponse.SetAccountUpdateResponseReader(mockXmlReader.Object);

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

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

            Communications mockedCommunication = mockCommunications.Object;
            litle.SetCommunication(mockedCommunication);

            LitleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object;
            litle.SetLitleXmlSerializer(mockedLitleXmlSerializer);

            LitleFile mockedLitleFile = mockLitleFile.Object;
            litle.SetLitleFile(mockedLitleFile);

            litle.SetLitleTime(mockLitleTime.Object);

            BatchRequest litleBatchRequest = new BatchRequest();
            litleBatchRequest.SetLitleFile(mockedLitleFile);
            litleBatchRequest.SetLitleTime(mockLitleTime.Object);
            litleBatchRequest.AddAccountUpdate(accountUpdate);
            litleBatchRequest.AddAccountUpdate(accountUpdate);
            litle.AddBatch(litleBatchRequest);

            string batchFileName = litle.SendToLitle();
            LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName);
            BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse();
            AccountUpdateResponse actualAccountUpdateResponse1 = actualLitleBatchResponse.NextAccountUpdateResponse();
            AccountUpdateResponse actualAccountUpdateResponse2 = actualLitleBatchResponse.NextAccountUpdateResponse();
            AccountUpdateResponse nullAccountUpdateResponse = actualLitleBatchResponse.NextAccountUpdateResponse();

            Assert.AreEqual(123, actualAccountUpdateResponse1.LitleTxnId);
            Assert.AreEqual("000", actualAccountUpdateResponse1.Response);
            Assert.AreEqual(124, actualAccountUpdateResponse2.LitleTxnId);
            Assert.AreEqual("000", actualAccountUpdateResponse2.Response);
            Assert.IsNull(nullAccountUpdateResponse);

            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));
        }
        public void testAddAccountUpdate()
        {
            AccountUpdate accountUpdate = new AccountUpdate();
            accountUpdate.ReportGroup = "Planets";
            accountUpdate.OrderId = "12344";
            CardType card = new CardType();
            card.Type = MethodOfPaymentTypeEnum.VI;
            card.Number = "4100000000000002";
            card.ExpDate = "1210";
            accountUpdate.Card = card;

            batchRequest.AddAccountUpdate(accountUpdate);

            Assert.AreEqual(1, batchRequest.GetNumAccountUpdates());

            mockLitleFile.Verify(litleFile => litleFile.CreateRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, accountUpdate.Serialize()));
        }
        public void accountUpdateBatch()
        {
            BatchRequest litleBatchRequest = new BatchRequest();

            AccountUpdate accountUpdate1 = new AccountUpdate();
            accountUpdate1.OrderId = "1111";
            CardType card = new CardType();
            card.Type = MethodOfPaymentTypeEnum.VI;
            card.Number = "414100000000000000";
            card.ExpDate = "1210";
            accountUpdate1.Card = card;

            litleBatchRequest.AddAccountUpdate(accountUpdate1);

            AccountUpdate accountUpdate2 = new AccountUpdate();
            accountUpdate2.OrderId = "1112";
            accountUpdate2.Card = card;

            litleBatchRequest.AddAccountUpdate(accountUpdate2);

            litle.AddBatch(litleBatchRequest);
            string batchName = litle.SendToLitle();

            litle.BlockAndWaitForResponse(batchName, estimatedResponseTime(0, 1 * 2));

            LitleResponse litleResponse = litle.ReceiveFromLitle(batchName);

            Assert.NotNull(litleResponse);
            Assert.AreEqual("0", litleResponse.Response);
            Assert.AreEqual("Valid Format", litleResponse.Message);

            BatchResponse litleBatchResponse = litleResponse.NextBatchResponse();
            while (litleBatchResponse != null)
            {
                AccountUpdateResponse accountUpdateResponse = litleBatchResponse.NextAccountUpdateResponse();
                while (accountUpdateResponse != null)
                {
                    Assert.AreEqual("301", accountUpdateResponse.Response);

                    accountUpdateResponse = litleBatchResponse.NextAccountUpdateResponse();
                }
                litleBatchResponse = litleResponse.NextBatchResponse();
            }
        }
        public void RFRBatch()
        {
            BatchRequest litleBatchRequest = new BatchRequest();
            litleBatchRequest.ID = "1234567A";

            AccountUpdate accountUpdate1 = new AccountUpdate();
            accountUpdate1.OrderId = "1111";
            CardType card = new CardType();
            card.Type = MethodOfPaymentTypeEnum.VI;
            card.Number = "4242424242424242";
            card.ExpDate = "1210";
            accountUpdate1.Card = card;

            litleBatchRequest.AddAccountUpdate(accountUpdate1);

            AccountUpdate accountUpdate2 = new AccountUpdate();
            accountUpdate2.OrderId = "1112";
            accountUpdate2.Card = card;

            litleBatchRequest.AddAccountUpdate(accountUpdate2);
            litle.AddBatch(litleBatchRequest);

            string batchName = litle.SendToLitle();
            litle.BlockAndWaitForResponse(batchName, estimatedResponseTime(0, 1 * 2));
            LitleResponse litleResponse = litle.ReceiveFromLitle(batchName);

            Assert.NotNull(litleResponse);

            BatchResponse litleBatchResponse = litleResponse.NextBatchResponse();
            Assert.NotNull(litleBatchResponse);
            while (litleBatchResponse != null)
            {
                AccountUpdateResponse accountUpdateResponse = litleBatchResponse.NextAccountUpdateResponse();
                Assert.NotNull(accountUpdateResponse);
                while (accountUpdateResponse != null)
                {
                    Assert.AreEqual("000", accountUpdateResponse.Response);

                    accountUpdateResponse = litleBatchResponse.NextAccountUpdateResponse();
                }
                litleBatchResponse = litleResponse.NextBatchResponse();
            }

            LitleRequest litleRfr = new LitleRequest();
            RfrRequest rfrRequest = new RfrRequest();
            AccountUpdateFileRequestData accountUpdateFileRequestData = new AccountUpdateFileRequestData();
            accountUpdateFileRequestData.MerchantId = Properties.Settings.Default.merchantId;
            accountUpdateFileRequestData.PostDay = DateTime.Now;
            rfrRequest.AccountUpdateFileRequestData = accountUpdateFileRequestData;

            litleRfr.AddRfrRequest(rfrRequest);

            string rfrBatchName = litleRfr.SendToLitle();

            try
            {
                litle.BlockAndWaitForResponse(rfrBatchName, 120000);
                LitleResponse litleRfrResponse = litle.ReceiveFromLitle(rfrBatchName);
                Assert.NotNull(litleRfrResponse);
                RFRResponse rfrResponse = litleRfrResponse.NextRFRResponse();
                Assert.NotNull(rfrResponse);
                while (rfrResponse != null)
                {
                    Assert.AreEqual("1", rfrResponse.Response);
                    Assert.AreEqual("The account update file is not ready yet.  Please try again later.", rfrResponse.Message);
                    rfrResponse = litleResponse.NextRFRResponse();
                }
            }
            catch (Exception)
            {
            }
        }
 public void AddAccountUpdate(AccountUpdate accountUpdate)
 {
     if (IsOnlyAccountUpdates())
     {
         _numAccountUpdates++;
         FillInReportGroup(accountUpdate);
         _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, accountUpdate);
     }
     else
     {
         throw new LitleOnlineException(AccountUpdateErrorMessage);
     }
 }