You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <exception cref="NSubstitute.Exceptions.ProtectedMethodNotFoundException">Error mocking method. Method must be protected virtual and with correct matching arguments and type</exception>
22
23
/// <exception cref="System.ArgumentException">Must provide valid protected method name to mock - methodName</exception>
thrownewProtectedMethodNotFoundException($"No protected virtual method found with signature {methodName}({string.Join(", ",argTypes.Select(x =>x.ForType))}) in {obj.GetType().BaseType!.Name}. "+
36
+
"Check that the method name and arguments are correct. Public virtual methods must use standard NSubstitute mocking. See the documentation for additional info.");
thrownewProtectedMethodNotVirtualException($"{mthdInfo} is not virtual. NSubstitute can only work with virtual members of the class that are overridable in the test assembly");
42
+
}
33
43
34
44
returnmthdInfo.Invoke(obj,args);
35
45
}
@@ -43,6 +53,7 @@ public static object Protected<T>(this T obj, string methodName, params object[]
/// <exception cref="NSubstitute.Exceptions.ProtectedMethodNotFoundException">Error mocking method. Method must be protected virtual and with correct matching arguments and type</exception>
46
57
/// <exception cref="System.ArgumentException">Must provide valid protected method name to mock - methodName</exception>
thrownewProtectedMethodNotFoundException($"No protected virtual method found with signature {methodName}({string.Join(", ",argTypes.Select(x =>x.ForType))}) in {obj.GetType().BaseType!.Name}. "+
70
+
"Check that the method name and arguments are correct. Public virtual methods must use standard NSubstitute mocking. See the documentation for additional info.");
thrownewProtectedMethodNotVirtualException($"{mthdInfo} is not virtual. NSubstitute can only work with virtual members of the class that are overridable in the test assembly");
76
+
}
57
77
58
78
returnnewWhenCalled<T>(SubstitutionContext.Current,obj, x =>mthdInfo.Invoke(x,args),MatchArgs.AsSpecifiedInCall);
0 commit comments