예제 #1
0
    // Start is called before the first frame update
    protected override void Start()
    {
        base.Start();
        ClientScene.RegisterPrefab(cardPrefab.gameObject);
        ClientScene.RegisterPrefab(creaturePrefab.gameObject);

        avatar = Resources.LoadAll <Sprite>(GameConstants.PATHS.CARD_IMAGES + GameUtils.GetDatabase().GetAvatarTexture(matchSettings.avatarIndex).name)[1];
        model  = GameUtils.GetDatabase().GetDeckModel(matchSettings.deckModelIndex);

        cardGenerator = new ProceduralCardGenerator(model, imageGlossary, gameSession.creatureModelIndex, nameModel);
        if (isLocalPlayer)
        {
            selectingTextPrompt = GameObject.Find("ScreenUI/SelectPrompt").GetComponent <TextPrompt>();
            selectingTextPrompt.gameObject.SetActive(false);

            ConfirmButton confirmButton = FindObjectOfType <ConfirmButton>();
            confirmButton.localPlayer = this;
            GameOverButton gameOverButton = FindObjectOfType <GameOverButton>();
            gameOverButton.localPlayer = this;
            SurrenderButton surrenderButton = FindObjectOfType <SurrenderButton>();
            surrenderButton.localPlayer = this;
        }
        turnTimer = FindObjectOfType <TurnTimer>();
    }
예제 #2
0
 public void SendPromptEvent(TextPrompt textP, TextPromptEventArgs textE)
 {
     textPrompted(textP, textE);
 }
예제 #3
0
 public TagPrompt(TextPrompt prompt)
 {
     _prompt = prompt;
 }
 /// <summary>
 /// Hides choices.
 /// </summary>
 /// <typeparam name="T">The prompt result type.</typeparam>
 /// <param name="obj">The prompt.</param>
 /// <returns>The same instance so that multiple calls can be chained.</returns>
 public static TextPrompt <T> HideChoices <T>(this TextPrompt <T> obj)
 {
     return(ShowChoices(obj, false));
 }
예제 #5
0
 public void DisplayTextPrompt(string title, string caption, float duration = 5f)
 {
     TextPrompt.Create(GetComponent <RectTransform>(), title, caption, duration);
 }
        public async Task TextPromptValidatorWithMessageShouldNotSendRetryPrompt()
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var dialogState = convoState.CreateProperty <DialogState>("dialogState");

            var adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName))
                          .Use(new AutoSaveStateMiddleware(convoState))
                          .Use(new TranscriptLoggerMiddleware(new TraceTranscriptLogger(traceActivity: false)));

            var dialogs = new DialogSet(dialogState);

            PromptValidator <string> validator = async(promptContext, cancellationToken) =>
            {
                var value = promptContext.Recognized.Value;
                if (value.Length <= 3)
                {
                    await promptContext.Context.SendActivityAsync(MessageFactory.Text("The text should be greater than 3 chars."), cancellationToken);

                    return(false);
                }
                else
                {
                    return(true);
                }
            };
            var textPrompt = new TextPrompt("TextPrompt", validator);

            dialogs.Add(textPrompt);

            await new TestFlow(adapter, async(turnContext, cancellationToken) =>
            {
                var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

                var results = await dc.ContinueDialogAsync(cancellationToken);
                if (results.Status == DialogTurnStatus.Empty)
                {
                    var options = new PromptOptions
                    {
                        Prompt = new Activity {
                            Type = ActivityTypes.Message, Text = "Enter some text."
                        },
                        RetryPrompt = new Activity {
                            Type = ActivityTypes.Message, Text = "Make sure the text is greater than three characters."
                        },
                    };
                    await dc.PromptAsync("TextPrompt", options);
                }
                else if (results.Status == DialogTurnStatus.Complete)
                {
                    var textResult = (string)results.Result;
                    await turnContext.SendActivityAsync(MessageFactory.Text($"Bot received the text '{textResult}'."), cancellationToken);
                }
            })
            .Send("hello")
            .AssertReply("Enter some text.")
            .Send("hi")
            .AssertReply("The text should be greater than 3 chars.")
            .Send("hello")
            .AssertReply("Bot received the text 'hello'.")
            .StartTestAsync();
        }
        private void DrawProxyNames()
        {
            using (new EditorHelper.Horizontal()) {
                EditorGUILayout.LabelField("Proxy names", GUILayout.Width(128), GUILayout.ExpandWidth(false));
                if (EditorHelper.MiniButton("Add", 64))
                {
                    TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                    textPrompt.textLabel     = "Name";
                    textPrompt.textValidator = s => {
                        if (string.IsNullOrEmpty(s))
                        {
                            return(false);
                        }
                        foreach (Proxy proxy in proxies)
                        {
                            string proxyName = proxy.name;
                            if (proxyName.Equals(s))
                            {
                                return(false);
                            }
                        }

                        return(true);
                    };
                    textPrompt.onTextValueApplied = (s, o) => {
                        proxies.Add(new Proxy()
                        {
                            id   = ++proxyCounter,
                            name = s
                        });
                        editor.Focus();
                    };
                    textPrompt.Show();
                }
            }

            int indexToRemove = -1;

            using (new EditorHelper.IndentPadding(20)) {
                for (int i = 0; i < proxies.Count; i++)
                {
                    string oldName = proxies[i].name;
                    using (new EditorHelper.Horizontal()) {
                        EditorGUILayout.TextField("Id " + proxies[i].id, oldName, GUILayout.ExpandWidth(false), GUILayout.Width(256));
                        if (EditorHelper.MiniButton("-"))
                        {
                            indexToRemove = i;
                        }

                        if (EditorHelper.MiniButton("Rename"))
                        {
                            TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                            textPrompt.obj           = new object[] { proxies, i, oldName };
                            textPrompt.textLabel     = "New name";
                            textPrompt.text          = oldName;
                            textPrompt.textValidator = s => {
                                if (string.IsNullOrEmpty(s))
                                {
                                    return(false);
                                }
                                foreach (Proxy proxy in proxies)
                                {
                                    string groupName = proxy.name;
                                    if (groupName.Equals(s))
                                    {
                                        return(false);
                                    }
                                }

                                return(true);
                            };
                            textPrompt.onTextValueApplied = (s, o) => {
                                List <Proxy> _proxies = (List <Proxy>)o[0];
                                int          index    = (int)o[1];
                                _proxies[index].name = s;

                                editor.Focus();
                            };
                            textPrompt.Show();
                        }
                    }
                }
            }

            if (indexToRemove != -1)
            {
                proxies.RemoveAt(indexToRemove);
            }
        }
