public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Stream_Incomplete_1()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            using (var stream = JSON_INCOMPLETE_1.ToStream())
            {
                var userRatingsStatistics = await jsonReader.ReadObjectAsync(stream);

                userRatingsStatistics.Should().NotBeNull();
                userRatingsStatistics.Total.Should().BeNull();
                userRatingsStatistics.Distribution.Should().NotBeNull();
                userRatingsStatistics.Distribution.Should().NotBeEmpty();
                userRatingsStatistics.Distribution.Should().HaveCount(10);
                userRatingsStatistics.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_UserRatingsStatisticsObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_1()
        {
            var traktJsonReader = new UserRatingsStatisticsObjectJsonReader();

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

                    userRatingsStatistics.Should().NotBeNull();
                    userRatingsStatistics.Total.Should().BeNull();
                    userRatingsStatistics.Distribution.Should().NotBeNull();
                    userRatingsStatistics.Distribution.Should().NotBeEmpty();
                    userRatingsStatistics.Distribution.Should().HaveCount(10);
                    userRatingsStatistics.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_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Stream_Null()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();
            Func <Task <ITraktUserRatingsStatistics> > userRatingsStatistics = () => jsonReader.ReadObjectAsync(default(Stream));

            userRatingsStatistics.Should().Throw <ArgumentNullException>();
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_JsonReader_Null()
        {
            var traktJsonReader = new UserRatingsStatisticsObjectJsonReader();

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

            userRatingsStatistics.Should().BeNull();
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Json_String_Empty()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

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

            userRatingsStatistics.Should().BeNull();
        }
Beispiel #6
0
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Stream_Null()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            var userRatingsStatistics = await jsonReader.ReadObjectAsync(default(Stream));

            userRatingsStatistics.Should().BeNull();
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Json_String_Incomplete_2()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            var userRatingsStatistics = await jsonReader.ReadObjectAsync(JSON_INCOMPLETE_2);

            userRatingsStatistics.Should().NotBeNull();
            userRatingsStatistics.Total.Should().Be(9257);
            userRatingsStatistics.Distribution.Should().BeNull();
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Json_String_Not_Valid_3()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            var userRatingsStatistics = await jsonReader.ReadObjectAsync(JSON_NOT_VALID_3);

            userRatingsStatistics.Should().NotBeNull();
            userRatingsStatistics.Total.Should().BeNull();
            userRatingsStatistics.Distribution.Should().BeNull();
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Stream_Empty()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            using (var stream = string.Empty.ToStream())
            {
                var userRatingsStatistics = await jsonReader.ReadObjectAsync(stream);

                userRatingsStatistics.Should().BeNull();
            }
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_JsonReader_Empty()
        {
            var traktJsonReader = new UserRatingsStatisticsObjectJsonReader();

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

                    userRatingsStatistics.Should().BeNull();
                }
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Stream_Not_Valid_2()
        {
            var jsonReader = new UserRatingsStatisticsObjectJsonReader();

            using (var stream = JSON_NOT_VALID_2.ToStream())
            {
                var userRatingsStatistics = await jsonReader.ReadObjectAsync(stream);

                userRatingsStatistics.Should().NotBeNull();
                userRatingsStatistics.Total.Should().Be(9257);
                userRatingsStatistics.Distribution.Should().BeNull();
            }
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_JsonReader_Incomplete_2()
        {
            var traktJsonReader = new UserRatingsStatisticsObjectJsonReader();

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

                    userRatingsStatistics.Should().NotBeNull();
                    userRatingsStatistics.Total.Should().Be(9257);
                    userRatingsStatistics.Distribution.Should().BeNull();
                }
        }
        public async Task Test_UserRatingsStatisticsObjectJsonReader_ReadObject_From_JsonReader_Not_Valid_3()
        {
            var traktJsonReader = new UserRatingsStatisticsObjectJsonReader();

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

                    userRatingsStatistics.Should().NotBeNull();
                    userRatingsStatistics.Total.Should().BeNull();
                    userRatingsStatistics.Distribution.Should().BeNull();
                }
        }
Beispiel #14
0
        public async Task Test_TraktUserRatingsStatistics_From_Json()
        {
            var jsonReader            = new UserRatingsStatisticsObjectJsonReader();
            var userRatingsStatistics = await jsonReader.ReadObjectAsync(JSON) as TraktUserRatingsStatistics;

            userRatingsStatistics.Should().NotBeNull();
            userRatingsStatistics.Total.Should().Be(9257);
            userRatingsStatistics.Distribution.Should().NotBeNull();
            userRatingsStatistics.Distribution.Should().NotBeEmpty();
            userRatingsStatistics.Distribution.Should().HaveCount(10);
            userRatingsStatistics.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_UserRatingsStatisticsObjectJsonReader_ReadObject_From_Json_String_Null()
 {
     var jsonReader = new UserRatingsStatisticsObjectJsonReader();
     Func <Task <ITraktUserRatingsStatistics> > userRatingsStatistics = () => jsonReader.ReadObjectAsync(default(string));
     await userRatingsStatistics.Should().ThrowAsync <ArgumentNullException>();
 }