public async Task <PersonResponse> Handle(GetPersonByIdQuery request, CancellationToken cancellationToken)
        {
            var result = await _personServiceProvider.GetPersonByIdAsync(request.Id);

            return(result == null ? null : new PersonResponse {
                Id = 1,
                FirstName = "test",
                LastName = "last"
            });
        }
Exemple #2
0
        public async Task GetPersonByIdAsync_ShouldReturnPerson_WhenPersonExists()
        {
            //Arrange
            int personId   = 1;
            var personData = new Person {
                Id        = 1,
                FirstName = "SafeAuto",
                LastName  = "Development",
                Addresses = new List <Address>()
            };

            _personRepository.Setup(s => s.GetPersonByIdAsync(personId)).ReturnsAsync(personData);

            //Act
            var result = await _personServiceProvider.GetPersonByIdAsync(personId);

            //Assert

            Assert.Equal(personId, result.Id);
            Assert.Equal(personData.FirstName, result.FirstName);
            Assert.Equal(personData.LastName, result.LastName);
        }