コード例 #1
0
        public async Task Test_PersonObjectJsonReader_ReadObject_From_Stream_Full_Complete()
        {
            var traktJsonReader = new PersonObjectJsonReader();

            using (var stream = FULL_JSON_COMPLETE.ToStream())
            {
                var traktPerson = await traktJsonReader.ReadObjectAsync(stream);

                traktPerson.Should().NotBeNull();
                traktPerson.Name.Should().Be("Bryan Cranston");
                traktPerson.Ids.Should().NotBeNull();
                traktPerson.Ids.Trakt.Should().Be(297737U);
                traktPerson.Ids.Slug.Should().Be("bryan-cranston");
                traktPerson.Ids.Imdb.Should().Be("nm0186505");
                traktPerson.Ids.Tmdb.Should().Be(17419U);
                traktPerson.Ids.TvRage.Should().Be(1797U);
                traktPerson.Biography.Should().Be("Bryan Lee Cranston(born March 7, 1956) is an American actor, voice actor, writer and director.He is perhaps best known for his roles as Hal, the father in the Fox situation comedy Malcolm in the Middle, and as Walter White in the AMC drama series Breaking Bad, for which he has won three consecutive Outstanding Lead Actor in a Drama Series Emmy Awards. Other notable roles include Dr. Tim Whatley on Seinfeld, Doug Heffernan's neighbor in The King of Queens, Astronaut Buzz Aldrin in From the Earth to the Moon, and Ted Mosby's boss on How I Met Your Mother. Description above from the Wikipedia article Bryan Cranston, licensed under CC-BY-SA, full list of contributors on Wikipedia.");
                traktPerson.Birthday.Should().Be(DateTime.Parse("1956-03-07T00:00:00Z").ToUniversalTime());
                traktPerson.Death.Should().Be(DateTime.Parse("2016-04-06T00:00:00Z").ToUniversalTime());
                traktPerson.Age.Should().Be(60);
                traktPerson.Birthplace.Should().Be("San Fernando Valley, California, USA");
                traktPerson.Homepage.Should().Be("http://www.bryancranston.com/");
            }
        }
