当前位置: 首页>>代码示例>>C#>>正文


C# AdminController.VerifyCode方法代码示例

本文整理汇总了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");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:15,代码来源:AdminControllerTests.cs

示例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");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:10,代码来源:AdminControllerTests.cs

示例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);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:15,代码来源:AdminControllerTests.cs

示例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.");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:11,代码来源:AdminControllerTests.cs

示例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));
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:AdminControllerTests.cs

示例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);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:AdminControllerTests.cs

示例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");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:8,代码来源:AdminControllerTests.cs

示例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);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:8,代码来源:AdminControllerTests.cs


注:本文中的AllReady.Controllers.AdminController.VerifyCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。