Skip to content
This repository was archived by the owner on Jun 30, 2022. It is now read-only.

Commit 4500f61

Browse files
DingmaomaoBJTUdarrenj
authored andcommitted
[Email] add advanced ut (#441)
* add advanced ut * fix comments~
1 parent 50163f0 commit 4500f61

27 files changed

+765
-115
lines changed

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/DeleteEmail/DeleteEmailDialog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public DeleteEmailDialog(
3030
GetAuthToken,
3131
AfterGetAuthToken,
3232
CollectSelectedEmail,
33+
AfterCollectSelectedEmail,
3334
PromptToDelete,
3435
DeleteEmail,
3536
};
@@ -60,7 +61,7 @@ public DeleteEmailDialog(
6061
var state = await EmailStateAccessor.GetAsync(sc.Context);
6162
var skillOptions = (EmailSkillDialogOptions)sc.Options;
6263

63-
var focusedMessage = state.Message.FirstOrDefault();
64+
var focusedMessage = state.Message?.FirstOrDefault();
6465
if (focusedMessage != null)
6566
{
6667
return await sc.PromptAsync(Actions.TakeFurtherAction, new PromptOptions { Prompt = sc.Context.Activity.CreateReply(DeleteEmailResponses.DeleteConfirm) });

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/ForwardEmail/ForwardEmailDialog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public ForwardEmailDialog(
3333
GetAuthToken,
3434
AfterGetAuthToken,
3535
CollectSelectedEmail,
36+
AfterCollectSelectedEmail,
3637
CollectRecipient,
3738
CollectAdditionalText,
3839
ConfirmBeforeSending,
@@ -41,7 +42,7 @@ public ForwardEmailDialog(
4142

4243
var showEmail = new WaterfallStep[]
4344
{
44-
IfClearContextStep,
45+
PagingStep,
4546
ShowEmails,
4647
};
4748

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/ReplyEmail/ReplyEmailDialog.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ public ReplyEmailDialog(
3131
GetAuthToken,
3232
AfterGetAuthToken,
3333
CollectSelectedEmail,
34+
AfterCollectSelectedEmail,
3435
CollectAdditionalText,
3536
ConfirmBeforeSending,
3637
ReplyEmail,
3738
};
3839

3940
var showEmail = new WaterfallStep[]
4041
{
41-
IfClearContextStep,
42+
PagingStep,
4243
ShowEmails,
4344
};
4445

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/EmailSkillDialog.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ protected override Task<DialogTurnResult> EndComponentAsync(DialogContext outerD
287287
{
288288
try
289289
{
290+
var state = await EmailStateAccessor.GetAsync(sc.Context);
291+
if (state.MessageList.Count == 0)
292+
{
293+
return await sc.EndDialogAsync(true);
294+
}
295+
290296
return await sc.PromptAsync(
291297
Actions.Prompt,
292298
new PromptOptions() { Prompt = sc.Context.Activity.CreateReply(EmailSharedResponses.NoFocusMessage, ResponseBuilder) });
@@ -352,6 +358,28 @@ protected override Task<DialogTurnResult> EndComponentAsync(DialogContext outerD
352358
}
353359
}
354360

361+
protected async Task<DialogTurnResult> AfterCollectSelectedEmail(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
362+
{
363+
try
364+
{
365+
var state = await EmailStateAccessor.GetAsync(sc.Context);
366+
367+
// End the dialog when there is no focused email
368+
if (state.Message.Count == 0)
369+
{
370+
return await sc.EndDialogAsync(true);
371+
}
372+
373+
return await sc.NextAsync();
374+
}
375+
catch (Exception ex)
376+
{
377+
await HandleDialogExceptions(sc, ex);
378+
379+
return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
380+
}
381+
}
382+
355383
protected async Task<DialogTurnResult> ConfirmBeforeSending(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
356384
{
357385
try
@@ -757,10 +785,6 @@ protected async Task<PromptOptions> GenerateOptions(List<Person> personList, Lis
757785

758786
options.Choices.Add(choice);
759787
}
760-
else if (skip >= ConfigData.GetInstance().MaxDisplaySize)
761-
{
762-
return options;
763-
}
764788
else
765789
{
766790
skip--;

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/Resources/EmailSharedResponses.de.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@
198198
"EmailNotFound": {
199199
"replies": [
200200
{
201-
"text": "Sie haben keine neuen Emails.",
202-
"speak": "Sie haben keine neuen Emails."
201+
"text": "Sie haben keine relevante Emails.",
202+
"speak": "Sie haben keine relevante Emails."
203203
},
204204
{
205-
"text": "Ich habe zu diesem Zeitpunkt keine neuen e-Mails gefunden. Sie können es später nochmal versuchen.",
206-
"speak": "Ich habe zu diesem Zeitpunkt keine neuen e-Mails gefunden. Sie können es später nochmal versuchen."
205+
"text": "Ich habe zu diesem Zeitpunkt keine relevante e-Mails gefunden. Sie können es später nochmal versuchen.",
206+
"speak": "Ich habe zu diesem Zeitpunkt keine relevante e-Mails gefunden. Sie können es später nochmal versuchen."
207207
}
208208
],
209209
"inputHint": "acceptingInput"

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/Resources/EmailSharedResponses.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@
237237
"EmailNotFound": {
238238
"replies": [
239239
{
240-
"text": "You have no new email.",
241-
"speak": "You have no new email."
240+
"text": "You have no relevant email.",
241+
"speak": "You have no relevant email."
242242
},
243243
{
244-
"text": "I did not retrieve any new emails at this time. You can try again later.",
245-
"speak": "I did not retrieve any new emails at this time. You can try again later."
244+
"text": "I did not retrieve any relevant emails at this time. You can try again later.",
245+
"speak": "I did not retrieve any relevant emails at this time. You can try again later."
246246
}
247247
],
248248
"inputHint": "acceptingInput"

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/Shared/Resources/EmailSharedResponses.zh.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@
236236
"EmailNotFound": {
237237
"replies": [
238238
{
239-
"text": "你没有新的电子邮件",
240-
"speak": "你没有新的电子邮件"
239+
"text": "你没有相关的电子邮件",
240+
"speak": "你没有相关的电子邮件"
241241
},
242242
{
243-
"text": "我此时没有检索到新的电子邮件。您可以稍后再试。",
244-
"speak": "我此时没有检索到新的电子邮件。您可以稍后再试。"
243+
"text": "我此时没有检索到相关的电子邮件。您可以稍后再试。",
244+
"speak": "我此时没有检索到相关的电子邮件。您可以稍后再试。"
245245
}
246246
],
247247
"inputHint": "acceptingInput"

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/ShowEmail/Resources/ShowEmailResponses.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ static ShowEmailResponses()
2222
}
2323

2424
// Generated accessors
25-
public static BotResponse EmailNotFound => GetBotResponse();
26-
2725
public static BotResponse ReadOutPrompt => GetBotResponse();
2826

27+
public static BotResponse ReadOutOnlyOnePrompt => GetBotResponse();
28+
2929
public static BotResponse ReadOutMessage => GetBotResponse();
3030

3131
public static BotResponse ReadOutMorePrompt => GetBotResponse();

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/ShowEmail/Resources/ShowEmailResponses.json

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
{
2-
"EmailNotFound": {
3-
"replies": [
4-
{
5-
"text": "You have no new email.",
6-
"speak": "You have no new email."
7-
},
8-
{
9-
"text": "I did not retrieve any new emails at this time. You can try again later.",
10-
"speak": "I did not retrieve any new emails at this time. You can try again later."
11-
}
12-
],
13-
"inputHint": "acceptingInput"
14-
},
152
"ReadOutPrompt": {
163
"replies": [
174
{
18-
"text": "Which one do you want to hear?",
19-
"speak": "Which one do you want to hear?"
5+
"text": "Which one do you want to hear? You can also forward, reply or delete any of these.",
6+
"speak": "Which one do you want to hear? You can also forward, reply or delete any of these."
207
},
218
{
22-
"text": "Which email would you like me to read out?",
23-
"speak": "Which email would you like me to read out?"
9+
"text": "Which email would you like me to read out? You can also forward, reply or delete any of these.",
10+
"speak": "Which email would you like me to read out? You can also forward, reply or delete any of these."
2411
},
2512
{
26-
"text": "Any email you would like me to read out?",
27-
"speak": "Any email you would like me to read out?"
13+
"text": "Any email you would like me to read out? You can also forward, reply or delete any of these.",
14+
"speak": "Any email you would like me to read out? You can also forward, reply or delete any of these."
2815
},
2916
{
30-
"text": "Which email do you want more details on?",
31-
"speak": "Which email do you want more details on?"
17+
"text": "Which email do you want more details on? You can also forward, reply or delete any of these.",
18+
"speak": "Which email do you want more details on? You can also forward, reply or delete any of these."
3219
},
3320
{
34-
"text": "Which one would you like to know the content of?",
35-
"speak": "Which one would you like to know the content of?"
21+
"text": "Which one would you like to know the content of? You can also forward, reply or delete any of these.",
22+
"speak": "Which one would you like to know the content of? You can also forward, reply or delete any of these."
3623
},
3724
{
38-
"text": "Which email do you want me to read out?",
39-
"speak": "Which email do you want me to read out?"
25+
"text": "Which email do you want me to read out? You can also forward, reply or delete any of these.",
26+
"speak": "Which email do you want me to read out? You can also forward, reply or delete any of these."
4027
},
4128
{
42-
"text": "Which one do you want to hear about?",
43-
"speak": "Which one do you want to hear about?"
29+
"text": "Which one do you want to hear about? You can also forward, reply or delete any of these.",
30+
"speak": "Which one do you want to hear about? You can also forward, reply or delete any of these."
4431
},
4532
{
46-
"text": "Which email do you want me to give you the details?",
47-
"speak": "Which email do you want me to give you the details?"
33+
"text": "Which email do you want me to give you the details? You can also forward, reply or delete any of these.",
34+
"speak": "Which email do you want me to give you the details? You can also forward, reply or delete any of these."
4835
},
4936
{
50-
"text": "Which email should I read to you?",
51-
"speak": "Which email should I read to you?"
37+
"text": "Which email should I read to you? You can also forward, reply or delete any of these.",
38+
"speak": "Which email should I read to you? You can also forward, reply or delete any of these."
39+
}
40+
],
41+
"inputHint": "expectingInput"
42+
},
43+
"ReadOutOnlyOnePrompt": {
44+
"replies": [
45+
{
46+
"text": "Do you want to hear this one? You can also forward, reply or delete any of these.",
47+
"speak": "Do you want to hear this one? You can also forward, reply or delete any of these."
5248
}
5349
],
5450
"inputHint": "expectingInput"
@@ -69,8 +65,8 @@
6965
"ReadOutMorePrompt": {
7066
"replies": [
7167
{
72-
"text": "Do you want to hear more? Which one do you want to hear?",
73-
"speak": "Do you want to hear more? Which one do you want to hear?"
68+
"text": "Do you want to hear more? You can also read, forward, reply or delete any of these.",
69+
"speak": "Do you want to hear more? You can also read, forward, reply or delete any of these."
7470
}
7571
],
7672
"inputHint": "expectingInput"

solutions/Virtual-Assistant/src/csharp/skills/emailskill/Dialogs/ShowEmail/Resources/ShowEmailResponses.zh.json

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,42 @@
11
{
2-
"EmailNotFound": {
3-
"replies": [
4-
{
5-
"text": "你没有新的电子邮件。",
6-
"speak": "你没有新的电子邮件。"
7-
},
8-
{
9-
"text": "我此时没有检索到新的电子邮件。您可以稍后再试。",
10-
"speak": "我此时没有检索到新的电子邮件。您可以稍后再试。"
11-
}
12-
],
13-
"inputHint": "acceptingInput"
14-
},
152
"ReadOutPrompt": {
163
"replies": [
174
{
18-
"text": "想听听哪一个?",
19-
"speak": "想听听哪一个?"
5+
"text": "想听听哪一个?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
6+
"speak": "想听听哪一个?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
207
},
218
{
22-
"text": "你希望我读出哪封电子邮件?",
23-
"speak": "你希望我读出哪封电子邮件?"
9+
"text": "你希望我读出哪封电子邮件?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
10+
"speak": "你希望我读出哪封电子邮件?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
2411
},
2512
{
26-
"text": "你希望我读出的电子邮件?",
27-
"speak": "你希望我读出的电子邮件?"
13+
"text": "您想要哪封电子邮件的详细内容?您还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
14+
"speak": "您想要哪封电子邮件的详细内容?您还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
2815
},
2916
{
30-
"text": "您想要哪封电子邮件的详细内容?",
31-
"speak": "您想要哪封电子邮件的详细内容?"
17+
"text": "您想要读出哪封电子邮件?您还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
18+
"speak": "您想要读出哪封电子邮件?您还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
3219
},
3320
{
34-
"text": "您想知道哪一个内容?",
35-
"speak": "您想知道哪一个内容?"
21+
"text": "你想听听哪一个?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
22+
"speak": "你想听听哪一个?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
3623
},
3724
{
38-
"text": "您想要读出哪封电子邮件?",
39-
"speak": "您想要读出哪封电子邮件?"
25+
"text": "你想让我给你哪封电子邮件的详细内容?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
26+
"speak": "你想让我给你哪封电子邮件的详细内容?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
4027
},
4128
{
42-
"text": "你想听听哪一个?",
43-
"speak": "你想听听哪一个?"
44-
},
45-
{
46-
"text": "你想让我给你哪封电子邮件的详细内容?",
47-
"speak": "你想让我给你哪封电子邮件的详细内容?"
48-
},
29+
"text": "我应该给你读哪封电子邮件?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
30+
"speak": "我应该给你读哪封电子邮件?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
31+
}
32+
],
33+
"inputHint": "expectingInput"
34+
},
35+
"ReadOutOnlyOnePrompt": {
36+
"replies": [
4937
{
50-
"text": "我应该给你读哪封电子邮件?",
51-
"speak": "我应该给你读哪封电子邮件?"
38+
"text": "您想要听这封邮件的具体内容么?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
39+
"speak": "您想要听这封邮件的具体内容么?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
5240
}
5341
],
5442
"inputHint": "expectingInput"
@@ -69,8 +57,8 @@
6957
"ReadOutMorePrompt": {
7058
"replies": [
7159
{
72-
"text": "你还想听更多吗? 想听哪一个呢?",
73-
"speak": "你还想听更多吗? 想听哪一个呢?"
60+
"text": "你还想听更多吗?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。",
61+
"speak": "你还想听更多吗?你还可以转发, 回复或者删除其中任何一个, 或者通过'下一页'浏览更多。"
7462
}
7563
],
7664
"inputHint": "expectingInput"

0 commit comments

Comments
 (0)