I have an interface
public interface IProgramer
bool ReturnStatus(Program prg,string filepath);
Class
public Class Programer :IProgramer
{
public bool ReturnStatus(Program prg,string filepath)
{
// logic
return status
}
}
Unit Testcase
public void StartOperationTest()
{
string dummyfilepath = "C://Users//x//";
Program dummyprgObj = new Program
{
Name = "x",
Rollno = 1,
};
var mock = new Mock<IProgramer>();
mock.Setup(x => x.ReturnStatus(dummyprgObj, dummyfilepath)).Returns(true);
}
setup method is always giving false.
Can someone please tell me what is wrong here?
Try using mock.SetupGet() instead of 'setup' you are using. and also one observation, the class 'Programer' should implement interface 'IProgramer'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.