public void TestSimple()
        {
            var regex = FormMatchExpression(
                "<cancelSubscription>",
                "<subscriptionId>12345</subscriptionId>",
                "</cancelSubscription>");
            const string value = @"
                <litleOnlineResponse version='8.20' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'>
                    <cancelSubscriptionResponse>
                        <subscriptionId>12345</subscriptionId>
                    </cancelSubscriptionResponse>
                </litleOnlineResponse>";
            var update = new CancelSubscription {SubscriptionId = 12345};

            MockLitlePost(regex, value);

            Litle.CancelSubscription(update);
        }
        public CancelSubscriptionResponse CancelSubscription(CancelSubscription cancelSubscription)
        {
            LitleOnlineRequest request = CreateLitleOnlineRequest();
            request.CancelSubscription = cancelSubscription;

            LitleOnlineResponse response = SendToLitle(request);
            return response.CancelSubscriptionResponse;
        }
        public void testCancelSubscription()
        {
            CancelSubscription 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>");

            BatchResponse mockLitleBatchResponse = new BatchResponse();
            mockLitleBatchResponse.SetCancelSubscriptionResponseReader(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.AddCancelSubscription(cancel);
            litle.AddBatch(litleBatchRequest);

            string batchFileName = litle.SendToLitle();
            LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName);
            BatchResponse 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));
        }
        public void testCancelSubscription_OnlyRequired()
        {
            var update = new CancelSubscription {SubscriptionId = 12345};

            string actual = update.Serialize();
            const string expected = @"
            <cancelSubscription>
            <subscriptionId>12345</subscriptionId>
            </cancelSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void TestCancelSubscription_Full()
        {
            var cancel = new CancelSubscription {SubscriptionId = 12345};

            string actual = cancel.Serialize();
            const string expected = @"
            <cancelSubscription>
            <subscriptionId>12345</subscriptionId>
            </cancelSubscription>";
            Assert.AreEqual(expected, actual);
        }
        public void testCancelSubscription()
        {
            CancelSubscription cancel = new CancelSubscription();
            cancel.SubscriptionId = 12345;

            batchRequest.AddCancelSubscription(cancel);

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

            mockLitleFile.Verify(litleFile => litleFile.CreateRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object));
            mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, cancel.Serialize()));
        }
 public void AddCancelSubscription(CancelSubscription cancelSubscription)
 {
     if (_numAccountUpdates == 0)
     {
         _numCancelSubscriptions++;
         _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, cancelSubscription);
     }
     else
     {
         throw new LitleOnlineException(AccountUpdateErrorMessage);
     }
 }