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

            // Act
            var result = await sut.Accept(inviteId);

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

            // Act
            await sut.Accept(inviteId);

            // Assert
            mockMediator.Verify(mock => mock.SendAsync(It.Is <AcceptDeclineEventManagerInviteDetailQuery>(q => q.EventManagerInviteId == inviteId)));
        }
Ejemplo n.º 3
0
        public async Task AcceptReturnsUnAuthorisedIfUserDoesNotMatchInvitedUser()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <AcceptDeclineEventManagerInviteDetailQuery>()))
            .ReturnsAsync(new AcceptDeclineEventManagerInviteViewModel {
                InviteId = inviteId, InviteeEmailAddress = "*****@*****.**"
            });

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

            // Act
            var result = await sut.Accept(inviteId);

            // Assert
            Assert.IsType <UnauthorizedResult>(result);
        }
Ejemplo n.º 4
0
        public async Task AcceptReturnsViewWhenCorrectUserAndInviteIdSupplied()
        {
            // Arrange
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(mock => mock.SendAsync(It.IsAny <AcceptDeclineEventManagerInviteDetailQuery>()))
            .ReturnsAsync(new AcceptDeclineEventManagerInviteViewModel
            {
                InviteId            = inviteId,
                InviteeEmailAddress = "*****@*****.**",
                CampaignName        = "My campaign",
                EventName           = "My event",
                EventId             = 200
            });

            var mockUserManager = UserManagerMockHelper.CreateUserManagerMock();

            mockUserManager.Setup(mock => mock.GetUserAsync(It.IsAny <ClaimsPrincipal>()))
            .ReturnsAsync(new ApplicationUser {
                Email = "*****@*****.**"
            });

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

            // Act
            var result = await sut.Accept(inviteId);

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

            Assert.Equal(inviteId, model.InviteId);
            Assert.Equal("*****@*****.**", model.InviteeEmailAddress);
            Assert.Equal("My campaign", model.CampaignName);
            Assert.Equal("My event", model.EventName);
            Assert.Equal(200, model.EventId);
        }