示例#1
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Stream_Not_Valid_2()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var stream = JSON_NOT_VALID_2.ToStream())
            {
                var traktRating = await traktJsonReader.ReadObjectAsync(stream);

                traktRating.Should().NotBeNull();
                traktRating.Rating.Should().Be(8.32715f);
                traktRating.Votes.Should().BeNull();
                traktRating.Distribution.Should().NotBeNull();
                traktRating.Distribution.Should().NotBeEmpty();
                traktRating.Distribution.Should().HaveCount(10);
                traktRating.Distribution.Should().Contain(new Dictionary <string, int>
                {
                    ["1"]  = 78,
                    ["2"]  = 45,
                    ["3"]  = 55,
                    ["4"]  = 96,
                    ["5"]  = 183,
                    ["6"]  = 545,
                    ["7"]  = 1361,
                    ["8"]  = 2259,
                    ["9"]  = 1772,
                    ["10"] = 2863
                });
            }
        }
        public async Task Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Incomplete_2()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var reader = new StringReader(JSON_INCOMPLETE_2))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktRating = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktRating.Should().NotBeNull();
                    traktRating.Rating.Should().Be(8.32715f);
                    traktRating.Votes.Should().BeNull();
                    traktRating.Distribution.Should().NotBeNull();
                    traktRating.Distribution.Should().NotBeEmpty();
                    traktRating.Distribution.Should().HaveCount(10);
                    traktRating.Distribution.Should().Contain(new Dictionary <string, int>
                    {
                        ["1"]  = 78,
                        ["2"]  = 45,
                        ["3"]  = 55,
                        ["4"]  = 96,
                        ["5"]  = 183,
                        ["6"]  = 545,
                        ["7"]  = 1361,
                        ["8"]  = 2259,
                        ["9"]  = 1772,
                        ["10"] = 2863
                    });
                }
        }
        public void Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Null()
        {
            var traktJsonReader = new RatingObjectJsonReader();
            Func <Task <ITraktRating> > traktRating = () => traktJsonReader.ReadObjectAsync(default(JsonTextReader));

            traktRating.Should().Throw <ArgumentNullException>();
        }
        public async Task Test_TraktRating_From_Json()
        {
            var jsonReader  = new RatingObjectJsonReader();
            var traktRating = await jsonReader.ReadObjectAsync(JSON) as TraktRating;

            traktRating.Should().NotBeNull();
            traktRating.Rating.Should().Be(8.32715f);
            traktRating.Votes.Should().Be(9274);
            traktRating.Distribution.Should().NotBeNull();
            traktRating.Distribution.Should().NotBeEmpty();
            traktRating.Distribution.Should().HaveCount(10);
            traktRating.Distribution.Should().Contain(new Dictionary <string, int>
            {
                ["1"]  = 78,
                ["2"]  = 45,
                ["3"]  = 55,
                ["4"]  = 96,
                ["5"]  = 183,
                ["6"]  = 545,
                ["7"]  = 1361,
                ["8"]  = 2259,
                ["9"]  = 1772,
                ["10"] = 2863
            });
        }
示例#5
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Json_String_Empty()
        {
            var jsonReader = new RatingObjectJsonReader();

            var traktRating = await jsonReader.ReadObjectAsync(string.Empty);

            traktRating.Should().BeNull();
        }
        public async Task Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Null()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            var traktRating = await traktJsonReader.ReadObjectAsync(default(JsonTextReader));

            traktRating.Should().BeNull();
        }
示例#7
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Stream_Empty()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var stream = string.Empty.ToStream())
            {
                var traktRating = await traktJsonReader.ReadObjectAsync(stream);

                traktRating.Should().BeNull();
            }
        }
示例#8
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Json_String_Incomplete_3()
        {
            var jsonReader = new RatingObjectJsonReader();

            var traktRating = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_3);

            traktRating.Should().NotBeNull();
            traktRating.Rating.Should().Be(8.32715f);
            traktRating.Votes.Should().Be(9274);
            traktRating.Distribution.Should().BeNull();
        }
示例#9
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Json_String_Not_Valid_4()
        {
            var jsonReader = new RatingObjectJsonReader();

            var traktRating = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_4);

            traktRating.Should().NotBeNull();
            traktRating.Rating.Should().BeNull();
            traktRating.Votes.Should().BeNull();
            traktRating.Distribution.Should().BeNull();
        }
        public async Task Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Empty()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var reader = new StringReader(string.Empty))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktRating = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktRating.Should().BeNull();
                }
        }
示例#11
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Stream_Not_Valid_4()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var stream = JSON_NOT_VALID_4.ToStream())
            {
                var traktRating = await traktJsonReader.ReadObjectAsync(stream);

                traktRating.Should().NotBeNull();
                traktRating.Rating.Should().BeNull();
                traktRating.Votes.Should().BeNull();
                traktRating.Distribution.Should().BeNull();
            }
        }
示例#12
0
        public async Task Test_RatingObjectJsonReader_ReadObject_From_Stream_Incomplete_3()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var stream = JSON_INCOMPLETE_3.ToStream())
            {
                var traktRating = await traktJsonReader.ReadObjectAsync(stream);

                traktRating.Should().NotBeNull();
                traktRating.Rating.Should().Be(8.32715f);
                traktRating.Votes.Should().Be(9274);
                traktRating.Distribution.Should().BeNull();
            }
        }
        public async Task Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_4()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var reader = new StringReader(JSON_NOT_VALID_4))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktRating = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktRating.Should().NotBeNull();
                    traktRating.Rating.Should().BeNull();
                    traktRating.Votes.Should().BeNull();
                    traktRating.Distribution.Should().BeNull();
                }
        }
        public async Task Test_RatingObjectJsonReader_ReadObject_From_JsonReader_Incomplete_3()
        {
            var traktJsonReader = new RatingObjectJsonReader();

            using (var reader = new StringReader(JSON_INCOMPLETE_3))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    var traktRating = await traktJsonReader.ReadObjectAsync(jsonReader);

                    traktRating.Should().NotBeNull();
                    traktRating.Rating.Should().Be(8.32715f);
                    traktRating.Votes.Should().Be(9274);
                    traktRating.Distribution.Should().BeNull();
                }
        }
示例#15
0
 public async Task Test_RatingObjectJsonReader_ReadObject_From_Stream_Null()
 {
     var traktJsonReader = new RatingObjectJsonReader();
     Func <Task <ITraktRating> > traktRating = () => traktJsonReader.ReadObjectAsync(default(Stream));
     await traktRating.Should().ThrowAsync <ArgumentNullException>();
 }