添加网站文件
This commit is contained in:
205
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/OpenLife/ClientTest.cs
vendored
Normal file
205
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/OpenLife/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Marketing.OpenLife.Models;
|
||||
using System.Collections.Generic;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Marketing.OpenLife
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.OpenLife.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateImageTextContent()
|
||||
{
|
||||
AlipayOpenPublicMessageContentCreateResponse response = Factory.Marketing.OpenLife().CreateImageTextContent("标题",
|
||||
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
|
||||
"示例", "T", "activity", "满100减10",
|
||||
"关键,热度", "13434343432,xxx@163.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.NotNull(response.ContentId);
|
||||
Assert.NotNull(response.ContentUrl);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestModifyImageTextContent()
|
||||
{
|
||||
AlipayOpenPublicMessageContentModifyResponse response = Factory.Marketing.OpenLife().ModifyImageTextContent(
|
||||
"20190510645210035577f788-d6cd-4020-9dba-1a195edb7342", "新标题",
|
||||
"http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
|
||||
"新示例", "T", "activity", "满100减20",
|
||||
"关键,热度", "13434343432,xxx@163.com");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.ContentId, "20190510645210035577f788-d6cd-4020-9dba-1a195edb7342");
|
||||
Assert.NotNull(response.ContentUrl);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSendText()
|
||||
{
|
||||
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendText("测试");
|
||||
|
||||
if (response.Code.Equals("10000"))
|
||||
{
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.NotNull(response.MessageId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
|
||||
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.Null(response.MessageId);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSendImageText()
|
||||
{
|
||||
Article article = new Article
|
||||
{
|
||||
ActionName = "测试",
|
||||
Desc = "测试",
|
||||
Title = "测试",
|
||||
ImageUrl = "http://dl.django.t.taobao.com/rest/1.0/image?fileIds=hOTQ1lT1TtOjcxGflvnUXgAAACMAAQED",
|
||||
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send"
|
||||
};
|
||||
AlipayOpenPublicMessageTotalSendResponse response = Factory.Marketing.OpenLife().SendImageText(new List<Article> { article });
|
||||
|
||||
if (response.Code.Equals("10000"))
|
||||
{
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.NotNull(response.MessageId);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "PUB.MSG_BATCH_SD_OVER");
|
||||
Assert.AreEqual(response.SubMsg, "批量发送消息频率超限");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.Null(response.MessageId);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSendSingleMessage()
|
||||
{
|
||||
Keyword keyword = new Keyword
|
||||
{
|
||||
Color = "#85be53",
|
||||
Value = "HU7142"
|
||||
};
|
||||
Context context = new Context
|
||||
{
|
||||
HeadColor = "#85be53",
|
||||
Url = "https://docs.open.alipay.com/api_6/alipay.open.public.message.single.send",
|
||||
ActionName = "查看详情",
|
||||
Keyword1 = keyword,
|
||||
Keyword2 = keyword,
|
||||
First = keyword,
|
||||
Remark = keyword
|
||||
};
|
||||
Alipay.EasySDK.Marketing.OpenLife.Models.Template template = new Alipay.EasySDK.Marketing.OpenLife.Models.Template
|
||||
{
|
||||
TemplateId = "e44cd3e52ffa46b1a50afc145f55d1ea",
|
||||
Context = context
|
||||
};
|
||||
AlipayOpenPublicMessageSingleSendResponse response = Factory.Marketing.OpenLife().SendSingleMessage(
|
||||
"2088002656718920", template);
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.IsNull(response.SubCode);
|
||||
Assert.IsNull(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRecallMessage()
|
||||
{
|
||||
AlipayOpenPublicLifeMsgRecallResponse response = Factory.Marketing.OpenLife().RecallMessage("201905106452100327f456f6-8dd2-4a06-8b0e-ec8a3a85c46a");
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.IsNull(response.SubCode);
|
||||
Assert.IsNull(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSetIndustry()
|
||||
{
|
||||
AlipayOpenPublicTemplateMessageIndustryModifyResponse response = Factory.Marketing.OpenLife().SetIndustry(
|
||||
"10001/20102", "IT科技/IT软件与服务",
|
||||
"10001/20102", "IT科技/IT软件与服务");
|
||||
|
||||
if (response.Code.Equals("10000"))
|
||||
{
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "3002");
|
||||
Assert.AreEqual(response.SubMsg, ("模板消息行业一月只能修改一次"));
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIndustry()
|
||||
{
|
||||
AlipayOpenPublicSettingCategoryQueryResponse response = Factory.Marketing.OpenLife().GetIndustry();
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.AreEqual(response.PrimaryCategory, "IT科技/IT软件与服务");
|
||||
Assert.AreEqual(response.SecondaryCategory, "IT科技/IT软件与服务");
|
||||
}
|
||||
}
|
||||
}
|
||||
100
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/Pass/ClientTest.cs
vendored
Normal file
100
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/Pass/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Marketing.Pass.Models;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Marketing.Pass
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTemplate()
|
||||
{
|
||||
AlipayPassTemplateAddResponse response = Factory.Marketing.Pass().CreateTemplate("123456789", GetTplContent());
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.True(response.Success);
|
||||
Assert.True(response.Result.Contains("tpl_id"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdateTemplate()
|
||||
{
|
||||
AlipayPassTemplateUpdateResponse response = Factory.Marketing.Pass().UpdateTemplate("2020012014534017917956080", GetTplContent());
|
||||
|
||||
Assert.IsTrue(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "10000");
|
||||
Assert.AreEqual(response.Msg, "Success");
|
||||
Assert.Null(response.SubCode);
|
||||
Assert.Null(response.SubMsg);
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.True(response.Success);
|
||||
Assert.True(response.Result.Contains("tpl_id"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAddInstance()
|
||||
{
|
||||
AlipayPassInstanceAddResponse response = Factory.Marketing.Pass().AddInstance("2020012014534017917956080", "{}",
|
||||
"1", "{\"partner_id\":\"2088102114633762\",\"out_trade_no\":\"1234567\"}");
|
||||
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_APPID_NOSUPPORT");
|
||||
Assert.AreEqual(response.SubMsg, "该AppId不支持");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.False(response.Success);
|
||||
Assert.True(response.Result.Contains("该AppId不支持"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdateInstance()
|
||||
{
|
||||
AlipayPassInstanceUpdateResponse response = Factory.Marketing.Pass().UpdateInstance("209919213",
|
||||
"2088918273", "{}", "USED", "8612231273", "wave");
|
||||
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "KP.AE_ALIPASS_NOTEXIST");
|
||||
Assert.AreEqual(response.SubMsg, "卡券不存在");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
Assert.False(response.Success);
|
||||
Assert.True(response.Result.Contains("{\"operate\":\"UPDATE\"}"));
|
||||
}
|
||||
|
||||
private string GetTplContent()
|
||||
{
|
||||
return "{\"logo\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\",\"strip\":null,\"icon\":null,"
|
||||
+ "\"content\":{\"evoucherInfo\":{\"goodsId\":\"\",\"title\":\"test\",\"type\":\"boardingPass\","
|
||||
+ "\"product\":\"air\",\"startDate\":\"2020-01-20 13:45:56\",\"endDate\":\"2020-01-25 13:45:56\","
|
||||
+ "\"operation\":[{\"message\":{\"img\":\"http://img01.taobaocdn.com/top/i1/LB1NDJuQpXXXXbYXFXXXXXXXXXX\","
|
||||
+ "\"target\":\"\"},\"format\":\"img\",\"messageEncoding\":\"utf-8\",\"altText\":\"\"}],"
|
||||
+ "\"einfo\":{\"logoText\":\"test\",\"headFields\":[{\"key\":\"test\",\"label\":\"测试\",\"value\":\"\","
|
||||
+ "\"type\":\"text\"}],\"primaryFields\":[{\"key\":\"from\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"},"
|
||||
+ "{\"key\":\"to\",\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"secondaryFields\":[{\"key\":\"fltNo\","
|
||||
+ "\"label\":\"航班号\",\"value\":\"CA123\",\"type\":\"text\"}],\"auxiliaryFields\":[{\"key\":\"test\","
|
||||
+ "\"label\":\"测试\",\"value\":\"\",\"type\":\"text\"}],\"backFields\":[]},\"locations\":[]},"
|
||||
+ "\"merchant\":{\"mname\":\"钟雨\",\"mtel\":\"\",\"minfo\":\"\"},\"platform\":{\"channelID\":\"2088201564809153\","
|
||||
+ "\"webServiceUrl\":\"https://alipass.alipay.com/builder/syncRecord.htm?tempId=2020012013442621326446216\"},"
|
||||
+ "\"style\":{\"backgroundColor\":\"RGB(26,150,219)\"},\"fileInfo\":{\"formatVersion\":\"2\",\"canShare\":true,"
|
||||
+ "\"canBuy\":false,\"canPresent\":true,\"serialNumber\":\"2020012013520759738677158\",\"supportTaxi\":\"true\","
|
||||
+ "\"taxiSchemaUrl\":\"alipays://platformapi/startapp?appId=20000778&bizid=260&channel=71322\"},"
|
||||
+ "\"appInfo\":{\"app\":{\"android_appid\":\"\",\"ios_appid\":\"\",\"android_launch\":\"\",\"ios_launch\":\"\","
|
||||
+ "\"android_download\":\"\",\"ios_download\":\"\"},\"label\":\"测试\",\"message\":\"\"},"
|
||||
+ "\"source\":\"alipassprod\",\"alipayVerify\":[\"qrcode\"]}}";
|
||||
}
|
||||
}
|
||||
}
|
||||
34
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/TemplateMessage/ClientTest.cs
vendored
Normal file
34
vendor/alipaysdk/easysdk/csharp/UnitTest/Marketing/TemplateMessage/ClientTest.cs
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
using NUnit.Framework;
|
||||
using Alipay.EasySDK.Factory;
|
||||
using Alipay.EasySDK.Marketing.TemplateMessage.Models;
|
||||
using Alipay.EasySDK.Kernel.Util;
|
||||
|
||||
namespace UnitTest.Marketing.TemplateMessage
|
||||
{
|
||||
public class ClientTest
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Factory.SetOptions(TestAccount.Mini.CONFIG);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSend()
|
||||
{
|
||||
AlipayOpenAppMiniTemplatemessageSendResponse response = Factory.Marketing.TemplateMessage().Send(
|
||||
"2088102122458832",
|
||||
"2017010100000000580012345678",
|
||||
"MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM=",
|
||||
"page/component/index",
|
||||
"{\"keyword1\": {\"value\" : \"12:00\"},\"keyword2\": {\"value\" : \"20180808\"},\"keyword3\": {\"value\" : \"支付宝\"}}");
|
||||
|
||||
Assert.IsFalse(ResponseChecker.Success(response));
|
||||
Assert.AreEqual(response.Code, "40004");
|
||||
Assert.AreEqual(response.Msg, "Business Failed");
|
||||
Assert.AreEqual(response.SubCode, "USER_TEMPLATE_ILLEGAL");
|
||||
Assert.AreEqual(response.SubMsg, "模板非法");
|
||||
Assert.NotNull(response.HttpBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user