本文整理汇总了C#中AllReady.Areas.Admin.Controllers.CampaignController类的典型用法代码示例。如果您正苦于以下问题:C# CampaignController类的具体用法?C# CampaignController怎么用?C# CampaignController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CampaignController类属于AllReady.Areas.Admin.Controllers命名空间,在下文中一共展示了CampaignController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IndexReturnsCorrectDataWhenUserIsOrgAdmin
public void IndexReturnsCorrectDataWhenUserIsOrgAdmin()
{
int OrganizationId = 99;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.Send(It.Is<CampaignListQuery>(c => c.OrganizationId == OrganizationId)))
.Returns((CampaignListQuery q) => {
List<CampaignSummaryModel> ret = new List<CampaignSummaryModel>();
ret.Add(new CampaignSummaryModel { OrganizationId = OrganizationId });
return ret;
}
);
CampaignController controller = new CampaignController(mockMediator.Object, null);
List<Claim> claims = new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, OrganizationId.ToString())
};
controller.SetClaims(claims);
ViewResult view = (ViewResult)controller.Index();
mockMediator.Verify(mock => mock.Send(It.Is<CampaignListQuery>(c => c.OrganizationId == OrganizationId)));
// Org admin should only see own campaigns
IEnumerable<CampaignSummaryModel> viewModel = (IEnumerable<CampaignSummaryModel>)view.ViewData.Model;
Assert.NotNull(viewModel);
Assert.Equal(viewModel.Count(), 1);
Assert.Equal(viewModel.First().OrganizationId, OrganizationId);
}
开发者ID:yobenzima,项目名称:allReady,代码行数:29,代码来源:CampaignAdminControllerTests.cs
示例2: IndexReturnsCorrectDataWhenUserIsOrgAdmin
private static void IndexReturnsCorrectDataWhenUserIsOrgAdmin()
{
const int organizationId = 99;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.Send(It.Is<CampaignListQuery>(c => c.OrganizationId == organizationId)))
.Returns((CampaignListQuery q) =>
{
var ret = new List<CampaignSummaryViewModel>
{
new CampaignSummaryViewModel { OrganizationId = organizationId }
};
return ret;
}
);
var controller = new CampaignController(mockMediator.Object, null);
controller.MakeUserAnOrgAdmin(organizationId.ToString());
var view = (ViewResult)controller.Index();
mockMediator.Verify(mock => mock.Send(It.Is<CampaignListQuery>(c => c.OrganizationId == organizationId)));
// Org admin should only see own campaigns
var viewModel = (IEnumerable<CampaignSummaryViewModel>)view.ViewData.Model;
Assert.NotNull(viewModel);
Assert.Equal(viewModel.Count(), 1);
Assert.Equal(viewModel.First().OrganizationId, organizationId);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:27,代码来源:CampaignAdminControllerTests.cs
示例3: DetailsSendsCampaignDetailQueryWithCorrectCampaignId
public async Task DetailsSendsCampaignDetailQueryWithCorrectCampaignId()
{
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
var sut = new CampaignController(mockMediator.Object, null);
await sut.Details(campaignId);
mockMediator.Verify(mock => mock.SendAsync(It.Is<CampaignDetailQuery>(c => c.CampaignId == campaignId)));
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:10,代码来源:CampaignAdminControllerTests.cs
示例4: IndexSendsIndexQueryWithCorrectData_WhenUserIsNotOrgAdmin
public async Task IndexSendsIndexQueryWithCorrectData_WhenUserIsNotOrgAdmin()
{
var mockMediator = new Mock<IMediator>();
var sut = new CampaignController(mockMediator.Object, null);
sut.MakeUserNotAnOrgAdmin();
await sut.Index();
mockMediator.Verify(mock => mock.SendAsync(It.Is<IndexQuery>(q => q.OrganizationId == null)));
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:10,代码来源:CampaignAdminControllerTests.cs
示例5: IndexSendsCampaignListQueryWithCorrectDataWhenUserIsOrgAdmin
public void IndexSendsCampaignListQueryWithCorrectDataWhenUserIsOrgAdmin()
{
const int organizationId = 99;
var mockMediator = new Mock<IMediator>();
var controller = new CampaignController(mockMediator.Object, null);
controller.MakeUserAnOrgAdmin(organizationId.ToString());
controller.Index();
mockMediator.Verify(mock => mock.Send(It.Is<CampaignListQuery>(q => q.OrganizationId == organizationId)));
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:11,代码来源:CampaignAdminControllerTests.cs
示例6: CampaignDetailsNoCampaignReturns404
public void CampaignDetailsNoCampaignReturns404()
{
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.Send(It.IsAny<CampaignDetailQuery>())).Returns(() => null).Verifiable();
var mockImageService = new Mock<IImageService>();
var mockDataAccess = new Mock<IAllReadyDataAccess>();
var controller = new CampaignController(
mockMediator.Object,
mockImageService.Object,
mockDataAccess.Object );
var actionResult = controller.Details(0);
Assert.IsType<HttpNotFoundResult>(actionResult);
mockMediator.Verify(mock => mock.Send(It.IsAny<CampaignDetailQuery>()), Times.Once);
}
开发者ID:SteveStrong,项目名称:allReady,代码行数:14,代码来源:CampaignControllerTests.cs
示例7: IndexSendsCampaignListQueryWithCorrectDataWhenUserIsNotOrgAdmin
public void IndexSendsCampaignListQueryWithCorrectDataWhenUserIsNotOrgAdmin()
{
var mockMediator = new Mock<IMediator>();
var controller = new CampaignController(mockMediator.Object, null);
var claims = new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
};
controller.SetClaims(claims);
controller.Index();
mockMediator.Verify(mock => mock.Send(It.Is<CampaignListQuery>(q => q.OrganizationId == null)));
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:CampaignAdminControllerTests.cs
示例8: IndexSendsCampaignListQueryWithCorrectDataWhenUserIsOrgAdmin
public void IndexSendsCampaignListQueryWithCorrectDataWhenUserIsOrgAdmin()
{
int OrganizationId = 99;
var mockMediator = new Mock<IMediator>();
var mockImageService = new Mock<IImageService>();
CampaignController controller = new CampaignController(mockMediator.Object, mockImageService.Object);
List<Claim> claims = new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, OrganizationId.ToString())
};
controller.SetClaims(claims);
controller.Index();
mockMediator.Verify(mock => mock.Send(It.Is<CampaignListQuery>(q => q.OrganizationId == OrganizationId)));
}
开发者ID:codethug,项目名称:allReady,代码行数:17,代码来源:CampaignAdminControllerTests.cs
示例9: LockUnlockSendsLockUnlockCampaignCommandWithCorrectCampaignIdWhenUserIsSiteAdmin
public async Task LockUnlockSendsLockUnlockCampaignCommandWithCorrectCampaignIdWhenUserIsSiteAdmin()
{
var CAMPAIGN_ID = 99;
var mockMediator = new Mock<IMediator>();
var controller = new CampaignController(mockMediator.Object, null);
var claims = new List<Claim> { new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString()) };
controller.SetClaims(claims);
await controller.LockUnlock(CAMPAIGN_ID);
mockMediator.Verify(mock => mock.SendAsync(It.Is<LockUnlockCampaignCommand>(q => q.CampaignId == CAMPAIGN_ID)), Times.Once);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:12,代码来源:CampaignAdminControllerTests.cs
示例10: 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
示例11: LockUnlockReturnsHttpUnauthorizedResultWhenUserIsNotSiteAdmin
public async Task LockUnlockReturnsHttpUnauthorizedResultWhenUserIsNotSiteAdmin()
{
var controller = new CampaignController(null, null);
controller.SetClaims(new List<Claim> { new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()) });
Assert.IsType<UnauthorizedResult>(await controller.LockUnlock(100));
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:6,代码来源:CampaignAdminControllerTests.cs
示例12: 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
示例13: 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
示例14: CreateReturnsCorrectViewWithCorrectViewModel
public void CreateReturnsCorrectViewWithCorrectViewModel()
{
var mockMediator = new Mock<IMediator>();
var controller = new CampaignController(mockMediator.Object, null);
var view = (ViewResult) controller.Create();
var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;
Assert.Equal(view.ViewName, "Edit");
Assert.NotNull(viewModel);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:9,代码来源:CampaignAdminControllerTests.cs
示例15: DeleteReturnsCorrectViewModelWhenUserIsOrgAdmin
public async Task DeleteReturnsCorrectViewModelWhenUserIsOrgAdmin()
{
const int organizationId = 99;
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == campaignId))).ReturnsAsync(new CampaignSummaryViewModel { Id = campaignId, OrganizationId = organizationId });
var controller = new CampaignController(mockMediator.Object, null);
controller.MakeUserAnOrgAdmin(organizationId.ToString());
var view = (ViewResult)await controller.Delete(campaignId);
var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;
Assert.Equal(viewModel.Id, campaignId);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:16,代码来源:CampaignAdminControllerTests.cs
示例16: LockUnlockRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsSiteAdmin
public async Task LockUnlockRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsSiteAdmin()
{
const int campaignId = 100;
var mockMediator = new Mock<IMediator>();
var sut = new CampaignController(mockMediator.Object, null);
sut.MakeUserASiteAdmin();
var view = (RedirectToActionResult)await sut.LockUnlock(campaignId);
// verify the next route
Assert.Equal(view.ActionName, nameof(CampaignController.Details));
Assert.Equal(view.RouteValues["area"], "Admin");
Assert.Equal(view.RouteValues["id"], campaignId);
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:15,代码来源:CampaignAdminControllerTests.cs
示例17: DeleteSendsCampaignSummaryQueryWithCorrectCampaignId
public async Task DeleteSendsCampaignSummaryQueryWithCorrectCampaignId()
{
var ORGANIZATION_ID = 99;
var CAMPAIGN_ID = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == CAMPAIGN_ID))).ReturnsAsync(new CampaignSummaryViewModel { Id = CAMPAIGN_ID, OrganizationId = ORGANIZATION_ID });
var controller = new CampaignController(mockMediator.Object, null);
controller.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, ORGANIZATION_ID.ToString())
});
var view = (ViewResult)(await controller.Delete(CAMPAIGN_ID));
mockMediator.Verify(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == CAMPAIGN_ID)), Times.Once);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:15,代码来源:CampaignAdminControllerTests.cs
示例18: CampaignControllerWithDetailQuery
private static CampaignController CampaignControllerWithDetailQuery(string userType, int organizationId)
{
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(mock => mock.SendAsync(It.IsAny<CampaignDetailQuery>())).ReturnsAsync(new CampaignDetailViewModel { OrganizationId = organizationId }).Verifiable();
var controller = new CampaignController(mockMediator.Object, null);
controller.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, userType),
new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
});
return controller;
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:CampaignAdminControllerTests.cs
示例19: DetailsSendsCampaignDetailQueryWithCorrectCampaignId
public async Task DetailsSendsCampaignDetailQueryWithCorrectCampaignId()
{
var CAMPAIGN_ID = 100;
var ORGANIZATION_ID = 99;
var mockMediator = new Mock<IMediator>();
// model is not null
mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignDetailQuery>(c => c.CampaignId == CAMPAIGN_ID))).ReturnsAsync(new CampaignDetailViewModel { OrganizationId = ORGANIZATION_ID, Id = CAMPAIGN_ID }).Verifiable();
var controller = new CampaignController(mockMediator.Object, null);
controller.SetClaims(new List<Claim>()); // create a User for the controller
var view = await controller.Details(CAMPAIGN_ID);
mockMediator.Verify(mock => mock.SendAsync(It.Is<CampaignDetailQuery>(c => c.CampaignId == CAMPAIGN_ID)));
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:CampaignAdminControllerTests.cs
示例20: EditPostInsertsCampaign
public async Task EditPostInsertsCampaign()
{
var OrganizationId = 99;
var NewCampaignId = 100;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<EditCampaignCommand>()))
.Returns((EditCampaignCommand q) => Task.FromResult<int>(NewCampaignId) );
var mockImageService = new Mock<IImageService>();
var controller = new CampaignController(mockMediator.Object, mockImageService.Object);
controller.MakeUserAnOrgAdmin(OrganizationId.ToString());
var model = MassiveTrafficLightOutage_model;
model.OrganizationId = OrganizationId;
// verify the model is valid
var validationContext = new ValidationContext(model, null, null);
var validationResults = new List<ValidationResult>();
Validator.TryValidateObject(model, validationContext, validationResults);
Assert.Equal(0, validationResults.Count());
var file = FormFile("image/jpeg");
var view = (RedirectToActionResult) await controller.Edit(model, file);
// verify the edit(add) is called
mockMediator.Verify(mock => mock.SendAsync(It.Is<EditCampaignCommand>(c => c.Campaign.OrganizationId == OrganizationId)));
// verify that the next route
Assert.Equal(view.RouteValues["area"], "Admin");
Assert.Equal(view.RouteValues["id"], NewCampaignId);
}
开发者ID:mheggeseth,项目名称:allReady,代码行数:32,代码来源:CampaignAdminControllerTests.cs
注:本文中的AllReady.Areas.Admin.Controllers.CampaignController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论