I have a class which contains an internal helper such as following code:
[assembly: InternalsVisibleTo("Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
namespace NS.B
{
public class A {
internal readonly B _bHealper;
public int GetBag(string s1, string s2){
return _bHelper.GetBag(s1, s2);
}
}
}
[assembly: InternalsVisibleTo("Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
namespace NS.B
{
internal class B
{
public int GetBag(string str1, string str2){
/// do some work
return result;
}
}
}
then I try to mock my helper inside A class and test A class GetBag function by this code:
[Fact]
public void checkBaggageRule()
{
var repo = Substitute.For<A>();
repo._bHelper.GetBag(Arg.Any<string>(), Arg.Any<string>()).Returns(30);
var result = repo.GetBag("oo", "L");
Assert.True(result != null);
Assert.True(result == 30);
}
but I am getting this exception while I debug my test:
NSubstitute.Exceptions.UnexpectedArgumentMatcherException : Argument matchers (Arg.Is, Arg.Any) should only be used in place of member arguments. Do not use in a Returns() statement or anywhere else outside of a member call.
how can I mock this internal member and pass my test?