public void GetUriTest()
        {
            var actual = OmdbUriBuilder.GetUri(new Dictionary <string, string> {
                { "t", "hitman" }
            });
            var expected = new Uri("http://www.omdbapi.com/?apikey=b1b769fe&type=movie&r=json&t=hitman");

            Assert.Equal(expected, actual);
        }
示例#2
0
        public async Task <MovieInfo> GetMoviesByTitle(string title)
        {
            var url = OmdbUriBuilder.GetUri(new Dictionary <string, string> {
                { "t", title }
            });

            using var responseMessage = await _client.GetAsync(url);

            if (!responseMessage.IsSuccessStatusCode)
            {
                return(null);
            }
            var output = await responseMessage.Content.ReadFromJsonAsync <MovieInfo>();

            return(output.ImdbID == null ? null : output);
        }