public void ToDictionary_ReturnsCorrectDictionary()
        {
            // Arrange
            var sut = new CharacterCriteria
            {
                Name           = "TestName456",
                NameStartsWith = "TestStartName789",
                ModifiedSince  = new DateTime(2015, 1, 15, 8, 59, 21),
                Comics         = new List <int> {
                    1, 2, 3
                },
                Series = new List <int> {
                    12
                },
                Events  = new List <int>(),
                Stories = new List <int> {
                    0
                },
                OrderBy = new List <CharacterOrder> {
                    CharacterOrder.NameAscending, CharacterOrder.ModifiedDescending
                }
            };

            // Act
            var result = sut.ToDictionary();

            // Assert
            Assert.AreEqual(7, result.Count);

            Assert.Contains(ParameterName, result.Keys);
            Assert.Contains(ParameterNameStartsWith, result.Keys);
            Assert.Contains(ParameterModifiedSince, result.Keys);
            Assert.Contains(ParameterComics, result.Keys);
            Assert.Contains(ParameterSeries, result.Keys);
            Assert.Contains(ParameterStories, result.Keys);
            Assert.Contains(ParameterOrderBy, result.Keys);

            Assert.IsFalse(result.Keys.Contains(ParameterEvents));

            Assert.AreEqual(sut.Name, result[ParameterName]);
            Assert.AreEqual(sut.NameStartsWith, result[ParameterNameStartsWith]);
            Assert.AreEqual(sut.ModifiedSince.Value.ToString(ParameterDateTimeFormat), result[ParameterModifiedSince]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Comics), result[ParameterComics]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Series), result[ParameterSeries]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Stories), result[ParameterStories]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.OrderBy.Select(o => o.GetStringValue())), result[ParameterOrderBy]);
        }
Esempio n. 2
0
        public async Task <Character> GetCharacter(string name)
        {
            _log.Information($"Searching for {name}.");

            var nameSearch = new CharacterCriteria()
            {
                Name = name
            };

            var response = await ApiService.GetAllCharactersAsync(5, 0, nameSearch);

            if (response.Success)
            {
                return(response.Data.Result.FirstOrDefault());
            }

            _log.Error(response.Code);
            return(null);
        }
Esempio n. 3
0
 /// <summary>
 ///     Fetches a list of comic characters appearing in the specified story, with optional filters
 /// </summary>
 /// <param name="storyId">The story ID.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <returns></returns>
 public async Task <Response <List <Character> > > GetStoryCharactersAsync(int storyId, int?limit = null,
                                                                           int?offset             = null, CharacterCriteria criteria = null)
 {
     return(await _characterService.GetByStoryAsync(storyId, limit, offset, criteria));
 }
Esempio n. 4
0
 /// <summary>
 ///     Fetches a list of comic characters, with optional filters
 /// </summary>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <returns></returns>
 public async Task <Response <List <Character> > > GetAllCharactersAsync(int?limit = null, int?offset = null,
                                                                         CharacterCriteria criteria = null)
 {
     return(await _characterService.GetAllAsync(limit, offset, criteria));
 }
Esempio n. 5
0
 /// <summary>
 ///     Fetches a list of characters that appear in a specific event, with optional filters
 /// </summary>
 /// <param name="eventId">The event ID.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <returns></returns>
 public async Task <Response <List <Character> > > GetEventCharactersAsync(int eventId, int?limit = null,
                                                                           int?offset             = null, CharacterCriteria criteria = null)
 {
     return(await _characterService.GetByEventAsync(eventId, limit, offset, criteria));
 }
Esempio n. 6
0
 /// <summary>
 ///     Fetches a list of characters that appear in a specific comic, with optional filters
 /// </summary>
 /// <param name="comicId">The comic ID.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <returns></returns>
 public async Task <Response <List <Character> > > GetComicCharactersAsync(int comicId, int?limit = null,
                                                                           int?offset             = null, CharacterCriteria criteria = null)
 {
     return(await _characterService.GetByComicAsync(comicId, limit, offset, criteria));
 }
Esempio n. 7
0
 internal async Task <Response <List <Character> > > GetByStoryAsync(int storyId, int?limit = null, int?offset = null, CharacterCriteria criteria = null)
 {
     return(await GetList(string.Format(UrlSuffixStoryCharacters, storyId), limit, offset, criteria));
 }
Esempio n. 8
0
 /// <summary>
 /// Fetches a list of comic characters, with optional filters
 /// </summary>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <returns></returns>
 internal async Task <Response <List <Character> > > GetAllAsync(int?limit = null, int?offset = null, CharacterCriteria criteria = null)
 {
     return(await GetList(UrlSuffixAllCharacters, limit, offset, criteria));
 }