You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
6.3 KiB
C#

5 years ago
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;
namespace Tianyi.DingtalkRobotKit.Test
{
public class SendMessageTest
{
[Fact]
public void TextMessage_Test()
5 years ago
{
var textMsg = new TextMessage("明天是美好的一天");
textMsg.at.isAtAll = true;
var result = SendMessage.Send<TextMessage>(textMsg);
Assert.Equal(0, result.errcode);
}
[Fact]
public void SendLinkMessage_Test()
{
LinkOption option = new LinkOption()
{
title = "上海防火门厂家",
text = "从事防火门和防火窗生产多年,是一家集设计、加工、销售、安装为一体的公司。",
picUrl = "http://www.ifiredoor.com/WebUpload/Images/Banner/20140414132822-18985320.jpg",
messageUrl = "http://www.ifiredoor.com/"
};
at linkAt = new at()
{
atMobiles = new List<string>() { "15601716045" },
isAtAll = true
};
var linkMsg = new LinkMessage(option, linkAt);
var result = SendMessage.Send<LinkMessage>(linkMsg);
Assert.Equal(0, result.errcode);
}
[Fact]
public void MarkdownMessage_Test()
{
MarkdownOption option = new MarkdownOption()
{
title = "防火门厂家新闻",
text = "#### 防火门厂家降价活动进行中 @15601716045 \n > 活动火热进行中... \n> ![热销中](http://www.ifiredoor.com/WebUpload/Images/Banner/20140908191900-97404602.jpg) \n > ###### 发布公司:[防火门厂家](http://www.ifiredoor.com/) "
};
at linkAt = new at()
{
atMobiles = new List<string>() { "15601716045" },
isAtAll = true
};
var mdMsg = new MarkdownMessage(option, linkAt);
var result = SendMessage.Send<MarkdownMessage>(mdMsg);
Assert.Equal(0, result.errcode);
}
[Fact]
public void WholeCardMessage_Test()
{
WholeCardOption option = new WholeCardOption()
{
title = "最新产品推荐",
text = "![screenshot](http://www.ifiredoor.com/WebUpload/Images/Banner/20180417215356-93814998.png) \n ### 钢质开启固定防火窗、钢制超大防火门,温控防火窗、钢制上旋防火窗,钢质防火逃生门、不锈钢防火门、不锈钢大玻璃门、钢质大玻璃门、防火卷帘门、木质防火门、实木门、钢制保温门、钢木门等,防火证书资质齐全生产链遍布各地,并通过 ISO9001-2008 国际体系认证.",
hideAvatar = "1",
btnOrientation = "1",
singleTitle = "阅读全文",
singleURL = "http://www.ifiredoor.com/Price.aspx?ItemID=22"
};
at linkAt = new at()
{
atMobiles = new List<string>() { "15601716045" },
isAtAll = true
};
var mdMsg = new WholeCardMessage(option, linkAt);
var result = SendMessage.Send<WholeCardMessage>(mdMsg);
Assert.Equal(0, result.errcode);
}
[Fact]
public void MultiCardMessage_Test()
{
MultiCardOption option = new MultiCardOption()
{
title = "典型客户案例",
text = "![screenshot](http://www.ifiredoor.com/WebUpload/Images/Product/20140415095636-39838472.jpg) \n ##### 我们的部分近期客户,很大方的哦",
hideAvatar = "1",
btnOrientation = "1",
btns = new List<MultiCardButton>()
{
new MultiCardButton()
{
title= "江阴隧道",
actionURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=6"
},
new MultiCardButton()
{
title= "绍兴玉澜花园",
actionURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=4"
},
new MultiCardButton()
{
title= "石油局防火门工程",
actionURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=14"
}
}
};
at linkAt = new at()
{
atMobiles = new List<string>() { "15601716045" },
isAtAll = true
};
var mdMsg = new MultiCardMessage(option, linkAt);
var result = SendMessage.Send<MultiCardMessage>(mdMsg);
Assert.Equal(0, result.errcode);
}
[Fact]
public void FeedCardMessage_Test()
{
FeedCardOption option = new FeedCardOption()
{
links = new List<FeedCardLink>()
{
new FeedCardLink()
{
title= "江阴隧道",
messageURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=6",
picURL= "http://www.ifiredoor.com/WebUpload/Images/Case/20140416112608-10209867.jpg"
},
new FeedCardLink()
{
title= "绍兴玉澜花园",
messageURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=4",
picURL= "http://www.ifiredoor.com/WebUpload/Images/Case/20140416133216-27355348.jpg"
},
new FeedCardLink()
{
title= "宁波宜家",
messageURL= "http://www.ifiredoor.com/CaseShow.aspx?ID=3",
picURL= "http://www.ifiredoor.com/WebUpload/Images/Case/20140416112252-61506570.jpg"
}
}
};
at linkAt = new at()
{
atMobiles = new List<string>() { "15601716045" },
isAtAll = true
};
var mdMsg = new FeedCardMessage(option, linkAt);
var result = SendMessage.Send<FeedCardMessage>(mdMsg);
Assert.Equal(0, result.errcode);
}
5 years ago
}
}