im unit testing my home controller. This test worked fine until I added a new feature which saves images.
The method that’s causing the issue is this below.
I agree with the Darin´s answer but if you really need to moq the Server.MapPath function you could do something like this
//...
var serverMock = new Mock(MockBehavior.Loose);
serverMock.Setup(i => i.MapPath(It.IsAny()))
.Returns((String a) => a.Replace("~/", @"C:\testserverdir\").Replace("/",@"\"));
//...
Performing this, the mock will simply replace the ~/ with the c:\testserverdir\ function
Hope it helps!