本文整理汇总了C#中AllReady.Areas.Admin.Controllers.SiteController.SetFakeHttpRequestSchemeTo方法的典型用法代码示例。如果您正苦于以下问题:C# SiteController.SetFakeHttpRequestSchemeTo方法的具体用法?C# SiteController.SetFakeHttpRequestSchemeTo怎么用?C# SiteController.SetFakeHttpRequestSchemeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.SiteController
的用法示例。
在下文中一共展示了SiteController.SetFakeHttpRequestSchemeTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetPasswordInvokesUrlActionWithCorrectParametersWhenUserIsNotNull
public async Task ResetPasswordInvokesUrlActionWithCorrectParametersWhenUserIsNotNull()
{
const string requestScheme = "requestScheme";
var mediator = new Mock<IMediator>();
var userManager = CreateApplicationUserMock();
var user = new ApplicationUser()
{
Id = "1234",
Email = "[email protected]"
};
mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
.Returns(user);
string code = "passcode";
userManager.Setup(u => u.GeneratePasswordResetTokenAsync(user)).ReturnsAsync(code);
var controller = new SiteController(userManager.Object, null, mediator.Object);
var urlHelper = new Mock<IUrlHelper>();
controller.Url = urlHelper.Object;
controller.SetFakeHttpRequestSchemeTo(requestScheme);
var result = await controller.ResetPassword(user.Id);
urlHelper.Verify(mock => mock.Action(It.Is<UrlActionContext>(uac =>
uac.Action == "ResetPassword" &&
uac.Controller == "Admin" &&
uac.Protocol == requestScheme)),
Times.Once);
}
示例2: CreateApplicationUserMock
public async Task EditUserPostInvokesUrlActionWithCorrectParametersWhenModelsIsOrganizationAdminIsTrueAndOrganizationAdminClaimWasAddedSuccessfully()
{
const string requestScheme = "requestScheme";
var mediator = new Mock<IMediator>();
var userManager = CreateApplicationUserMock();
EditUserViewModel model = new EditUserViewModel()
{
IsOrganizationAdmin = true,
UserId = It.IsAny<string>()
};
var user = new ApplicationUser()
{
Id = model.UserId,
Email = "[email protected]"
};
mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == model.UserId)))
.Returns(user);
userManager.Setup(x => x.AddClaimAsync(It.IsAny<ApplicationUser>(), It.IsAny<Claim>()))
.Returns(() => Task.FromResult(IdentityResult.Success));
var controller = new SiteController(userManager.Object, null, mediator.Object);
controller.SetFakeHttpRequestSchemeTo(requestScheme);
var urlHelper = new Mock<IUrlHelper>();
controller.Url = urlHelper.Object;
await controller.EditUser(model);
urlHelper.Verify(mock => mock.Action(It.Is<UrlActionContext>(uac =>
uac.Action == "Login" &&
uac.Controller == "Admin" &&
uac.Protocol == requestScheme)),
Times.Once);
}