While unit testing, I stumbled across the static FreshPageModelResolver.ResolvePageModel
which is, obviously, untestable.
I was going to go through doing a wrapper and an interface but part of me was saying "FreshMvvm is a modern framework, made for a modern architecture that should be fully testable"
Am I missing anything? Should I have not used FreshPageModelResolver.ResolvePageModel
?
Looking at the source code, there is no real need for static implementation: https://github.com/rid00z/FreshMvvm/blob/master/src/FreshMvvm/FreshPageModelResolver.cs
Nothing is wrong with using the FreshPageModelResolver.ResolvePageModel
if you are satisfied with the functionality that it provides. But treat it like the 3rd party dependency that it is and encapsulate it behind your own abstractions in order to keep your code decoupled and maintainable.
public interface IFreshPageModelResolver {
Page ResolvePageModel (Type type, object data);
//...code removed for brevity
}
The implementation will wrap the static dependency
public class DefaultPageModelResolver : IFreshPageModelResolver {
public Page ResolvePageModel (Type type, object data) {
return FreshPageModelResolver.ResolvePageModel(type, data);
}
//...code removed for brevity
}
and the interface can be injected into dependent classes as needed.
You could consider forking the repository and submitting the abstraction and its implementation to the project as a pull request.