예제 #8
0
 public PackageIdPrompt(TextPrompt prompt)
 {
     _prompt = prompt;
 }
예제 #9
0
        private void DrawMaterialNames()
        {
            using (new EditorHelper.Horizontal()) {
                EditorGUILayout.LabelField("Group names", GUILayout.Width(128), GUILayout.ExpandWidth(false));
                if (EditorHelper.MiniButton("Add", 64))
                {
                    TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                    textPrompt.textLabel     = "Name";
                    textPrompt.textValidator = s => {
                        if (string.IsNullOrEmpty(s))
                        {
                            return(false);
                        }
                        foreach (string groupName in groupNames)
                        {
                            if (groupName.Equals(s))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    };
                    textPrompt.onTextValueApplied = (s, o) => {
                        groupCounter++;
                        groupNames.Add(s);
                        ids.Add(groupCounter);
                        editor.Focus();
                    };
                    textPrompt.Show();
                }
            }

            int indexToRemove = -1;

            using (new EditorHelper.IndentPadding(20)) {
                for (int i = 0; i < groupNames.Count; i++)
                {
                    string oldName = groupNames[i];
                    using (new EditorHelper.Horizontal()) {
                        EditorGUILayout.TextField("#" + ids[i], oldName, GUILayout.ExpandWidth(false), GUILayout.Width(256));
                        if (EditorHelper.MiniButton("-"))
                        {
                            if (IsIdInUse(ids[i]))
                            {
                                DLog.Log($"Group name {oldName} is in use, cannot delete");
                                return;
                            }
                            indexToRemove = i;
                        }
                        if (EditorHelper.MiniButton("Rename"))
                        {
                            TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                            textPrompt.obj           = new object[] { groupNames, i, oldName };
                            textPrompt.textLabel     = "New name";
                            textPrompt.text          = oldName;
                            textPrompt.textValidator = s => {
                                if (string.IsNullOrEmpty(s))
                                {
                                    return(false);
                                }
                                foreach (string groupName in groupNames)
                                {
                                    if (groupName.Equals(s))
                                    {
                                        return(false);
                                    }
                                }
                                return(true);
                            };
                            textPrompt.onTextValueApplied = (s, o) => {
                                List <string> _groupNames = (List <string>)o[0];
                                int           index       = (int)o[1];
                                _groupNames[index] = s;
                                editor.Focus();
                            };
                            textPrompt.Show();
                        }
                    }
                }
            }

            if (indexToRemove != -1)
            {
                groupNames.RemoveAt(indexToRemove);
                ids.RemoveAt(indexToRemove);
            }
        }
예제 #10
0
        void rightadd(object sender, EventArgs e)
        {
            string syms = TextPrompt.Prompt("Symbols to add", "Enter symbols seperated by commas: ");

            addbasket(BasketImpl.FromString(syms));
        }
예제 #11
0
 public ProductNamePrompt(TextPrompt prompt)
 {
     _prompt = prompt;
 }
예제 #12
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string Property = e.Link.LinkData as string;

            PropertyInfo info = action.GetType().GetProperty(Property);

            if (info == null)
            {
                MessageBox.Show("Property " + Property + " Does not exist for " + action.GetType().Name);
                return;
            }

            DialogResult result = DialogResult.Cancel;

            string valueResult = "";

            if (info.PropertyType == typeof(NumberValue))
            {
                VariableEditor editor = new VariableEditor();
                if (Variables != null)
                {
                    editor.SetVariable(Variables.Select(x => x.Name));
                }
                else
                {
                    editor.SetVariable(new string[] { });
                }
                NumberValue val = info.GetMethod.Invoke(action, new object[] { }) as NumberValue;
                editor.SetDefault(val == null ? "" : val.ToString());
                editor.Text = "Variable Editor - " + Property;

                result = editor.ShowDialog();

                if (result == DialogResult.OK)
                {
                    info.SetMethod.Invoke(action, new object[] { new NumberValue(valueResult) });
                }
            }
            if (info.PropertyType == typeof(TargetKey))
            {
                TargetKeyEditor editor = new TargetKeyEditor();
                editor.SetPresets(ActionContext);
                editor.VariableList = Variables;

                TargetKey t = info.GetMethod.Invoke(action, new object[] { }) as TargetKey;
                if (t == null)
                {
                    t = new TargetKey();
                }
                editor.Target = t;

                result = editor.ShowDialog();

                if (result == DialogResult.OK)
                {
                    TargetKey target = editor.Target;
                    info.SetMethod.Invoke(action, new object[] { target });
                }
            }
            //It's an Enum!
            if (typeof(Enum).IsAssignableFrom(info.PropertyType))
            {
                Enum enumValue = info.GetMethod.Invoke(action, new object[] { }) as Enum;


                //Find out if it's a flag and open the flag editor
                if (info.PropertyType.GetCustomAttribute <FlagsAttribute>() != null)
                {
                    FlagCheckBoxEditor editor = new FlagCheckBoxEditor();
                    editor.EnumValue = enumValue;

                    result = editor.ShowDialog();

                    enumValue = editor.EnumValue;
                }
                else
                {
                    EnumEditor editor = new EnumEditor();
                    editor.EnumValue = enumValue;

                    result = editor.ShowDialog();

                    enumValue = editor.EnumValue;
                }

                if (result == DialogResult.OK)
                {
                    info.SetMethod.Invoke(action, new object[] { enumValue });

                    valueResult = enumValue.ToString();
                }
            }

            if (typeof(bool) == info.PropertyType)
            {
                bool val = (bool)info.GetMethod.Invoke(action, new object[] { });

                BoolEditor editor = new BoolEditor();
                editor.Value = val;

                result = editor.ShowDialog();

                if (result == DialogResult.OK)
                {
                    info.SetMethod.Invoke(action, new object[] { editor.Value });
                }
            }
            if (typeof(string) == info.PropertyType)
            {
                string val = (string)info.GetMethod.Invoke(action, new object[] { });

                TextPrompt editor = new TextPrompt();

                editor.Text       = Property;
                editor.PromptText = val;

                result = editor.ShowDialog();
                if (result == DialogResult.OK)
                {
                    info.SetMethod.Invoke(action, new object[] { editor.PromptText });
                }
            }
            if (typeof(ActionCollection) == info.PropertyType)
            {
                ActionCollection actions = info.GetMethod.Invoke(action, new object[] { }) as ActionCollection;

                ActionListEditor editor = new ActionListEditor();
                if (actions == null)
                {
                    actions = new ActionCollection(Property);
                }

                editor.ActionContext = ActionContext;
                editor.Variables     = Variables;
                editor.Actions       = actions;

                result = editor.ShowDialog();

                if (result == DialogResult.OK)
                {
                    info.SetMethod.Invoke(action, new object[] { editor.Actions });
                }
            }


            if (result == DialogResult.OK)
            {
                UpdateLinkTexts();
            }

            if (LinkClicked != null)
            {
                LinkClicked.Invoke(this, new LinkClickedEventArgs(e.Link.LinkData as string));
            }
        }
