Ejemplo n.º 1
0
 public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Exceptions()
 {
     var traktJsonWriter = new RecommendationObjectJsonWriter();
     ITraktRecommendation  traktRecommendation = new TraktRecommendation();
     Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktRecommendation);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Ejemplo n.º 2
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Only_Show_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Show = new TraktShow
                {
                    Title = "The Walking Dead",
                    Year  = 2010,
                    Ids   = new TraktShowIds
                    {
                        Trakt = 2U,
                        Slug  = "the-walking-dead",
                        Tvdb  = 153021U,
                        Imdb  = "tt1520211",
                        Tmdb  = 1402U
                    }
                }
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""show"":{""title"":""The Walking Dead"",""year"":2010," +
                             @"""ids"":{""trakt"":2,""slug"":""the-walking-dead""," +
                             @"""tvdb"":153021,""imdb"":""tt1520211"",""tmdb"":1402}}}");
        }
Ejemplo n.º 3
0
        public async Task Test_RecommendationObjectJsonWriter_Movie_WriteObject_StringWriter_Complete()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Rank     = 1,
                ListedAt = LISTED_AT,
                Type     = TraktRecommendationObjectType.Movie,
                Notes    = "Daft Punk really knocks it out of the park on the soundtrack.",
                Movie    = new TraktMovie
                {
                    Title = "TRON: Legacy",
                    Year  = 2010,
                    Ids   = new TraktMovieIds
                    {
                        Trakt = 1U,
                        Slug  = "tron-legacy-2010",
                        Imdb  = "tt1104001",
                        Tmdb  = 20526U
                    }
                }
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""rank"":1," +
                             $"\"listed_at\":\"{LISTED_AT.ToTraktLongDateTimeString()}\"," +
                             @"""type"":""movie""," +
                             @"""notes"":""Daft Punk really knocks it out of the park on the soundtrack.""," +
                             @"""movie"":{""title"":""TRON: Legacy"",""year"":2010," +
                             @"""ids"":{""trakt"":1,""slug"":""tron-legacy-2010""," +
                             @"""imdb"":""tt1104001"",""tmdb"":20526}}}");
        }
Ejemplo n.º 4
0
        public async Task Test_RecommendationObjectJsonWriter_Movie_WriteObject_StringWriter_Only_Movie_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Movie = new TraktMovie
                {
                    Title = "TRON: Legacy",
                    Year  = 2010,
                    Ids   = new TraktMovieIds
                    {
                        Trakt = 1U,
                        Slug  = "tron-legacy-2010",
                        Imdb  = "tt1104001",
                        Tmdb  = 20526U
                    }
                }
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""movie"":{""title"":""TRON: Legacy"",""year"":2010," +
                             @"""ids"":{""trakt"":1,""slug"":""tron-legacy-2010""," +
                             @"""imdb"":""tt1104001"",""tmdb"":20526}}}");
        }
Ejemplo n.º 5
0
        public void Test_RecommendationObjectJsonWriter_Movie_WriteObject_JsonWriter_Exceptions()
        {
            var traktJsonWriter = new RecommendationObjectJsonWriter();
            ITraktRecommendation traktRecommendation = new TraktRecommendation();
            Func <Task>          action = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktRecommendation);

            action.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 6
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Only_Notes_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Notes = "Atmospheric for days."
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""notes"":""Atmospheric for days.""}");
        }
Ejemplo n.º 7
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Only_Type_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Type = TraktRecommendationObjectType.Show
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""type"":""show""}");
        }
Ejemplo n.º 8
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Only_ListedAt_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                ListedAt = LISTED_AT
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be($"{{\"listed_at\":\"{LISTED_AT.ToTraktLongDateTimeString()}\"}}");
        }
Ejemplo n.º 9
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_StringWriter_Only_Rank_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Rank = 1
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""rank"":1}");
        }
Ejemplo n.º 10
0
        public async Task Test_RecommendationObjectJsonWriter_Movie_WriteObject_StringWriter_Only_Notes_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Notes = "Daft Punk really knocks it out of the park on the soundtrack."
            };

            using var stringWriter = new StringWriter();

            var    traktJsonWriter = new RecommendationObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRecommendation);

            json.Should().Be(@"{""notes"":""Daft Punk really knocks it out of the park on the soundtrack.""}");
        }
        public async Task Test_RecommendationObjectJsonWriter_Movie_WriteObject_JsonWriter_Only_Type_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Type = TraktRecommendationObjectType.Movie
            };

            using var stringWriter = new StringWriter();
            using var jsonWriter   = new JsonTextWriter(stringWriter);

            var traktJsonWriter = new RecommendationObjectJsonWriter();
            await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRecommendation);

            stringWriter.ToString().Should().Be(@"{""type"":""movie""}");
        }
        public async Task Test_RecommendationObjectJsonWriter_Movie_WriteObject_JsonWriter_Only_Rank_Property()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Rank = 1
            };

            using var stringWriter = new StringWriter();
            using var jsonWriter   = new JsonTextWriter(stringWriter);

            var traktJsonWriter = new RecommendationObjectJsonWriter();
            await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRecommendation);

            stringWriter.ToString().Should().Be(@"{""rank"":1}");
        }
Ejemplo n.º 13
0
        public async Task Test_RecommendationObjectJsonWriter_Show_WriteObject_JsonWriter_Complete()
        {
            ITraktRecommendation traktRecommendation = new TraktRecommendation
            {
                Rank     = 1,
                ListedAt = LISTED_AT,
                Type     = TraktRecommendationObjectType.Show,
                Notes    = "Atmospheric for days.",
                Show     = new TraktShow
                {
                    Title = "The Walking Dead",
                    Year  = 2010,
                    Ids   = new TraktShowIds
                    {
                        Trakt = 2U,
                        Slug  = "the-walking-dead",
                        Tvdb  = 153021U,
                        Imdb  = "tt1520211",
                        Tmdb  = 1402U
                    }
                }
            };

            using var stringWriter = new StringWriter();
            using var jsonWriter   = new JsonTextWriter(stringWriter);

            var traktJsonWriter = new RecommendationObjectJsonWriter();
            await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRecommendation);

            stringWriter.ToString().Should().Be(@"{""rank"":1," +
                                                $"\"listed_at\":\"{LISTED_AT.ToTraktLongDateTimeString()}\"," +
                                                @"""type"":""show""," +
                                                @"""notes"":""Atmospheric for days.""," +
                                                @"""show"":{""title"":""The Walking Dead"",""year"":2010," +
                                                @"""ids"":{""trakt"":2,""slug"":""the-walking-dead""," +
                                                @"""tvdb"":153021,""imdb"":""tt1520211"",""tmdb"":1402}}}");
        }