private async Task <OmdbMovie> GetByIdOrTitleAsync( string?imdbId, string?title, OmdbSearchType resultType = OmdbSearchType.NONE, int?yearOfRelease = null, OmdbPlotOption omdbPlotOption = OmdbPlotOption.SHORT) { if (imdbId is null && title is null) { throw new ArgumentException("Both imdbId and title are null which is not allowed"); } RestRequest request = new(Method.GET); this.AddDefaultParameters(request); if (imdbId is not null) { request.AddParameter("i", imdbId); } if (title is not null) { request.AddParameter("t", title); } if (resultType is not OmdbSearchType.NONE) { request.AddParameter("type", resultType.ToQueryValue()); } if (yearOfRelease is not null) { request.AddParameter("y", yearOfRelease); } request.AddParameter("plot", omdbPlotOption.ToQueryValue()); return(await this.restClient.GetAsync <OmdbMovie>(request)); }
public async Task GetByMovieTitleFeatureWithSpecifiedTitle(string imdbId, string title, OmdbPlotOption plotOption, OmdbMovie expected) { OmdbMovie result = await this._client.GetByMovieTitleAsync(title, omdbPlotOption : plotOption); Assert.AreEqual(expected, result, $"Expected: \n{expected.ToDetailedString()}\nActual: \n{result.ToDetailedString()}\n"); }
public async Task <OmdbMovie> GetByMovieTitleAsync( string title, OmdbSearchType resultType = OmdbSearchType.NONE, int?yearOfRelease = null, OmdbPlotOption omdbPlotOption = OmdbPlotOption.SHORT) => await this.GetByIdOrTitleAsync(null, title, resultType, yearOfRelease, omdbPlotOption);
public static string ToQueryValue(this OmdbPlotOption option) => option switch {