public async Task Handle_ValidRequest_ReturnsTrue()
        {
            var request = new UpdateOrganisationTrusteesRequest
            {
                Ukprn     = _ukprn,
                UpdatedBy = _updatedBy,
                Trustees  = new List <Trustee> {
                    new Trustee {
                        Id = 1, Name = "Cody McCodeface"
                    }
                }
            };

            var organisation = new Organisation
            {
                OrganisationDetails = new OrganisationDetails
                {
                    CharityCommissionDetails = new CharityCommissionDetails()
                }
            };

            _repository.Setup(x => x.GetOrganisationByUkprn(_ukprn)).ReturnsAsync(organisation);

            var result = await _handler.Handle(request, new CancellationToken());

            Assert.IsTrue(result);
            _repository.Verify(x => x.UpdateOrganisation(It.IsAny <Organisation>(), _updatedBy), Times.Once);
        }
Пример #2
0
        public async Task <ActionResult <bool> > UpdateOrganisationTrustees([FromBody] UpdateOrganisationTrusteesRequest request)
        {
            var result = await _mediator.Send(request);

            if (result is false)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
        public async Task <bool> UpdateTrustees(string ukprn, List <InternalApi.Types.CharityCommission.Trustee> trustees, Guid userId)
        {
            var request = new UpdateOrganisationTrusteesRequest
            {
                Ukprn     = ukprn,
                UpdatedBy = userId,
                Trustees  = trustees
            };

            return(await Put <UpdateOrganisationTrusteesRequest, bool>($"/Organisations/Trustees", request));
        }
        public async Task Handle_OrganisationNotFound_ReturnsFalse()
        {
            var request = new UpdateOrganisationTrusteesRequest
            {
                Ukprn     = _ukprn,
                UpdatedBy = _updatedBy,
                Trustees  = new List <Trustee> {
                    new Trustee {
                        Id = 1, Name = "Cody McCodeface"
                    }
                }
            };

            Organisation organisation = null;

            _repository.Setup(x => x.GetOrganisationByUkprn(_ukprn)).ReturnsAsync(organisation);

            var result = await _handler.Handle(request, new CancellationToken());

            Assert.IsFalse(result);
            _repository.Verify(x => x.UpdateOrganisation(It.IsAny <Organisation>(), It.IsAny <Guid>()), Times.Never);
        }