예제 #1
0
        public async Task MarkCompleteReturnsHttpUnauthorizedWhenOrganizationIdIsZero()
        {
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(0);

            var sut = new ItineraryController(mockMediator.Object, null);

            Assert.IsType <UnauthorizedResult>(await sut.MarkComplete(It.IsAny <int>(), It.IsAny <Guid>()));
        }
        public async Task MarkCompleteSendsOrganizationIdQueryWithCorrectIntineraryId()
        {
            var itineraryId  = It.IsAny <int>();
            var mockMediator = new Mock <IMediator>();

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);

            await sut.MarkComplete(itineraryId, It.IsAny <Guid>());

            mockMediator.Verify(x => x.SendAsync(It.Is <OrganizationIdQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
        }
예제 #3
0
        public async Task MarkCompleteReturnsRedirectToActionWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
        {
            const int orgId = 1;

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(orgId);

            var sut = new ItineraryController(mockMediator.Object, null);

            sut.MakeUserAnOrgAdmin(orgId.ToString());

            var result = await sut.MarkComplete(It.IsAny <int>(), It.IsAny <Guid>());

            Assert.IsType <RedirectToActionResult>(result);
        }
예제 #4
0
        public async Task MarkCompleteSendsRequestStatusChangeCommandWithCorrectRequestIdWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
        {
            var       requestId = Guid.NewGuid();
            const int orgId     = 1;

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(orgId);

            var sut = new ItineraryController(mockMediator.Object, null);

            sut.MakeUserAnOrgAdmin(orgId.ToString());

            await sut.MarkComplete(It.IsAny <int>(), requestId);

            mockMediator.Verify(x => x.SendAsync(It.Is <RequestStatusChangeCommand>(y => y.RequestId == requestId)), Times.Once);
        }
        public async Task MarkCompleteReturnsHttpUnauthorizedWhenUserIsNotOrgAdmin()
        {
            var itineraryId = It.IsAny <int>();
            var requestId   = It.IsAny <Guid>();

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);

            sut.SetClaims(new List <Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.BasicUser.ToString())
            });

            Assert.IsType <UnauthorizedResult>(await sut.MarkComplete(itineraryId, requestId));
        }
예제 #6
0
        public async Task MarkCompleteReturnsRedirectToAction_WithActionName_Details()
        {
            const int orgId = 1;

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(orgId);

            var sut = new ItineraryController(mockMediator.Object, null);

            sut.MakeUserAnOrgAdmin(orgId.ToString());

            var result = await sut.MarkComplete(It.IsAny <int>(), It.IsAny <Guid>());

            var actionResult = (RedirectToActionResult)result;

            Assert.Equal("Details", actionResult.ActionName);
        }
        public async Task MarkCompleteReturnsRedirectToActionWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
        {
            var itineraryId = It.IsAny <int>();
            var requestId   = It.IsAny <Guid>();

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);

            sut.SetClaims(new List <Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
                new Claim(AllReady.Security.ClaimTypes.Organization, "1")
            });

            var result = await sut.MarkComplete(itineraryId, requestId);

            Assert.IsType <RedirectToActionResult>(result);
        }
        public async Task MarkCompleteSendsRequestStatusChangeCommandWithCorrectTaskSignupIdWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
        {
            var itineraryId = It.IsAny <int>();
            var requestId   = It.IsAny <Guid>();

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(x => x.SendAsync(It.IsAny <OrganizationIdQuery>())).ReturnsAsync(1);

            var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);

            sut.SetClaims(new List <Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
                new Claim(AllReady.Security.ClaimTypes.Organization, "1")
            });

            await sut.MarkComplete(itineraryId, requestId);

            mockMediator.Verify(x => x.SendAsync(It.Is <RequestStatusChangeCommand>(y => y.RequestId == requestId)), Times.Once);
        }