diff --git a/FastMoq.Core/Mocker.cs b/FastMoq.Core/Mocker.cs index fc7b99e..22e054e 100644 --- a/FastMoq.Core/Mocker.cs +++ b/FastMoq.Core/Mocker.cs @@ -1602,10 +1602,24 @@ internal MockModel GetMockModel(Mock? mock = null, bool autoCreate = tr /// /// Type of the parameter. /// object?. - internal object? GetParameter(Type parameterType) => - (parameterType.IsClass || parameterType.IsInterface) && !parameterType.IsSealed - ? GetObject(parameterType) - : GetDefaultValue(parameterType); + internal object? GetParameter(Type parameterType) + { + if (parameterType.IsClass || parameterType.IsInterface) + { + var typeValueModel = GetMapModel(parameterType); + if (typeValueModel?.CreateFunc != null) + { + return typeValueModel.CreateFunc.Invoke(this); + } + + if (!parameterType.IsSealed) + { + return GetObject(parameterType); + } + } + + return GetDefaultValue(parameterType); + } /// /// Gets the type from interface.