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


C# CampaignController.DeleteCampaignImage方法代码示例

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


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

示例1: DeleteCampaignImageReturnsJsonObjectWithStatusOfNothingToDeleteIfThereWasNoExistingImage

        public async Task DeleteCampaignImageReturnsJsonObjectWithStatusOfNothingToDeleteIfThereWasNoExistingImage()
        {
            var mediatorMock = new Mock<IMediator>();

            var campaignSummaryViewModel = new CampaignSummaryViewModel
            {
                OrganizationId = 1
            };

            mediatorMock.Setup(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var imageServiceMock = new Mock<IImageService>();

            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);
            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            var result = await sut.DeleteCampaignImage(It.IsAny<int>());

            result.Value.GetType()
                .GetProperty("status")
                .GetValue(result.Value)
                .ShouldBe("NothingToDelete");
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:23,代码来源:CampaignAdminControllerTests.cs

示例2: DeleteCampaignImageCallsEditCampaignCommandWithCorrectData

        public async Task DeleteCampaignImageCallsEditCampaignCommandWithCorrectData()
        {
            var mediatorMock = new Mock<IMediator>();

            var campaignSummaryViewModel = new CampaignSummaryViewModel
            {
                OrganizationId = 1,
                ImageUrl = "URL!"
            };

            mediatorMock.Setup(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var imageServiceMock = new Mock<IImageService>();

            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);
            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            await sut.DeleteCampaignImage(It.IsAny<int>());

            mediatorMock.Verify(m => m.SendAsync(It.Is<EditCampaignCommand>(s => s.Campaign == campaignSummaryViewModel)), Times.Once);
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:21,代码来源:CampaignAdminControllerTests.cs

示例3: DeleteCampaignImageReturnsJsonObjectWithStatusOfDateInvalidIfCampaignEndDateIsLessThanStartDate

        public async Task DeleteCampaignImageReturnsJsonObjectWithStatusOfDateInvalidIfCampaignEndDateIsLessThanStartDate()
        {
            var mediatorMock = new Mock<IMediator>();

            var campaignSummaryViewModel = new CampaignSummaryViewModel
            {
                OrganizationId = 1,
                StartDate = DateTimeOffset.Now.AddDays(10),
                EndDate = DateTimeOffset.Now
            };
            mediatorMock.Setup(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var imageServiceMock = new Mock<IImageService>();

            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);
            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            var result = await sut.DeleteCampaignImage(It.IsAny<int>());

            result.Value.GetType()
                .GetProperty("status")
                .GetValue(result.Value)
                .ShouldBe("DateInvalid");

            result.Value.GetType()
                .GetProperty("message")
                .GetValue(result.Value)
                .ShouldBe("The end date must fall on or after the start date.");
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:29,代码来源:CampaignAdminControllerTests.cs

示例4: DeleteCampaignSendsTheCorrectIdToCampaignSummaryQuery

        public async Task DeleteCampaignSendsTheCorrectIdToCampaignSummaryQuery()
        {
            var mediatorMock = new Mock<IMediator>();
            var imageServiceMock = new Mock<IImageService>();
            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);

            const int campaignId = 2;

            await sut.DeleteCampaignImage(campaignId);

            mediatorMock.Verify(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>()), Times.Once);
            mediatorMock.Verify(m => m.SendAsync(It.Is<CampaignSummaryQuery>(s => s.CampaignId == campaignId)));
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:13,代码来源:CampaignAdminControllerTests.cs

示例5: DeleteCampaignImageReturnsJsonObjectWithStatusOfUnauthorizedIfUserIsNotOrganizationAdmin

        public async Task DeleteCampaignImageReturnsJsonObjectWithStatusOfUnauthorizedIfUserIsNotOrganizationAdmin()
        {
            var mediatorMock = new Mock<IMediator>();
            mediatorMock.Setup(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(new CampaignSummaryViewModel());
            var imageServiceMock = new Mock<IImageService>();
            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);
            sut.MakeUserNotAnOrgAdmin();

            var result = await sut.DeleteCampaignImage(It.IsAny<int>());

            result.Value.GetType()
                .GetProperty("status")
                .GetValue(result.Value)
                .ShouldBe("Unauthorized");
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:15,代码来源:CampaignAdminControllerTests.cs

示例6: DeleteCampaignImageReturnsJsonObjectWithStatusOfNotFound

        public async Task DeleteCampaignImageReturnsJsonObjectWithStatusOfNotFound()
        {
            var mediatorMock = new Mock<IMediator>();
            mediatorMock.Setup(m => m.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(null);
            var imageServiceMock = new Mock<IImageService>();
            var sut = new CampaignController(mediatorMock.Object, imageServiceMock.Object);

            var result = await sut.DeleteCampaignImage(It.IsAny<int>());

            result.ShouldNotBeNull();
            result.ShouldBeOfType<JsonResult>();

            result.Value.GetType()
                .GetProperty("status")
                .GetValue(result.Value)
                .ShouldBe("NotFound");
        }
开发者ID:stevejgordon,项目名称:allReady,代码行数:17,代码来源:CampaignAdminControllerTests.cs


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