public void SimpleActivate() { var activate = new activate { id = "1", reportGroup = "Planets", orderId = "12344", amount = 1500, orderSource = orderSourceType.ecommerce, card = new giftCardCardType { type = methodOfPaymentTypeEnum.GC, number = "414100000000000000", cardValidationNum = "123", expDate = "1215" } }; var response = _cnp.Activate(activate); Assert.AreEqual("000", response.response); }
public void TestActivate() { activate activate = new activate(); activate.orderId = "2"; activate.orderSource = orderSourceType.ecommerce; activate.card = new giftCardCardType(); var mock = new Mock <Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<cnpOnlineRequest.*?<activate.*?<orderId>2</orderId>.*?</activate>.*?", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >())) .Returns(@" <cnpOnlineResponse version=""11.0"" xmlns=""http://www.vantivcnp.com/schema"" response=""0"" message=""ValidFormat""> <activateResponse id=""1"" reportGroup=""Planets""> <cnpTxnId>82919789861357149</cnpTxnId> <response>000</response> <responseTime>2017-01-23T19:31:10</responseTime> <message>InvalidAccountNumber</message> <postDate>2017-01-24</postDate> <fraudResult/> <virtualGiftCardResponse> <accountNumber>123456</accountNumber> <cardValidationNum>123456</cardValidationNum> <pin>1234</pin> </virtualGiftCardResponse> </activateResponse> </cnpOnlineResponse>"); Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); activateResponse activateResponse = cnp.Activate(activate); Assert.AreEqual(82919789861357149, activateResponse.cnpTxnId); Assert.AreEqual("123456", activateResponse.virtualGiftCardResponse.accountNumber); Assert.AreEqual("123456", activateResponse.virtualGiftCardResponse.cardValidationNum); Assert.AreEqual("1234", activateResponse.virtualGiftCardResponse.pin); }