test(tenpayv2): 补充若干单元测试用例

This commit is contained in:
Fu Diwei 2022-05-11 18:43:43 +08:00
parent 8486d3dafb
commit db3aa0a8f3
2 changed files with 40 additions and 2 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Xunit;
@ -6,8 +6,27 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests
{
public class TestCase_ApiExecutePayTests
{
[Fact(DisplayName = "测试用例:调用 API [POST] /pay/unifiedorder")]
public async Task TestCase_ApiExecuteCreatePayUnifiedOrderTests()
{
var request = new Models.CreatePayUnifiedOrderRequest()
{
OutTradeNumber = "TEST_OTN_" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"),
Body = "TEST_BODY",
TotalFee = 1,
ClientIp = "127.0.0.7",
AppId = TestConfigs.WechatAppId,
OpenId = TestConfigs.WechatOpenId,
TradeType = "JSAPI",
NotifyUrl = "https://example.com"
};
var response = await TestClients.Instance.ExecuteCreatePayUnifiedOrderAsync(request);
Assert.NotNull(response.PrepayId);
}
[Fact(DisplayName = "测试用例:调用 API [POST] /pay/micropay")]
public async Task TestCase_ApiExecuteExecuteCreatePayMicroPayTests()
public async Task TestCase_ApiExecuteCreatePayMicroPayTests()
{
var request = new Models.CreatePayMicroPayRequest()
{

View File

@ -0,0 +1,19 @@
using Newtonsoft.Json.Linq;
using Xunit;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests
{
public class TestCase_XmlUtilityTests
{
[Fact(DisplayName = "测试用例XML2JSON")]
public void TestXmlConvertToJson()
{
string xml = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
string json = Utilities.XmlUtility.ConvertToJson(xml); ;
JObject jObject = JObject.Parse(json)!;
Assert.Equal("SUCCESS", jObject["return_code"]!.ToString());
Assert.Equal("OK", jObject["return_msg"]!.ToString());
}
}
}