-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Feature request
Is your feature request related to a problem? Please describe.
Hi. I am trying to unit test the this library and I am coming across the issue of ModeledResponse<T> not being testable.
ModeledResponse<T> does not have a parameterless constructor, meaning that a framework like NSubstitute or Moq cannot create a proxy object easily.
ModeledResponse<T>.Trip/ModeledResponse<T>.Trips are both inaccessible properties making them unusable using a Mock wrapper like what Moq does (see below).
_myMock.Setup(obj => obj.Trip = fakeTripInstance)
Describe the solution you'd like
I would like for either ModeledResponse<T> to have a parameterless constructor and for the JSON deserialization process to happen outside the constructor, or for the behaviour to be contained within some kind of class outside of ModeledResponse<T>.
An alternative is to have ModeledResponse<T> inherit from a new abstraction IModeledResponse<T> where T : BaseModel.
This is probably preferred as it doesn't require a reconsideration of how conversions are handled. This would also mean that IPostgrestTable<T> and Table<T> would need their response types to be updated respectively.
Describe alternatives you've considered
I have tried numerous mocking frameworks with these classes and how their are configured means they are very sealed and unmockable.
Happy to make a PR if need be 😃