public void PayWithCardOnFileTest() { var testJObject = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success"), new JProperty("transactionId", "123"), new JProperty("creditCardListType", new JObject() { new JProperty("cardsList", new JArray(new List <JObject>() { new JObject() { new JProperty("cardNumber", "123") } })) }) }; var messageHandler = new FakeHttpMessageHandler(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(testJObject), Encoding.UTF8, "application/json") }); var mockServiceClient = new MockServiceClient(messageHandler); var mockGraphService = new MockGraphService(); var mockB2CGraphService = new MockB2CGraphService(); var serviceId = new ServiceId(mockGraphService, mockB2CGraphService, _mockServiceClientServiceId); var payment = new Payment(serviceId, mockServiceClient); var input = new JObject() { new JProperty("token", "123"), new JProperty("serviceUrl", ServiceUrl.Url), new JProperty("transactionAmount", "1") }; var expectedOutput = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success"), new JProperty("transactionId", "123") }; var response = payment.PayWithCardOnFile(input); var responseObj = JObject.Parse(response); foreach (var item in responseObj) { Assert.True(expectedOutput.ContainsKey(item.Key)); var value = expectedOutput.GetValue(item.Key); Assert.Equal(value, item.Value); } }
public void GetCurrentBalanceTest() { var testJObject = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success"), new JProperty("accountDetail", new JObject() { new JProperty("currentBalance", "123") }) }; var messageHandler = new FakeHttpMessageHandler(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(testJObject), Encoding.UTF8, "application/json") }); var mockServiceClient = new MockServiceClient(messageHandler); var mockGraphService = new MockGraphService(); var mockB2CGraphService = new MockB2CGraphService(); var serviceId = new ServiceId(mockGraphService, mockB2CGraphService, _mockServiceClientServiceId); var accountDetails = new AccountDetails(serviceId, mockServiceClient); var input = new JObject() { new JProperty("token", "123"), new JProperty("serviceUrl", ServiceUrl.Url) }; var expectedOutput = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success"), new JProperty("currentBalance", "123") }; var response = accountDetails.GetCurrentBalance(input); var responseObj = JObject.Parse(response); foreach (var item in responseObj) { Assert.True(expectedOutput.ContainsKey(item.Key)); var value = expectedOutput.GetValue(item.Key); Assert.Equal(value, item.Value); } }
public void OrderTollTagTest() { var testJObject = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success"), }; var messageHandler = new FakeHttpMessageHandler(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(testJObject), Encoding.UTF8, "application/json") }); var mockServiceClient = new MockServiceClient(messageHandler); var mockGraphService = new MockGraphService(); var mockB2CGraphService = new MockB2CGraphService(); var serviceId = new ServiceId(mockGraphService, mockB2CGraphService, _mockServiceClientServiceId); var tollTag = new TollTag(serviceId, mockServiceClient); var input = new JObject() { new JProperty("token", "123"), new JProperty("serviceUrl", ServiceUrl.Url), new JProperty("quantity", "1"), new JProperty("transponderType", "interior") }; var expectedOutput = new JObject() { new JProperty("statusCode", "0"), new JProperty("message", "Success") }; var response = tollTag.OrderTollTag(input); var responseObj = JObject.Parse(response); foreach (var item in responseObj) { Assert.True(expectedOutput.ContainsKey(item.Key)); var value = expectedOutput.GetValue(item.Key); Assert.Equal(value, item.Value); } }