Exemplo n.º 1
0
        public async Task SearchCharacterAsync_InvalidLetter_ShouldThrowValidationException(char notLetter)
        {
            // Given
            var config = new CharacterSearchConfig {
                Letter = notLetter
            };

            // When
            var func = _jikan.Awaiting(x => x.SearchCharacterAsync(config));

            // Then
            await func.Should().ThrowExactlyAsync <JikanValidationException>();
        }
Exemplo n.º 2
0
        public async Task SearchCharacterAsync_InvalidPageSize_ShouldThrowValidationException(int pageSize)
        {
            // Given
            var config = new CharacterSearchConfig {
                PageSize = pageSize
            };

            // When
            var func = _jikan.Awaiting(x => x.SearchCharacterAsync(config));

            // Then
            await func.Should().ThrowExactlyAsync <JikanValidationException>();
        }
Exemplo n.º 3
0
        public async Task SearchCharacterAsync_LupinQueryByMalIdWithLimit2_ShouldReturnThirdAndKaitoKuroba()
        {
            // Given
            var config = new CharacterSearchConfig {
                Query = "Lupin", OrderBy = CharacterSearchOrderBy.MalId, PageSize = 2
            };

            // When
            var people = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            people.Data.Should().HaveCount(config.PageSize.Value);
            people.Data.Should().Contain(x => x.Name.Equals("Lupin"));
        }
Exemplo n.º 4
0
        public async Task SearchCharacterAsync_EmptyConfig_ShouldReturnFirst25People()
        {
            // Given
            var config = new CharacterSearchConfig();

            // When
            var characters = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            characters.Data.Should().HaveCount(ParameterConsts.MaximumPageSize);
            characters.Data.First().Name.Should().Be("Spike Spiegel");
            characters.Data.First().NameKanji.Should().Be("スパイク・スピーゲル");
            characters.Pagination.LastVisiblePage.Should().BeGreaterThan(2350);
        }
Exemplo n.º 5
0
        public async Task SearchCharacterAsync_ValidLetter_ShouldReturnRecordsOnlyStartingOnLetter(char letter)
        {
            // Given
            var config = new CharacterSearchConfig {
                Letter = letter
            };

            // When
            var people = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            people.Data.Should().HaveCount(ParameterConsts.MaximumPageSize);
            people.Data.Should().OnlyContain(x => x.Name.StartsWith(letter));
        }
Exemplo n.º 6
0
        public async Task SearchCharacterAsync_LupinQueryByPopularity_ShouldReturnLupinsWithKurobaFirst()
        {
            // Given
            var config = new CharacterSearchConfig {
                Query = "Lupin", OrderBy = CharacterSearchOrderBy.Favorites, SortDirection = SortDirection.Descending
            };

            // When
            var people = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            people.Data.Should().Contain(x => x.Name.Equals("Fake Lupin"));
            people.Data.Should().Contain(x => x.Name.Equals("Arsène Lupin"));
            people.Data.Should().Contain(x => x.Name.Equals("Lupin II"));
            people.Data.First().Name.Should().Be("Lupin");
        }
Exemplo n.º 7
0
        public async Task SearchCharacterAsync_LupinQuery_ShouldReturnLupins()
        {
            // Given
            var config = new CharacterSearchConfig {
                Query = "Lupin"
            };

            // When
            var people = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            people.Data.Should().Contain(x => x.Name.Equals("Fake Lupin"));
            people.Data.Should().Contain(x => x.Name.Equals("Arsène Lupin"));
            people.Data.Should().Contain(x => x.Name.Equals("Lupin II"));
            people.Data.First().Name.Should().Be("Lupin");
        }
Exemplo n.º 8
0
        public async Task SearchCharacterAsync_GivenValidPageAndPageSize_ShouldReturnPageSizeNumberOfRecordsFromNextPage()
        {
            // Given
            const int pageSize = 5;
            var       config   = new CharacterSearchConfig {
                PageSize = pageSize, Page = 2
            };

            // When
            var characters = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            characters.Data.Should().HaveCount(pageSize);
            characters.Data.First().Name.Should().Be("Rukia Kuchiki");
            characters.Pagination.CurrentPage.Should().Be(2);
            characters.Pagination.Items.Count.Should().Be(pageSize);
            characters.Pagination.Items.PerPage.Should().Be(pageSize);
        }
Exemplo n.º 9
0
        public async Task SearchCharacterAsync_GivenValidPageSize_ShouldReturnPageSizeNumberOfRecords()
        {
            // Given
            const int pageSize = 5;
            var       config   = new CharacterSearchConfig {
                PageSize = pageSize
            };

            // When
            var characters = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            characters.Data.Should().HaveCount(pageSize);
            characters.Data.First().Name.Should().Be("Spike Spiegel");
            characters.Data.First().NameKanji.Should().Be("スパイク・スピーゲル");
            characters.Pagination.CurrentPage.Should().Be(1);
            characters.Pagination.Items.Count.Should().Be(pageSize);
            characters.Pagination.Items.PerPage.Should().Be(pageSize);
        }
Exemplo n.º 10
0
        public async Task SearchCharacterAsync_GivenSecondPage_ShouldReturnSecondPage()
        {
            // Given
            var config = new CharacterSearchConfig {
                Page = 2
            };

            // When
            var characters = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            characters.Data.Should().HaveCount(ParameterConsts.MaximumPageSize);
            characters.Data.First().Name.Should().Be("Leorio Paladiknight");
            characters.Data.First().NameKanji.Should().StartWith("レオリオ=パラディナイト");
            characters.Pagination.LastVisiblePage.Should().BeGreaterThan(2350);
            characters.Pagination.CurrentPage.Should().Be(2);
            characters.Pagination.Items.Count.Should().Be(25);
            characters.Pagination.Items.PerPage.Should().Be(25);
        }
Exemplo n.º 11
0
        public async Task SearchCharacterAsync_KirumiQuery_ShouldReturnSingleKirumi()
        {
            // Given
            var config = new CharacterSearchConfig {
                Query = "kirumi to"
            };

            // When
            var people = await _jikan.SearchCharacterAsync(config);

            // Then
            using var _ = new AssertionScope();
            people.Data.Should().ContainSingle();

            var result = people.Data.First();

            result.Name.Should().Be("Kirumi Toujou");
            result.Nicknames.Should().BeEmpty();
            result.About.Should().NotBeEmpty();
            result.MalId.Should().Be(157604);
        }