public void testInitialization() { Dictionary<String, String> mockConfig = new Dictionary<string, string>(); mockConfig["url"] = "https://www.mockurl.com"; mockConfig["reportGroup"] = "Mock Report Group"; mockConfig["username"] = "******"; mockConfig["printxml"] = "false"; mockConfig["timeout"] = "35"; mockConfig["proxyHost"] = "www.mockproxy.com"; mockConfig["merchantId"] = "MOCKID"; mockConfig["password"] = "******"; mockConfig["proxyPort"] = "3000"; mockConfig["sftpUrl"] = "www.mockftp.com"; mockConfig["sftpUsername"] = "******"; mockConfig["sftpPassword"] = "******"; mockConfig["knownHostsFile"] = "C:\\MockKnownHostsFile"; mockConfig["onlineBatchUrl"] = "www.mockbatch.com"; mockConfig["onlineBatchPort"] = "4000"; mockConfig["requestDirectory"] = "C:\\MockRequests"; mockConfig["responseDirectory"] = "C:\\MockResponses"; rfrRequest = new RfrRequest(mockConfig); Assert.AreEqual("C:\\MockRequests\\Requests\\", rfrRequest.GetRequestDirectory()); Assert.AreEqual("C:\\MockResponses\\Responses\\", rfrRequest.GetResponseDirectory()); Assert.NotNull(rfrRequest.GetLitleTime()); Assert.NotNull(rfrRequest.GetLitleFile()); }
public void setUpBeforeTest() { rfrRequest = new RfrRequest(); }
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 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)); }
public string SerializeRfrRequestToFile(RfrRequest rfrRequest, string filePath) { filePath = _litleFile.CreateRandomFile(_requestDirectory, Path.GetFileName(filePath), "_temp_litleRequest.xml", _litleTime); var tempFilePath = rfrRequest.Serialize(); _litleFile.AppendFileToFile(filePath, tempFilePath); return filePath; }
public void AddRfrRequest(RfrRequest rfrRequest) { if (_numOfLitleBatchRequest != 0) { throw new LitleOnlineException("Can not add an RFRRequest to a batch with requests!"); } if (_numOfRfrRequest >= 1) { throw new LitleOnlineException("Can not add more than one RFRRequest to a batch!"); } _batchFilePath = SerializeRfrRequestToFile(rfrRequest, _batchFilePath); _numOfRfrRequest++; }