Ejemplo n.º 1
0
        public async Task SendReturnsUnauthorizedResult_WhenUserIsNotOrgAdmin()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <CampaignManagerInviteQuery>())).ReturnsAsync(new CampaignManagerInviteViewModel()
            {
                CampaignId = campaignId
            });

            var sut = new CampaignManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            sut.MakeUserNotAnOrgAdmin();

            // Act
            IActionResult result = await sut.Send(campaignId);

            // Assert
            Assert.IsType <UnauthorizedResult>(result);
        }
Ejemplo n.º 2
0
        public async Task CancelReturnsUnauthorizedResult_WhenUserIsNotOrgAdminForCampaign()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var campaign     = new CampaignManagerInviteDetailsViewModel()
            {
                CampaignId = campaignId, OrganizationId = 1, Id = 5
            };

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <CampaignManagerInviteDetailQuery>())).ReturnsAsync(campaign);

            var sut = new CampaignManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            sut.MakeUserNotAnOrgAdmin();

            // Act
            var result = await sut.Cancel(5);

            // Assert
            Assert.IsType <UnauthorizedResult>(result);
        }
Ejemplo n.º 3
0
        public async Task SendShouldNotCreateInvite_WhenUserIsNotOrgAdmin()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var campaign     = new Campaign()
            {
                ManagingOrganizationId = 1
            };

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <CampaignByCampaignIdQuery>())).ReturnsAsync(campaign);

            var sut = new CampaignManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            sut.MakeUserNotAnOrgAdmin();
            var invite = new CampaignManagerInviteViewModel();

            // Act
            IActionResult result = await sut.Send(campaignId, invite);

            // Assert
            mockMediator.Verify(x => x.SendAsync(It.IsAny <CreateCampaignManagerInviteCommand>()), Times.Never);
        }