public void testDefaultReportGroup() { var authorization = new authorization(); authorization.orderId = "12344"; authorization.amount = 106; authorization.orderSource = orderSourceType.ecommerce; var card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; authorization.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns( "<authorizationResponse reportGroup=\"Default Report Group\" xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></authorizationResponse>") .Returns( "<authorizationResponse reportGroup=\"Default Report Group\" xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></authorizationResponse>"); var mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setAuthorizationResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()) .Returns(mockedLitleBatchResponse); var mockedLitleResponse = mockLitleResponse.Object; var mockedCommunications = mockCommunications.Object; mockLitleXmlSerializer.Setup( litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>())) .Returns(mockedLitleResponse); var mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; var mockedLitleFile = mockLitleFile.Object; litle.setCommunication(mockedCommunications); litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); var litleBatchRequest = new batchRequest(_mockCache.Object); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addAuthorization(authorization); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); var batchFileName = litle.sendToLitle(); var actualLitleResponse = litle.receiveFromLitle(batchFileName); var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); var actualAuthorizationResponse1 = actualLitleBatchResponse.nextAuthorizationResponse(); var actualAuthorizationResponse2 = actualLitleBatchResponse.nextAuthorizationResponse(); var nullAuthorizationResponse = actualLitleBatchResponse.nextAuthorizationResponse(); Assert.AreEqual(123, actualAuthorizationResponse1.litleTxnId); Assert.AreEqual("Default Report Group", actualAuthorizationResponse1.reportGroup); Assert.AreEqual(124, actualAuthorizationResponse2.litleTxnId); Assert.AreEqual("Default Report Group", actualAuthorizationResponse2.reportGroup); Assert.IsNull(nullAuthorizationResponse); mockLitleFile.Verify( litleFile => litleFile.AppendLineToFile(mockFilePath, It.IsRegex(".*reportGroup=\"Default Report Group\".*", RegexOptions.Singleline))); 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 testAuth() { var authorization = new authorization(); authorization.reportGroup = "Planets"; authorization.orderId = "12344"; authorization.amount = 106; authorization.orderSource = orderSourceType.ecommerce; var card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; authorization.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns( "<authorizationResponse id=\"\" reportGroup=\"Planets\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId><orderId>123</orderId><response>000</response><responseTime>2013-06-19T19:54:42</responseTime><message>Approved</message><authCode>123457</authCode><fraudResult><avsResult>00</avsResult></fraudResult><tokenResponse><litleToken>1711000103054242</litleToken><tokenResponseCode>802</tokenResponseCode><tokenMessage>Account number was previously registered</tokenMessage><type>VI</type><bin>424242</bin></tokenResponse></authorizationResponse>") .Returns( "<authorizationResponse id=\"\" reportGroup=\"Planets\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId><orderId>124</orderId><response>000</response><responseTime>2013-06-19T19:54:42</responseTime><message>Approved</message><authCode>123457</authCode><fraudResult><avsResult>00</avsResult></fraudResult><tokenResponse><litleToken>1711000103054242</litleToken><tokenResponseCode>802</tokenResponseCode><tokenMessage>Account number was previously registered</tokenMessage><type>VI</type><bin>424242</bin></tokenResponse></authorizationResponse>"); var mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setAuthorizationResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); var mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup( litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromString(It.IsAny<string>())) .Returns(mockedLitleResponse); var mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); var mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); var mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); var litleBatchRequest = new batchRequest(_mockCache.Object); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addAuthorization(authorization); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); var batchFileName = litle.sendToLitle(); var actualLitleResponse = litle.receiveFromLitle(batchFileName); var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual(123, actualLitleBatchResponse.nextAuthorizationResponse().litleTxnId); Assert.AreEqual(124, actualLitleBatchResponse.nextAuthorizationResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextAuthorizationResponse()); 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)); }