本文整理汇总了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");
}
示例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);
}
示例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.");
}
示例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)));
}
示例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");
}
示例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");
}