public void Test_TraktRecommendationObjectType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll<TraktRecommendationObjectType>();

            allValues.Should().NotBeNull().And.HaveCount(3);
            allValues.Should().Contain(new List<TraktRecommendationObjectType>() { TraktRecommendationObjectType.Unspecified, TraktRecommendationObjectType.Movie,
                                                                                   TraktRecommendationObjectType.Show });
        }
        public void Test_TraktAccessTokenType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktAccessTokenType>();

            allValues.Should().NotBeNull().And.HaveCount(2);
            allValues.Should().Contain(new List <TraktAccessTokenType>()
            {
                TraktAccessTokenType.Unspecified, TraktAccessTokenType.Bearer
            });
        }
        public void Test_TraktLastActivity_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktLastActivity>();

            allValues.Should().NotBeNull().And.HaveCount(2);
            allValues.Should().Contain(new List <TraktLastActivity>()
            {
                TraktLastActivity.Unspecified, TraktLastActivity.Collected
            });
        }
        /// <summary>Deserializes a JSON string to an <see cref="TraktAuthorization" /> instance.</summary>
        /// <param name="authorizationJson">The JSON string, which should be deserialized.</param>
        /// <returns>
        /// An <see cref="TraktAuthorization" /> instance, containing the information from the JSON string, if successful.
        /// If the JSON string could not be parsed, null will be returned.
        /// </returns>
        /// <exception cref="ArgumentException">Thrown, if the given authorizationJson is null or empty.</exception>
        public static TraktAuthorization DeserializeAuthorization(string authorizationJson)
        {
            if (string.IsNullOrEmpty(authorizationJson))
            {
                throw new ArgumentException("authorization JSON is invalid", nameof(authorizationJson));
            }

            var authorizationWrapper = new
            {
                AccessToken      = string.Empty,
                RefreshToken     = string.Empty,
                ExpiresIn        = 0,
                Scope            = string.Empty,
                TokenType        = string.Empty,
                CreatedAtTicks   = 0L,
                IgnoreExpiration = false
            };

            var anonymousAuthorization = JsonConvert.DeserializeAnonymousType(authorizationJson, authorizationWrapper);

            if (anonymousAuthorization != null)
            {
                var accessToken      = anonymousAuthorization.AccessToken;
                var refreshToken     = anonymousAuthorization.RefreshToken;
                var expiresIn        = anonymousAuthorization.ExpiresIn;
                var scope            = anonymousAuthorization.Scope;
                var tokenType        = anonymousAuthorization.TokenType;
                var createdAtTicks   = anonymousAuthorization.CreatedAtTicks;
                var ignoreExpiration = anonymousAuthorization.IgnoreExpiration;

                if (accessToken == null || refreshToken == null || scope == null || tokenType == null)
                {
                    return(default(TraktAuthorization));
                }

                var accessScope     = scope != string.Empty ? TraktEnumeration.FromObjectName <TraktAccessScope>(scope) : TraktAccessScope.Public;
                var accessTokenType = tokenType != string.Empty ? TraktEnumeration.FromObjectName <TraktAccessTokenType>(tokenType) : TraktAccessTokenType.Bearer;
                var createdDateTime = new DateTime(createdAtTicks, DateTimeKind.Utc);

                var authorization = new TraktAuthorization
                {
                    AccessToken      = accessToken,
                    RefreshToken     = refreshToken,
                    ExpiresInSeconds = expiresIn,
                    AccessScope      = accessScope,
                    TokenType        = accessTokenType,
                    IgnoreExpiration = ignoreExpiration,
                    Created          = createdDateTime
                };

                return(authorization);
            }

            return(default(TraktAuthorization));
        }
        public void Test_TraktDateFormat_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktDateFormat>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktDateFormat>()
            {
                TraktDateFormat.Unspecified, TraktDateFormat.MonthDayYear,
                TraktDateFormat.DayMonthYear, TraktDateFormat.YearMonthDay, TraktDateFormat.YearDayMonth
            });
        }
        public void TestTraktGenreTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktGenreType>();

            allValues.Should().NotBeNull().And.HaveCount(3);
            allValues.Should().Contain(new List <TraktGenreType>()
            {
                TraktGenreType.Unspecified, TraktGenreType.Shows,
                TraktGenreType.Movies
            });
        }
        public void Test_TraktScrobbleActionType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktScrobbleActionType>();

            allValues.Should().NotBeNull().And.HaveCount(4);
            allValues.Should().Contain(new List <TraktScrobbleActionType>()
            {
                TraktScrobbleActionType.Unspecified, TraktScrobbleActionType.Start,
                TraktScrobbleActionType.Pause, TraktScrobbleActionType.Stop
            });
        }
        public void Test_TraktSyncType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktSyncType>();

            allValues.Should().NotBeNull().And.HaveCount(3);
            allValues.Should().Contain(new List <TraktSyncType>()
            {
                TraktSyncType.Unspecified, TraktSyncType.Movie,
                TraktSyncType.Episode
            });
        }
        public void TestTraktHiddenItemTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktHiddenItemType>();

            allValues.Should().NotBeNull().And.HaveCount(4);
            allValues.Should().Contain(new List <TraktHiddenItemType>()
            {
                TraktHiddenItemType.Unspecified, TraktHiddenItemType.Movie,
                TraktHiddenItemType.Show, TraktHiddenItemType.Season
            });
        }