예제 #13
0
 public void ShowPrompt()
 {
     TextPrompt.CreatePrompt(DisplayResult);
 }
예제 #14
0
        private void ToolbarClicked(object sender, EventArgs e)
        {
            ToolbarItem tappedItem = sender as ToolbarItem;

            if (tappedItem == m_mnuProjectInfo)
            {
                ProjectInfoPage p = new ProjectInfoPage();
                p.Description.Text = m_proj.Description;
                p.Title            = this.Title;
                ((NavigationPage)m_mdp.Detail).PushAsync(p);
            }
            else if (tappedItem == m_mnuDelProj)
            {
                Prompt p = new Prompt()
                {
                    PromptTitle = "Are you sure?", PositiveButtonText = "Yes", NegativeButtonText = "No"
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    DeleteCommand cmd = new DeleteCommand()
                    {
                        Title = m_proj.ID
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the project list
                        ((MainPage)m_mdp).DeleteProject(m_proj);
                        //go back to the home page
                        ((MainPage)m_mdp).DisplayHome();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
            else if (tappedItem == m_mnuAddMember)
            {
                TextPrompt p = new TextPrompt()
                {
                    PromptTitle = "Enter a Mattermost User ID", Hint = "user_id", PositiveButtonText = "Add", NegativeButtonText = "Cancel", Keyboard = Keyboard.Plain
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    AddMemberCommand cmd = new AddMemberCommand()
                    {
                        Project = m_proj.ID, Member = p.Text
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the task with the new member
                        Member newMember = new Member()
                        {
                            Role = Role.MEMBER, ID = p.Text
                        };
                        m_proj.Members.Add(newMember);
                        //reload the project display
                        ReloadProjectDisplay();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
            else if (tappedItem == m_mnuCreateTask)
            {
                ManageTaskPrompt p = new ManageTaskPrompt(m_proj)
                {
                    CanAssign = false, CanSetTitle = true, CanDelete = false, PositiveButtonText = "Create", NegativeButtonText = "Cancel"
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    CreateTaskCommand cmd = new CreateTaskCommand()
                    {
                        Project = m_proj.ID, Title = p.TaskTitle, Due = p.Date, Description = p.Description
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the project with the new Task
                        Models.Task t = new Models.Task()
                        {
                            Name = p.TaskTitle, Due = p.Date, Description = p.Description
                        };
                        m_proj.Tasks.Add(t);
                        //reload the project display
                        ReloadProjectDisplay();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
        }
        public virtual ICollection <string> PromptForArgumentValues(
            CommandContext ctx, IArgument argument, out bool isCancellationRequested)
        {
            isCancellationRequested = false;

            var argumentName = _getPromptTextCallback?.Invoke(ctx, argument) ?? argument.Name;
            var promptText   = $"{argumentName} ({argument.TypeInfo.DisplayName})";
            var isPassword   = argument.TypeInfo.UnderlyingType == typeof(Password);
            var defaultValue = argument.Default?.Value;

            var ansiConsole = ctx.Services.GetOrThrow <IAnsiConsole>();

            // https://spectreconsole.net/prompts/

            if (argument.Arity.AllowsMany())
            {
                if (argument.AllowedValues.Any())
                {
                    // TODO: how to show default? is it the first choice?

                    var p = new MultiSelectionPrompt <string>
                    {
                        MoreChoicesText  = Resources.A.Selection_paging_instructions(argument.Name),
                        InstructionsText = Resources.A.MultiSelection_selection_instructions(argument.Name)
                    }
                    .Title(promptText)
                    .AddChoices(argument.AllowedValues)
                    .PageSize(_pageSize);

                    return(ansiConsole.Prompt(p));
                }
                else
                {
                    return(MultiPrompt(ansiConsole, promptText));
                }
            }
            else
            {
                if (argument.TypeInfo.Type == typeof(bool))
                {
                    var result = defaultValue != null
                        ? ansiConsole.Confirm(promptText, (bool)defaultValue)
                        : ansiConsole.Confirm(promptText);

                    return(new[] { result.ToString() });
                }
                if (argument.AllowedValues.Any())
                {
                    var p = new SelectionPrompt <string>()
                    {
                        Title           = promptText,
                        PageSize        = _pageSize,
                        MoreChoicesText = Resources.A.Selection_paging_instructions(argument.Name)
                    }
                    .AddChoices(argument.AllowedValues);

                    // TODO: how to show default? is it the first choice?

                    return(new [] { ansiConsole.Prompt(p) });
                }
                else
                {
                    var p = new TextPrompt <string>(promptText)
                    {
                        IsSecret         = isPassword,
                        AllowEmpty       = argument.Arity.RequiresNone(),
                        ShowDefaultValue = true
                    };
                    if (defaultValue != null)
                    {
                        p.DefaultValue(defaultValue.ToString() !);
                    }
                    return(new[] { ansiConsole.Prompt(p) });
                }
            }
        }
예제 #16
0
        static void Main(string[] args)
        {
            TextPrompt <string> modePrompt = new TextPrompt <string>("Select DynamoDB Connect Mode")
                                             .InvalidChoiceMessage("[red]Invalid Mode[/]")
                                             .AddChoice("ApiKey")
                                             .AddChoice("CredentialsFile")
                                             .DefaultValue("ApiKey");

            var    apiKey = ApiKey;
            var    secret = Secret;
            string credentialsFilePath = string.Empty;
            string profileName         = string.Empty;

            var mode = AnsiConsole.Prompt(modePrompt);

            if (mode == "ApiKey")
            {
                if (string.IsNullOrEmpty(apiKey))
                {
                    apiKey = AnsiConsole.Ask <string>("Enter your DynamoDB [blue]API Key[/]");
                }

                TextPrompt <string> secretPrompt = new TextPrompt <string>("Enter your DynamoDB [blue]API Secret[/]")
                                                   .PromptStyle("red")
                                                   .Secret();

                if (string.IsNullOrEmpty(secret))
                {
                    secret = AnsiConsole.Prompt(secretPrompt);
                }
            }
            else
            {
                var credentialsFilePathPrompt = new TextPrompt <string>("Enter your [blue]Credentials File Path[/]");
                credentialsFilePath = AnsiConsole.Prompt(credentialsFilePathPrompt);

                var profilePrompt = new TextPrompt <string>("Enter your [blue]Credentials Profile name[/]");

                profileName = AnsiConsole.Prompt(profilePrompt);
            }

            TextPrompt <string> regionPrompt = new TextPrompt <string>("Enter your DynamoDB [blue]Region[/]?")
                                               .InvalidChoiceMessage("[red]Invalid Region[/]")
                                               .DefaultValue("APNortheast2");

            foreach (string regionName in Enum.GetNames(typeof(AwsRegion)))
            {
                regionPrompt.AddChoice(regionName);
            }

            var region = AnsiConsole.Prompt(regionPrompt);

            var connection = new PrimarSqlConnection(new PrimarSqlConnectionStringBuilder
            {
                AccessKey           = apiKey,
                AccessSecretKey     = secret,
                CredentialsFilePath = credentialsFilePath,
                ProfileName         = profileName,
                AwsRegion           = Enum.Parse <AwsRegion>(region),
            });

            connection.Open();

            while (true)
            {
                try
                {
                    var query   = AnsiConsole.Prompt(new TextPrompt <string>("[blue]Query[/]"));
                    var command = connection.CreateDbCommand(query);
                    using var dbDataReader = command.ExecuteReader();

                    var table = new Table
                    {
                        Border = TableBorder.Rounded
                    };

                    for (int i = 0; i < dbDataReader.FieldCount; i++)
                    {
                        table.AddColumn($"[green]{Markup.Escape(dbDataReader.GetName(i))}[/]");
                    }

                    while (dbDataReader.Read())
                    {
                        var list = new List <string>();

                        for (int i = 0; i < dbDataReader.FieldCount; i++)
                        {
                            var value = dbDataReader[i];

                            list.Add(Markup.Escape(value switch
                            {
                                byte[] bArr => Convert.ToBase64String(bArr),
                                DateTime dt => dt.ToString("u"),
                                _ => value.ToString()
                            }));
                        }

                        table.AddRow(list.ToArray());
                    }
예제 #17
0
 public VersionPrompt(TextPrompt prompt)
 {
     _prompt = prompt;
 }
예제 #18
0
 public SimplePromptBot()
 {
     namePrompt = new TextPrompt();
     agePrompt  = new NumberPrompt <int>(Culture.English, ValidateAge);
 }
예제 #19
0
 public virtual string GetLabel()
 {
     return(TextPrompt.NullEmpty() ?? Name);
 }
 /// <summary>
 /// Shows the default value.
 /// </summary>
 /// <typeparam name="T">The prompt result type.</typeparam>
 /// <param name="obj">The prompt.</param>
 /// <returns>The same instance so that multiple calls can be chained.</returns>
 public static TextPrompt <T> ShowDefaultValue <T>(this TextPrompt <T> obj)
 {
     return(ShowDefaultValue(obj, true));
 }
 public void TextPromptWithEmptyIdShouldFail()
 {
     var emptyId    = string.Empty;
     var textPrompt = new TextPrompt(emptyId);
 }
 /// <summary>
 /// Hides the default value.
 /// </summary>
 /// <typeparam name="T">The prompt result type.</typeparam>
 /// <param name="obj">The prompt.</param>
 /// <returns>The same instance so that multiple calls can be chained.</returns>
 public static TextPrompt <T> HideDefaultValue <T>(this TextPrompt <T> obj)
 {
     return(ShowDefaultValue(obj, false));
 }
        public async Task TextPromptWithNaughtyStrings()
        {
            var convoState  = new ConversationState(new MemoryStorage());
            var dialogState = convoState.CreateProperty <DialogState>("dialogState");

            var adapter = new TestAdapter(TestAdapter.CreateConversation(TestContext.TestName))
                          .Use(new AutoSaveStateMiddleware(convoState))
                          .Use(new TranscriptLoggerMiddleware(new TraceTranscriptLogger(traceActivity: false)));

            var dialogs = new DialogSet(dialogState);

            var textPrompt = new TextPrompt("TextPrompt");

            dialogs.Add(textPrompt);

            var filePath = Path.Combine(new string[] { "..", "..", "..", "Resources", "naughtyStrings.txt" });

            using var sr = new StreamReader(filePath);
            var naughtyString = string.Empty;

            do
            {
                naughtyString = GetNextNaughtyString(sr);
                try
                {
                    await new TestFlow(adapter, async(turnContext, cancellationToken) =>
                    {
                        var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);

                        var results = await dc.ContinueDialogAsync(cancellationToken);
                        if (results.Status == DialogTurnStatus.Empty)
                        {
                            var options = new PromptOptions {
                                Prompt = new Activity {
                                    Type = ActivityTypes.Message, Text = "Enter some text."
                                }
                            };
                            await dc.PromptAsync("TextPrompt", options, cancellationToken);
                        }
                        else if (results.Status == DialogTurnStatus.Complete)
                        {
                            var textResult = (string)results.Result;
                            await turnContext.SendActivityAsync(MessageFactory.Text(textResult), cancellationToken);
                        }
                    })
                    .Send("hello")
                    .AssertReply("Enter some text.")
                    .Send(naughtyString)
                    .AssertReply(naughtyString)
                    .StartTestAsync();
                }
                catch (Exception e)
                {
                    // If the input message is empty after a .Trim() operation, character the comparison will fail because the reply message will be a
                    // Message Activity with null as Text, this is expected behavior
                    var messageIsBlank = e.Message.Equals(" :\nExpected: \nReceived:", StringComparison.CurrentCultureIgnoreCase) && naughtyString.Equals(" ", StringComparison.CurrentCultureIgnoreCase);
                    var messageIsEmpty = e.Message.Equals(":\nExpected:\nReceived:", StringComparison.CurrentCultureIgnoreCase) && naughtyString.IsNullOrEmpty();
                    if (!(messageIsBlank || messageIsEmpty))
                    {
                        throw;
                    }
                }
            }while (!string.IsNullOrEmpty(naughtyString));
        }
 /// <summary>
 /// Shows choices.
 /// </summary>
 /// <typeparam name="T">The prompt result type.</typeparam>
 /// <param name="obj">The prompt.</param>
 /// <returns>The same instance so that multiple calls can be chained.</returns>
 public static TextPrompt <T> ShowChoices <T>(this TextPrompt <T> obj)
 {
     return(ShowChoices(obj, true));
 }