public async Task DetailsReturnsHttpNotFoundResult_WhenEventIsNull() { var sut = new EventController(null, Mock.Of<IMediator>(), null); var result = await sut.Details(It.IsAny<int>()); Assert.IsType<NotFoundResult>(result); }
public async Task DetailsReturnsHttpUnauthorizedResult_WhenEventIsNotNull_AndUserIsNotAnOrgAdmin() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny<EventDetailQuery>())).ReturnsAsync(new EventDetailViewModel { Id = 1, Name = "Itinerary", OrganizationId = 1 }); var sut = new EventController(null, mediator.Object, null); sut.MakeUserNotAnOrgAdmin(); Assert.IsType<UnauthorizedResult>(await sut.Details(It.IsAny<int>())); }
public async Task DetailsReturnsHttpNotFoundResultWhenEventIsNull() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny<CampaignSummaryQuery>())).ReturnsAsync(new CampaignSummaryViewModel()); var sut = new EventController(null, mediator.Object, null); var result = await sut.Details(It.IsAny<int>()); Assert.IsType<NotFoundResult>(result); }
public async Task DetailsReturnsHttpUnauthorizedResultWhenEventIsNotNullAndUserIsNotAnOrgAdmin() { var mediator = new Mock<IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny<EventDetailQuery>())).ReturnsAsync(new EventDetailViewModel { Id = 1, Name = "Itinerary", OrganizationId = 1 }); var sut = new EventController(null, mediator.Object, null); sut.SetClaims(new List<Claim> { new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()), new Claim(AllReady.Security.ClaimTypes.Organization, It.IsAny<int>().ToString()) }); Assert.IsType<UnauthorizedResult>(await sut.Details(It.IsAny<int>())); }