public UpdatePlanResponse UpdatePlan(UpdatePlan updatePlan)
        {
            LitleOnlineRequest request = CreateLitleOnlineRequest();
            request.UpdatePlan = updatePlan;

            LitleOnlineResponse response = SendToLitle(request);
            return response.UpdatePlanResponse;
        }
        public void testUpdatePlan()
        {
            UpdatePlan updatePlan = new UpdatePlan();
            updatePlan.PlanCode = "theCode";

            var mock = new Mock<Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<updatePlan.*?<planCode>theCode</planCode>.*?</updatePlan>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<String, String>>()))
                .Returns("<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><updatePlanResponse><planCode>theCode</planCode></updatePlanResponse></litleOnlineResponse>");

            Communications mockedCommunication = mock.Object;
            litle.SetCommunication(mockedCommunication);
            UpdatePlanResponse updatePlanResponse = litle.UpdatePlan(updatePlan);
            Assert.AreEqual("theCode", updatePlanResponse.PlanCode);
        }
        public void testUpdatePlan()
        {
            UpdatePlan updatePlan = new UpdatePlan();
            updatePlan.PlanCode = "thePlanCode";
            updatePlan.Active = true;

            var mockLitleResponse = new Mock<LitleResponse>();
            var mockLitleXmlSerializer = new Mock<LitleXmlSerializer>();

            mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml())
                .Returns("<updatePlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></updatePlanResponse>")
                .Returns("<updatePlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></updatePlanResponse>");

            BatchResponse mockLitleBatchResponse = new BatchResponse();
            mockLitleBatchResponse.SetUpdatePlanResponseReader(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.AddUpdatePlan(updatePlan);
            litleBatchRequest.AddUpdatePlan(updatePlan);
            litle.AddBatch(litleBatchRequest);

            string batchFileName = litle.SendToLitle();
            LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName);
            BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse();

            Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse);
            Assert.AreEqual("123", actualLitleBatchResponse.NextUpdatePlanResponse().LitleTxnId);
            Assert.AreEqual("124", actualLitleBatchResponse.NextUpdatePlanResponse().LitleTxnId);
            Assert.IsNull(actualLitleBatchResponse.NextUpdatePlanResponse());

            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 TestUpdatePlan_Full()
        {
            var update = new UpdatePlan {PlanCode = "abc", Active = true};

            string actual = update.Serialize();
            const string expected = @"
            <updatePlan>
            <planCode>abc</planCode>
            <active>true</active>
            </updatePlan>";
            Assert.AreEqual(expected, actual);
        }
        public void testUpdatePlan()
        {
            UpdatePlan updatePlan = new UpdatePlan();

            batchRequest.AddUpdatePlan(updatePlan);

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

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