Telegram bot mock testing
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.
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...
hi, im very busy at the moment, so hadn't time to review the pull requests. I'll take a look tomorrow
should be solved with PR #216
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 do you mean the internal sets?
@MrRoundRobin definetly yes.
Is it possible to make those internals public? If yes, I'll prepare pull request.
I'd make them protected instead of public.
@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.
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.
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, love that idea. Public ctors are really enough.
I'm okay with constructors. If you like you could create a pull request.