c# - Mocking generic repository factory method -
i've made refactoring if our repository factory make more generic , right method creating repositories looks that: public trepository createrepository<trepository>(params object[] parameters) trepository : class { if (_serviceprovider == null) throw new argumentnullexception(nameof(_serviceprovider)); return activatorutilities.createinstance<trepository>(_serviceprovider, parameters); } in production code using , works charm: _concreterepo = repofactory.createrepository<concreterepo>(); but when trying refactor unit tests having difficulties setting factory, how doesn't work. public class tests { // since using moq can't mock abstract types having problems type conversion in set up. protected readonly mock<iconcreterepository> _concreterepositorymock = new mock<iconcreterepository>(); protected readonly mock<irepositoryfactory> _factorymock = new mock<irepositoryfactory>(); [s...