From db3aa0a8f3d018612c9d224b5a81a0e00a84177c Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Wed, 11 May 2022 18:43:43 +0800 Subject: [PATCH] =?UTF-8?q?test(tenpayv2):=20=E8=A1=A5=E5=85=85=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestCase_ApiExecutePayTests.cs | 23 +++++++++++++++++-- .../TestCase_XmlUtilityTests.cs | 19 +++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_XmlUtilityTests.cs diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecutePayTests.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecutePayTests.cs index 4afedfb2..1f24a85f 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecutePayTests.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecutePayTests.cs @@ -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() { diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_XmlUtilityTests.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_XmlUtilityTests.cs new file mode 100644 index 00000000..d7e10486 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_XmlUtilityTests.cs @@ -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 = ""; + 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()); + } + } +}