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


C# AdminController.ConfirmEmail方法代码示例

本文整理汇总了C#中AllReady.Controllers.AdminController.ConfirmEmail方法的典型用法代码示例。如果您正苦于以下问题:C# AdminController.ConfirmEmail方法的具体用法?C# AdminController.ConfirmEmail怎么用?C# AdminController.ConfirmEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AllReady.Controllers.AdminController的用法示例。


在下文中一共展示了AdminController.ConfirmEmail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfirmEmailReturnsCorrectViewWhenUsersConfirmationIsSuccessful

        public async Task ConfirmEmailReturnsCorrectViewWhenUsersConfirmationIsSuccessful()
        {
            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser()));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Success));

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var settings = new Mock<IOptions<SampleDataSettings>>();
            settings.Setup(x => x.Value).Returns(new SampleDataSettings { DefaultAdminUsername = It.IsAny<string>() });

            var sut = new AdminController(userManager.Object, null, Mock.Of<IMediator>(), settings.Object, null);
            sut.SetFakeHttpRequestSchemeTo(It.IsAny<string>());
            sut.Url = urlHelper.Object;

            var result = await sut.ConfirmEmail("userId", "code") as ViewResult;

            Assert.Equal(result.ViewName, "ConfirmEmail");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:20,代码来源:AdminControllerTests.cs

示例2: ConfirmEmailReturnsCorrectViewWhenUsersConfirmationIsUnsuccessful

        public async Task ConfirmEmailReturnsCorrectViewWhenUsersConfirmationIsUnsuccessful()
        {
            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser()));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Failed()));

            var sut = new AdminController(userManager.Object, null, null, null, null);
            var result = await sut.ConfirmEmail("userId", "code") as ViewResult;

            Assert.Equal(result.ViewName, "Error");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:11,代码来源:AdminControllerTests.cs

示例3: ConfirmEmailInvokesUrlActionWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully

        public async Task ConfirmEmailInvokesUrlActionWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully()
        {
            const string requestScheme = "requestScheme";
            const string userId = "1";

            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser { Id = userId }));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Success));

            var settings = new Mock<IOptions<SampleDataSettings>>();
            settings.Setup(x => x.Value).Returns(new SampleDataSettings());

            var urlHelper = new Mock<IUrlHelper>();

            var sut = new AdminController(userManager.Object, null, Mock.Of<IMediator>(), settings.Object, null);
            sut.SetFakeHttpRequestSchemeTo(requestScheme);
            sut.Url = urlHelper.Object;

            await sut.ConfirmEmail(It.IsAny<string>(), "code");

            urlHelper.Verify(x => x.Action(It.Is<UrlActionContext>(uac =>
                uac.Action == "EditUser" &&
                uac.Controller == "Site" &&
                uac.Protocol == requestScheme &&
                uac.Values.ToString() == $"{{ area = Admin, userId = {userId} }}")),
                Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:27,代码来源:AdminControllerTests.cs

示例4: CreateUserManagerMock

        public async Task ConfirmEmailSendsSendApproveOrganizationUserAccountEmailWithCorrectDataWhenUsersEmailIsConfirmedSuccessfully()
        {
            const string defaultAdminUserName = "requestScheme";
            const string callbackUrl = "callbackUrl";

            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser()));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Success));

            var settings = new Mock<IOptions<SampleDataSettings>>();
            settings.Setup(x => x.Value).Returns(new SampleDataSettings { DefaultAdminUsername = defaultAdminUserName });

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(callbackUrl);

            var mediator = new Mock<IMediator>();

            var sut = new AdminController(userManager.Object, null, mediator.Object, settings.Object, null);
            sut.SetFakeHttpRequestSchemeTo(It.IsAny<string>());
            sut.Url = urlHelper.Object;

            await sut.ConfirmEmail(It.IsAny<string>(), "code");

            mediator.Verify(x => x.SendAsync(It.Is<SendApproveOrganizationUserAccountEmail>(y => y.DefaultAdminUsername == defaultAdminUserName && y.CallbackUrl == callbackUrl)));
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:25,代码来源:AdminControllerTests.cs

