OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.42k stars 2.39k forks source link

UserTimeZoneService needs an interface #16613

Closed deanmarcussen closed 1 month ago

deanmarcussen commented 2 months ago

annoying to mock

UserTimeZoneService

sebastienros commented 2 months ago

What exactly do you need to mock in your tests? I would have assumed that only ITimeZoneSelector would be useful to change, because only UserTimeZoneDisplayDriver is using UserTimeZoneService.

deanmarcussen commented 2 months ago

and yet we extend orchard core way past what is in the orchard core repository :)

which means we use UserTimeZoneService in many more places than just the UserTimeZoneDisplayDriver

Is that a good thing or not? I don't know, but its easier to use the orchard core services that are available, than copying hte code into our repository

sebastienros commented 2 months ago

Does Moq support mocking this class? Methods are not overridable so probably no possible?

Adding an interface to a public service would mean that we'll add interface to any public service when someone asks for it. We should have made this type internal if we thought it would not be used externally (and mocked). If mocking works, even if that's not easy, I would not add an interface.

Another point of view is that we may actually want it to be public if someone wants to create a feature enhances/uses this feature. In that case we could add the interface.

github-actions[bot] commented 2 months ago

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

hishamco commented 2 months ago

I will try to write a unit test mocking this service