コード例 #2
0
        public async Task Test_SeasonArrayJsonReader_ReadArray_From_Stream_Full_Complete()
        {
            var traktJsonReader = new ArrayJsonReader <ITraktSeason>();

            using (var stream = FULL_JSON_COMPLETE.ToStream())
            {
                var traktSeasons = await traktJsonReader.ReadArrayAsync(stream);

                traktSeasons.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(2);

                var seasons = traktSeasons.ToArray();

                seasons[0].Should().NotBeNull();
                seasons[0].Number.Should().Be(1);
                seasons[0].Ids.Should().NotBeNull();
                seasons[0].Ids.Trakt.Should().Be(61430U);
                seasons[0].Ids.Tvdb.Should().Be(279121U);
                seasons[0].Ids.Tmdb.Should().Be(60523U);
                seasons[0].Ids.TvRage.Should().Be(36939U);
                seasons[0].Rating.Should().Be(8.57053f);
                seasons[0].Votes.Should().Be(794);
                seasons[0].TotalEpisodesCount.Should().Be(10);
                seasons[0].AiredEpisodesCount.Should().Be(10);
                seasons[0].Overview.Should().Be("Trouble is brewing in the Seven Kingdoms of Westeros. For the driven inhabitants of this visionary world, control of Westeros' Iron Throne holds the lure of great power. But in a land where the seasons can last a lifetime, winter is coming...and beyond the Great Wall that protects them, an ancient evil has returned. In Season One, the story centers on three primary areas: the Stark and the Lannister families, whose designs on controlling the throne threaten a tenuous peace; the dragon princess Daenerys, heir to the former dynasty, who waits just over the Narrow Sea with her malevolent brother Viserys; and the Great Wall--a massive barrier of ice where a forgotten danger is stirring.");
                seasons[0].FirstAired.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());
                seasons[0].Network.Should().Be("The CW");
                seasons[0].Episodes.Should().NotBeNull().And.HaveCount(2);

                var episodes = seasons[0].Episodes.ToArray();

                episodes[0].Should().NotBeNull();
                episodes[0].SeasonNumber.Should().Be(1);
                episodes[0].Number.Should().Be(1);
                episodes[0].Title.Should().Be("Winter Is Coming");
                episodes[0].Ids.Should().NotBeNull();
                episodes[0].Ids.Trakt.Should().Be(73640U);
                episodes[0].Ids.Tvdb.Should().Be(3254641U);
                episodes[0].Ids.Imdb.Should().Be("tt1480055");
                episodes[0].Ids.Tmdb.Should().Be(63056U);
                episodes[0].Ids.TvRage.Should().Be(1065008299U);
                episodes[0].NumberAbsolute.Should().NotHaveValue();
                episodes[0].Overview.Should().BeNullOrEmpty();
                episodes[0].Runtime.Should().NotHaveValue();
                episodes[0].Rating.Should().NotHaveValue();
                episodes[0].Votes.Should().NotHaveValue();
                episodes[0].FirstAired.Should().NotHaveValue();
                episodes[0].UpdatedAt.Should().NotHaveValue();
                episodes[0].AvailableTranslationLanguageCodes.Should().BeNull();
                episodes[0].Translations.Should().BeNull();

                episodes[1].Should().NotBeNull();
                episodes[1].SeasonNumber.Should().Be(1);
                episodes[1].Number.Should().Be(2);
                episodes[1].Title.Should().Be("The Kingsroad");
                episodes[1].Ids.Should().NotBeNull();
                episodes[1].Ids.Trakt.Should().Be(74138U);
                episodes[1].Ids.Tvdb.Should().Be(3436411U);
                episodes[1].Ids.Imdb.Should().Be("tt1668746");
                episodes[1].Ids.Tmdb.Should().Be(63141U);
                episodes[1].Ids.TvRage.Should().Be(1325718577U);
                episodes[1].NumberAbsolute.Should().NotHaveValue();
                episodes[1].Overview.Should().BeNullOrEmpty();
                episodes[1].Runtime.Should().NotHaveValue();
                episodes[1].Rating.Should().NotHaveValue();
                episodes[1].Votes.Should().NotHaveValue();
                episodes[1].FirstAired.Should().NotHaveValue();
                episodes[1].UpdatedAt.Should().NotHaveValue();
                episodes[1].AvailableTranslationLanguageCodes.Should().BeNull();
                episodes[1].Translations.Should().BeNull();

                // ------------------------------------------------------------

                seasons[1].Should().NotBeNull();
                seasons[1].Number.Should().Be(2);
                seasons[1].Ids.Should().NotBeNull();
                seasons[1].Ids.Trakt.Should().Be(3964U);
                seasons[1].Ids.Tvdb.Should().Be(473271U);
                seasons[1].Ids.Tmdb.Should().Be(3625U);
                seasons[1].Ids.TvRage.Should().Be(36940U);
                seasons[1].Rating.Should().Be(9.10629f);
                seasons[1].Votes.Should().Be(1590);
                seasons[1].TotalEpisodesCount.Should().Be(10);
                seasons[1].AiredEpisodesCount.Should().Be(10);
                seasons[1].Overview.Should().Be("The cold winds of winter are rising in Westeros...war is coming...and five kings continue their savage quest for control of the all-powerful Iron Throne. With winter fast approaching, the coveted Iron Throne is occupied by the cruel Joffrey, counseled by his conniving mother Cersei and uncle Tyrion. But the Lannister hold on the Throne is under assault on many fronts. Meanwhile, a new leader is rising among the wildings outside the Great Wall, adding new perils for Jon Snow and the order of the Night's Watch.");
                seasons[1].FirstAired.Should().Be(DateTime.Parse("2012-04-02T01:00:00.000Z").ToUniversalTime());
                seasons[1].Network.Should().Be("The CW");
                seasons[1].Episodes.Should().NotBeNull().And.HaveCount(2);

                episodes = seasons[1].Episodes.ToArray();

                episodes[0].Should().NotBeNull();
                episodes[0].SeasonNumber.Should().Be(2);
                episodes[0].Number.Should().Be(1);
                episodes[0].Title.Should().Be("The North Remembers");
                episodes[0].Ids.Should().NotBeNull();
                episodes[0].Ids.Trakt.Should().Be(73650U);
                episodes[0].Ids.Tvdb.Should().Be(4161693U);
                episodes[0].Ids.Imdb.Should().Be("tt1971833");
                episodes[0].Ids.Tmdb.Should().Be(63066U);
                episodes[0].Ids.TvRage.Should().Be(1065074755U);
                episodes[0].NumberAbsolute.Should().NotHaveValue();
                episodes[0].Overview.Should().BeNullOrEmpty();
                episodes[0].Runtime.Should().NotHaveValue();
                episodes[0].Rating.Should().NotHaveValue();
                episodes[0].Votes.Should().NotHaveValue();
                episodes[0].FirstAired.Should().NotHaveValue();
                episodes[0].UpdatedAt.Should().NotHaveValue();
                episodes[0].AvailableTranslationLanguageCodes.Should().BeNull();
                episodes[0].Translations.Should().BeNull();

                episodes[1].Should().NotBeNull();
                episodes[1].SeasonNumber.Should().Be(2);
                episodes[1].Number.Should().Be(2);
                episodes[1].Title.Should().Be("The Night Lands");
                episodes[1].Ids.Should().NotBeNull();
                episodes[1].Ids.Trakt.Should().Be(73651U);
                episodes[1].Ids.Tvdb.Should().Be(4245771U);
                episodes[1].Ids.Imdb.Should().Be("tt2069318");
                episodes[1].Ids.Tmdb.Should().Be(974430U);
                episodes[1].Ids.TvRage.Should().Be(1065150289U);
                episodes[1].NumberAbsolute.Should().NotHaveValue();
                episodes[1].Overview.Should().BeNullOrEmpty();
                episodes[1].Runtime.Should().NotHaveValue();
                episodes[1].Rating.Should().NotHaveValue();
                episodes[1].Votes.Should().NotHaveValue();
                episodes[1].FirstAired.Should().NotHaveValue();
                episodes[1].UpdatedAt.Should().NotHaveValue();
                episodes[1].AvailableTranslationLanguageCodes.Should().BeNull();
                episodes[1].Translations.Should().BeNull();
            }
        }
