public async Task ToDoHelperTest_GetAll_Success() { List <ToDo> to = new List <ToDo>(); Mock <IToDoService> mockTodoService = new Mock <IToDoService>(); mockTodoService.Setup(t => t.GetAll()).ReturnsAsync(to).Verifiable(); ToDoHelper todo = new ToDoHelper(mockTodoService.Object); var result = await todo.GetAll(); Assert.IsInstanceOfType(result, typeof(List <ToDo>)); }
/// <summary> /// Run every turn of the conversation. Handles orchestration of messages. /// </summary> /// <param name="dc">Current dialog context.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Completed Task.</returns> protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken)) { // Get the conversation state from the turn context var state = await this.toDoSkillAccessors.ToDoSkillState.GetAsync(dc.Context, () => new ToDoSkillState()); var dialogState = await this.toDoSkillAccessors.ConversationDialogState.GetAsync(dc.Context, () => new DialogState()); ToDo luisResult = null; if (this.skillMode && state.LuisResultPassedFromSkill != null) { luisResult = (ToDo)state.LuisResultPassedFromSkill; state.LuisResultPassedFromSkill = null; } else if (this.toDoSkillServices?.LuisRecognizer != null) { luisResult = await this.toDoSkillServices.LuisRecognizer.RecognizeAsync <ToDo>(dc.Context, cancellationToken); if (luisResult == null) { throw new Exception("ToDoSkill: Could not get Luis Recognizer result."); } } else { throw new Exception("ToDoSkill: Could not get Luis Recognizer result."); } state.LuisResult = luisResult; await ToDoHelper.DigestLuisResultAsync(dc.Context, this.toDoSkillAccessors); var skillOptions = new ToDoSkillDialogOptions { SkillMode = this.skillMode, }; var intent = luisResult?.TopIntent().intent; switch (intent) { case ToDo.Intent.Greeting: { await dc.BeginDialogAsync(GreetingDialog.Name, skillOptions); break; } case ToDo.Intent.ShowToDo: case ToDo.Intent.Previous: case ToDo.Intent.Next: { await dc.BeginDialogAsync(ShowToDoTasksDialog.Name, skillOptions); break; } case ToDo.Intent.AddToDo: { await dc.BeginDialogAsync(AddToDoTaskDialog.Name, skillOptions); break; } case ToDo.Intent.MarkToDo: { await dc.BeginDialogAsync(MarkToDoTaskDialog.Name, skillOptions); break; } case ToDo.Intent.DeleteToDo: { await dc.BeginDialogAsync(DeleteToDoTaskDialog.Name, skillOptions); break; } case ToDo.Intent.None: { await this.toDoSkillResponses.ReplyWith(dc.Context, ToDoSkillResponses.Confused); if (skillMode) { await CompleteAsync(dc); } break; } default: { await dc.Context.SendActivityAsync("This feature is not yet available in the To Do Skill. Please try asking something else."); if (skillMode) { await CompleteAsync(dc); } break; } } }