Example #1
0
        public async Task AuthorizationController_AccessApprenticeshipRequest_ShouldReturnOkAndBoolResult()
        {
            var request = new ApprenticeshipAccessRequest {
                ApprenticeshipId = 1, Party = Party.Employer, PartyId = 2
            };

            var retVal = await _fixture.SetCanAccessApprenticeshipToReturnTrue().AuthorizationController.CanAccessApprenticeship(request);

            Assert.IsInstanceOf <OkObjectResult>(retVal);
            Assert.IsTrue((bool)((OkObjectResult)retVal).Value);
        }
        public async Task <IActionResult> CanAccessApprenticeship(ApprenticeshipAccessRequest request)
        {
            var query = new CanAccessApprenticeshipQuery
            {
                ApprenticeshipId = request.ApprenticeshipId,
                Party            = request.Party,
                PartyId          = request.PartyId
            };

            return(Ok(await _mediator.Send(query)));
        }
Example #3
0
        public async Task AuthorizationController_AccessApprenticeshipRequest_ShouldCallCommandWithCorrectQueryValues(
            Party party, long partyId, long apprenticeshipId)
        {
            var request = new ApprenticeshipAccessRequest {
                ApprenticeshipId = apprenticeshipId, Party = party, PartyId = partyId
            };

            await _fixture.AuthorizationController.CanAccessApprenticeship(request);

            _fixture.MediatorMock.Verify(x => x.Send(It.Is <CanAccessApprenticeshipQuery>(p => p.ApprenticeshipId == apprenticeshipId &&
                                                                                          p.Party == party &&
                                                                                          p.PartyId == partyId),
                                                     CancellationToken.None), Times.Once);
        }