I have the following interface:
public interface IHealthHandler
{
bool GetCurrentHealthStatus();
void SetCurrentHealthStatus(bool status);
}
I'm trying to mock it in such a way that GetCurrentHealthStatus
is true
.
I thought this should have worked but it doesn't:
var mockIHealthHandler = new Mock<IHealthHandler>();
mockIHealthHandler.SetupProperty(x => x.GetCurrentHealthStatus(), true);
How is this done?
Have a look at https://github.com/Moq/moq4/wiki/Quickstart
try this
mockIHealthHandler.Setup(x => x.GetCurrentHealthStatus()).Returns(true);
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.