diff --git a/backend/BGC.Core/Models/Dtos/BoardGameGeek/BoardGameSearchResponseDto.cs b/backend/BGC.Core/Models/Dtos/BoardGameGeek/BoardGameSearchResponseDto.cs index 018efd17..f3745cea 100644 --- a/backend/BGC.Core/Models/Dtos/BoardGameGeek/BoardGameSearchResponseDto.cs +++ b/backend/BGC.Core/Models/Dtos/BoardGameGeek/BoardGameSearchResponseDto.cs @@ -6,14 +6,14 @@ namespace BGC.Core.Models.Dtos.BoardGameGeek; public class BoardGameSearchResponseDto { [XmlElement(typeof(BoardGameSearchItemDto), ElementName = "item")] - public BoardGameSearchItemDto[] BoardGames { get; init; } = Array.Empty(); + public BoardGameSearchItemDto[]? BoardGames { get; init; } = Array.Empty(); [XmlIgnore] - public bool IsEmpty => !BoardGames.Any(); + public bool IsEmpty => !(BoardGames?.Any() ?? false); [XmlAttribute(AttributeName = "total")] public int Total { get; set; } [XmlAttribute(AttributeName = "termsofuse")] - public string TermsOfUse { get; set; } + public string? TermsOfUse { get; set; } } \ No newline at end of file diff --git a/backend/BGC.SearchApi/Services/SearchService.cs b/backend/BGC.SearchApi/Services/SearchService.cs index 33f372b5..a25381ba 100644 --- a/backend/BGC.SearchApi/Services/SearchService.cs +++ b/backend/BGC.SearchApi/Services/SearchService.cs @@ -49,8 +49,8 @@ public async Task> Search(string query, return Array.Empty(); } - var boardGameSummaries = bggSearchResponse.BoardGames.Select(boardGame => new BoardGameSummaryDto(boardGame.Id.ToString(), boardGame.Name.Value, boardGame.YearPublished?.Value)) - .ToArray(); + var boardGameSummaries = bggSearchResponse.BoardGames!.Select(boardGame => new BoardGameSummaryDto(boardGame.Id.ToString(), boardGame.Name.Value, boardGame.YearPublished?.Value)) + .ToArray(); var boardGamesDetails = await _boardGamesRepository.GetBoardGames(boardGameSummaries.Select(boardGame => boardGame.Id), cancellationToken); var boardGamesDetailsDict = boardGamesDetails.ToDictionary(boardGame => boardGame.Id); diff --git a/backend/BGC.SearchApi/search.http b/backend/BGC.SearchApi/search.http index 360602bb..b4ec4e22 100644 --- a/backend/BGC.SearchApi/search.http +++ b/backend/BGC.SearchApi/search.http @@ -11,6 +11,11 @@ X-Api-Key: whatever ### +GET https://{{hostname}}:{{port}}/api/search?query=smallworld +X-Api-Key: whatever + +### + GET https://{{hostname}}:{{port}}/api/search?query=My Little Scythe ### diff --git a/backend/tests/BGC.SearchApi.UnitTests/Services/SearchServiceTests.cs b/backend/tests/BGC.SearchApi.UnitTests/Services/SearchServiceTests.cs index fa1bbd5b..5b531f8e 100644 --- a/backend/tests/BGC.SearchApi.UnitTests/Services/SearchServiceTests.cs +++ b/backend/tests/BGC.SearchApi.UnitTests/Services/SearchServiceTests.cs @@ -1,3 +1,4 @@ +using BGC.Core; using BGC.Core.Extensions; using BGC.Core.Models.Domain; using BGC.Core.Models.Dtos.BoardGameGeek; @@ -112,6 +113,7 @@ public async Task Search_EnrichesBoardGameDetails_ReturnsEnrichedGameDetailResul var enrichedBoardGameDetails = new BoardGame() { Id = "1238", + Type = Constants.BggApi.BoardGameTypes.MainGame, ImageUrl = "https://fancy.image.net/funny.jpg", Prices = new[] { @@ -131,6 +133,7 @@ public async Task Search_EnrichesBoardGameDetails_ReturnsEnrichedGameDetailResul searchResults.Should().HaveCount(bggSearchResposne.BoardGames.Length); searchResults.Should().ContainEquivalentOf(new BoardGameSummaryDto("1238", "Scythe", 1987) { + Type = Constants.Domain.BoardGameTypes.MainGame, ImageUrl = enrichedBoardGameDetails.ImageUrl, Prices = new BoardGameSummaryPriceDto[] {