Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

Telegram bot mock testing

Open Ruberoid opened this issue 10 years ago • 12 comments

Hey there, all c# telegram bot lib lovers.

I'm not quite sure if this issue place is correct for some sort for aside discussion, and please pardon me for bad english.

I just gonna open some discussion regarding how do you guys mass test your telegram bot implementations. For sure you cannot easily perform some real heavy traffic load (for long-pooling telegram bot for sure), and also I haven't found some interesting interfaces for easy mocking up some fakes instead of true telegram(tm) servers communication.

Has anyone implemented some of that I'm talking about? Maybe some good practicies, shortcuts, ideas at least?

Thank's in advance, guys. You're perfect.

Ruberoid avatar Sep 07 '16 16:09 Ruberoid

There is this pull request: https://github.com/MrRoundRobin/telegram.bot/pull/216 which is basically an interface for the bot to be able to mock it in your code, but for some reason the project maintainer did not accept it yet. Let's hope it gets review and released along with other interesting pull requests which are pending...

CristianT avatar Sep 07 '16 21:09 CristianT

hi, im very busy at the moment, so hadn't time to review the pull requests. I'll take a look tomorrow

MrRoundRobin avatar Sep 08 '16 00:09 MrRoundRobin

should be solved with PR #216

MrRoundRobin avatar Sep 16 '16 00:09 MrRoundRobin

Hey there, Robin.

I've got some small issues regarding your PR #216 commit. I just tried mocking ITelegramBot interface. but unfortunately many of class constructors and properties of c# Telegram.Bot types are marked as internal. So, I can't use objects outside base assembly, without dirty hacks.

Is it made intentionally or by accident?

Please, let me offer pull request with changed internal modifers to public ones? That is all about Telegram.Bot.Types.User Telegram.Bot.Types.MessageEventArgs Telegram.Bot.Types.UpdateEventArgs and so on..

Ruberoid avatar Sep 18 '16 21:09 Ruberoid

@Ruberoid do you mean the internal sets?

MrRoundRobin avatar Sep 19 '16 13:09 MrRoundRobin

@MrRoundRobin definetly yes.

Is it possible to make those internals public? If yes, I'll prepare pull request.

Ruberoid avatar Sep 19 '16 15:09 Ruberoid

I'd make them protected instead of public.

MrZoidberg avatar Sep 19 '16 19:09 MrZoidberg

@MrZoidberg. Protected doesnot make sense. In this case calling from outside still has no access to protected properties. protected just opens the door for inherited ones, but i would like to use existing structs.

Ruberoid avatar Sep 19 '16 20:09 Ruberoid

Currently, these structures are immutable and you're proposing to make them mutable just for mock testing. So I think that any other method (e.g. interfaces, inheritance) is better for this case.

MrZoidberg avatar Sep 19 '16 20:09 MrZoidberg

Hello all,

Would making public constructors where all properties are set be a solution? That way, the internal sets can stay internal, but the behavior can be mimicked for testing purposes.

Kind regards,

Martijn Verbakel

mhverbakel avatar Sep 19 '16 20:09 mhverbakel

@mhverbakel, love that idea. Public ctors are really enough.

Ruberoid avatar Sep 19 '16 21:09 Ruberoid

I'm okay with constructors. If you like you could create a pull request.

MrRoundRobin avatar Sep 19 '16 21:09 MrRoundRobin