public async Task SelectRequestsPostWithTwoParametersSetsSelectItineraryRequestsModelWithTheCorrectData()
        {
            var itineraryRequestsModel = new SelectItineraryRequestsViewModel { KeywordsFilter = "These are keywords" };
            var itinerary = GetItineraryForSelectRequestHappyPathTests();
            var returnedRequests = GetRequestsForSelectRequestHappyPathTests();

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itinerary.Id)))
                    .ReturnsAsync(itinerary);
            mediator.Setup(x => x.SendAsync(It.Is<RequestListItemsQuery>(y =>
                y.Criteria.Keywords.Equals(itineraryRequestsModel.KeywordsFilter) &&
                y.Criteria.EventId == itinerary.EventId)))
                .ReturnsAsync(returnedRequests);

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

            var view = await sut.SelectRequests(itinerary.Id, itineraryRequestsModel);

            RunSelectRequestsHappyPathTests(view, itinerary, returnedRequests);
        }
        public async Task SelectRequestsPostWithSingleParameterSetsSelectItineraryRequestsModelWithTheCorrectData()
        {
            const int organizationId = 4;

            var itinerary = GetItineraryForSelectRequestHappyPathTests();
            var returnedRequests = GetRequestsForSelectRequestHappyPathTests();

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itinerary.Id))).ReturnsAsync(itinerary);
            mediator.Setup(x => x.SendAsync(It.IsAny<RequestListItemsQuery>())).ReturnsAsync(returnedRequests);
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(organizationId);

            var sut = new ItineraryController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var view = await sut.SelectRequests(itinerary.Id, new SelectItineraryRequestsViewModel());

            RunSelectRequestsHappyPathTests(view, itinerary, returnedRequests);
        }
        public async Task SelectRequestsGetReturnsUnauthorizedResult_WhenUserIsNotOrgAdmin()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);

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

            var result = await sut.SelectRequests(It.IsAny<int>());

            Assert.IsType<UnauthorizedResult>(result);
        }
        public async Task SelectRequestsGetReturnsUnauthorizedResult_WhenOrgIdIsZero()
        {
            var sut = new ItineraryController(Mock.Of<IMediator>(), null);

            var result = await sut.SelectRequests(It.IsAny<int>());

            Assert.IsType<UnauthorizedResult>(result);
        }
        public async Task SelectRequestsGetSendsOrganizationIdQueryWithCorrectItineraryId()
        {
            const int itineraryId = 1;

            var mediator = new Mock<IMediator>();

            var sut = new ItineraryController(mediator.Object, null);
            await sut.SelectRequests(itineraryId);

            mediator.Verify(x => x.SendAsync(It.Is<OrganizationIdQuery>(y => y.ItineraryId == itineraryId)));
        }
        public async Task SelectRequestsWithSingleParameterSetsSelectItineraryRequestsModelWithTheCorrectData()
        {
            var organizationId = 4;
            var itineraryRequestsModel = new SelectItineraryRequestsModel();
            var itinerary = GetItineraryForSelectRequestHappyPathTests();
            var returnedRequests = GetRequestsForSelectRequestHappyPathTests();
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itinerary.Id)))
                    .ReturnsAsync(itinerary);
            mediator.Setup(x => x.SendAsync(It.IsAny<RequestListItemsQuery>()))
                    .ReturnsAsync(returnedRequests);
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>()))
                    .ReturnsAsync(organizationId);
            var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
            sut.SetClaims(new List<Claim>
            {
                new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
                new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
            });

            var view = await sut.SelectRequests(itinerary.Id, itineraryRequestsModel);

            RunSelectRequestsHappyPathTests(view, itinerary, returnedRequests);
        }