public void testCreatePlan() { createPlan createPlan = new createPlan(); createPlan.planCode = "thePlanCode"; createPlan.name = "theName"; createPlan.intervalType = intervalType.ANNUAL; createPlan.amount = 100; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></createPlanResponse>") .Returns("<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></createPlanResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setCreatePlanResponseReader(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.addCreatePlan(createPlan); litleBatchRequest.addCreatePlan(createPlan); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("123", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId); Assert.AreEqual("124", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextCreatePlanResponse()); 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 addCreatePlan(createPlan createPlan) { if (numAccountUpdates == 0) { numCreatePlans++; tempBatchFilePath = saveElement(litleFile, litleTime, tempBatchFilePath, createPlan); } else { throw new LitleOnlineException(accountUpdateErrorMessage); } }
public void TestCreatePlan_OnlyRequired() { createPlan create = new createPlan(); create.planCode = "abc"; create.name = "thePlan"; create.intervalType = intervalType.ANNUAL; create.amount = 100; String actual = create.Serialize(); String expected = @" <createPlan> <planCode>abc</planCode> <name>thePlan</name> <intervalType>ANNUAL</intervalType> <amount>100</amount> </createPlan>"; Assert.AreEqual(expected, actual); }
public void TestCreatePlan_Full() { createPlan create = new createPlan(); create.planCode = "abc"; create.name = "thePlan"; create.description = "theDescription"; create.intervalType = intervalType.ANNUAL; create.amount = 100; create.numberOfPayments = 3; create.trialNumberOfIntervals = 2; create.trialIntervalType = trialIntervalType.MONTH; create.active = true; String actual = create.Serialize(); String expected = @" <createPlan> <planCode>abc</planCode> <name>thePlan</name> <description>theDescription</description> <intervalType>ANNUAL</intervalType> <amount>100</amount> <numberOfPayments>3</numberOfPayments> <trialNumberOfIntervals>2</trialNumberOfIntervals> <trialIntervalType>MONTH</trialIntervalType> <active>true</active> </createPlan>"; Assert.AreEqual(expected, actual); }
public createPlanResponse CreatePlan(createPlan createPlan) { litleOnlineRequest request = createLitleOnlineRequest(); request.createPlan = createPlan; litleOnlineResponse response = sendToLitle(request); createPlanResponse createPlanResponse = response.createPlanResponse; return createPlanResponse; }
public void testCreatePlan() { createPlan createPlan = new createPlan(); batchRequest.addCreatePlan(createPlan); Assert.AreEqual(1, batchRequest.getNumCreatePlans()); mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, createPlan.Serialize())); }
public void testCreatePlan() { createPlan createPlan = new createPlan(); createPlan.planCode = "theCode"; var mock = new Mock<Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<createPlan.*?<planCode>theCode</planCode>.*?</createPlan>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<String, String>>())) .Returns("<litleOnlineResponse version='8.21' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><createPlanResponse><planCode>theCode</planCode></createPlanResponse></litleOnlineResponse>"); Communications mockedCommunication = mock.Object; litle.setCommunication(mockedCommunication); createPlanResponse createPlanResponse = litle.CreatePlan(createPlan); Assert.AreEqual("theCode", createPlanResponse.planCode); }