コード例 #3
0
        public async Task Test_EpisodeArrayJsonReader_ReadArray_From_Stream_Full_Complete()
        {
            var traktJsonReader = new EpisodeArrayJsonReader();

            using (var stream = FULL_JSON_COMPLETE.ToStream())
            {
                var traktEpisodes = await traktJsonReader.ReadArrayAsync(stream);

                traktEpisodes.Should().NotBeNull().And.NotBeEmpty().And.HaveCount(2);

                var episodes = traktEpisodes.ToArray();

                episodes[0].Should().NotBeNull();
                episodes[0].SeasonNumber.Should().Be(1);
                episodes[0].Number.Should().Be(1);
                episodes[0].Title.Should().Be("Winter Is Coming");
                episodes[0].Ids.Should().NotBeNull();
                episodes[0].Ids.Trakt.Should().Be(73640U);
                episodes[0].Ids.Tvdb.Should().Be(3254641U);
                episodes[0].Ids.Imdb.Should().Be("tt1480055");
                episodes[0].Ids.Tmdb.Should().Be(63056U);
                episodes[0].Ids.TvRage.Should().Be(1065008299U);
                episodes[0].NumberAbsolute.Should().Be(1);
                episodes[0].Overview.Should().Be("Ned Stark, Lord of Winterfell learns that his mentor, Jon Arryn, has died and that King Robert is on his way north to offer Ned Arryn’s position as the King’s Hand. Across the Narrow Sea in Pentos, Viserys Targaryen plans to wed his sister Daenerys to the nomadic Dothraki warrior leader, Khal Drogo to forge an alliance to take the throne.");
                episodes[0].Runtime.Should().Be(55);
                episodes[0].Rating.Should().Be(9.0f);
                episodes[0].Votes.Should().Be(111);
                episodes[0].FirstAired.Should().Be(DateTime.Parse("2011-04-18T01:00:00.000Z").ToUniversalTime());
                episodes[0].UpdatedAt.Should().Be(DateTime.Parse("2014-08-29T23:16:39.000Z").ToUniversalTime());
                episodes[0].AvailableTranslationLanguageCodes.Should().NotBeNull().And.HaveCount(2).And.Contain("en", "es");
                episodes[0].Translations.Should().NotBeNull().And.HaveCount(2);

                var translations = episodes[0].Translations.ToArray();

                translations[0].Should().NotBeNull();
                translations[0].Title.Should().Be("Winter Is Coming");
                translations[0].Overview.Should().Be("Jon Arryn, the Hand of the King, is dead. King Robert Baratheon plans to ask his oldest friend, Eddard Stark, to take Jon's place. Across the sea, Viserys Targaryen plans to wed his sister to a nomadic warlord in exchange for an army.");
                translations[0].LanguageCode.Should().Be("en");

                translations[1].Should().NotBeNull();
                translations[1].Title.Should().Be("Se acerca el invierno");
                translations[1].Overview.Should().Be("El Lord Ned Stark está preocupado por los perturbantes reportes de un desertor del Nights Watch; El Rey Robert y los Lannisters llegan a Winterfell; el exiliado Viserys Targaryen forja una nueva y poderosa alianza.");
                translations[1].LanguageCode.Should().Be("es");

                episodes[1].Should().NotBeNull();
                episodes[1].SeasonNumber.Should().Be(1);
                episodes[1].Number.Should().Be(2);
                episodes[1].Title.Should().Be("The Kingsroad");
                episodes[1].Ids.Should().NotBeNull();
                episodes[1].Ids.Trakt.Should().Be(73641U);
                episodes[1].Ids.Tvdb.Should().Be(3436411U);
                episodes[1].Ids.Imdb.Should().Be("tt1668746");
                episodes[1].Ids.Tmdb.Should().Be(63057U);
                episodes[1].Ids.TvRage.Should().Be(1065023912U);
                episodes[1].NumberAbsolute.Should().Be(2);
                episodes[1].Overview.Should().Be("Having agreed to become the King’s Hand, Ned leaves Winterfell with daughters Sansa and Arya, while Catelyn stays behind in Winterfell. Jon Snow heads north to join the brotherhood of the Night’s Watch. Tyrion decides to forego the trip south with his family, instead joining Jon in the entourage heading to the Wall. Viserys bides his time in hopes of winning back the throne, while Daenerys focuses her attention on learning how to please her new husband, Drogo.");
                episodes[1].Runtime.Should().Be(55);
                episodes[1].Rating.Should().Be(8.22255f);
                episodes[1].Votes.Should().Be(6183);
                episodes[1].FirstAired.Should().Be(DateTime.Parse("2011-04-25T01:00:00.000Z").ToUniversalTime());
                episodes[1].UpdatedAt.Should().Be(DateTime.Parse("2017-03-05T14:47:14.000Z").ToUniversalTime());
                episodes[1].AvailableTranslationLanguageCodes.Should().NotBeNull().And.HaveCount(2).And.Contain("en", "es");
                episodes[1].Translations.Should().NotBeNull().And.HaveCount(2);

                translations = episodes[1].Translations.ToArray();

                translations[0].Should().NotBeNull();
                translations[0].Title.Should().Be("The Kingsroad");
                translations[0].Overview.Should().Be("While Bran recovers from his fall, Ned takes only his daughters to Kings Landing. Jon Snow goes with his uncle Benjen to The Wall. Tyrion joins them.");
                translations[0].LanguageCode.Should().Be("en");

                translations[1].Should().NotBeNull();
                translations[1].Title.Should().Be("El Camino Real");
                translations[1].Overview.Should().Be("Cuando Bran sobrevive milagrosamente a su caída de la torre, Cersei y Jaime conspiran para asegurar su silencio; Jon Snow y Tyrion se dirigen a El Muro; al convertirse en la mano derecha del rey, Ned deja Winterfell con sus hijas Sansa y Arya.");
                translations[1].LanguageCode.Should().Be("es");
            }
        }