示例#10
0
        public void TestTraktHistoryActionTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktHistoryActionType>();

            allValues.Should().NotBeNull().And.HaveCount(4);
            allValues.Should().Contain(new List <TraktHistoryActionType>()
            {
                TraktHistoryActionType.Unspecified, TraktHistoryActionType.Scrobble,
                TraktHistoryActionType.Checkin, TraktHistoryActionType.Watch
            });
        }
        public void Test_TraktAccessScope_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktAccessScope>();

            allValues.Should().NotBeNull().And.HaveCount(4);
            allValues.Should().Contain(new List <TraktAccessScope>()
            {
                TraktAccessScope.Unspecified, TraktAccessScope.Private,
                TraktAccessScope.Public, TraktAccessScope.Friends
            });
        }
示例#12
0
        public void Test_TraktCommentType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktCommentType>();

            allValues.Should().NotBeNull().And.HaveCount(4);
            allValues.Should().Contain(new List <TraktCommentType>()
            {
                TraktCommentType.Unspecified, TraktCommentType.Review,
                TraktCommentType.Shout, TraktCommentType.All
            });
        }
示例#13
0
        public void Test_TraktUserLikeType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktUserLikeType>();

            allValues.Should().NotBeNull().And.HaveCount(3);
            allValues.Should().Contain(new List <TraktUserLikeType>()
            {
                TraktUserLikeType.Unspecified, TraktUserLikeType.Comment,
                TraktUserLikeType.List
            });
        }
示例#14
0
        public void Test_TraktMediaType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll<TraktMediaType>();

            allValues.Should().NotBeNull().And.HaveCount(9);
            allValues.Should().Contain(new List<TraktMediaType>() { TraktMediaType.Unspecified, TraktMediaType.Digital,
                                                                    TraktMediaType.Bluray, TraktMediaType.HD_DVD,
                                                                    TraktMediaType.DVD, TraktMediaType.VCD,
                                                                    TraktMediaType.VHS, TraktMediaType.BetaMax,
                                                                    TraktMediaType.LaserDisc });
        }
示例#15
0
        public void Test_TraktMediaHDR_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktMediaHDR>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktMediaHDR>()
            {
                TraktMediaHDR.Unspecified, TraktMediaHDR.DolbyVision,
                TraktMediaHDR.HDR_10, TraktMediaHDR.HDR_10_Plus,
                TraktMediaHDR.HLG
            });
        }
示例#16
0
        public void Test_TraktListItemType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktListItemType>();

            allValues.Should().NotBeNull().And.HaveCount(6);
            allValues.Should().Contain(new List <TraktListItemType>()
            {
                TraktListItemType.Unspecified, TraktListItemType.Movie,
                TraktListItemType.Show, TraktListItemType.Season,
                TraktListItemType.Episode, TraktListItemType.Person
            });
        }
示例#17
0
        public void Test_TraktSearchIdType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktSearchIdType>();

            allValues.Should().NotBeNull().And.HaveCount(6);
            allValues.Should().Contain(new List <TraktSearchIdType>()
            {
                TraktSearchIdType.Unspecified, TraktSearchIdType.Trakt,
                TraktSearchIdType.ImDB, TraktSearchIdType.TmDB,
                TraktSearchIdType.TvDB, TraktSearchIdType.TVRage
            });
        }
示例#18
0
        public void Test_TraktWatchlistSortOrder_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktWatchlistSortOrder>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktWatchlistSortOrder>()
            {
                TraktWatchlistSortOrder.Unspecified, TraktWatchlistSortOrder.Rank,
                TraktWatchlistSortOrder.Added, TraktWatchlistSortOrder.Released,
                TraktWatchlistSortOrder.Title
            });
        }
示例#19
0
        public void TestTraktCommentSortOrderGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktCommentSortOrder>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktCommentSortOrder>()
            {
                TraktCommentSortOrder.Unspecified, TraktCommentSortOrder.Newest,
                TraktCommentSortOrder.Oldest, TraktCommentSortOrder.Likes,
                TraktCommentSortOrder.Replies
            });
        }
        public void TestTraktTimePeriodGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktTimePeriod>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktTimePeriod>()
            {
                TraktTimePeriod.Unspecified, TraktTimePeriod.Weekly,
                TraktTimePeriod.Monthly, TraktTimePeriod.Yearly,
                TraktTimePeriod.All
            });
        }
        public void TestTraktShowStatusGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktShowStatus>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktShowStatus>()
            {
                TraktShowStatus.Unspecified, TraktShowStatus.ReturningSeries,
                TraktShowStatus.InProduction, TraktShowStatus.Canceled,
                TraktShowStatus.Ended
            });
        }
