public void testCancelSubscription() { var cancel = new cancelSubscription(); cancel.subscriptionId = 12345; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns( "<cancelSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>54321</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>12345</subscriptionId></cancelSubscriptionResponse>") .Returns( "<cancelSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>12345</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>54321</subscriptionId></cancelSubscriptionResponse>"); var mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setCancelSubscriptionResponseReader(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.addCancelSubscription(cancel); litle.addBatch(litleBatchRequest); var batchFileName = litle.sendToLitle(); var actualLitleResponse = litle.receiveFromLitle(batchFileName); var actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("12345", actualLitleBatchResponse.nextCancelSubscriptionResponse().subscriptionId); Assert.AreEqual("54321", actualLitleBatchResponse.nextCancelSubscriptionResponse().subscriptionId); Assert.IsNull(actualLitleBatchResponse.nextCancelSubscriptionResponse()); 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)); }