public void GetShow() { // Pull XML tree trough the show builder var builder = new Builder(_dataProvider); var showId = int.Parse(_data.GetShowData().Keys.First(x => x.XmlValue == "id").XmlValue); var result = builder.BuildShow(showId); var showData = _data.GetShowData(); var episodeData = _data.GetEpisodeData(); // Assert equality between value conversions for show data foreach (var key in showData.Keys) { var prop = result.GetType().GetProperty(key.ObjValue); Assert.IsTrue(prop.GetValue(result).ToString() == showData[key].ObjValue, "!Show object! Property: " + prop.Name + " ;Actual object value: " + prop.GetValue(result) + " ;Expected value: " + showData[key].ObjValue); } // Assert equality between value conversion for episode data for (var i = 0; i < result.Episodes.Count; i++) { var currentEpisode = result.Episodes[i]; var dic = episodeData[i]; foreach (var key in dic.Keys) { var prop = currentEpisode.GetType().GetProperty(key.ObjValue); // Checks whether or not we're dealing with a list // ToString() method on lists will not show the values and are therefore not suited for comparison // That's why we manually check the entries if (new List<string> {"Actors", "Genres", "GuestStars", "Writers"}.Contains(key.ObjValue)) { foreach (var entry in dic[key].XmlValue.Split('|')) { Assert.IsTrue(((List<string>) prop.GetValue(currentEpisode)).Contains(entry), "!List object! Property: " + prop.Name + " ;Actual object value: " + string.Join(", ", (List<string>) prop.GetValue(currentEpisode)) + ";Expected value: " + dic[key].XmlValue); } } var value = prop.GetValue(currentEpisode).ToString(); var expected = dic[key].ObjValue; Assert.IsTrue(value == expected, "!Episode object! Property: " + prop.Name + " ;Actual object value: " + prop.GetValue(currentEpisode) + " ;Expected value: " + dic[key].ObjValue); } } }
/// <summary> /// Creates a new instance with the provided API key and standard <see cref="IDataProvider"/>. /// </summary> /// <param name="apiKey">The API key provided by TVDB.</param> public TVDB(string apiKey) { _builder = new Builder(new DataProvider { ApiKey = apiKey }); }
/// <summary> /// Creates a new instance with the provided API key and dataProvider. /// </summary> /// <param name="apiKey">The API key provided by TVDB.</param> /// <param name="dataProvider">Specify your own <see cref="IDataProvider"/> instance.</param> public TVDB(string apiKey, IDataProvider dataProvider) { dataProvider.ApiKey = apiKey; _builder = new Builder(dataProvider); }