Пример #1
0
        public async Task <IEnumerable <GameSearchResponse> > Handle(SearchForGameRequest request, CancellationToken cancellationToken)
        {
            if (request.Category == GameCategoryReference.BoardGame)
            {
                var boardGameResponse = await _boardGameGeekProvider.SearchForGame(request.Title);

                return(boardGameResponse.IsSuccess ? boardGameResponse.Value : throw new BadHttpRequestException(boardGameResponse.Error));
            }

            var videoGameResponse = await _giantBombProvider.SearchForGame(request.Title);

            return(videoGameResponse.IsSuccess ? videoGameResponse.Value : throw new BadHttpRequestException(videoGameResponse.Error));
        }
        public async Task Search_For_Game_Returns_Failure_If_Api_Client_Returns_Failure()
        {
            _apiClient
            .Setup(x => x.SendSearchForGameRequest(It.IsAny <string>()))
            .ReturnsAsync(Result.Failure <BoardGameGeekSearchResult>("Error"));

            var result = await _provider.SearchForGame("Dark Souls III");

            result.IsFailure.Should().BeTrue();
        }