private void RegisterThisObjectInTheIoCContainer(Type type, Mock mock) { // this is meant to replicate this generic method call // container.RegisterInstance<T>(mock.Object) _ioc.GetType() .GetMethods() .First(x => x.Name == "RegisterInstance" && x.IsGenericMethod) .MakeGenericMethod(type) .Invoke(_ioc, new[] { mock.Object }); }