我使用Moq尝试对function someFunctionName()
{
//# do what need when user's finger leaves a mouse button (release)
alert("finger was released from button");
//# if such Function exists in your code
this.gotoAndStop("DASHBOARD");
//# or else run some other Function manually
FlashDecision("DASHBOARD");
}
function FlashDecision( input_txt )
{
alert("Show content here of frame labeled : " + input_txt); //where input_txt is "DASHBOARD"...
}
类进行单元测试。
但是,当类在UserManager
上调用SetLockoutEnabledAsync
方法时,该函数始终返回 null 。
我尝试嘲笑UserManager
,但这没做。
IUserLockoutStore
我希望var mockUserLockoutStore = mockUserStore.As<IUserLockoutStore<ApplicationUser>>();
mockUserLockoutStore
.Setup(x => x.SetLockoutEnabledAsync(It.IsAny<ApplicationUser>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Returns((string normalizedEmail, bool enabled, CancellationToken token) =>
{
return Task.CompletedTask;
});
返回预期的userManager.SetLockoutEnabledAsync
,而不是当前返回的 null 。