c# - Method Shadowing Using NSubstitute in NUnit -


i have public method test calls public child-method:

the child method has optional parameter :

public class childclass : ichildclass {         public bool mychildmethod(string param1, string param2, string param3 = null)     {     ...     } } 

the parent methods invokes child like:

_childclassinstance.mychildmethod("param1","param2") 

when run unittestcase, want substitute like:

_childclassinstance.mychildmethod("param1","param2","param3") 

how ?

the short answer there no way mock behavior of private method , don't want concern private methods in unit testing since considered "implementation detail".

if method public however, using moq framework following.

mock<mychildclass> mockchildclass = new mock<mychildclass>(); mockchildclass.setup(x => x.mychildmethod("param1", "param2", "param3")); 

Comments