public override async Task ProcessCallback(CallbackQuery callbackQuery,
                                                   CancellationToken cancellationToken = default)
        {
            var callbackData = CallbackData <SampleState> .Parse(callbackQuery.Data);

            switch (callbackData.NextState)
            {
            case SampleState.TouchMe:
                await SendMessageAsync(new TextMessage(callbackQuery.From.Id)
                {
                    Text        = "Oh my",
                    ReplyMarkup = new InlineKeyboardMarkup(new List <List <InlineKeyboardButton> >
                    {
                        new List <InlineKeyboardButton>
                        {
                            new InlineKeyboardButton
                            {
                                Text         = "Touch me",
                                CallbackData = new CallbackData <SampleState>(SampleState.TouchMe).ToString()
                            }
                        }
                    })
                }, cancellationToken);

                break;

            default:
                throw new ArgumentException(nameof(callbackData.NextState));
            }
        }
        public void Should_parse_callback_data_without_args()
        {
            var callbackData = new CallbackData <TestState>(TestState.Pending);

            Assert.NotNull(callbackData);
            Assert.Equal(TestState.Pending, callbackData.NextState);
            Assert.Empty(callbackData.Args);

            var callbackDataStr = callbackData.ToString();

            Assert.Equal("1>", callbackDataStr);

            var parsed = CallbackData <TestState> .Parse(callbackDataStr);

            Assert.NotNull(parsed);
            Assert.Equal(TestState.Pending, parsed.NextState);
            Assert.Empty(parsed.Args);
        }
 public void Should_throw_ANE_when_parse_empty_string()
 {
     Assert.Throws <ArgumentNullException>(() => CallbackData <TestState> .Parse(null));
     Assert.Throws <ArgumentNullException>(() => CallbackData <TestState> .Parse(string.Empty));
 }