您可以找到 Enterprise Bot 模板的 C# 和 TS 版本的单元测试示例。
它是用 mocha 编写的,与用于为 botbuilder-js 存储库本身编写单元测试的测试框架相同。
这是Main 对话框中Intro Card 测试的一个小sn-p。
describe("Intro Card", function () {
it("Send conversationUpdate and verify card is received", function (done) {
const testAdapter = botTestBase.getTestAdapter();
const flow = testAdapter
.send({
type: "conversationUpdate",
membersAdded: [
{
id: "1",
name: "Bot"
}
],
channelId: "emulator",
recipient: {
id: "1"
}
})
.assertReply(function (activity, description) {
assert.equal(activity.attachments[0].contentType, 'application/vnd.microsoft.card.adaptive');
assert.deepEqual(activity.attachments[0].content, introJson);
})
testNock.resolveWithMocks('mainDialog_introCard_response', done, flow);
});
});
请记住,模板团队正在积极构建虚拟助手和企业机器人,因此模式可能会改变,但这是他们现在发布的内容:)