public void TestSimple() { var update = new UpdateSubscription { BillingDate = new DateTime(2002, 10, 9), BillToAddress = new Contact { Name = "Greg Dake", City = "Lowell", State = "MA", Email = "*****@*****.**" }, Card = new CardType { Number = "4100000000000001", ExpDate = "1215", Type = MethodOfPaymentTypeEnum.VI }, PlanCode = "abcdefg", SubscriptionId = 12345 }; var regex = FormMatchExpression( "<litleOnlineRequest.*?", "<updateSubscription>", "<subscriptionId>12345</subscriptionId>", "<planCode>abcdefg</planCode>", "<billToAddress>", "<name>Greg Dake</name>", "</billToAddress>", "<card>", "<type>VI</type>", "</card>", "<billingDate>2002-10-09</billingDate>", "</updateSubscription>", "</litleOnlineRequest>"); const string value = "<litleOnlineResponse version='8.20' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><updateSubscriptionResponse ><litleTxnId>456</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04</responseTime><subscriptionId>12345</subscriptionId></updateSubscriptionResponse></litleOnlineResponse>"; MockLitlePost(regex, value); UpdateSubscriptionResponse response = Litle.UpdateSubscription(update); Assert.AreEqual("12345", response.SubscriptionId); Assert.AreEqual("456", response.LitleTxnId); Assert.AreEqual("000", response.Response); Assert.NotNull(response.ResponseTime); }
public UpdateSubscriptionResponse UpdateSubscription(UpdateSubscription updateSubscription) { LitleOnlineRequest request = CreateLitleOnlineRequest(); request.UpdateSubscription = updateSubscription; LitleOnlineResponse response = SendToLitle(request); return response.UpdateSubscriptionResponse; }
public void testUpdateSubscription() { UpdateSubscription update = new UpdateSubscription(); update.BillingDate = new DateTime(2002, 10, 9); Contact billToAddress = new Contact(); billToAddress.Name = "Greg Dake"; billToAddress.City = "Lowell"; billToAddress.State = "MA"; billToAddress.Email = "*****@*****.**"; update.BillToAddress = billToAddress; CardType card = new CardType(); card.Number = "4100000000000001"; card.ExpDate = "1215"; card.Type = MethodOfPaymentTypeEnum.VI; update.Card = card; update.PlanCode = "abcdefg"; update.SubscriptionId = 12345; var mockLitleResponse = new Mock<LitleResponse>(); var mockLitleXmlSerializer = new Mock<LitleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<updateSubscriptionResponse 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></updateSubscriptionResponse>") .Returns("<updateSubscriptionResponse 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></updateSubscriptionResponse>"); BatchResponse mockLitleBatchResponse = new BatchResponse(); mockLitleBatchResponse.SetUpdateSubscriptionResponseReader(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.AddUpdateSubscription(update); litle.AddBatch(litleBatchRequest); string batchFileName = litle.SendToLitle(); LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName); BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("12345", actualLitleBatchResponse.NextUpdateSubscriptionResponse().SubscriptionId); Assert.AreEqual("54321", actualLitleBatchResponse.NextUpdateSubscriptionResponse().SubscriptionId); Assert.IsNull(actualLitleBatchResponse.NextUpdateSubscriptionResponse()); 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 testUpdateSubscription_CanContainToken() { var update = new UpdateSubscription { SubscriptionId = 1, Token = new CardTokenType {LitleToken = "123456"} }; string actual = update.Serialize(); const string expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <token> <litleToken>123456</litleToken> </token> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_CanContainUpdateAddOns() { var update = new UpdateSubscription { SubscriptionId = 1, UpdateAddOns = { new UpdateAddOn { AddOnCode = "1", Name = "addOn1", Amount = 100, StartDate = new DateTime(2013, 9, 5), EndDate = new DateTime(2013, 9, 6) }, new UpdateAddOn { AddOnCode = "2", Name = "addOn2", Amount = 200, StartDate = new DateTime(2013, 9, 4), EndDate = new DateTime(2013, 9, 5) } } }; string actual = update.Serialize(); const string expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <updateAddOn> <addOnCode>1</addOnCode> <name>addOn1</name> <amount>100</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate> </updateAddOn> <updateAddOn> <addOnCode>2</addOnCode> <name>addOn2</name> <amount>200</amount> <startDate>2013-09-04</startDate> <endDate>2013-09-05</endDate> </updateAddOn> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_CanContainDeleteDiscounts() { var update = new UpdateSubscription { SubscriptionId = 1, DeleteDiscounts = { new DeleteDiscount {DiscountCode = "1"}, new DeleteDiscount {DiscountCode = "2"} } }; string actual = update.Serialize(); const string expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <deleteDiscount> <discountCode>1</discountCode> </deleteDiscount> <deleteDiscount> <discountCode>2</discountCode> </deleteDiscount> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_CanContainPaypage() { var update = new UpdateSubscription { SubscriptionId = 1, Paypage = new CardPaypageType {PaypageRegistrationId = "abc123"} }; string actual = update.Serialize(); const string expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <paypage> <paypageRegistrationId>abc123</paypageRegistrationId> </paypage> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_CanContainCreateDiscounts() { var update = new UpdateSubscription { SubscriptionId = 1, CreateDiscounts = { new CreateDiscount { DiscountCode = "1", Name = "cheaper", Amount = 200, StartDate = new DateTime(2013, 9, 5), EndDate = new DateTime(2013, 9, 6) }, new CreateDiscount { DiscountCode = "2", Name = "cheap", Amount = 100, StartDate = new DateTime(2013, 9, 3), EndDate = new DateTime(2013, 9, 4) } } }; string actual = update.Serialize(); const string expected = @" <updateSubscription> <subscriptionId>1</subscriptionId> <createDiscount> <discountCode>1</discountCode> <name>cheaper</name> <amount>200</amount> <startDate>2013-09-05</startDate> <endDate>2013-09-06</endDate> </createDiscount> <createDiscount> <discountCode>2</discountCode> <name>cheap</name> <amount>100</amount> <startDate>2013-09-03</startDate> <endDate>2013-09-04</endDate> </createDiscount> </updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription_OnlyRequired() { var update = new UpdateSubscription { SubscriptionId = 12345 }; string actual = update.Serialize(); const string expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n</updateSubscription>"; Assert.AreEqual(expected, actual); }
public void TestUpdateSubscription_Full() { var update = new UpdateSubscription { BillingDate = new DateTime(2002, 10, 9), BillToAddress = new Contact { Name = "Greg Dake", City = "Lowell", State = "MA", Email = "*****@*****.**" }, Card = new CardType { Number = "4100000000000001", ExpDate = "1215", Type = MethodOfPaymentTypeEnum.VI }, PlanCode = "abcdefg", SubscriptionId = 12345 }; string actual = update.Serialize(); const string expected = "\r\n<updateSubscription>\r\n<subscriptionId>12345</subscriptionId>\r\n<planCode>abcdefg</planCode>\r\n<billToAddress>\r\n<name>Greg Dake</name>\r\n<city>Lowell</city>\r\n<state>MA</state>\r\n<email>[email protected]</email>\r\n</billToAddress>\r\n<card>\r\n<type>VI</type>\r\n<number>4100000000000001</number>\r\n<expDate>1215</expDate>\r\n</card>\r\n<billingDate>2002-10-09</billingDate>\r\n</updateSubscription>"; Assert.AreEqual(expected, actual); }
public void testUpdateSubscription() { UpdateSubscription update = new UpdateSubscription(); update.BillingDate = new DateTime(2002, 10, 9); Contact billToAddress = new Contact(); billToAddress.Name = "Greg Dake"; billToAddress.City = "Lowell"; billToAddress.State = "MA"; billToAddress.Email = "*****@*****.**"; update.BillToAddress = billToAddress; CardType card = new CardType(); card.Number = "4100000000000001"; card.ExpDate = "1215"; card.Type = MethodOfPaymentTypeEnum.VI; update.Card = card; update.PlanCode = "abcdefg"; update.SubscriptionId = 12345; batchRequest.AddUpdateSubscription(update); Assert.AreEqual(1, batchRequest.GetNumUpdateSubscriptions()); mockLitleFile.Verify(litleFile => litleFile.CreateRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, update.Serialize())); }
public void AddUpdateSubscription(UpdateSubscription updateSubscription) { if (_numAccountUpdates == 0) { _numUpdateSubscriptions++; _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, updateSubscription); } else { throw new LitleOnlineException(AccountUpdateErrorMessage); } }