i'm trying to mock a custom variable inside a class that's readonly and has a return inside the get.
public class BaseController
{
public string Local
{
return GlobalVariable.Local
}
}
[TestMethod]
public void TestMethod()
{
var baseControllerMock = Substitute.For<BaseController>();
baseControllerMock.Local.Returns("local");
}
My problem it's that even if i use ReturnsForAnyArgs when it goes inside the return I tired to look for the global variable and it breaks because
System.NullReferenceException: 'Object reference not set to an instance of an object.' since the GlobalVariable is null.
I also tryed to mock the global Variable
[TestMethod]
public void TestMethod()
{
var baseControllerMock = Substitute.For<BaseController>();
var globalVarMock = Substitute.For<GlobalVariable>();
globalVarMock.Local.returns("local");
baseControllerMock.Local.Returns("local");
}
but when it goes to the return it says that it is still null.