public void choices_must_be_two_or_more() { var sut = new ChoiceOptions(); List <string> optoins = new List <string> { "A" }; Assert.Throws <ArgumentOutOfRangeException>(() => sut.Choices = optoins); }
/// <summary> /// Method which renders the prompt to the user given the current input state. /// </summary> /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param> /// <param name="state">Dialog <see cref="InputState"/>.</param> /// <param name="cancellationToken">Optional, the <see cref="CancellationToken"/> that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Activity to send to the user.</returns> protected override async Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default) { var locale = DetermineCulture(dc); var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false); var channelId = dc.Context.Activity.ChannelId; var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? DefaultChoiceOptions[locale]; var options = dc.State.GetValue <ChoiceInputOptions>(ThisPath.Options); return(AppendChoices(prompt.AsMessageActivity(), channelId, options.Choices, Style.GetValue(dc.State), choiceOptions)); }
/// <summary> /// Method which renders the prompt to the user given the current input state. /// </summary> /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param> /// <param name="state">Dialog <see cref="InputState"/>.</param> /// <param name="cancellationToken">Optional, the <see cref="CancellationToken"/> that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Activity to send to the user.</returns> protected override async Task <IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default) { var locale = DetermineCulture(dc); var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false); var channelId = dc.Context.Activity.ChannelId; var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? DefaultChoiceOptions[locale]; var(choices, error) = Choices.TryGetValue(dc.State); if (error != null) { throw new InvalidOperationException(error); } return(AppendChoices(prompt.AsMessageActivity(), channelId, choices, Style.GetValue(dc.State), choiceOptions)); }
static void Main(string[] args) { ChoiceOptions choiceOptions = new ChoiceOptions(); choiceOptions.ShowMainMenu(); }
public Sql(ChoiceOptions choice, string connectionString) { Choice = choice; ConnectionString = connectionString; }
public void AddChoiceOption(ChoiceOption choiceOption) { ChoiceOptions.Add(choiceOption); }