From f99c8ef14cae43e521c481659dfc6f084f876920 Mon Sep 17 00:00:00 2001 From: Florian Zevedei Date: Wed, 13 Sep 2023 14:49:03 +0200 Subject: [PATCH] Adding test for ArrayPromptDialog --- .../Tests/ArrayPromptDialogTest.cs | 27 +++++++++++++++++++ TelegramBotBase.Test/Tests/Menu.cs | 13 ++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 TelegramBotBase.Test/Tests/ArrayPromptDialogTest.cs diff --git a/TelegramBotBase.Test/Tests/ArrayPromptDialogTest.cs b/TelegramBotBase.Test/Tests/ArrayPromptDialogTest.cs new file mode 100644 index 0000000..d5c3f9f --- /dev/null +++ b/TelegramBotBase.Test/Tests/ArrayPromptDialogTest.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TelegramBotBase.Form; + +namespace TelegramBotBase.Example.Tests +{ + public class ArrayPromptDialogTest : ArrayPromptDialog + { + + public ArrayPromptDialogTest() : base("Choose an option", new[] { new ButtonBase("Option 1", "option1"), new ButtonBase("Option 2", "option2") }) + { + + this.ButtonClicked += ArrayPromptDialogTest_ButtonClicked; + } + + private void ArrayPromptDialogTest_ButtonClicked(object sender, Args.ButtonClickedEventArgs e) + { + + Console.WriteLine(e.Button.Text + " has been clicked"); + + + } + } +} diff --git a/TelegramBotBase.Test/Tests/Menu.cs b/TelegramBotBase.Test/Tests/Menu.cs index 0b181af..6c74cf8 100644 --- a/TelegramBotBase.Test/Tests/Menu.cs +++ b/TelegramBotBase.Test/Tests/Menu.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; using Telegram.Bot.Types.Enums; using TelegramBotBase.Base; using TelegramBotBase.Enums; @@ -215,6 +216,14 @@ public class Menu : AutoCleanForm break; + case "arraypromptdialog": + + var apt = new ArrayPromptDialogTest(); + + await NavigateTo(apt); + + break; + default: message.Handled = false; @@ -271,6 +280,8 @@ public class Menu : AutoCleanForm btn.AddButtonRow(new ButtonBase("#20 Label", new CallbackData("a", "label").Serialize())); + btn.AddButtonRow(new ButtonBase("#21 ArrayPromptDialogTest", new CallbackData("a", "arraypromptdialog").Serialize())); + await Device.Send("Choose your test:", btn); } }