test(tenpayv2): 补充发起退款接口的单元测试用例

This commit is contained in:
Fu Diwei 2022-01-25 13:44:22 +08:00
parent ad9c8dab8d
commit ba9665f62e
5 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1 @@
appsettings.local.json

View File

@ -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);
}
}
}

View File

@ -8,6 +8,7 @@
{
MerchantId = TestConfigs.WechatMerchantId,
MerchantSecret = TestConfigs.WechatMerchantSecret,
MerchantCertificateBytes = TestConfigs.WechatMerchantCertificateBytes,
AppId = TestConfigs.WechatAppId
});
}

View File

@ -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;

View File

@ -3,6 +3,7 @@
"AppId": "请在此填写用于测试的微信 AppId",
"MerchantId": "请在此填写用于测试的微信商户号",
"MerchantSecret": "请在此填写用于测试的微信商户 API 密钥",
"MerchantCertificateBase64String": "请在此填写用于测试的微信商户证书内容的 Base64 字节数组",
"OpenId": "请在此填写用于测试的微信用户唯一标识"
},
"ProjectSourceDirectory": "请输入当前 SDK 项目所在的目录完整路径,如 C:\\Project\\src\\SKIT.FlurlHttpClient.Wechat.TenpayV2\\",