Ejemplo n.º 1
0
        public async Task DetailsReturnsNotFoundResult_WhenNoInviteMatchesId()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var sut          = new EventManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

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

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Ejemplo n.º 2
0
        public async Task DetailsSendsEventManagerInviteDetailQueryWithCorrectInviteId()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var sut          = new EventManagerInviteController(mockMediator.Object, UserManagerMockHelper.CreateUserManagerMock().Object);

            // Act
            await sut.Details(inviteId);

            // Assert
            mockMediator.Verify(mock => mock.SendAsync(It.Is <EventManagerInviteDetailQuery>(c => c.EventManagerInviteId == inviteId)));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public async Task DetailsReturnsView_WhenUserIsOrgAdminForCampaign()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();
            var invite       = new EventManagerInviteDetailsViewModel()
            {
                Id = inviteId, OrganizationId = 1
            };

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

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

            sut.MakeUserAnOrgAdmin(organizationId: "1");

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

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

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

            var sut = new EventManagerInviteController(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 <EventManagerInviteDetailsViewModel>(view.ViewData.Model);

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