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); }
public CreatePlanResponse CreatePlan(CreatePlan createPlan) { LitleOnlineRequest request = CreateLitleOnlineRequest(); request.CreatePlan = createPlan; LitleOnlineResponse response = SendToLitle(request); return response.CreatePlanResponse; }
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 TestCreatePlan_OnlyRequired() { var create = new CreatePlan { PlanCode = "abc", Name = "thePlan", IntervalType = IntervalType.Annual, Amount = 100 }; string actual = create.Serialize(); const string expected = @" <createPlan> <planCode>abc</planCode> <name>thePlan</name> <intervalType>ANNUAL</intervalType> <amount>100</amount> </createPlan>"; Assert.AreEqual(expected, actual); }
public void TestCreatePlan_Full() { var create = new CreatePlan { PlanCode = "abc", Name = "thePlan", Description = "theDescription", IntervalType = IntervalType.Annual, Amount = 100, NumberOfPayments = 3, TrialNumberOfIntervals = 2, TrialIntervalType = TrialIntervalType.Month, Active = true }; string actual = create.Serialize(); const 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 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 AddCreatePlan(CreatePlan createPlan) { if (_numAccountUpdates == 0) { _numCreatePlans++; _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, createPlan); } else { throw new LitleOnlineException(AccountUpdateErrorMessage); } }