示例#22
0
        public void TestTraktAccessTokenGrantTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktAccessTokenGrantType>();

            allValues.Should().NotBeNull().And.HaveCount(3);
            allValues.Should().Contain(new List <TraktAccessTokenGrantType>()
            {
                TraktAccessTokenGrantType.Unspecified,
                TraktAccessTokenGrantType.AuthorizationCode,
                TraktAccessTokenGrantType.RefreshToken
            });
        }
        public void Test_TraktListType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktListType>();

            allValues.Should().NotBeNull().And.HaveCount(5);
            allValues.Should().Contain(new List <TraktListType>()
            {
                TraktListType.Unspecified, TraktListType.Personal,
                TraktListType.Official, TraktListType.Watchlist,
                TraktListType.All
            });
        }
示例#24
0
        public void Test_TraktListSortOrder_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktListSortOrder>();

            allValues.Should().NotBeNull().And.HaveCount(7);
            allValues.Should().Contain(new List <TraktListSortOrder>()
            {
                TraktListSortOrder.Unspecified, TraktListSortOrder.Popular,
                TraktListSortOrder.Likes, TraktListSortOrder.Comments,
                TraktListSortOrder.Items, TraktListSortOrder.Added,
                TraktListSortOrder.Updated
            });
        }
        public void Test_TraktMovieStatus_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktMovieStatus>();

            allValues.Should().NotBeNull().And.HaveCount(7);
            allValues.Should().Contain(new List <TraktMovieStatus>()
            {
                TraktMovieStatus.Unspecified, TraktMovieStatus.Released,
                TraktMovieStatus.InProduction, TraktMovieStatus.PostProduction,
                TraktMovieStatus.Planned, TraktMovieStatus.Rumored,
                TraktMovieStatus.Canceled
            });
        }
示例#26
0
        public void Test_TraktReleaseType_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktReleaseType>();

            allValues.Should().NotBeNull().And.HaveCount(8);
            allValues.Should().Contain(new List <TraktReleaseType>()
            {
                TraktReleaseType.Unspecified, TraktReleaseType.Unknown,
                TraktReleaseType.Premiere, TraktReleaseType.Limited,
                TraktReleaseType.Theatrical, TraktReleaseType.Digital,
                TraktReleaseType.Physical, TraktReleaseType.TV
            });
        }
示例#27
0
        public void TestTraktObjectTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktObjectType>();

            allValues.Should().NotBeNull().And.HaveCount(7);
            allValues.Should().Contain(new List <TraktObjectType>()
            {
                TraktObjectType.Unspecified, TraktObjectType.Movie,
                TraktObjectType.Show, TraktObjectType.Season,
                TraktObjectType.Episode, TraktObjectType.List,
                TraktObjectType.All
            });
        }
        public void TestTraktSearchIdLookupTypeGetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktSearchIdLookupType>();

            allValues.Should().NotBeNull().And.HaveCount(8);
            allValues.Should().Contain(new List <TraktSearchIdLookupType>()
            {
                TraktSearchIdLookupType.Unspecified, TraktSearchIdLookupType.TraktMovie,
                TraktSearchIdLookupType.TraktShow, TraktSearchIdLookupType.TraktEpisode,
                TraktSearchIdLookupType.ImDB, TraktSearchIdLookupType.TmDB,
                TraktSearchIdLookupType.TvDB, TraktSearchIdLookupType.TVRage
            });
        }
示例#29
0
        public void Test_TraktSearchField_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktSearchField>();

            allValues.Should().NotBeNull().And.HaveCount(10);
            allValues.Should().Contain(new List <TraktSearchField>()
            {
                TraktSearchField.Unspecified, TraktSearchField.Title,
                TraktSearchField.Tagline, TraktSearchField.Overview,
                TraktSearchField.People, TraktSearchField.Translations,
                TraktSearchField.Aliases, TraktSearchField.Name,
                TraktSearchField.Biography, TraktSearchField.Description
            });
        }
        public void Test_TraktMediaResolution_GetAll()
        {
            var allValues = TraktEnumeration.GetAll <TraktMediaResolution>();

            allValues.Should().NotBeNull().And.HaveCount(9);
            allValues.Should().Contain(new List <TraktMediaResolution>()
            {
                TraktMediaResolution.Unspecified, TraktMediaResolution.UHD_4k,
                TraktMediaResolution.HD_1080p, TraktMediaResolution.HD_1080i,
                TraktMediaResolution.HD_720p, TraktMediaResolution.SD_480p,
                TraktMediaResolution.SD_480i, TraktMediaResolution.SD_576p,
                TraktMediaResolution.SD_576i
            });
        }