Ejemplo n.º 1
0
        public async Task ThenIShouldGetAMatchingCharityFromTheRepository()
        {
            //Arrange
            var query = new GetCharityByRegistrationNumberQuery
            {
                RegistrationNumber = 123
            };

            //Act
            var result = await _handler.Handle(query);

            //Assert
            Assert.IsInstanceOf <Charity>(result.Charity);
            Assert.IsNotNull(result.Charity);
        }
        public async Task <IHttpActionResult> GetCharity(int registrationNumber)
        {
            var query = new GetCharityByRegistrationNumberQuery
            {
                RegistrationNumber = registrationNumber
            };

            var response = await _mediator.SendAsync(query);

            if (response.Charity == null)
            {
                return(NotFound());
            }

            return(Ok(response.Charity));
        }