示例5: ConfirmEmailInvokesConfirmEmailAsyncWithCorrectUserAndCode

        public async Task ConfirmEmailInvokesConfirmEmailAsyncWithCorrectUserAndCode()
        {
            const string code = "code";
            var user = new ApplicationUser();

            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(user));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Failed()));

            var sut = new AdminController(userManager.Object, null, null, null, null);
            await sut.ConfirmEmail(null, code);

            userManager.Verify(x => x.ConfirmEmailAsync(user, code), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:AdminControllerTests.cs

示例6: ConfirmEmailInvokesFindByIdAsyncWithCorrectUserId

        public async Task ConfirmEmailInvokesFindByIdAsyncWithCorrectUserId()
        {
            const string userId = "userId";
            var userManager = CreateUserManagerMock();
            var sut = new AdminController(userManager.Object, null, null, null, null);
            await sut.ConfirmEmail(userId, "code");

            userManager.Verify(x => x.FindByIdAsync(userId), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:9,代码来源:AdminControllerTests.cs

示例7: ConfirmEmailReturnsErrorWhenCannotFindUserByUserId

 public async Task ConfirmEmailReturnsErrorWhenCannotFindUserByUserId()
 {
     var userManager = CreateUserManagerMock();
     var sut = new AdminController(userManager.Object, null, null, null, null);
     var result = await sut.ConfirmEmail(null, "code") as ViewResult;
     Assert.Equal(result.ViewName, "Error");
 }
开发者ID:mheggeseth,项目名称:allReady,代码行数:7,代码来源:AdminControllerTests.cs

示例8: ConfirmEmailInvokesSendEmailAsyncWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully

        public async Task ConfirmEmailInvokesSendEmailAsyncWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully()
        {
            const string defaultAdminUserName = "requestScheme";
            const string callbackUrl = "callbackUrl";

            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser()));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Success));

            var settings = new Mock<IOptions<SampleDataSettings>>();
            settings.Setup(x => x.Value).Returns(new SampleDataSettings { DefaultAdminUsername = defaultAdminUserName });

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(callbackUrl);

            var emailSender = new Mock<IEmailSender>();

            var sut = new AdminController(userManager.Object, null, emailSender.Object, null, settings.Object, null);
            sut.SetFakeHttpRequestSchemeTo(It.IsAny<string>());
            sut.Url = urlHelper.Object;

            await sut.ConfirmEmail(It.IsAny<string>(), "code");

            emailSender.Verify(x => x.SendEmailAsync(defaultAdminUserName, "Approve organization user account", 
                $"Please approve this account by clicking this <a href=\"{callbackUrl}\">link</a>"));
        }
开发者ID:mmoore99,项目名称:allReady,代码行数:26,代码来源:AdminControllerTests.cs

示例9: ConfirmEmailInvokesUrlActionWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully

        public async Task ConfirmEmailInvokesUrlActionWithCorrectParametersWhenUsersEmailIsConfirmedSuccessfully()
        {
            const string requestScheme = "requestScheme";

            var userManager = CreateUserManagerMock();
            userManager.Setup(x => x.FindByIdAsync(It.IsAny<string>())).Returns(() => Task.FromResult(new ApplicationUser()));
            userManager.Setup(x => x.ConfirmEmailAsync(It.IsAny<ApplicationUser>(), It.IsAny<string>())).Returns(() => Task.FromResult(IdentityResult.Success));

            var settings = new Mock<IOptions<SampleDataSettings>>();
            settings.Setup(x => x.Value).Returns(new SampleDataSettings());

            var urlHelper = new Mock<IUrlHelper>();

            var sut = new AdminController(userManager.Object, null, Mock.Of<IEmailSender>(), null, settings.Object, null);
            sut.SetFakeHttpRequestSchemeTo(requestScheme);
            sut.Url = urlHelper.Object;

            await sut.ConfirmEmail(It.IsAny<string>(), "code");

            //note: I can't test the Values part here b/c I do not have control over the Id generation on ApplicationUser b/c it's new'ed up in the controller
            urlHelper.Verify(x => x.Action(It.Is<UrlActionContext>(uac =>
                uac.Action == "EditUser" &&
                uac.Controller == "Site" &&
                uac.Protocol == requestScheme)),
                Times.Once);
        }
开发者ID:mmoore99,项目名称:allReady,代码行数:26,代码来源:AdminControllerTests.cs


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