public void ShouldRenderUnincludedNumbersChoicesAsAList() { var activity = ChoiceFactory.List(colorChoices, "select from:", options: new ChoiceFactoryOptions { IncludeNumbers = false }); Assert.AreEqual("select from:\n\n - red\n - green\n - blue", activity.Text); }
protected IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList <Choice> choices, ListStyle style, ChoiceFactoryOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { // Get base prompt text (if any) var text = prompt != null && !string.IsNullOrEmpty(prompt.Text) ? prompt.Text : string.Empty; // Create temporary msg IMessageActivity msg; switch (style) { case ListStyle.Inline: msg = ChoiceFactory.Inline(choices, text, null, options); break; case ListStyle.List: msg = ChoiceFactory.List(choices, text, null, options); break; case ListStyle.SuggestedAction: msg = ChoiceFactory.SuggestedAction(choices, text); break; case ListStyle.None: msg = Activity.CreateMessageActivity(); msg.Text = text; break; default: msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options); break; } // Update prompt with text and actions if (prompt != null) { // clone the prompt the set in the options (note ActivityEx has Properties so this is the safest mechanism) prompt = JsonConvert.DeserializeObject <Activity>(JsonConvert.SerializeObject(prompt)); prompt.Text = msg.Text; if (msg.SuggestedActions != null && msg.SuggestedActions.Actions != null && msg.SuggestedActions.Actions.Count > 0) { prompt.SuggestedActions = msg.SuggestedActions; } return(prompt); } else { msg.InputHint = InputHints.ExpectingInput; return(msg); } }
protected IMessageActivity AppendChoices(IMessageActivity prompt, string channelId, IList <Choice> choices, ListStyle style, ChoiceFactoryOptions options = null) { // Get base prompt text (if any) var text = prompt != null && !string.IsNullOrEmpty(prompt.Text) ? prompt.Text : string.Empty; // Create temporary msg IMessageActivity msg; switch (style) { case ListStyle.Inline: msg = ChoiceFactory.Inline(choices, text, null, options); break; case ListStyle.List: msg = ChoiceFactory.List(choices, text, null, options); break; case ListStyle.SuggestedAction: msg = ChoiceFactory.SuggestedAction(choices, text); break; case ListStyle.None: msg = Activity.CreateMessageActivity(); msg.Text = text; break; default: msg = ChoiceFactory.ForChannel(channelId, choices, text, null, options); break; } // Update prompt with text and actions if (prompt != null) { prompt.Text = msg.Text; if (msg.SuggestedActions != null && msg.SuggestedActions.Actions != null && msg.SuggestedActions.Actions.Count > 0) { prompt.SuggestedActions = msg.SuggestedActions; } return(prompt); } else { msg.InputHint = InputHints.ExpectingInput; return(msg); } }
public async Task Prompt(ITurnContext context, List <Choice> choices, string prompt = null, string speak = null) { BotAssert.ContextNotNull(context); if (choices == null) { throw new ArgumentNullException(nameof(choices)); } IMessageActivity msg; switch (Style) { case ListStyle.Inline: msg = ChoiceFactory.Inline(choices, prompt, speak, ChoiceOptions); break; case ListStyle.List: msg = ChoiceFactory.List(choices, prompt, speak, ChoiceOptions); break; case ListStyle.SuggestedAction: msg = ChoiceFactory.SuggestedAction(choices, prompt, speak); break; case ListStyle.None: msg = Activity.CreateMessageActivity(); msg.Text = prompt; msg.Speak = speak; break; case ListStyle.Auto: default: msg = ChoiceFactory.ForChannel(context, choices, prompt, speak, ChoiceOptions); break; } msg.InputHint = InputHints.ExpectingInput; await context.SendActivity(msg); }
public void ShouldRenderChoicesAsAList() { var activity = ChoiceFactory.List(colorChoices, "select from:"); Assert.AreEqual("select from:\n\n 1. red\n 2. green\n 3. blue", activity.Text); }