本文整理汇总了C#中AllReady.Areas.Admin.Controllers.CampaignController.DeleteConfirmed方法的典型用法代码示例。如果您正苦于以下问题:C# CampaignController.DeleteConfirmed方法的具体用法?C# CampaignController.DeleteConfirmed怎么用?C# CampaignController.DeleteConfirmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.CampaignController
的用法示例。
在下文中一共展示了CampaignController.DeleteConfirmed方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetailConfirmedRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsOrgAdmin
public async Task DetailConfirmedRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsOrgAdmin()
{
const int organizationId = 1;
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(new CampaignSummaryViewModel { OrganizationId = organizationId });
var sut = new CampaignController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(organizationId.ToString());
var routeValues = new Dictionary<string, object> { ["area"] = "Admin" };
var result = await sut.DeleteConfirmed(campaignId) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(CampaignController.Index));
Assert.Equal(result.RouteValues, routeValues);
}
示例2: DeleteConfirmedSendsCampaignSummaryQueryWithCorrectCampaignId
public async Task DeleteConfirmedSendsCampaignSummaryQueryWithCorrectCampaignId()
{
const int campaignId = 1;
var mediator = new Mock<IMediator>();
var sut = new CampaignController(mediator.Object, null);
await sut.DeleteConfirmed(campaignId);
mediator.Verify(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(i => i.CampaignId == campaignId)), Times.Once);
}
示例3: DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin
public async Task DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin()
{
const int organizationId = 1;
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(new CampaignSummaryViewModel { OrganizationId = organizationId });
var sut = new CampaignController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(organizationId.ToString());
await sut.DeleteConfirmed(campaignId);
mockMediator.Verify(mock => mock.SendAsync(It.Is<DeleteCampaignCommand>(i => i.CampaignId == campaignId)), Times.Once);
}
示例4: DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin
public async Task DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin()
{
const int organizationId = 1;
var mockMediator = new Mock<IMediator>();
var viewModel = new DeleteViewModel { Id = 100, UserIsOrgAdmin = true };
var sut = new CampaignController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(organizationId.ToString());
await sut.DeleteConfirmed(viewModel);
mockMediator.Verify(mock => mock.SendAsync(It.Is<DeleteCampaignCommand>(i => i.CampaignId == viewModel.Id)), Times.Once);
}
示例5: DetailConfirmedRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsOrgAdmin
public async Task DetailConfirmedRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsOrgAdmin()
{
const int organizationId = 1;
var viewModel = new DeleteViewModel { Id = 100, UserIsOrgAdmin = true };
var sut = new CampaignController(Mock.Of<IMediator>(), null);
sut.MakeUserAnOrgAdmin(organizationId.ToString());
var routeValues = new Dictionary<string, object> { ["area"] = "Admin" };
var result = await sut.DeleteConfirmed(viewModel) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(CampaignController.Index));
Assert.Equal(result.RouteValues, routeValues);
}
示例6: DetailConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task DetailConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var sut = new CampaignController(Mock.Of<IMediator>(), null);
Assert.IsType<UnauthorizedResult>(await sut.DeleteConfirmed(new DeleteViewModel { UserIsOrgAdmin = false }));
}
示例7: DeleteConfirmedSendsDeleteCampaignCommandWithCorrectCampaignId
public async Task DeleteConfirmedSendsDeleteCampaignCommandWithCorrectCampaignId()
{
var viewModel = new DeleteViewModel { Id = 1 };
var mediator = new Mock<IMediator>();
var sut = new CampaignController(mediator.Object, null);
await sut.DeleteConfirmed(viewModel);
mediator.Verify(mock => mock.SendAsync(It.Is<DeleteCampaignCommand>(i => i.CampaignId == viewModel.Id)), Times.Once);
}
示例8: CampaignDetailConfirmedMockChecksForAdminUser
public void CampaignDetailConfirmedMockChecksForAdminUser()
{
const int tenantId = 1;
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.Send(It.IsAny<CampaignSummaryQuery>()))
.Returns(() => new CampaignSummaryModel { TenantId = tenantId })
.Verifiable();
mockMediator.Setup(mock => mock.Send(It.IsAny<DeleteCampaignCommand>()))
.Verifiable();
var mockImageService = new Mock<IImageService>();
var mockDataAccess = new Mock<IAllReadyDataAccess>();
var controller = new CampaignController(
mockMediator.Object,
mockImageService.Object,
mockDataAccess.Object);
var mockHttpContext = new Mock<HttpContext>();
mockHttpContext.Setup(mock => mock.User)
.Returns(() => GetClaimsPrincipal(UserType.TenantAdmin.ToString(), tenantId));
var mockContext = new Mock<ActionContext>();
mockContext.Object.HttpContext = mockHttpContext.Object;
controller.ActionContext = mockContext.Object;
var result = controller.DeleteConfirmed(campaignId);
Assert.IsType<RedirectToActionResult>(result);
mockMediator.Verify(mock => mock.Send(It.Is<CampaignSummaryQuery>(i => i.CampaignId == campaignId)), Times.Once);
mockMediator.Verify(mock => mock.Send(It.Is<DeleteCampaignCommand>(i => i.CampaignId == campaignId)), Times.Once);
}
示例9: DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin
public async Task DetailConfirmedSendsDeleteCampaignCommandWithCorrectCampaignIdWhenUserIsOrgAdmin()
{
const int organizationId = 1;
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(new CampaignSummaryModel { OrganizationId = organizationId });
var sut = new CampaignController(mockMediator.Object, null);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
});
await sut.DeleteConfirmed(campaignId);
mockMediator.Verify(mock => mock.SendAsync(It.Is<DeleteCampaignCommand>(i => i.CampaignId == campaignId)), Times.Once);
}
示例10: DeleteConfirmedSendsDeleteCampaignCommandWithCorrectCampaignId
public async Task DeleteConfirmedSendsDeleteCampaignCommandWithCorrectCampaignId()
{
var viewModel = new DeleteViewModel {Id = 1 , OrganizationId = 1};
var mediator = new Mock<IMediator>();
mediator.Setup(a => a.SendAsync(It.IsAny<DeleteCampaignCommand>())).Verifiable();
var sut = new CampaignController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(viewModel.OrganizationId.ToString());
await sut.DeleteConfirmed(viewModel);
mediator.Verify(mock => mock.SendAsync(It.Is<DeleteCampaignCommand>(i => i.CampaignId == viewModel.Id)), Times.Once);
}