Beispiel #1
0
        public async Task Test_RatingObjectJsonWriter_WriteObject_StringWriter_Only_Distribution_Property()
        {
            ITraktRating traktRating = new TraktRating
            {
                Distribution = new Dictionary <string, int>
                {
                    ["1"]  = 1,
                    ["2"]  = 2,
                    ["3"]  = 3,
                    ["4"]  = 4,
                    ["5"]  = 5,
                    ["6"]  = 6,
                    ["7"]  = 7,
                    ["8"]  = 8,
                    ["9"]  = 9,
                    ["10"] = 10
                }
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new RatingObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktRating);

                json.Should().Be(@"{""distribution"":{""1"":1,""2"":2,""3"":3,""4"":4,""5"":5,""6"":6,""7"":7,""8"":8,""9"":9,""10"":10}}");
            }
        }
        public async Task Test_RatingObjectJsonWriter_WriteObject_JsonWriter_Only_Distribution_Property_Incomplete()
        {
            ITraktRating traktRating = new TraktRating
            {
                Distribution = new Dictionary <string, int>
                {
                    ["1"] = 1,
                    ["2"] = 2,
                    ["3"] = 3,
                    ["5"] = 5,
                    ["6"] = 6,
                    ["8"] = 8,
                    ["9"] = 9
                }
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new RatingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRating);

                    stringWriter.ToString().Should().Be(@"{""distribution"":{""1"":1,""2"":2,""3"":3,""4"":0,""5"":5,""6"":6,""7"":0,""8"":8,""9"":9,""10"":0}}");
                }
        }
        public async Task Test_RatingObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktRating traktRating = new TraktRating
            {
                Rating       = 7.4561f,
                Votes        = 2453,
                Distribution = new Dictionary <string, int>
                {
                    ["1"]  = 1,
                    ["2"]  = 2,
                    ["3"]  = 3,
                    ["4"]  = 4,
                    ["5"]  = 5,
                    ["6"]  = 6,
                    ["7"]  = 7,
                    ["8"]  = 8,
                    ["9"]  = 9,
                    ["10"] = 10
                }
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new RatingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRating);

                    stringWriter.ToString().Should().Be(@"{""rating"":7.4561,""votes"":2453," +
                                                        @"""distribution"":{""1"":1,""2"":2,""3"":3,""4"":4,""5"":5,""6"":6,""7"":7,""8"":8,""9"":9,""10"":10}}");
                }
        }
Beispiel #4
0
 public async Task Test_RatingObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var                   traktJsonWriter = new RatingObjectJsonWriter();
     ITraktRating          traktRating     = new TraktRating();
     Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktRating);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
Beispiel #5
0
        public void Test_RatingObjectJsonWriter_WriteObject_Object_Exceptions()
        {
            var traktJsonWriter          = new RatingObjectJsonWriter();
            Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default(ITraktRating));

            action.Should().Throw <ArgumentNullException>();
        }
        public void Test_RatingObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var          traktJsonWriter = new RatingObjectJsonWriter();
            ITraktRating traktRating     = new TraktRating();
            Func <Task>  action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktRating);

            action.Should().Throw <ArgumentNullException>();
        }
Beispiel #7
0
        public async Task Test_RatingObjectJsonWriter_WriteObject_Object_Only_Votes_Property()
        {
            ITraktRating traktRating = new TraktRating
            {
                Votes = 2453
            };

            var    traktJsonWriter = new RatingObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktRating);

            json.Should().Be(@"{""votes"":2453}");
        }
Beispiel #8
0
        public async Task Test_RatingObjectJsonWriter_WriteObject_Object_Only_Rating_Property()
        {
            ITraktRating traktRating = new TraktRating
            {
                Rating = 7.4561f
            };

            var    traktJsonWriter = new RatingObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktRating);

            json.Should().Be(@"{""rating"":7.4561}");
        }
        public async Task Test_RatingObjectJsonWriter_WriteObject_JsonWriter_Only_Votes_Property()
        {
            ITraktRating traktRating = new TraktRating
            {
                Votes = 2453
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new RatingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRating);

                    stringWriter.ToString().Should().Be(@"{""votes"":2453}");
                }
        }
        public async Task Test_RatingObjectJsonWriter_WriteObject_JsonWriter_Only_Rating_Property()
        {
            ITraktRating traktRating = new TraktRating
            {
                Rating = 7.4561f
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new RatingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktRating);

                    stringWriter.ToString().Should().Be(@"{""rating"":7.4561}");
                }
        }
 public void Test_RatingObjectJsonWriter_WriteObject_Object_Exceptions()
 {
     var traktJsonWriter          = new RatingObjectJsonWriter();
     Func <Task <string> > action = () => traktJsonWriter.WriteObjectAsync(default);