Beispiel #1
0
        public async Task DetailsReturnsNotFoundResult_WhenNoInviteMatchesId()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var sut          = new CampaignManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            // Act
            IActionResult result = await sut.Details(inviteId);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #2
0
        public async Task DetailsSendsCampaignManagerInviteDetailQueryWithCorrectInviteId()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var sut          = new CampaignManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            // Act
            await sut.Details(inviteId);

            // Assert
            mockMediator.Verify(mock => mock.SendAsync(It.Is <CampaignManagerInviteDetailQuery>(c => c.CampaignManagerInviteId == inviteId)));
        }
Beispiel #3
0
        public async Task DetailsReturnsUnauthorizedResult_WhenUserIsNotOrgAdmin()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <CampaignManagerInviteDetailQuery>()))
            .ReturnsAsync(new CampaignManagerInviteDetailsViewModel {
                Id = inviteId
            });

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

            sut.MakeUserNotAnOrgAdmin();

            // Act
            IActionResult result = await sut.Details(inviteId);

            // Assert
            Assert.IsType <UnauthorizedResult>(result);
        }
Beispiel #4
0
        public async Task DetailsReturnsView_WhenUserIsOrgAdminForCampaign()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var invite       = new CampaignManagerInviteDetailsViewModel()
            {
                Id = inviteId, OrganizationId = 1
            };

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

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

            sut.MakeUserAnOrgAdmin(organizationId: "1");

            // Act
            IActionResult result = await sut.Details(inviteId);

            // Assert
            Assert.IsType <ViewResult>(result);
        }
Beispiel #5
0
        public async Task DetailsPassesCorrectViewModelToView()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var invite       = new CampaignManagerInviteDetailsViewModel()
            {
                Id = inviteId, OrganizationId = 1
            };

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

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

            sut.MakeUserAnOrgAdmin(organizationId: "1");

            // Act
            IActionResult result = await sut.Details(inviteId);

            // Assert
            ViewResult view  = result as ViewResult;
            var        model = Assert.IsType <CampaignManagerInviteDetailsViewModel>(view.ViewData.Model);

            Assert.Equal(inviteId, model.Id);
        }