public async Task Returns_person_when_found()
        {
            var personId = Guid.NewGuid();
            var dateTime = DateTime.UtcNow;

            var result = Person.Create(personId, "any name", dateTime);

            _stubGetPerson.Get(personId).Returns(Result <Person> .Success(result.Value));

            var response = await _handler.Get(new GetPersonRequest(personId));

            response.PersonModel.Id.Equals(personId);
            response.PersonModel.Name.Equals("any name");
            response.PersonModel.DateCreated.Equals(dateTime);
            response.ResponseType.ShouldBe(ResponseType.Found);
        }
예제 #2
0
        public async Task <GetPersonResponse> Get(GetPersonRequest request)
        {
            var personResult = await _getPersons.Get(request.PersonId);

            return(!personResult.IsSuccess
                ? GetPersonResponse.Failed(personResult.ErrorMessage)
                : GetPersonResponse.Success(new PersonModel(personResult.Value.Id, personResult.Value.Name, personResult.Value.DateCreated)));
        }