예제 #1
0
        public async Task WhenGettingSizeInKBForRoot_ShouldReturnWholeTreeSize()
        {
            var characterFileSource = new CharacterFileSource();
            var adapter             = new CharacterFileSourceAdapter("People.json", characterFileSource);

            var people = await adapter.GetCharacters();

            people.First().Gender.Should().Be("male");
        }
        public async Task <ActionResult> Get()
        {
            try
            {
                ICharacterSourceAdapter characterSourceAdapter = new CharacterFileSourceAdapter(_configuration["CharacterFilePath"], new CharacterFileSource());
                var people = await characterSourceAdapter.GetCharacters();

                var sb        = new StringBuilder();
                int nameWidth = 30;
                sb.AppendLine($"{"NAME".PadRight(nameWidth)}   {"BirthYear"}");
                foreach (Character character in people)
                {
                    sb.AppendLine($"{character.Name.PadRight(nameWidth)}   {character.BirthYear}");
                }

                return(Ok(sb.ToString()));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }