Beispiel #1
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_Json_String_Empty()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();
            IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(string.Empty);

            traktAuthorizations.Should().BeNull();
        }
Beispiel #2
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_Json_String_Incomplete_2()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader
            {
                CompleteDeserialization = true
            };

            IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(JSON_INCOMPLETE_2);

            traktAuthorizations.Should().NotBeNull();
            ITraktAuthorization[] items = traktAuthorizations.ToArray();

            items[0].Should().NotBeNull();
            items[0].AccessToken.Should().Be("mockAccessToken1");
            items[0].RefreshToken.Should().Be("mockRefreshToken1");
            items[0].Scope.Should().Be(TraktAccessScope.Public);
            items[0].ExpiresInSeconds.Should().Be(7200U);
            items[0].TokenType.Should().Be(TraktAccessTokenType.Bearer);
            items[0].CreatedAtTimestamp.Should().Be(1506271312UL);
            items[0].IgnoreExpiration.Should().BeTrue();

            items[1].Should().NotBeNull();
            items[1].AccessToken.Should().Be("mockAccessToken2");
            items[1].RefreshToken.Should().BeNull();
            items[1].Scope.Should().BeNull();
            items[1].ExpiresInSeconds.Should().Be(0);
            items[1].TokenType.Should().BeNull();
            items[1].CreatedAtTimestamp.Should().Be(0);
            items[1].IgnoreExpiration.Should().BeFalse();
        }
Beispiel #3
0
        public async Task Test_AuthorizationArrayJsonReader_ReadArray_From_Json_String_Empty_Array()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();
            IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(JSON_EMPTY_ARRAY);

            traktAuthorizations.Should().NotBeNull().And.BeEmpty();
        }
Beispiel #4
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_Stream_Not_Valid_1()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader
            {
                CompleteDeserialization = true
            };

            using (var stream = JSON_NOT_VALID_1.ToStream())
            {
                IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(stream);

                traktAuthorizations.Should().NotBeNull();
                ITraktAuthorization[] items = traktAuthorizations.ToArray();

                items[0].Should().NotBeNull();
                items[0].AccessToken.Should().BeNull();
                items[0].RefreshToken.Should().Be("mockRefreshToken1");
                items[0].Scope.Should().Be(TraktAccessScope.Public);
                items[0].ExpiresInSeconds.Should().Be(7200U);
                items[0].TokenType.Should().Be(TraktAccessTokenType.Bearer);
                items[0].CreatedAtTimestamp.Should().Be(1506271312UL);
                items[0].IgnoreExpiration.Should().BeTrue();

                items[1].Should().NotBeNull();
                items[1].AccessToken.Should().Be("mockAccessToken2");
                items[1].RefreshToken.Should().Be("mockRefreshToken2");
                items[1].Scope.Should().Be(TraktAccessScope.Public);
                items[1].ExpiresInSeconds.Should().Be(7200U);
                items[1].TokenType.Should().Be(TraktAccessTokenType.Bearer);
                items[1].CreatedAtTimestamp.Should().Be(1506271312UL);
                items[1].IgnoreExpiration.Should().BeTrue();
            }
        }
Beispiel #5
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_JsonReader_Null()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();
            IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(default(JsonTextReader));

            traktAuthorizations.Should().BeNull();
        }
Beispiel #6
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_Stream_Empty()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();

            using (var stream = string.Empty.ToStream())
            {
                IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(stream);

                traktAuthorizations.Should().BeNull();
            }
        }
Beispiel #7
0
        public async Task Test_AuthorizationArrayJsonReader_ReadArray_From_Stream_Empty_Array()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();

            using (var stream = JSON_EMPTY_ARRAY.ToStream())
            {
                IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(stream);

                traktAuthorizations.Should().NotBeNull().And.BeEmpty();
            }
        }
Beispiel #8
0
        public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_JsonReader_Empty()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();

            using (var reader = new StringReader(string.Empty))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(jsonReader);

                    traktAuthorizations.Should().BeNull();
                }
        }
Beispiel #9
0
        public async Task Test_AuthorizationArrayJsonReader_ReadArray_From_JsonReader_Empty_Array()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();

            using (var reader = new StringReader(JSON_EMPTY_ARRAY))
                using (var jsonReader = new JsonTextReader(reader))
                {
                    IEnumerable <ITraktAuthorization> traktAuthorizations = await objectJsonReader.ReadArrayAsync(jsonReader);

                    traktAuthorizations.Should().NotBeNull().And.BeEmpty();
                }
        }
Beispiel #10
0
        public void Test_AuthorizationArrayJsonReader_ReadObject_From_Json_String_Null()
        {
            var objectJsonReader = new AuthorizationArrayJsonReader();
            Func <Task <IEnumerable <ITraktAuthorization> > > traktAuthorizations = () => objectJsonReader.ReadArrayAsync(default(string));

            traktAuthorizations.Should().Throw <ArgumentNullException>();
        }
Beispiel #11
0
 public async Task Test_AuthorizationArrayJsonReader_ReadObject_From_Stream_Null()
 {
     var objectJsonReader = new AuthorizationArrayJsonReader();
     Func <Task <IEnumerable <ITraktAuthorization> > > traktAuthorizations = () => objectJsonReader.ReadArrayAsync(default(Stream));
     await traktAuthorizations.Should().ThrowAsync <ArgumentNullException>();
 }