From ba9665f62e740ac641b1ce11208e1678d7a85c09 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Tue, 25 Jan 2022 13:44:22 +0800 Subject: [PATCH] =?UTF-8?q?test(tenpayv2):=20=E8=A1=A5=E5=85=85=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E9=80=80=E6=AC=BE=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=8D=95?= =?UTF-8?q?=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 --- .../.gitignore | 1 + .../TestCase_ApiExecuteExecutePayTests.cs | 20 ++++++++++++++++++- .../TestClients.cs | 1 + .../TestConfigs.cs | 2 ++ .../appsettings.json | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/.gitignore diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/.gitignore b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/.gitignore new file mode 100644 index 00000000..63666fbf --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/.gitignore @@ -0,0 +1 @@ +appsettings.local.json \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecuteExecutePayTests.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecuteExecutePayTests.cs index 9d79684b..065d356d 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecuteExecutePayTests.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestCase_ApiExecuteExecutePayTests.cs @@ -7,7 +7,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests public class TestCase_ApiExecuteExecutePayTransactionsTests { [Fact(DisplayName = "测试用例:调用 API [POST] /pay/micropay")] - public async Task TestCase_ApiExecuteExecutePayTests() + public async Task TestCase_ApiExecuteExecuteCreatePayMicroPayTests() { var request = new Models.CreatePayMicroPayRequest() { @@ -23,5 +23,23 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests Assert.NotNull(response.ReturnMessage); Assert.NotNull(response.TransactionId); } + + [Fact(DisplayName = "测试用例:调用 API [POST] /secapi/pay/refund")] + public async Task TestCase_ApiExecuteCreatePayRefundTests() + { + var request = new Models.CreatePayRefundRequest() + { + OutTradeNumber = "TSET_OUTTRADENO", + OutRefundNumber = "TEST_OTN_" + DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"), + TotalFee = 1, + RefundFee = 1, + Description = "TEST_DESC" + }; + var response = await TestClients.Instance.ExecuteCreatePayRefundAsync(request); + + Assert.NotNull(response.ReturnCode); + Assert.NotNull(response.ReturnMessage); + Assert.NotNull(response.RefundId); + } } } diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestClients.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestClients.cs index 879d3d8a..fba0559a 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestClients.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestClients.cs @@ -8,6 +8,7 @@ { MerchantId = TestConfigs.WechatMerchantId, MerchantSecret = TestConfigs.WechatMerchantSecret, + MerchantCertificateBytes = TestConfigs.WechatMerchantCertificateBytes, AppId = TestConfigs.WechatAppId }); } diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestConfigs.cs b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestConfigs.cs index 79237051..254a52de 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestConfigs.cs +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/TestConfigs.cs @@ -21,6 +21,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests WechatAppId = config.GetProperty("AppId").GetString()!; WechatMerchantId = config.GetProperty("MerchantId").GetString()!; WechatMerchantSecret = config.GetProperty("MerchantSecret").GetString()!; + WechatMerchantCertificateBytes = config.GetProperty("MerchantCertificateBase64String").GetBytesFromBase64(); WechatOpenId = config.GetProperty("OpenId").GetString()!; ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString()!; @@ -35,6 +36,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests public static readonly string WechatAppId; public static readonly string WechatMerchantId; public static readonly string WechatMerchantSecret; + public static readonly byte[] WechatMerchantCertificateBytes; public static readonly string WechatOpenId; public static readonly string ProjectSourceDirectory; diff --git a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/appsettings.json b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/appsettings.json index a36666fb..edeb299e 100644 --- a/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/appsettings.json +++ b/test/SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests/appsettings.json @@ -3,6 +3,7 @@ "AppId": "请在此填写用于测试的微信 AppId", "MerchantId": "请在此填写用于测试的微信商户号", "MerchantSecret": "请在此填写用于测试的微信商户 API 密钥", + "MerchantCertificateBase64String": "请在此填写用于测试的微信商户证书内容的 Base64 字节数组", "OpenId": "请在此填写用于测试的微信用户唯一标识" }, "ProjectSourceDirectory": "请输入当前 SDK 项目所在的目录完整路径,如 C:\\Project\\src\\SKIT.FlurlHttpClient.Wechat.TenpayV2\\",