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>
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
+
}
43
+
44
+
returnmthdInfo.Invoke(obj,args);
45
+
}
46
+
47
+
/// <summary>
48
+
/// Configure behavior for a protected method with no return vlaue
49
+
/// </summary>
50
+
/// <typeparam name="T"></typeparam>
51
+
/// <param name="obj">The object.</param>
52
+
/// <param name="methodName">Name of the method.</param>
/// <exception cref="NSubstitute.Exceptions.ProtectedMethodNotFoundException">Error mocking method. Method must be protected virtual and with correct matching arguments and type</exception>
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
+
}
77
+
78
+
returnnewWhenCalled<T>(SubstitutionContext.Current,obj, x =>mthdInfo.Invoke(x,args),MatchArgs.AsSpecifiedInCall);
0 commit comments