本文整理汇总了C#中AllReady.Controllers.AdminController.VerifyCode方法的典型用法代码示例。如果您正苦于以下问题:C# AdminController.VerifyCode方法的具体用法?C# AdminController.VerifyCode怎么用?C# AdminController.VerifyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Controllers.AdminController
的用法示例。
在下文中一共展示了AdminController.VerifyCode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyCodePostRedirectsToHomeControllerIndexWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsNotLocalUrl
public async Task VerifyCodePostRedirectsToHomeControllerIndexWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsNotLocalUrl()
{
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>()))
.ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Success);
var urlHelper = new Mock<IUrlHelper>();
urlHelper.Setup(x => x.IsLocalUrl(It.IsAny<string>())).Returns(false);
var sut = new AdminController(null, signInManager.Object, null, null, null) { Url = urlHelper.Object };
var result = await sut.VerifyCode(new VerifyCodeViewModel()) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(HomeController.Index));
Assert.Equal(result.ControllerName, "Home");
}
示例2: VerifyCodePostReturnsLockoutViewIfTwoFactorSignInAsyncFailsAndIsLockedOut
public async Task VerifyCodePostReturnsLockoutViewIfTwoFactorSignInAsyncFailsAndIsLockedOut()
{
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.LockedOut);
var sut = new AdminController(null, signInManager.Object, null, null, null);
var result = await sut.VerifyCode(new VerifyCodeViewModel()) as ViewResult;
Assert.Equal(result.ViewName, "Lockout");
}
示例3: VerifyCodePostRedirectsToReturnUrlWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsLocalUrl
public async Task VerifyCodePostRedirectsToReturnUrlWhenTwoFactorSignInAsyncSucceedsAndReturnUrlIsLocalUrl()
{
var model = new VerifyCodeViewModel { ReturnUrl = "returnUrl" };
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Success);
var urlHelper = new Mock<IUrlHelper>();
urlHelper.Setup(x => x.IsLocalUrl(model.ReturnUrl)).Returns(true);
var sut = new AdminController(null, signInManager.Object, null, null, null) { Url = urlHelper.Object };
var result = await sut.VerifyCode(model) as RedirectResult;
Assert.Equal(result.Url, model.ReturnUrl);
}
示例4: VerifyCodePostAddsErrorMessageToModelStateErrorWhenTwoFactorSignInAsyncIsNotSuccessful
public async Task VerifyCodePostAddsErrorMessageToModelStateErrorWhenTwoFactorSignInAsyncIsNotSuccessful()
{
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(new Microsoft.AspNetCore.Identity.SignInResult());
var sut = new AdminController(null, signInManager.Object, null, null, null);
await sut.VerifyCode(new VerifyCodeViewModel());
var errorMessage = sut.ModelState.GetErrorMessages().Single();
Assert.Equal(errorMessage, "Invalid code.");
}
示例5: VerifyCodePostInvokesTwoFactorSignInAsyncWithCorrectParameters
public async Task VerifyCodePostInvokesTwoFactorSignInAsyncWithCorrectParameters()
{
var model = new VerifyCodeViewModel
{
Provider = "provider",
Code = "code",
RememberBrowser = true,
RememberMe = true
};
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.TwoFactorSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(new Microsoft.AspNetCore.Identity.SignInResult());
var sut = new AdminController(null, signInManager.Object, null, null, null);
await sut.VerifyCode(model);
signInManager.Verify(x => x.TwoFactorSignInAsync(model.Provider, model.Code, model.RememberMe, model.RememberBrowser));
}
示例6: VerifyCodeGetReturnsCorrectViewModel
public async Task VerifyCodeGetReturnsCorrectViewModel()
{
const string provider = "provider";
const bool rememberMe = true;
const string returnUrl = "returnUrl";
var signInManager = CreateSignInManagerMock();
signInManager.Setup(x => x.GetTwoFactorAuthenticationUserAsync()).ReturnsAsync(new ApplicationUser());
var sut = new AdminController(null, signInManager.Object, null, null, null);
var result = await sut.VerifyCode(provider, rememberMe, returnUrl) as ViewResult;
var modelResult = result.ViewData.Model as VerifyCodeViewModel;
Assert.Equal(modelResult.Provider, provider);
Assert.Equal(modelResult.ReturnUrl, returnUrl);
Assert.Equal(modelResult.RememberMe, rememberMe);
}
示例7: VerifyCodeGetReturnsErrorViewWhenUserIsNull
public async Task VerifyCodeGetReturnsErrorViewWhenUserIsNull()
{
var signInManager = CreateSignInManagerMock();
var sut = new AdminController(null, signInManager.Object, null, null, null);
var result = await sut.VerifyCode(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<string>()) as ViewResult;
Assert.Equal(result.ViewName, "Error");
}
示例8: VerifyCodeGetInvokesGetTwoFactorAuthenticationUserAsync
public async Task VerifyCodeGetInvokesGetTwoFactorAuthenticationUserAsync()
{
var signInManager = CreateSignInManagerMock();
var sut = new AdminController(null, signInManager.Object, null, null, null);
await sut.VerifyCode(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<string>());
signInManager.Verify(x => x.GetTwoFactorAuthenticationUserAsync(), Times.Once);
}