public void addDeactivate(deactivate deactivate) { if (numAccountUpdates == 0) { numDeactivates++; tempBatchFilePath = saveElement(litleFile, litleTime, tempBatchFilePath, deactivate); } else { throw new LitleOnlineException(accountUpdateErrorMessage); } }
public void testDeactivate() { deactivate deactivate = new deactivate(); deactivate.orderId = "theOrderId"; deactivate.orderSource = orderSourceType.ecommerce; deactivate.card = new cardType(); var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<deactivateResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></deactivateResponse>") .Returns("<deactivateResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></deactivateResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setDeactivateResponseReader(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.addDeactivate(deactivate); litleBatchRequest.addDeactivate(deactivate); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("123", actualLitleBatchResponse.nextDeactivateResponse().litleTxnId); Assert.AreEqual("124", actualLitleBatchResponse.nextDeactivateResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextDeactivateResponse()); 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 testDeactivate_OnlyRequired() { deactivate deactivate = new deactivate(); deactivate.orderId = "12345"; deactivate.orderSource = orderSourceType.ecommerce; deactivate.card = new cardType(); deactivate.id = "theId"; deactivate.reportGroup = "theReportGroup"; String actual = deactivate.Serialize(); String expected = @" <deactivate id=""theId"" reportGroup=""theReportGroup""> <orderId>12345</orderId> <orderSource>ecommerce</orderSource> <card> <type>MC</type> </card> </deactivate>"; Assert.AreEqual(expected, actual); }
public deactivateResponse Deactivate(deactivate deactivate) { litleOnlineRequest request = createLitleOnlineRequest(); request.deactivate = deactivate; litleOnlineResponse response = sendToLitle(request); deactivateResponse deactivateResponse = response.deactivateResponse; return deactivateResponse; }
public void testDeactivate() { deactivate deactivate = new deactivate(); deactivate.orderSource = orderSourceType.ecommerce; deactivate.card = new cardType(); batchRequest.addDeactivate(deactivate); Assert.AreEqual(1, batchRequest.getNumDeactivates()); mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, deactivate.Serialize())); }
public void testDeactivate() { deactivate deactivate = new deactivate(); deactivate.orderId = "2"; deactivate.orderSource = orderSourceType.ecommerce; deactivate.card = new cardType(); var mock = new Mock<Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<deactivate.*?<orderId>2</orderId>.*?</deactivate>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<String, String>>())) .Returns("<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><deactivateResponse><litleTxnId>123</litleTxnId></deactivateResponse></litleOnlineResponse>"); Communications mockedCommunication = mock.Object; litle.setCommunication(mockedCommunication); deactivateResponse deactivateResponse = litle.Deactivate(deactivate); Assert.AreEqual("123", deactivateResponse.litleTxnId); }