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


C# CampaignController.DeleteConfirmed方法代码示例

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

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

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

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

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

示例6: DetailConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin

 public async Task DetailConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
 {
     var sut = new CampaignController(Mock.Of<IMediator>(), null);
     Assert.IsType<UnauthorizedResult>(await sut.DeleteConfirmed(new DeleteViewModel { UserIsOrgAdmin = false }));
 }
开发者ID:nicolastarzia,项目名称:allReady,代码行数:5,代码来源:CampaignAdminControllerTests.cs

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

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

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

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


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