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

Commit 6e44560

Browse files
authored
[DO NOT MERGE] Add calendar test cases (#440)
* add some test case * add create and summary flow test * add test case for next meeting, update, and delete flow * add sample test case for connect to meeting flow and time remaining flow * add end action * fix style cop warning * handle invaild duration
1 parent efb8213 commit 6e44560

28 files changed

+1259
-481
lines changed

solutions/Virtual-Assistant/src/csharp/skills/calendarskill/Dialogs/CreateEvent/CreateEventDialog.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ public CreateEventDialog(
848848
endtime.Hour,
849849
endtime.Minute,
850850
endtime.Second);
851+
endDateTime = TimeZoneInfo.ConvertTimeToUtc(endDateTime, state.GetUserTimeZone());
851852
if (state.EndDateTime == null || endDateTime >= state.StartDateTime)
852853
{
853854
state.EndDateTime = endDateTime;
@@ -857,6 +858,7 @@ public CreateEventDialog(
857858
else
858859
{
859860
state.EndDateTime = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);
861+
state.EndDateTime = TimeZoneInfo.ConvertTimeToUtc(state.EndDateTime.Value, state.GetUserTimeZone());
860862
}
861863

862864
var ts = state.StartDateTime.Value.Subtract(state.EndDateTime.Value).Duration();
@@ -882,10 +884,20 @@ public CreateEventDialog(
882884
}
883885
else
884886
{
885-
// TODO: Handle improper duration
887+
state.EndDate = new List<DateTime>();
888+
state.EndTime = new List<DateTime>();
889+
state.EndDateTime = null;
886890
}
887891

888-
return await sc.BeginDialogAsync(Actions.UpdateDurationForCreate, new UpdateDateTimeDialogOptions(UpdateDateTimeDialogOptions.UpdateReason.NotADateTime), cancellationToken);
892+
if (state.Duration <= 0)
893+
{
894+
await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(CreateEventResponses.InvaildDuration));
895+
return await sc.BeginDialogAsync(Actions.UpdateDurationForCreate, new UpdateDateTimeDialogOptions(UpdateDateTimeDialogOptions.UpdateReason.NotFound), cancellationToken);
896+
}
897+
else
898+
{
899+
return await sc.BeginDialogAsync(Actions.UpdateDurationForCreate, new UpdateDateTimeDialogOptions(UpdateDateTimeDialogOptions.UpdateReason.NotADateTime), cancellationToken);
900+
}
889901
}
890902
catch
891903
{

solutions/Virtual-Assistant/src/csharp/skills/calendarskill/Dialogs/CreateEvent/Resources/CreateEventResponses.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ static CreateEventResponses()
4848

4949
public static BotResponse NoDuration => GetBotResponse();
5050

51-
public static BotResponse FindUserErrorMessage => GetBotResponse();
52-
5351
public static BotResponse ConfirmRecipient => GetBotResponse();
5452

53+
public static BotResponse InvaildDuration => GetBotResponse();
54+
5555
private static BotResponse GetBotResponse([CallerMemberName] string propertyName = null)
5656
{
5757
return _responseManager.GetBotResponse(propertyName);

solutions/Virtual-Assistant/src/csharp/skills/calendarskill/Dialogs/CreateEvent/Resources/CreateEventResponses.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,26 @@
156156
],
157157
"inputHint": "expectingInput"
158158
},
159-
"FindUserErrorMessage": {
160-
"replies": [
161-
{
162-
"text": "I can't find the person named {UserName} right now. Please try again or cancel.",
163-
"speak": "I can't find the person named {UserName} right now. Please try again or cancel."
164-
}
165-
],
166-
"inputHint": "acceptingInput"
167-
},
168-
"ConfirmRecipient": {
169-
"replies": [
170-
{
171-
"text": "Who do you want to invite?",
172-
"speak": "Who do you want to invite?"
173-
},
174-
{
175-
"text": "What contact do you want to select?",
176-
"speak": "What contact do you want to select?"
177-
}
178-
],
179-
"inputHint": "expectingInput"
180-
}
159+
"ConfirmRecipient": {
160+
"replies": [
161+
{
162+
"text": "Who do you want to invite?",
163+
"speak": "Who do you want to invite?"
164+
},
165+
{
166+
"text": "What contact do you want to select?",
167+
"speak": "What contact do you want to select?"
168+
}
169+
],
170+
"inputHint": "expectingInput"
171+
},
172+
"InvaildDuration": {
173+
"replies": [
174+
{
175+
"text": "The end time of the meeting cannot be earlier than or equal to the start time. Please try again.",
176+
"speak": "The end time of the meeting cannot be earlier than or equal to the start time. Please try again."
177+
}
178+
],
179+
"inputHint": "expectingInput"
180+
}
181181
}

0 commit comments

Comments
 (0)