public async Task SendShouldNotCreateInvite_WhenUserIsNotOrgAdmin() { // Arrange var mockMediator = new Mock <IMediator>(); var @event = new Event { Campaign = new Campaign() { ManagingOrganizationId = 1 } }; mockMediator.Setup(mock => mock.SendAsync(It.IsAny <EventByEventIdQuery>())).ReturnsAsync(@event); var sut = new EventManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object); sut.MakeUserNotAnOrgAdmin(); var invite = new EventManagerInviteViewModel(); // Act IActionResult result = await sut.Send(eventId, invite); // Assert mockMediator.Verify(x => x.SendAsync(It.IsAny <CreateEventManagerInviteCommand>()), Times.Never); }
public async Task SendPostReturnsUnauthorizedResult_WhenUserIsNotOrgAdmin() { // Arrange var mockMediator = new Mock <IMediator>(); var @event = new Event { Campaign = new Campaign() { ManagingOrganizationId = 1 } }; mockMediator.Setup(mock => mock.SendAsync(It.IsAny <EventByEventIdQuery>())).ReturnsAsync(@event); var sut = new EventManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object); sut.MakeUserNotAnOrgAdmin(); var invite = new EventManagerInviteViewModel(); // Act IActionResult result = await sut.Send(eventId, invite); // Assert Assert.IsType <UnauthorizedResult>(result); }
public async Task DetailsReturnsUnauthorizedResult_WhenUserIsNotOrgAdmin() { // Arrange var mockMediator = new Mock <IMediator>(); mockMediator.Setup(mock => mock.SendAsync(It.IsAny <EventManagerInviteDetailQuery>())) .ReturnsAsync(new EventManagerInviteDetailsViewModel { Id = inviteId }); var sut = new EventManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object); sut.MakeUserNotAnOrgAdmin(); // Act IActionResult result = await sut.Details(inviteId); // Assert Assert.IsType <UnauthorizedResult>(result); }